pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: luciano@geocontrol.com.br
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6496: Why the SQL is not reported as incorrect? Is there a builtin column named "name"?
Date: Tue, 28 Feb 2012 16:47:06 -0500
Message-ID: <25074.1330465626@sss.pgh.pa.us> (raw)
In-Reply-To: <E1S2PCV-0007Nn-Sm@wrigleys.postgresql.org>
References: <E1S2PCV-0007Nn-Sm@wrigleys.postgresql.org>

luciano@geocontrol.com.br writes:
> -- Wrong SQL. Reports no syntax error but yields unexpected data
> SELECT s."name" FROM (SELECT DISTINCT SUBSTRING(bug."name" FROM 1 FOR 3)
> FROM public.is_this_a_bug bug) s;

This is not a bug, exactly, although I'll agree that it's surprising
behavior.  What is happening is that the system is taking s."name" as a
coercion from the subquery's composite rowtype to the string type
"name".  We got enough complaints about that that 9.1 no longer does it,
cf this release note entry:

	Disallow function-style and attribute-style data type casts for
	composite types (Tom Lane)

	For example, disallow composite_value.text and
	text(composite_value). Unintentional uses of this syntax have
	frequently resulted in bug reports; although it was not a bug,
	it seems better to go back to rejecting such expressions. The
	CAST and :: syntaxes are still available for use when a cast of
	an entire composite value is actually intended.

There are also some possibly illuminating details here:
http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=543d22fc7423747afd59fe7214...

			regards, tom lane



view thread (2+ messages)

Message-ID: <25074.1330465626@sss.pgh.pa.us>
Permalink:  ../25074.1330465626@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25074.1330465626@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, luciano@geocontrol.com.br
  Subject: Re: BUG #6496: Why the SQL is not reported as incorrect? Is there a builtin column named "name"?
  In-Reply-To: <25074.1330465626@sss.pgh.pa.us>
  References: <E1S2PCV-0007Nn-Sm@wrigleys.postgresql.org> <25074.1330465626@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox