Unary Operators

Поиск
Список
Период
Сортировка
От Andreas Ulbrich
Тема Unary Operators
Дата
Msg-id 5235FD3B.9000605@matheversum.de
обсуждение исходный текст
Ответы Re: Unary Operators  (Rowan Collins <rowan.collins@gmail.com>)
Re: Unary Operators  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: v9.3.0: bug with pgdump -s?
Следующее
От: "Eric B. Ridge"
Дата:
Сообщение: Re: v9.3.0: bug with pgdump -s?