dbTalk Databases Forums  

Re: [BUGS] Bug in create operator and/or initdb

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] Bug in create operator and/or initdb in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Bug in create operator and/or initdb - 01-29-2005 , 08:56 PM






"John Hansen" <john (AT) geeknet (DOT) com.au> writes:
Quote:
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 ...

Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
John Hansen
 
Posts: n/a

Default Re: [BUGS] Bug in create operator and/or initdb - 01-29-2005 , 08:57 PM






Quote:
My opinion is that this is a very bogus shortcut in the=20
network datatype code. There are no cases outside the=20
inet/cidr group where an operator doesn't exactly match its=20
underlying function. (The whole business of inet and cidr=20
being almost but not quite the same type is maldesigned
anyway...)
=20
The right solution for you is to declare two SQL functions.=20=20
Whether you make them point at the same underlying C code is=20
up to you.
Right,...

In that case may I suggest fixing the catalog so network_* functions exists=
for both datatypes!
Anything less I'd consider inconsistent...

Kind regards,

John

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Bug in create operator and/or initdb - 01-29-2005 , 09:18 PM



"John Hansen" <john (AT) geeknet (DOT) com.au> writes:
Quote:
In that case may I suggest fixing the catalog so network_* functions exists for both datatypes!
Redesigning the inet/cidr distinction is on the to-do list (though I'm
afraid not very high on the list). ISTM it should either be one type
with a distinguishing bit in the runtime representation, or two types
with no such bit needed. Having both is a schizophrenic design. It's
led directly to bugs in the past, and I think there are still some
corner cases that act oddly (see the archives).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.