From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Gregory Stark <stark(at)enterprisedb(dot)com> |
Cc: | "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Implicit casts with generic arrays |
Date: | 2007-06-05 01:25:41 |
Message-ID: | 2486.1181006741@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> we should do is make oper() specifically test for the case of operator
>> 349 with UNKNOWN left input, or operator 374 with UNKNOWN right input,
>> and throw a custom error message hinting that the other operand
>> needs to be cast to text.
> Wouldn't that mean that 'foo'||'bar' would *still* fail?
No, because that would preferentially match to text || text, it being
a preferred-type case. The current behavior with the implicit casts
removed is
template1=# select 'abc' || '34';
?column?
----------
abc34
(1 row)
ie, this was matched to the text || text operator;
template1=# select 'abc' || 34;
ERROR: array value must start with "{" or dimension information
ie, this was matched to the anyarray || anyelement operator --- because
it clearly can't match text || text.
> It really seems to me that at some point down the line we're going to
> cave and admit that users do expect 'foo' to be a string first and
> cast to other types only if the context requires it.
We already do that to some extent, as shown above; and it's got
approximately nothing to do with this problem anyway. The cases where
we have got a problem are where the other argument is clearly *not*
text.
But having said that, I'm currently leaning to the other solution of
generalizing the || operator (and only that operator) instead of
fooling with the type resolution rules.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-06-05 01:28:22 | Re: TOAST usage setting |
Previous Message | Robert Haas | 2007-06-05 01:16:24 | Re: Command tags in create/drop scripts |