agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Michael Moore <michaeljmoore@gmail.com>
Cc: postgres list <pgsql-sql@postgresql.org>
Subject: Re: weird error message
Date: Fri, 06 May 2016 12:35:24 -0400
Message-ID: <5722.1462552524@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbyw_zayifKfKwKzdso+y021kjxfXkLpki0VBrsih2Jow@mail.gmail.com>
References: <CACpWLjMK8J2O_zjrhBgfYoYU=eO=+CNO7DE0BNM6YNTkbYV4Hw@mail.gmail.com>
	<e9b9f162-ad10-74a8-9f5a-3198b2a36144@aklaver.com>
	<CAKFQuwbyw_zayifKfKwKzdso+y021kjxfXkLpki0VBrsih2Jow@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

"David G. Johnston" <david.g.johnston@gmail.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (9+ messages)  latest in thread

Message-ID: <5722.1462552524@sss.pgh.pa.us>
Permalink:  ../5722.1462552524@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5722.1462552524@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, adrian.klaver@aklaver.com, michaeljmoore@gmail.com
  Subject: Re: weird error message
  In-Reply-To: <5722.1462552524@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox