From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Raphael Araújo e Silva <raphael(at)pgmodeler(dot)com(dot)br> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Confusion about CREATE OPERATOR syntax. |
Date: | 2017-09-06 00:31:08 |
Message-ID: | CAKFQuwbh+PEChcZpRQJu_C7pxar+Bs23=LSvcJ8G11G+TTn0Wg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tuesday, September 5, 2017, Raphael Araújo e Silva <
raphael(at)pgmodeler(dot)com(dot)br> wrote:
>
> 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:
>
> ...
> 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?
>
My understanding and your experience match, the "typmod" aspect of the base
data type is ignored. Here specifically and also generally when dealing
with functions. So, no, you cannot write two functions/operators whose
inputs distinguish/differ in the type modifier - and are thus the same
underlying type.
Reading the docs for numeric it seems that the application of the modifier
is only used during input value parsing - though table columns retain the
info so that column literal inputs can be correctly processed. When
dealing with functions the inputs to the functions are already existing
and typed values and so no input value parsing is needed.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Ertan Küçükoğlu | 2017-09-12 11:31:47 | FirebirdSQL to PostgreSQL |
Previous Message | Raphael Araújo e Silva | 2017-09-05 18:38:03 | Confusion about CREATE OPERATOR syntax. |