X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD7B43A4FB9 for ; Fri, 7 Jan 2005 20:39:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06641-08 for ; Fri, 7 Jan 2005 20:39:13 +0000 (GMT) Received: from web40621.mail.yahoo.com (web40621.mail.yahoo.com [66.218.92.50]) by svr1.postgresql.org (Postfix) with SMTP id 9CA283A4F8F for ; Fri, 7 Jan 2005 20:39:17 +0000 (GMT) Received: (qmail 56051 invoked by uid 60001); 7 Jan 2005 20:39:16 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=noMrlVBwaPEsy1UuTqwXoMTm8eFokXp+FvlbhNwHNQcGU4xgEmzXnLGQkrN8DOVwe1x2NmcWWBYbwI+MF1KMc1h8MNHOtJuQegh44Aqr+4+YhSvsXlBrVomF0Kyel98HUTL8RQHfat8T7r4aAIk2LQivxSM2AihG9HCc3VfZ0E8= ; Message-ID: <20050107203916.56049.qmail@web40621.mail.yahoo.com> Received: from [207.171.180.101] by web40621.mail.yahoo.com via HTTP; Fri, 07 Jan 2005 12:39:16 PST Date: Fri, 7 Jan 2005 12:39:16 -0800 (PST) From: Keith Hankin Subject: Re: One byte integer support To: Kris Jurka Cc: pgsql-jdbc@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.516 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200501/47 X-Sequence-Number: 11927 But Postgres 'char' is just an alias for 'character', so it will won't be just a single byte. And I've already accounted for padding and alignment in my structures and using bytes instead of shorts would result in a significant savings both in memory as well as disk. I don't understand why Postgres doesn't have a single-byte int support. Even MySQL does. --- Kris Jurka wrote: > > > On Thu, 6 Jan 2005, Keith Hankin wrote: > > > Is there any way to support one byte integers? I > am > > using JDBC and would like to use setByte() method > to > > populate values of a single-byte integer valued > > column. I tried defining the column as > character(1), > > but I get the error message: > > > > Exception in thread "main" > > org.postgresql.util.PSQLException: ERROR: value > too > > long for type character(1) > > > > I don't see how a byte is too long for > character(1). > > Character is a textual data type, byte is a numeric > value so when you set > a byte value of say 145 to a text type you get the > string '145' which is > three characters. > > Note that character(1) does not take up one byte of > space on disk. It is > a one character field, not one byte. Multibyte > character sets may need > more than one byte to store a single character, so > this is variable byte > length field that takes up at least 5 bytes of > space. 4 bytes of length > data and then the actual data bytes. > > > Is there any data type like MySQL's tinyint? > > > > Possibly the system type "char" (needs the quotes), > but I have no idea how > that will work with the JDBC driver. Going with > smallint may be the best > thing to do. Before assuming that a tinyint would > actually save you space > you need to make sure you take into account padding > and alignment. > > Kris Jurka > __________________________________ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com