Re: Selecting a constant question: A summary - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Selecting a constant question: A summary
Date
Msg-id 1397.1181710207@sss.pgh.pa.us
Whole thread Raw
In response to Re: Selecting a constant question: A summary  ("Chuck McDevitt" <cmcdevitt@greenplum.com>)
Responses Re: Selecting a constant question: A summary
List pgsql-hackers
"Chuck McDevitt" <cmcdevitt@greenplum.com> writes:
> Just a curiosity question:  Why is the type of a literal '1' "unknown"
> instead of varchar(1)?

Because, for instance, it might be intended as an integer or float or
numeric value.  Change the content a little, like '(1,2)' or '12:34',
and maybe it's a point or time value.  There are plenty of contexts in
which the intended type of a literal is obviously not text/varchar.

We assign unknown initially as a way of flagging that the type
assignment is uncertain.  Once we have a value that we think is varchar
(a table column for instance), the rules for deciding to cast it to a
different type get a lot more stringent.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Chuck McDevitt"
Date:
Subject: Re: Selecting a constant question: A summary
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Selecting a constant question