Re: weird error message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Michael Moore <michaeljmoore(at)gmail(dot)com>, postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: weird error message
Date: 2016-05-06 16:35:24
Message-ID: 5722.1462552524@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> I don't know that this is covered all that well in the documentation.

It'd be better to do something about it than document it. The core of
the problem is that if we don't resolve the type of an unknown literal
while processing the sub-SELECT's target list, it doesn't work to try
to make a conversion later.

I think there's a rough consensus that it'd be okay to resolve unknown to
text at the time that the subquery is parsed, if there's no reason to
resolve it to something else. There would be cases where that's not
really what you want, but it would be unsurprising for it to act that way.

The hard part is that we've historically allowed

INSERT INTO sometab SELECT 'foo', ...

to resolve 'foo' as the type of sometab's first column (and I think this
is required by SQL spec, actually). So some work would have to be done
to not break that behavior. But I think this could be managed by
explicitly passing down knowledge of the INSERT's target column types into
the parsing of the sub-SELECT, and then the rule could be "resolve an
unknown SELECT output column to whatever target type is provided by
context, or to TEXT if the context provides no target".

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2016-05-06 17:00:57 Re: weird error message
Previous Message Michael Moore 2016-05-06 15:31:32 Re: weird error message