about value storage

Started by lsliangover 14 years ago2 messagesdocs
Jump to latest
#1lsliang
lsliang@pconline.com.cn

http://www.postgresql.org/docs/9.0/interactive/typeconv-query.html

example shows:

CREATE TABLE vv (v character(20));
INSERT INTO vv SELECT 'abc' || 'def';
SELECT v, length(v) FROM vv;

v | length
----------------------+--------
abcdef | 20
(1 row)

but my test show not like this :

^
lsl=# select version();
version
-------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.0.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)

lsl=# CREATE TABLE vv (v character(20));
INSERT INTO vv SELECT 'abc' || 'def';
SELECT v, length(v) FROM vv;
CREATE TABLE
lsl=# INSERT INTO vv SELECT 'abc' || 'def';
INSERT 0 1
lsl=# SELECT v, length(v) FROM vv;
v | length
----------------------+--------
abcdef | 6
(1 row)

why ?? anyone help me ?

or it is a doc mistake ?

thank you!

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: lsliang (#1)
Re: about value storage

"lsliang" <lsliang@pconline.com.cn> writes:

http://www.postgresql.org/docs/9.0/interactive/typeconv-query.html
example shows:

CREATE TABLE vv (v character(20));
INSERT INTO vv SELECT 'abc' || 'def';
SELECT v, length(v) FROM vv;

v | length
----------------------+--------
abcdef | 20
(1 row)

but my test show not like this :

Hmm, looks like that example was overlooked when we changed the behavior
years ago:
http://git.postgresql.org/gitweb/?p=postgresql.git&amp;a=commitdiff&amp;h=f27976c85b1fb9002727cce65b9f9567e158f754

Given the context, we should change it to use octet_length().
Will fix, thanks.

regards, tom lane