@@ -758,9 +758,11 @@ cast is a cast from that type to itself. If one is found in the
758758<structname>pg_cast</> catalog, apply it to the expression before storing
759759into the destination column. The implementation function for such a cast
760760always takes an extra parameter of type <type>integer</type>, which receives
761- the destination column's declared length (actually, its
762- <structfield>atttypmod</> value; the interpretation of
763- <structfield>atttypmod</> varies for different data types). The cast function
761+ the destination column's <structfield>atttypmod</> value (typically its
762+ declared length, although the interpretation of <structfield>atttypmod</>
763+ varies for different data types), and it may take a third <type>boolean</>
764+ parameter that says whether the cast is explicit or implicit. The cast
765+ function
764766is responsible for applying any length-dependent semantics such as size
765767checking or truncation.
766768</para>
@@ -772,17 +774,17 @@ checking or truncation.
772774<title><type>character</type> Storage Type Conversion</title>
773775
774776<para>
775- For a target column declared as <type>character(20)</type> the following statement
776- ensures that the stored value is sized correctly:
777+ For a target column declared as <type>character(20)</type> the following
778+ statement shows that the stored value is sized correctly:
777779
778780<screen>
779781CREATE TABLE vv (v character(20));
780782INSERT INTO vv SELECT 'abc' || 'def';
781- SELECT v, length (v) FROM vv;
783+ SELECT v, octet_length (v) FROM vv;
782784
783- v | length
784- ----------------------+--------
785- abcdef | 20
785+ v | octet_length
786+ ----------------------+--------------
787+ abcdef | 20
786788(1 row)
787789</screen>
788790</para>
@@ -796,7 +798,7 @@ char</>, the internal name of the <type>character</type> data type) to match the
796798column type. (Since the conversion from <type>text</type> to
797799<type>bpchar</type> is binary-coercible, this conversion does
798800not insert any real function call.) Finally, the sizing function
799- <literal>bpchar(bpchar, integer)</literal > is found in the system catalog
801+ <literal>bpchar(bpchar, integer, boolean )</> is found in the system catalog
800802and applied to the operator's result and the stored column length. This
801803type-specific function performs the required length check and addition of
802804padding spaces.
0 commit comments