I have also tried out 1.4.181 as I have some scripts that specify "use 
*db_name*". I believe the syntax is "USE *db_name*" where "USE" is a 
reserved word and "*db_name*" identifies the database/schema by name (see 
http://dev.mysql.com/doc/refman/5.5/en/use.html).

The following patch should work:

Index: h2/src/main/org/h2/command/Parser.java
===================================================================
--- h2/src/main/org/h2/command/Parser.java (revision 5925)
+++ h2/src/main/org/h2/command/Parser.java (working copy)
@@ -5083,13 +5083,10 @@
     }
 
     private Prepared parseUse() {
-        if (readIf("SCHEMA")) {
-            readIfEqualOrTo();
-            Set command = new Set(session, SetTypes.SCHEMA);
-            command.setString(readAliasIdentifier());
-            return command;
-        }
-        throw getSyntaxError();
+        readIfEqualOrTo();
+        Set command = new Set(session, SetTypes.SCHEMA);
+        command.setString(readAliasIdentifier());
+        return command;
     }
 
     private Set parseSetCollation() {
Index: h2/src/test/org/h2/test/db/TestCompatibility.java
===================================================================
--- h2/src/test/org/h2/test/db/TestCompatibility.java (revision 5925)
+++ h2/src/test/org/h2/test/db/TestCompatibility.java (working copy)
@@ -231,10 +231,10 @@
     private void testMySQL() throws SQLException {
         Statement stat = conn.createStatement();
         stat.execute("create schema test_schema");
-        stat.execute("use schema test_schema");
+        stat.execute("use test_schema");
         assertResult("TEST_SCHEMA", stat,
                 "select schema()");
-        stat.execute("use schema public");
+        stat.execute("use public");
         assertResult("PUBLIC", stat,
                 "select schema()");

Can you apply the patch for me? If Karl does really need the syntax "USE 
SCHEMA *db_name*" (although I'm not sure why he would) then perhaps we can 
make the "SCHEMA" word optional. I look forward to an update as soon as 
possible. Thank you!

On Friday, August 8, 2014 4:43:13 AM UTC-6, Fabreax wrote:
>
> Hello,
>
> I downloaded the version 1.4.181 of H2 because I need "USE schema_name" but
> the MySQL compatibility seems to be on "USE SCHEMA schema_name" which is 
> not
> valid on MySQL.
>
> Is it ok ?
>
> Le lundi 28 juillet 2014 21:15:29 UTC+2, Thomas Mueller a écrit :
>>
>> Hi,
>>
>> Thanks! The patch is merged now.
>>
>> Regards,
>> Thomas
>>
>>
>> On Mon, Jul 28, 2014 at 4:39 PM, Karl Pietrzak <[email protected]> wrote:
>>
>>>
>>> On Mon, Jul 28, 2014 at 2:10 AM, Thomas Mueller <[email protected]> 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I can  definitely submit a patch, especially if someone can send me the 
>>>>> name of the class/unit test to look at to point me in the right direction.
>>>>>
>>>>
>>>> Yes, that would be the Parser class, method parsePrepared. The 
>>>> statement "use schema x" would be the same as "set schema x" I believe. A 
>>>> simple test case would be nice as well, but I can do that as well.
>>>>
>>>
>>> Here's a tiny patch.  It's quite simplistic; I'm not sure if this is how 
>>> you guys wanna handle this case.
>>>
>>>
>>> -- 
>>> Karl
>>>  
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "H2 Database" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/h2-database.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to