@@ -2894,37 +2894,36 @@ SELECT EXTRACT(days from '80 hours'::interval);
2894
2894
</table>
2895
2895
2896
2896
<para>
2897
- Valid literal values for the <quote>true</quote> state are:
2897
+ Boolean constants can be represented in SQL queries by the SQL
2898
+ key words <literal>TRUE</literal>, <literal>FALSE</literal>,
2899
+ and <literal>NULL</literal>.
2900
+ </para>
2901
+
2902
+ <para>
2903
+ The datatype input function for type <type>boolean</type> accepts these
2904
+ string representations for the <quote>true</quote> state:
2898
2905
<simplelist>
2899
- <member><literal>TRUE</literal></member>
2900
- <member><literal>'t'</literal></member>
2901
- <member><literal>'true'</literal></member>
2902
- <member><literal>'y'</literal></member>
2903
- <member><literal>'yes'</literal></member>
2904
- <member><literal>'on'</literal></member>
2905
- <member><literal>'1'</literal></member>
2906
+ <member><literal>true</literal></member>
2907
+ <member><literal>yes</literal></member>
2908
+ <member><literal>on</literal></member>
2909
+ <member><literal>1</literal></member>
2906
2910
</simplelist>
2907
- For the <quote>false</quote> state, the following values can be
2908
- used:
2911
+ and these representations for the <quote>false</quote> state:
2909
2912
<simplelist>
2910
- <member><literal>FALSE</literal></member>
2911
- <member><literal>'f'</literal></member>
2912
- <member><literal>'false'</literal></member>
2913
- <member><literal>'n'</literal></member>
2914
- <member><literal>'no'</literal></member>
2915
- <member><literal>'off'</literal></member>
2916
- <member><literal>'0'</literal></member>
2913
+ <member><literal>false</literal></member>
2914
+ <member><literal>no</literal></member>
2915
+ <member><literal>off</literal></member>
2916
+ <member><literal>0</literal></member>
2917
2917
</simplelist>
2918
+ Unique prefixes of these strings are also accepted, for
2919
+ example <literal>t</literal> or <literal>n</literal>.
2918
2920
Leading or trailing whitespace is ignored, and case does not matter.
2919
- The key words
2920
- <literal>TRUE</literal> and <literal>FALSE</literal> are the preferred
2921
- (<acronym>SQL</acronym>-compliant) usage.
2922
2921
</para>
2923
2922
2924
2923
<para>
2925
- <xref linkend=" datatype- boolean-example"/> shows that
2926
- <type>boolean</type> values are output using the letters
2927
- <literal>t</literal> and <literal>f</literal >.
2924
+ The datatype output function for type <type> boolean</type> always emits
2925
+ either <literal>t</literal> or <literal>f</literal>, as shown in
2926
+ <xref linkend="datatype-boolean-example"/ >.
2928
2927
</para>
2929
2928
2930
2929
<example id="datatype-boolean-example">
@@ -2946,6 +2945,27 @@ SELECT * FROM test1 WHERE a;
2946
2945
t | sic est
2947
2946
</programlisting>
2948
2947
</example>
2948
+
2949
+ <para>
2950
+ The key words <literal>TRUE</literal> and <literal>FALSE</literal> are
2951
+ the preferred (<acronym>SQL</acronym>-compliant) method for writing
2952
+ Boolean constants in SQL queries. But you can also use the string
2953
+ representations by following the generic string-literal constant syntax
2954
+ described in <xref linkend="sql-syntax-constants-generic"/>, for
2955
+ example <literal>'yes'::boolean</literal>.
2956
+ </para>
2957
+
2958
+ <para>
2959
+ Note that the parser automatically understands
2960
+ that <literal>TRUE</literal> and <literal>FALSE</literal> are of
2961
+ type <type>boolean</type>, but this is not so
2962
+ for <literal>NULL</literal> because that can have any type.
2963
+ So in some contexts you might have to cast <literal>NULL</literal>
2964
+ to <type>boolean</type> explicitly, for
2965
+ example <literal>NULL::boolean</literal>. Conversely, the cast can be
2966
+ omitted from a string-literal Boolean value in contexts where the parser
2967
+ can deduce that the literal must be of type <type>boolean</type>.
2968
+ </para>
2949
2969
</sect1>
2950
2970
2951
2971
<sect1 id="datatype-enum">