phpmyadmin / sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.
https://packagist.org/packages/phpmyadmin/sql-parser
GNU General Public License v2.0
440 stars 102 forks source link

Support for special syntaxes for example in SQL_MODE='ORACLE' #425

Open calebdw opened 1 year ago

calebdw commented 1 year ago

Hello!

I know this library is primarily for MySQL dialects, but this is the only PHP SQL parser I could find...

This can't parse the 'custom' Postgres dump, but I found it can sort of parser the plain text format with varying results.

The parser seems to stop after the first timestamp column (it parsed created_at) so I have a bunch of table create statements with only two columns:

CREATE TABLE public.urls (
    id integer NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    long_url text NOT NULL
);

Any ideas why?

Thanks!

williamdes commented 1 year ago

Hi! That's interesting, probably out of the scope of the parser unless MariaDB has a postgres sql compatibility mode?

Tehy already do have compatibility for sql server things or supports the without time zone? Can you research this a bit more before we investigate?

calebdw commented 1 year ago

@williamdes, thanks for the response. I ended up implementing a solution that didn't involve parsing Postgres dumps.

I understand if this is out-of-scope and you'd like to close the issue, just figured I raise it in case others experienced the same thing. I dug around a bit but unfortunately this is a little over my head

williamdes commented 1 year ago

I understand if this is out-of-scope and you'd like to close the issue, just figured I raise it in case others experienced the same thing. I dug around a bit but unfortunately this is a little over my head

Thank you for reporting ;)

Let's keep this one open so we can check about SET SQL_MODE='ORACLE';: https://mariadb.com/kb/en/sql_modeoracle/

Especially about :param1 query placeholders

See: #202