Re: COMMUTATOR doesn't seem to work
От | D'Arcy Cain |
---|---|
Тема | Re: COMMUTATOR doesn't seem to work |
Дата | |
Msg-id | 4FE48B72.8040605@druid.net обсуждение исходный текст |
Ответ на | Re: COMMUTATOR doesn't seem to work (Florian Pflug <fgp@phlo.org>) |
Ответы |
Re: COMMUTATOR doesn't seem to work
|
Список | pgsql-hackers |
On 12-06-22 07:11 AM, Florian Pflug wrote: > On Jun22, 2012, at 06:32 , D'Arcy Cain wrote: >> So I have my type working now but I had to create a new C function >> that take the opposite argument order. Seems redundant but I could >> not see a better way. > > There isn't. Postgres itself contains a huge number of such functions, > e.g. for every *lt() (less-than) there's a *gt() (greater-than). Right but that's not the same thing. Assuming you meant lt/gte and lte/gt those still are not self-commutating (SC). For example, '=' on two ints is SC. The issue here is that the operator is SC but the args are different types. It would be nice if there was a way to automatically generate code that reverses arguments. Maybe such a thing belongs in the CREATE FUNCTION command. Or, I guess this works and keeps from creating a second C function: CREATE OR REPLACE FUNCTION eq(chkpass, text) RETURNS bool STRICT AS 'chkpass.so', 'chkpass_eq' LANGUAGE 'c' RETURNS NULL ON NULL INPUT; CREATE OR REPLACE FUNCTION eq(text, chkpass) RETURNS bool AS 'select eq($2, $1);' LANGUAGE SQL RETURNS NULL ONNULL INPUT; -- D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. IM: darcy@Vex.Net
В списке pgsql-hackers по дате отправления: