|
1 |
| -<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.381 2007/05/30 18:13:29 momjian Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.382 2007/06/06 23:00:35 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="functions">
|
4 | 4 | <title>Functions and Operators</title>
|
|
986 | 986 | <para>
|
987 | 987 | This section describes functions and operators for examining and
|
988 | 988 | manipulating string values. Strings in this context include values
|
989 |
| - of all the types <type>character</type>, <type>character |
990 |
| - varying</type>, and <type>text</type>. Unless otherwise noted, all |
| 989 | + of the types <type>character</type>, <type>character varying</type>, |
| 990 | + and <type>text</type>. Unless otherwise noted, all |
991 | 991 | of the functions listed below work on all of these types, but be
|
992 |
| - wary of potential effects of the automatic padding when using the |
993 |
| - <type>character</type> type. Generally, the functions described |
994 |
| - here also work on data of non-string types by converting that data |
995 |
| - to a string representation first. Some functions also exist |
| 992 | + wary of potential effects of automatic space-padding when using the |
| 993 | + <type>character</type> type. Some functions also exist |
996 | 994 | natively for the bit-string types.
|
997 | 995 | </para>
|
998 | 996 |
|
999 | 997 | <para>
|
1000 |
| - <acronym>SQL</acronym> defines some string functions with a special syntax where |
1001 |
| - certain key words rather than commas are used to separate the |
| 998 | + <acronym>SQL</acronym> defines some string functions with a special syntax |
| 999 | + wherein certain key words rather than commas are used to separate the |
1002 | 1000 | arguments. Details are in <xref linkend="functions-string-sql">.
|
1003 | 1001 | These functions are also implemented using the regular syntax for
|
1004 | 1002 | function invocation. (See <xref linkend="functions-string-other">.)
|
1005 | 1003 | </para>
|
1006 | 1004 |
|
| 1005 | + <note> |
| 1006 | + <para> |
| 1007 | + Before <productname>PostgreSQL</productname> 8.3, these functions would |
| 1008 | + silently accept values of several non-string data types as well, due to |
| 1009 | + the presence of implicit coercions from those data types to |
| 1010 | + <type>text</>. Those coercions have been removed because they frequently |
| 1011 | + caused surprising behaviors. However, the string concatenation operator |
| 1012 | + (<literal>||</>) still accepts non-string input, so long as at least one |
| 1013 | + input is of a string type, as shown in <xref |
| 1014 | + linkend="functions-string-sql">. For other cases, insert an explicit |
| 1015 | + coercion to <type>text</> if you need to duplicate the previous behavior. |
| 1016 | + </para> |
| 1017 | + </note> |
| 1018 | + |
1007 | 1019 | <indexterm>
|
1008 | 1020 | <primary>bit_length</primary>
|
1009 | 1021 | </indexterm>
|
|
1064 | 1076 | <entry><literal>PostgreSQL</literal></entry>
|
1065 | 1077 | </row>
|
1066 | 1078 |
|
| 1079 | + <row> |
| 1080 | + <entry> |
| 1081 | + <literal><parameter>string</parameter> <literal>||</literal> |
| 1082 | + <parameter>non-string</parameter></literal> |
| 1083 | + or |
| 1084 | + <literal><parameter>non-string</parameter> <literal>||</literal> |
| 1085 | + <parameter>string</parameter></literal> |
| 1086 | + </entry> |
| 1087 | + <entry> <type>text</type> </entry> |
| 1088 | + <entry> |
| 1089 | + String concatenation with one non-string input |
| 1090 | + </entry> |
| 1091 | + <entry><literal>'Value: ' || 42</literal></entry> |
| 1092 | + <entry><literal>Value: 42</literal></entry> |
| 1093 | + </row> |
| 1094 | + |
1067 | 1095 | <row>
|
1068 | 1096 | <entry><literal><function>bit_length</function>(<parameter>string</parameter>)</literal></entry>
|
1069 | 1097 | <entry><type>int</type></entry>
|
|
0 commit comments