Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.1/8.9.1) with ESMTP id NAA18785 for ; Wed, 25 Nov 1998 13:05:42 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id NAA28658 for ; Wed, 25 Nov 1998 13:05:11 -0500 (EST) To: pgsql-sql@hub.org Subject: char type seems the same as char(1) Date: Wed, 25 Nov 1998 13:05:11 -0500 Message-ID: <28655.912017111@sss.pgh.pa.us> From: Tom Lane 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... regards, tom lane