]> begriffs open source - ai-pg/blob - full-docs/txt/typeconv-select.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / typeconv-select.txt
1
2 10.6. SELECT Output Columns #
3
4    The rules given in the preceding sections will result in assignment of
5    non-unknown data types to all expressions in an SQL query, except for
6    unspecified-type literals that appear as simple output columns of a
7    SELECT command. For example, in
8 SELECT 'Hello World';
9
10    there is nothing to identify what type the string literal should be
11    taken as. In this situation PostgreSQL will fall back to resolving the
12    literal's type as text.
13
14    When the SELECT is one arm of a UNION (or INTERSECT or EXCEPT)
15    construct, or when it appears within INSERT ... SELECT, this rule is
16    not applied since rules given in preceding sections take precedence.
17    The type of an unspecified-type literal can be taken from the other
18    UNION arm in the first case, or from the destination column in the
19    second case.
20
21    RETURNING lists are treated the same as SELECT output lists for this
22    purpose.
23
24 Note
25
26    Prior to PostgreSQL 10, this rule did not exist, and unspecified-type
27    literals in a SELECT output list were left as type unknown. That had
28    assorted bad consequences, so it's been changed.