From lsliang@pconline.com.cn Tue Sep 6 02:53:07 2011 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 85050B5DE73 for ; Mon, 5 Sep 2011 23:53:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 56490-01 for ; Tue, 6 Sep 2011 02:52:59 +0000 (UTC) X-Greylist: delayed 00:08:58.44265 by SQLgrey-1.7.6 Received: from mail.pc.com.cn (mail.pconline.com.cn [202.96.159.232]) by mail.postgresql.org (Postfix) with ESMTP id 18F3FB5DE4A for ; Mon, 5 Sep 2011 23:52:59 -0300 (ADT) Received: from JISHU-LSLIANG (unknown [192.168.20.4]) by mail.pc.com.cn (Postfix - by pc.com.cn) with ESMTPA id B141B1DEF8E for ; Tue, 6 Sep 2011 10:43:55 +0800 (CST) Date: Tue, 6 Sep 2011 10:43:57 +0800 From: "lsliang" To: "pgsql-docs" Subject: about value storage Message-ID: <201109061043572514728@pconline.com.cn> X-mailer: Foxmail 6, 15, 201, 23 [cn] Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====003_Dragon715338250033_=====" X-Antivirus: avast! (VPS 110905-1, 2011/09/06), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.297 tagged_above=-5 required=5 tests=BAYES_50=0.8, HTML_MESSAGE=0.001, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/17 X-Sequence-Number: 6938 This is a multi-part message in MIME format. --=====003_Dragon715338250033_===== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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! --=====003_Dragon715338250033_===== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit
 
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!
 
--=====003_Dragon715338250033_=====-- From tgl@sss.pgh.pa.us Tue Sep 6 15:52:48 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A96E3B5DC15 for ; Tue, 6 Sep 2011 12:52:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 14548-07 for ; Tue, 6 Sep 2011 15:52:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C1E1BB5DC12 for ; Tue, 6 Sep 2011 12:52:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p86FqW1L007709; Tue, 6 Sep 2011 11:52:33 -0400 (EDT) To: "lsliang" cc: "pgsql-docs" Subject: Re: about value storage In-reply-to: <201109061043572514728@pconline.com.cn> References: <201109061043572514728@pconline.com.cn> Comments: In-reply-to "lsliang" message dated "Tue, 06 Sep 2011 10:43:57 +0800" Date: Tue, 06 Sep 2011 11:52:32 -0400 Message-ID: <7708.1315324352@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/19 X-Sequence-Number: 6940 "lsliang" 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&a=commitdiff&h=f27976c85b1fb9002727cce65b9f9567e158f754 Given the context, we should change it to use octet_length(). Will fix, thanks. regards, tom lane