Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Christopher Kings-Lynne wrote: >> Needs to return 0 or 1 though. > All Boolean operators in MySQL do that, so to create an illusion of > MySQL compatibility, you'd need to redefine all standard Boolean > operators. I don't think you want that. Won

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Tom Lane
Christopher Kings-Lynne <[EMAIL PROTECTED]> writes: >> test=# select null_safe_cmp (NULL,NULL); >> ERROR: could not determine anyarray/anyelement type because input has >> type "unknown" >> Same casting problem due to anyelement, of course. > Yes - I wonder what the trick to getting around that

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread R, Rajesh (STSD)
Hello there, I have included the ipv6 auth. line in my pg_hba.conf file(::1/128) I keep getting error msgs from postmaster everytime I try to connect. Going by previous posts on the topic am unable to conclude. Does this mean pg 8.0.3 doesn't support ipv6 client auth. ?? Or is there a patch som

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Peter Eisentraut
Christopher Kings-Lynne wrote: > Needs to return 0 or 1 though. All Boolean operators in MySQL do that, so to create an illusion of MySQL compatibility, you'd need to redefine all standard Boolean operators. I don't think you want that. -- Peter Eisentraut http://developer.postgresql.org/~pet

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Michael Glaesemann
On Nov 25, 2005, at 17:06 , Christopher Kings-Lynne wrote: test=# select null_safe_cmp (NULL,NULL); ERROR: could not determine anyarray/anyelement type because input has type "unknown" test=# select null_safe_cmp (NULL::integer,NULL::integer); null_safe_cmp --- 1 (

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Christopher Kings-Lynne
CREATE OR REPLACE FUNCTION null_safe_cmp (ANYELEMENT, ANYELEMENT) RETURNS INTEGER IMMUTABLE LANGUAGE SQL AS $$ SELECT CASE WHEN NOT ($1 IS DISTINCT FROM $2) THEN 1 ELSE 0 END; $$; Even cooler: CREATE OR REPLACE FUNCTION null_safe_cmp(anyelement, anyelement) RETURNS integer AS ' SELECT

Re: [HACKERS] NULL safe equality operator

2005-11-25 Thread Christopher Kings-Lynne
test=# select null_safe_cmp (NULL,NULL); ERROR: could not determine anyarray/anyelement type because input has type "unknown" test=# select null_safe_cmp (NULL::integer,NULL::integer); null_safe_cmp --- 1 (1 row) Same casting problem due to anyelement, of course. Ye

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Michael Glaesemann
On Nov 25, 2005, at 16:43 , Christopher Kings-Lynne wrote: Yeah, I saw your commit. Nice shortcut. Also didn't know you could define operators using SQL functions. Tom's suggestion of NOT (a DISTINCT FROM b) is really cool. Much cleaner in my opinion. I learn a lot from these lists :)

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Michael Glaesemann
On Nov 25, 2005, at 16:37 , Michael Glaesemann wrote: Tom's suggestion of NOT (a DISTINCT FROM b) is really cool. Even cooler if I spell it correctly: NOT (a IS DISTINCT FROM b) Michael Glaesemann grzm myrealbox com ---(end of broadcast)---

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Christopher Kings-Lynne
Yeah, I saw your commit. Nice shortcut. Also didn't know you could define operators using SQL functions. Tom's suggestion of NOT (a DISTINCT FROM b) is really cool. Much cleaner in my opinion. I learn a lot from these lists :) Needs to return 0 or 1 though. Chris

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Michael Glaesemann
On Nov 25, 2005, at 16:24 , Christopher Kings-Lynne wrote: when ($1 is null and $2 is not null) or ($1 is not null and $2 is null) then 0 That's the same as: when $1 is null != $2 is null then 0 Yeah, I saw your commit. Nice shortcut. Also didn't know you could define operato

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Christopher Kings-Lynne
when ($1 is null and $2 is not null) or ($1 is not null and $2 is null) then 0 That's the same as: when $1 is null != $2 is null then 0 Chris ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropri

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Dennis Bjorklund
On Thu, 24 Nov 2005, Tom Lane wrote: > NOT (x IS DISTINCT FROM y) would be the standard-compliant way of > spelling that. That's the sql99 way. In sql2003 (but not in pg) one can also do X IS NOT DISTINCT FROM y -- /Dennis Björklund ---(end of broadcast)

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Tom Lane
Christopher Kings-Lynne <[EMAIL PROTECTED]> writes: > Does anyone know how I'd go about implementing the following MySQL > operator in PostgreSQL? NOT (x IS DISTINCT FROM y) would be the standard-compliant way of spelling that. regards, tom lane -

Re: [HACKERS] NULL safe equality operator

2005-11-24 Thread Michael Glaesemann
On Nov 25, 2005, at 11:17 , Christopher Kings-Lynne wrote: Hi guys, Does anyone know how I'd go about implementing the following MySQL operator in PostgreSQL? I'm sure you know how to implement this with a stored procedure. AFAICT, if you wanted to actually implement this as an operator,

[HACKERS] NULL safe equality operator

2005-11-24 Thread Christopher Kings-Lynne
Hi guys, Does anyone know how I'd go about implementing the following MySQL operator in PostgreSQL? --- NULL-safe equal. This operator performs an equality comparison like the = operator, but returns 1 rather than NULL if both operands are NULL, and 0 rather than NULL if one operand isNULL