Re: [HACKERS] WIP: hooking parser

2009-02-20 Thread Peter Eisentraut
Tom Lane wrote: How about introducing a varchar2 type as in Oracle? Maybe. I think right now we don't allow input functions to decide that a non-null input string should be converted to a NULL, but that might be fixable. It'd still be an ugly mess though, since I suspect you'd have to

Re: [HACKERS] WIP: hooking parser

2009-02-20 Thread Pavel Stehule
Curiously enough, Oracle has it so that || of null arguments treats the arguments as empty string. It's beyond comprehension. what is result of '' || '' ? Pavel But yeah, a varchar2 type with a full set of functions and operators could work. If you choose not to bother with supporting

Re: [HACKERS] WIP: hooking parser

2009-02-20 Thread Gregory Stark
Pavel Stehule pavel.steh...@gmail.com writes: Curiously enough, Oracle has it so that || of null arguments treats the arguments as empty string. It's beyond comprehension. what is result of '' || '' ? Well the result of this is NULL of course (which is the same as '') What's more puzzling

Re: [HACKERS] WIP: hooking parser

2009-02-19 Thread Sam Mason
On Wed, Feb 18, 2009 at 10:30:12AM -0500, Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I'd be quite interested to support some kind of hook to deal with this Oracle null issue. It would be a great help for porting projects. However, doing this properly is probably more

Re: [HACKERS] WIP: hooking parser

2009-02-19 Thread Kenneth Marshall
On Thu, Feb 19, 2009 at 06:29:25PM +, Sam Mason wrote: On Wed, Feb 18, 2009 at 10:30:12AM -0500, Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I'd be quite interested to support some kind of hook to deal with this Oracle null issue. It would be a great help for porting

Re: [HACKERS] WIP: hooking parser

2009-02-19 Thread Tom Lane
Sam Mason s...@samason.me.uk writes: On Wed, Feb 18, 2009 at 10:30:12AM -0500, Tom Lane wrote: AFAIK, the Oracle behavior is just about entirely unrelated to the parser --- it's a matter of runtime comparison behavior. It is certainly *not* restricted to literal NULL/'' constants, which is

Re: [HACKERS] WIP: hooking parser

2009-02-19 Thread Sam Mason
On Thu, Feb 19, 2009 at 02:02:06PM -0500, Tom Lane wrote: Sam Mason s...@samason.me.uk writes: On Wed, Feb 18, 2009 at 10:30:12AM -0500, Tom Lane wrote: AFAIK, the Oracle behavior is just about entirely unrelated to the parser --- it's a matter of runtime comparison behavior. It is

Re: [HACKERS] WIP: hooking parser

2009-02-18 Thread Peter Eisentraut
Pavel Stehule wrote: 2009/2/16 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: Next sample of parser hook using: attachment contains module that transform every empty string to null. I am not sure, if this behave is exactly compatible with Oracle, Surely a parser

Re: [HACKERS] WIP: hooking parser

2009-02-18 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: I'd be quite interested to support some kind of hook to deal with this Oracle null issue. It would be a great help for porting projects. However, doing this properly is probably more complex and needs further thought. I'd suggest writing a type of

Re: [HACKERS] WIP: hooking parser

2009-02-18 Thread Pavel Stehule
2009/2/18 Peter Eisentraut pete...@gmx.net: Pavel Stehule wrote: 2009/2/16 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: Next sample of parser hook using: attachment contains module that transform every empty string to null. I am not sure, if this behave is

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
Next sample of parser hook using: attachment contains module that transform every empty string to null. I am not sure, if this behave is exactly compatible with Oracle, but for first iteration it is good. postgres=# select length('') is null; ?column? -- t (1 row) I thing, so this

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 02:35:54PM +0100, Pavel Stehule wrote: attachment contains module that transform every empty string to null. Why would anyone ever want to do this? This would appear to break all sorts of things in very non-obvious ways: SELECT CASE s WHEN '' THEN 'empty string' ELSE

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 02:35:54PM +0100, Pavel Stehule wrote: attachment contains module that transform every empty string to null. Why would anyone ever want to do this? This would appear to break all sorts of things in very non-obvious ways: I

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 03:21:12PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 02:35:54PM +0100, Pavel Stehule wrote: attachment contains module that transform every empty string to null. Why would anyone ever want to do this? This would

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: Next sample of parser hook using: attachment contains module that transform every empty string to null. I am not sure, if this behave is exactly compatible with Oracle, Surely a parser hook like this would have nothing whatsoever to do with

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 03:21:12PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 02:35:54PM +0100, Pavel Stehule wrote: attachment contains module that transform every empty string to null. Why would

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 04:40:23PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@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

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 04:40:23PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@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

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 08:03:42PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@samason.me.uk: 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

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
2009/2/16 Sam Mason s...@samason.me.uk: On Mon, Feb 16, 2009 at 08:03:42PM +0100, Pavel Stehule wrote: 2009/2/16 Sam Mason s...@samason.me.uk: 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:

