Re: Bug in create operator and/or initdb

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "John Hansen" <john(at)geeknet(dot)com(dot)au>
Cc: pgsql-bugs(at)postgresql(dot)org, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in create operator and/or initdb
Date: 2005-01-30 02:42:49
Message-ID: 28832.1107052969@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

"John Hansen" <john(at)geeknet(dot)com(dot)au> writes:
> CREATE FUNCTION my_func (inet, inet) as '$libdir/my_func.so' LANGUAGE 'C' IMMUTABLE STRICT;
> CREATE OPERATOR <<< (
> PROCEDURE = my_func,
> LEFTARG = cidr,
> RIGHTARG = cidr,
> RESTRICT = contsel,
> JOIN = contjoinsel
> );

> ERROR: function my_func(cidr, cidr) does not exist

Right ...

> Now, if you look at the catalog, and the < (less than operator) as an example you will see that:

> Two operators are defined for < - one for inet,inet and another for cidr,cidr.
> Only one function exists named network_lt, and is declared as taking (inet,inet) as arguments.

My opinion is that this is a very bogus shortcut in the network datatype
code. There are no cases outside the inet/cidr group where an operator
doesn't exactly match its underlying function. (The whole business of
inet and cidr being almost but not quite the same type is maldesigned
anyway...)

The right solution for you is to declare two SQL functions. Whether you
make them point at the same underlying C code is up to you.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message John Hansen 2005-01-30 02:46:34 Re: Bug in create operator and/or initdb
Previous Message John Hansen 2005-01-30 01:56:58 Bug in create operator and/or initdb

Browse pgsql-hackers by date

  From Date Subject
Next Message John Hansen 2005-01-30 02:46:34 Re: Bug in create operator and/or initdb
Previous Message John Hansen 2005-01-30 01:56:58 Bug in create operator and/or initdb