Example 10.9. character
Storage Type Conversion
For a target column declared as character(20)
the following statement shows that the stored value is sized correctly:
CREATE TABLE vv (v character(20)); INSERT INTO vv SELECT 'abc' || 'def'; SELECT v, octet_length(v) FROM vv; v | octet_length ----------------------+-------------- abcdef | 20 (1 row)
What has really happened here is that the two unknown literals are resolved to text
by default, allowing the ||
operator to be resolved as text
concatenation. Then the text
result of the operator is converted to bpchar
(“blank-padded char”, the internal name of the character
data type) to match the target column type. (Since the conversion from text
to bpchar
is binary-coercible, this conversion does not insert any real function call.) Finally, the sizing function bpchar(bpchar, integer, boolean)
is found in the system catalog and applied to the operator's result and the stored column length. This type-specific function performs the required length check and addition of padding spaces.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4