SELECT出力列 #
The rules given in the preceding sections will result in assignment
of non-<type>unknown</type> data types to all expressions in an SQL query,
except for unspecified-type literals that appear as simple output
columns of a <command>SELECT</command> command. For example, in
これまでの節で挙げた規則は、SELECTコマンドの単純な出力列として現れる型の指定されていないリテラルを除いて、SQL問い合わせでunknownでないデータ型をすべての式に割り当てることになります。
例えば、以下で
SELECT 'Hello World';
there is nothing to identify what type the string literal should be
taken as. In this situation <productname>PostgreSQL</productname> will fall back
to resolving the literal's type as <type>text</type>.
文字列リテラルをどの型とみなすべきかを示すものは何もありません。
この状況ではPostgreSQLはリテラルの型をtextとして解決することになります。
When the <command>SELECT</command> is one arm of a <literal>UNION</literal>
(or <literal>INTERSECT</literal> or <literal>EXCEPT</literal>) construct, or when it
appears within <command>INSERT ... SELECT</command>, 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 other <literal>UNION</literal> arm
in the first case, or from the destination column in the second case.
SELECTがUNION(またはINTERSECT、またはEXCEPT)構文の片方である場合やINSERT ... SELECTの中に現れる場合は、これまでの節で挙げた規則が優先しますので、この規則は適用されません。
型の指定されていないリテラルの型は、1番目の場合にはUNIONの他の側から、2番目の場合には対象とする列から取られるでしょう。
<literal>RETURNING</literal> lists are treated the same as <command>SELECT</command>
output lists for this purpose.
RETURNINGリストは、この目的のためにSELECT出力リストと同様に扱われます。
Prior to <productname>PostgreSQL</productname> 10, this rule did not exist, and
unspecified-type literals in a <command>SELECT</command> output list were
left as type <type>unknown</type>. That had assorted bad consequences,
so it's been changed.
PostgreSQL 10より前では、この規則は存在せず、SELECT出力リストの中の型の指定されていないリテラルは型unknownのままでした。
これは様々な悪い結果をもたらしましたので、変更されました。