Skip to content

Commit 1426abb

Browse files
committed
Update type-conversion documentation for long-ago changes.
This example wasn't updated when we changed the behavior of bpcharlen() in 8.0, nor when we changed the number of parameters taken by the bpchar() cast function in 7.3. Per report from lsliang.
1 parent c2042d0 commit 1426abb

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

doc/src/sgml/typeconv.sgml

+12-10
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,11 @@ cast is a cast from that type to itself. If one is found in the
734734
<structname>pg_cast</> catalog, apply it to the expression before storing
735735
into the destination column. The implementation function for such a cast
736736
always takes an extra parameter of type <type>integer</type>, which receives
737-
the destination column's declared length (actually, its
738-
<structfield>atttypmod</> value; the interpretation of
739-
<structfield>atttypmod</> varies for different data types). The cast function
737+
the destination column's <structfield>atttypmod</> value (typically its
738+
declared length, although the interpretation of <structfield>atttypmod</>
739+
varies for different data types), and it may take a third <type>boolean</>
740+
parameter that says whether the cast is explicit or implicit. The cast
741+
function
740742
is responsible for applying any length-dependent semantics such as size
741743
checking or truncation.
742744
</para>
@@ -748,17 +750,17 @@ checking or truncation.
748750
<title><type>character</type> Storage Type Conversion</title>
749751

750752
<para>
751-
For a target column declared as <type>character(20)</type> the following statement
752-
ensures that the stored value is sized correctly:
753+
For a target column declared as <type>character(20)</type> the following
754+
statement shows that the stored value is sized correctly:
753755

754756
<screen>
755757
CREATE TABLE vv (v character(20));
756758
INSERT INTO vv SELECT 'abc' || 'def';
757-
SELECT v, length(v) FROM vv;
759+
SELECT v, octet_length(v) FROM vv;
758760

759-
v | length
760-
----------------------+--------
761-
abcdef | 20
761+
v | octet_length
762+
----------------------+--------------
763+
abcdef | 20
762764
(1 row)
763765
</screen>
764766
</para>
@@ -772,7 +774,7 @@ char</>, the internal name of the <type>character</type> data type) to match the
772774
column type. (Since the types <type>text</type> and
773775
<type>bpchar</type> are binary-compatible, this conversion does
774776
not insert any real function call.) Finally, the sizing function
775-
<literal>bpchar(bpchar, integer)</literal> is found in the system catalog
777+
<literal>bpchar(bpchar, integer, boolean)</> is found in the system catalog
776778
and applied to the operator's result and the stored column length. This
777779
type-specific function performs the required length check and addition of
778780
padding spaces.

0 commit comments

Comments
 (0)