Re: [HACKERS] WIP: hooking parser

2009-02-16 Thread Pavel Stehule
2009/2/16 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: Next sample of parser hook using: attachment contains module that transform every empty string to null. I am not sure, if this behave is exactly compatible with Oracle, Surely a parser hook like this would

Re: [HACKERS] WIP: hooking parser

2009-02-13 Thread Peter Eisentraut
Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I think what you want here is some way to define a function that takes an arbitrary number of arguments of arbitrary type and let the function figure everything out. I see no reason why this can't be a variant on CREATE FUNCTION,

Re: [HACKERS] WIP: hooking parser

2009-02-13 Thread Heikki Linnakangas
Peter Eisentraut wrote: Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I think what you want here is some way to define a function that takes an arbitrary number of arguments of arbitrary type and let the function figure everything out. I see no reason why this can't be a variant

Re: [HACKERS] WIP: hooking parser

2009-02-13 Thread Pavel Stehule
2009/2/13 Heikki Linnakangas heikki.linnakan...@enterprisedb.com: Peter Eisentraut wrote: Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: I think what you want here is some way to define a function that takes an arbitrary number of arguments of arbitrary type and let the function

Re: [HACKERS] WIP: hooking parser

2009-02-13 Thread Peter Eisentraut
Heikki Linnakangas wrote: And on top of that, decode() is supposed to do short-circuit evaluation of the arguments. Then the only solution is to hack it right into the parser. There is an existing decode() function however ... -- Sent via pgsql-hackers mailing list

Re: [HACKERS] WIP: hooking parser

2009-02-12 Thread Peter Eisentraut
On Wednesday 11 February 2009 12:05:03 Pavel Stehule wrote: It works. And I thing, this should to solve lot of special task related to increase compatibility with Oracle, Informix, or it could be usefull for some others (json support). postgres=# load 'decode'; LOAD postgres=# select

Re: [HACKERS] WIP: hooking parser

2009-02-12 Thread Pavel Stehule
2009/2/12 Peter Eisentraut pete...@gmx.net: On Wednesday 11 February 2009 12:05:03 Pavel Stehule wrote: It works. And I thing, this should to solve lot of special task related to increase compatibility with Oracle, Informix, or it could be usefull for some others (json support). postgres=#

Re: [HACKERS] WIP: hooking parser

2009-02-12 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: I think what you want here is some way to define a function that takes an arbitrary number of arguments of arbitrary type and let the function figure everything out. I see no reason why this can't be a variant on CREATE FUNCTION, except that of

[HACKERS] WIP: hooking parser

2009-02-11 Thread Pavel Stehule
Hello some years ago there was some plans about parser's extensibility. I am able write bison extensions, but I thing, so lot of work should be done via hooking of transform stage. I did small example - real implementation of Oracle's decode function. It's based on hooking transformExpr

Re: [HACKERS] WIP: hooking parser

2009-02-11 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: some years ago there was some plans about parser's extensibility. I am able write bison extensions, but I thing, so lot of work should be done via hooking of transform stage. This strikes me as next door to useless, because it can only handle

Re: [HACKERS] WIP: hooking parser

2009-02-11 Thread Pavel Stehule
2009/2/11 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: some years ago there was some plans about parser's extensibility. I am able write bison extensions, but I thing, so lot of work should be done via hooking of transform stage. This strikes me as next door to

Re: [HACKERS] WIP: hooking parser

2009-02-11 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2009/2/11 Tom Lane t...@sss.pgh.pa.us: This strikes me as next door to useless, because it can only handle things that look like valid expressions to the existing grammar. So pretty much all you can do is weird sorts of functions, which are

Re: [HACKERS] WIP: hooking parser

2009-02-11 Thread Pavel Stehule
2009/2/11 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/2/11 Tom Lane t...@sss.pgh.pa.us: This strikes me as next door to useless, because it can only handle things that look like valid expressions to the existing grammar. So pretty much all you can do is