Unary Operators
От | Andreas Ulbrich |
---|---|
Тема | Unary Operators |
Дата | |
Msg-id | 5235FD3B.9000605@matheversum.de обсуждение исходный текст |
Ответы |
Re: Unary Operators
Re: Unary Operators |
Список | pgsql-general |
Salvete! I have the following problem. I'd like to define the operator symbol / as a left unary operator for reciprocal value of a number. I did this with a C-function and all the stuff around, but it does not work. Hiere is an extract and simplified example with the same error message as in my complex example: create function reciproce(float) returns float as $$ values(1.0::float / $1) $$ language sql immutable strict; create operator / (rightarg = float, procedure = reciproce); select / 5.0::float; --> ERROR: syntax error at or near "/" LINE 1: select / 5.0; This is in 9.3.0 and 9.2.4 the same. If I take the ! as the operator all is fine: create operator ! (rightarg = float, procedure = reciproce); select ! 5.0::float; --> ?column? ---------- 0.2 (1 row) The definition seems to be equivalent: # \do List of operators Schema | Name | Left arg type | Right arg type | Result type | Description --------+------+---------------+------------------+------------------+------------- public | ! | | double precision | double precision | public | / | | double precision | double precision | (2 rows) create operator ^- (leftarg = float, procedure = reciproce); works too, but create operator / (leftarg = float, procedure = reciproce); not. In the documentation I can't find, that / is not possible as an unary operator. Are there any restrictions.
В списке pgsql-general по дате отправления: