10.6. SELECT輸出規則1

The rules given in the preceding sections will result in assignment of non-unknowndata types to all expressions in a SQL query, except for unspecified-type literals that appear as simple output columns of aSELECTcommand. For example, in

SELECT 'Hello World';

there is nothing to identify what type the string literal should be taken as. In this situationPostgreSQLwill fall back to resolving the literal's type astext.

When theSELECTis one arm of aUNION(orINTERSECTorEXCEPT) construct, or when it appears withinINSERT ... SELECT, this rule is not applied since rules given in preceding sections take precedence. The type of an unspecified-type literal can be taken from the otherUNIONarm in the first case, or from the destination column in the second case.

RETURNINGlists are treated the same asSELECToutput lists for this purpose.


Prior toPostgreSQL10, this rule did not exist, and unspecified-type literals in aSELECToutput list were left as typeunknown. That had assorted bad consequences, so it's been changed.

1. PostgreSQL: Documentation: 10: 10.6. SELECT Output Columns

results matching ""

    No results matching ""