Received: from candle.pha.pa.us (maillist@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.1/8.9.1) with ESMTP id WAA12862 for ; Sat, 12 Dec 1998 22:42:32 -0500 (EST) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id WAA12919; Sat, 12 Dec 1998 22:41:09 -0500 (EST) From: Bruce Momjian Message-Id: <199812130341.WAA12919@candle.pha.pa.us> Subject: Re: [SQL] char type seems the same as char(1) In-Reply-To: <28655.912017111@sss.pgh.pa.us> from Tom Lane at "Nov 25, 1998 1: 5:11 pm" To: tgl@sss.pgh.pa.us (Tom Lane) Date: Sat, 12 Dec 1998 22:41:09 -0500 (EST) Cc: pgsql-sql@hub.org X-Mailer: ELM [version 2.4ME+ PL47 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > 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