Re: MySQL compatibility mode: SET NAMES

128 views
Skip to first unread message

Noel Grandin

unread,
Jul 6, 2012, 3:09:57 AM7/6/12
to h2-da...@googlegroups.com, awebdeveloper
Start with the org.h2.command.Parser class. It's a standard recursive
descent parser, very easy to work with.

On 2012-07-05 23:56, awebdeveloper wrote:
> Hi,
>
> I am connecting to H2 in MySQL compatibility mode using a MySQL driver
> (Caucho Quercus' MySQL driver to be exact). I am getting an error
> during connection, saying there is a syntax error in the SQL query:
> SET NAMES 'latin1'; (Basically SET NAMES is not supported by H2 yet.)
> This is valid for MySQL, but as I am aware, H2's MySQL compatibility
> is not 100%. I've seen that solving this is already on the todo list
> for H2, but it's kind of tucked away somewhere in the lower half of
> priorities :-) I am trying to raise awareness for this issue, maybe it
> can be given a higher priority. Also, I would be interested in
> working/coding on this issue myself. But I probably need some help in
> that area, since I have never worked with the H2 code base before.
>
> If anyone could give me some feedback/tips/help with this, it would be
> greatly appreciated :-)
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/VtdpwtcF7UkJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.


awebdeveloper

unread,
Jul 6, 2012, 12:13:02 PM7/6/12
to h2-da...@googlegroups.com, awebdeveloper
Hi Noel,

Thank you for giving me a place to start! :-) 

awebdeveloper

unread,
Jul 8, 2012, 1:18:55 PM7/8/12
to h2-da...@googlegroups.com, awebdeveloper
Awesome! I managed to fix it :-)

It was really simple, I added the following code snippet to the parseSet() method of the org.h2.command.Parser class.

        else if(readIf("NAMES")) {
            // Quercus PHP MySQL driver compatibility
            readIfEqualOrTo();
            read();
            return new NoOperation(session);
        }

after line 4604 (after the "else if(readIf("RECOVER")) {}" block). After that I tested it with the Quercus PHP MySQL driver and it worked like a charm!

How do I proceed to have the fix included in the H2 distribution?

Noel Grandin

unread,
Jul 9, 2012, 2:30:00 AM7/9/12
to h2-da...@googlegroups.com, awebdeveloper
We need a patch, and a license statement:

http://www.h2database.com/html/build.html#providing_patches
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/nisT4YPA2hYJ.

To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.

awebdeveloper

unread,
Jul 9, 2012, 5:14:38 AM7/9/12
to h2-da...@googlegroups.com, awebdeveloper
Thanks! I'll get on it :)

awebdeveloper

unread,
Aug 7, 2012, 8:55:07 AM8/7/12
to h2-da...@googlegroups.com, awebdeveloper
I finally got around to creating the patch with all the other steps. I attached the patch.

For the record: :-)

I wrote the code, it's mine, and I'm contributing it to H2 for distribution multiple-licensed under the H2 License, version 1.0, and under the Eclipse Public License, version 1.0 (http://h2database.com/html/license.html).
set-names-patch.diff

Noel Grandin

unread,
Aug 7, 2012, 9:09:49 AM8/7/12
to h2-da...@googlegroups.com, awebdeveloper
Thanks, patch committed :-)

awebdeveloper

unread,
Aug 7, 2012, 9:15:05 AM8/7/12
to h2-da...@googlegroups.com, awebdeveloper
Wow, that's fast! Thanks :-)
Reply all
Reply to author
Forward
0 new messages