BUG: text(varchar) truncates at 31 bytes - Mailing list pgsql-hackers

From Dave Blasby
Subject BUG: text(varchar) truncates at 31 bytes
Date
Msg-id 3BBB5B57.4FEF2C2B@refractions.net
Whole thread Raw
Responses Re: BUG: text(varchar) truncates at 31 bytes
Re: BUG: text(varchar) truncates at 31 bytes
Re: BUG: text(varchar) truncates at 31 bytes
List pgsql-hackers
#create table t (v varchar);
#insert into t values ('0123456789a0123456789b0123456789c0123456789d');

#select v from t;
                     v                       
----------------------------------------------0123456789a0123456789b0123456789c0123456789d
(1 row)

So far, so good.

#select text(v) from t;
            text               
---------------------------------0123456789a0123456789b012345678
(1 row)

Truncation occurs.

Work around:

# select v::text from t;                  ?column?                   
----------------------------------------------0123456789a0123456789b0123456789c0123456789d
(1 row)

I couldnt figure out what happens during a text(varchar) call.  I looked
around in pg_proc, but couldnt find the function.  There's probably an
automagic type conversion going on or something.

Could someone explain what all the internal varchar-like types are (ie.
varchar,varchar(n),text,char,_char,bpchar) and when they're used?  I
find it all really confusing - I'm sure others do too.

Is there anyway to determine what postgresql is doing in its automagic
function calls? I guess I'm asking for an EXPLAIN that describes
function calls.  For example, 
EXPLAIN select text(v) from t;

--> {Description of conversion from varchar to whatever the text()
function actually works on}


Thanks,
dave


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: HISTORY for 7.2
Next
From: Bruce Momjian
Date:
Subject: Re: BUG: text(varchar) truncates at 31 bytes