Re: Syntax Issue in Trigger Function?? - Mailing list pgsql-general

From Tom Lane
Subject Re: Syntax Issue in Trigger Function??
Date
Msg-id 19727.1096408564@sss.pgh.pa.us
Whole thread Raw
In response to Re: Syntax Issue in Trigger Function??  (Andre Maasikas <andre.maasikas@abs.ee>)
List pgsql-general
Andre Maasikas <andre.maasikas@abs.ee> writes:
> Without escaping it looks like v_ref := ''/'';
> dividing 2 empty strings, and indeed gives
> division by zero in psql. What dividing 2 strings is actually
> supposed to mean is not evident form the docs in the first glance.

This is a pet peeve of mine that I unfortunately forgot to do anything
about before 8.0 beta started; so it's too late for this release, unless
there is another reason for forcing initdb before final.  The problem is
that the "char" type (not to be confused with CHAR(n) type) has basic
arithmetic operators defined, and since it is considered a member of the
STRING type class, these operators get selected whenever a couple of
undecorated strings are provided.

Try these on for size :-(

regression=# select '2' + '2';
 ?column?
----------
 d
(1 row)

regression=# select 'A' * 'B';
 ?column?
----------
 �
(1 row)

regression=# select '1' / '';
ERROR:  division by zero

Given the one-byte precision, these operators are surely of pretty
marginal use.  I'd leave 'em alone if it weren't that the type coercion
rules cause the parser to seize on these operators in cases where a "no
operator could be identified" error would be far more appropriate.

            regards, tom lane

pgsql-general by date:

Previous
From: "Scrappy"
Date:
Subject: Re: Hello
Next
From: Jerry LeVan
Date:
Subject: Controlling order of evaluation?