Re: [HACKERS] Creating operators
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] Creating operators |
Дата | |
Msg-id | 12034.940402313@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Creating operators ("Gene Sokolov" <hook@aktrad.ru>) |
Список | pgsql-hackers |
"Gene Sokolov" <hook@aktrad.ru> writes: > Q1: > Let's say I want to create a '+' operator for <my own type> + int4. Do I > really have to > define two '+' operators, one > <my own type> + int > and the other > int + <my own type> Yes. There's nothing compelling them to behave the same, after all (consider '-' instead of '+'). If they do behave the same you should indicate this with "commutator" links --- see the discussion in the manual. > Can I create an operator '::', such as <my own type>::double ? You can't redefine the meaning of the typecast construct '::', if that's what you meant. But perhaps what you really meant was that you want to provide a conversion from your type to double. For that you just make a function named 'double', yielding double, and taking your type as input. The typecast code will use it automatically. (Of course "double" is spelled "float8" in Postgres-land, but you knew that...) regards, tom lane
В списке pgsql-hackers по дате отправления: