Confusion about CREATE OPERATOR syntax.

From: Raphael Araújo e Silva <raphael(at)pgmodeler(dot)com(dot)br>
To: pgsql-sql(at)postgresql(dot)org
Subject: Confusion about CREATE OPERATOR syntax.
Date: 2017-09-05 18:38:03
Message-ID: CABJ1nXxMdZWEsSUphsfrT-vOZZxRo3ZMeaOA9WS=5KHEvv5fzg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi guys!

I'm the creator of the PostgreSQL Database Modeler and I'm improving the
reverse engineering feature after some requests from the users.

I've stumbled on a bug when importing operators and while I was writing a
fix for that bug a great confusion came into my mind. It's about the CREATE
OPERATOR syntax, more specifically, about the LEFTARG and RIGHTARG
attributes.

I've read the docs but cannot find a proper answer and that's why I'm
here... I hope you guys can help me. Well, my doubt is: when specifying
LEFTARG and RIGHTARG the datatypes should be written in the complete form?
By "complete form" I mean specifying the precision and/or length... For
instance, I want to create an operator to handle certain operation between
two numeric(5,2) values, said that, my operator should be written as:

CREATE OPERATOR ++ (
PROCEDURE = func_name(numeric,numeric),
LEFTARG = numeric,
RIGHTARG = numeric
)

Or(?):

CREATE OPERATOR ++ (
PROCEDURE = func_name(numeric,numeric),
LEFTARG = *numeric(5,2)*,
RIGHTARG = *numeric(5,2)*
)

Well, I've tested both forms and them work fine. If I try to run one after
another an error will raise for the second reporting that the operator
already exists. Is PostgreSQL simply interpreting them as the same? Is the
precision/length ignored/not needed?

Thanks in advance and forgive my rusty English, I'm Brazilian! :)
--
Raphael Araújo e Silva
pgModeler Project Developer

raphael(at)pgmodeler(dot)com(dot)br
http://pgmodeler.com.br
https://github.com/pgmodeler

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2017-09-06 00:31:08 Re: Confusion about CREATE OPERATOR syntax.
Previous Message Viktor Bojović 2017-09-01 07:59:16 Re: autogenerated json path