Re: Type of bare text strings - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Type of bare text strings
Date
Msg-id 20060608161208.GB17421@surnet.cl
Whole thread Raw
In response to Type of bare text strings  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: Type of bare text strings  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Type of bare text strings  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Jim C. Nasby wrote:
> What type are bare strings considered if they haven't been cast? I'm curious as
> to how the first case is of size 5, and how the last case is 301...
> 
> decibel=# select pg_column_size('test');
>               5

"unknown".  This seems to be a cstring (i.e. length 5 considering the
trailing \0)

> decibel=# select pg_column_size('test'::varchar);
>               8
> decibel=# select pg_column_size('test'::text);
>               8
> decibel=# select pg_column_size('test'::char(4));
>               8

4 fixed varlena + 4 string length

> decibel=# select pg_column_size('test'::name);
>              64

name is fixed 64 bytes (not varlena)


> decibel=# select
pg_column_size('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
>             301

Same as the first case.  (There are actual 300 chars here according to
my count, is that right?)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to avoid transaction ID wrap
Next
From: "Joshua D. Drake"
Date:
Subject: Re: How to avoid transaction ID wrap