pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <maillist@candle.pha.pa.us>
To: tgl@sss.pgh.pa.us
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] char type seems the same as char(1)
Date: Sat, 12 Dec 1998 22:41:09 -0500 (EST)
Message-ID: <199812130341.WAA12919@candle.pha.pa.us> (raw)
In-Reply-To: <28655.912017111@sss.pgh.pa.us>

> The Postgres documentation (chapter "Data Types" in the User's Manual)
> states that type char is a single byte, whereas char(n) requires 4+n
> bytes.  Some experimentation, however, shows that "char" is actually
> equivalent to char(1) --- it takes 5 bytes to store, even though psql's
> "\d table" command lies and claims it takes only 1.  Worse, the field
> requires 4-byte alignment, which means if you have several of them
> in a row, it's costing you 8 bytes apiece.
> 
> Is this a documentation error, or a code bug?  If not a bug, is there
> any other way to store a character as a single-byte field?  I'm
> currently using char fields all over the place as "poor man's enumerated
> type" values, and I'm rather annoyed to find that what I thought was
> taking 1 byte per field is actually taking 8...

Should I add this to the TODO list, that char is not char1 but has
4-byte length?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



view thread (9+ messages)  latest in thread

Message-ID: <199812130341.WAA12919@candle.pha.pa.us>
Permalink:  ../199812130341.WAA12919@candle.pha.pa.us/
Also on:    postgresql.org/message-id/199812130341.WAA12919@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: maillist@candle.pha.pa.us, tgl@sss.pgh.pa.us, pgsql-sql@hub.org
  Subject: Re: [SQL] char type seems the same as char(1)
  In-Reply-To: <199812130341.WAA12919@candle.pha.pa.us>
  References: <28655.912017111@sss.pgh.pa.us> <199812130341.WAA12919@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox