Re: Implicit cast of literal in SQL statements - Mailing list pgsql-bugs

From Thomas Lockhart
Subject Re: Implicit cast of literal in SQL statements
Date
Msg-id 3C2B9295.91DD8559@fourpalms.org
Whole thread Raw
In response to Implicit cast of literal in SQL statements  (Scott Royston <scroyston71@yahoo.com>)
Responses Re: Implicit cast of literal in SQL statements  (Scott Royston <scroyston71@yahoo.com>)
List pgsql-bugs
> I've seen a few postings in multiple newsgroups saying that in 7.1.x and
> up, literals in SQL statements are implicitly cast to strings.

In some contexts, that statement is true, yes. The cases where this is
true is when the parser is trying to match literals with available
function calls. If there is a literal of unknown type, and if there is a
function which could take a string literal as input, then that function
is the one chosen.

> does this really work for everybody else?  Can someone point me to a
> compile flag I may be missing, or the code that actually does the
> implicit cast?

It looks like we are not handling the case where there is no explicit
function call, and there a string literal in the target list (so no
underlying column to infer a type from), and there is a subsequent
ordering operation. That might be fixable, but it may not be a useful
real world example afaict.

Do you have another example to illustrate the problem for a query which
one might actually need to use?

                     - Thomas

pgsql-bugs by date:

Previous
From: Scott Royston
Date:
Subject: Implicit cast of literal in SQL statements
Next
From: Tom Lane
Date:
Subject: Re: Implicit cast of literal in SQL statements