Re: WIP: hooking parser

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: WIP: hooking parser
Дата
Msg-id 162867790902161103l140be0cawcc015280fb58a9b@mail.gmail.com
обсуждение исходный текст
Ответ на Re: WIP: hooking parser  (Sam Mason <sam@samason.me.uk>)
Ответы Re: WIP: hooking parser
Список pgsql-hackers
2009/2/16 Sam Mason <sam@samason.me.uk>:
> On Mon, Feb 16, 2009 at 04:40:23PM +0100, Pavel Stehule wrote:
>> 2009/2/16 Sam Mason <sam@samason.me.uk>:
>> > On Mon, Feb 16, 2009 at 03:21:12PM +0100, Pavel Stehule wrote:
>> >> so these modules (decode, oraemptystr) decrease differences between
>> >> PostgreSQL and Oracle.
>> >
>> > wouldn't it be better/easier to extend something like pgpool to
>> > transform Oracle style SQL code to PG style code?  You'd certainly
>> > be able to get it more complete in reasonable amounts of time, but
>> > performance would suffer when you went to look up table definitions to
>> > check the types of various things.
>>
>> then you should to rewrite complete PostgreSQL parser :) and
>> performance will be worse (you have to parse query string two times).
>
> Yes, there'd be a few thousand lines of code to write.
>
> Note that you only need to parse things twice, planning only needs to be
> done by PG, so it shouldn't be too bad.  It'll add maybe a millisecond
> or so to query execution times, with most of that time spent going off
> to find table and function definitions from the real database.
Hello
>
> But to do it properly inside PG would be difficult; how would your hooks
> know to transform:
>
>  SELECT s FROM foo WHERE s IS NULL;
>
> into:
>
>  SELECT s FROM foo WHERE (s = '' OR s IS NULL);

I don't need it. Oracle store NULL without ''. So expression some IS
NULL is stable.

>
> that all looks a bit tricky to me.  Hum... actually it's not.  All you
> need to do is to rewrite any string reference "s" into NULLIF(s,'').
> That would tank performance as indexes wouldn't be used most of the
> time, but never mind.
>

look to source what I do. It' just simple. But you have to emulate
Oracle behave everywhere. Then all is simple, because Oracle doesn't
know ''.

>
> That would be a *much* bigger change; you're actually changing PG's
> parser there and not just modifying the parse tree.  If it was done
> externally it would be a much easier thing to do.
>

No I don't do it. Loadable modules are really external. I need only
hook inside parser.

Regards
Pavel Stehule

> --
>  Sam  http://samason.me.uk/
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Martin Rusoff
Дата:
Сообщение: Re: SE-PostgreSQL and row level security
Следующее
От: Sam Mason
Дата:
Сообщение: Re: WIP: hooking parser