X-Original-To: pgsql-interfaces@postgresql.org Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 8FB8A475921; Thu, 13 Mar 2003 16:41:34 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id QAA20251; Thu, 13 Mar 2003 16:41:31 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma020247; Thu, 13 Mar 03 16:41:01 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id QAA30205; Thu, 13 Mar 2003 16:36:48 -0500 Message-ID: <3E70FB55.68CEDE4@nsd.ca> Date: Thu, 13 Mar 2003 16:42:45 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-hackers@postgresql.org, pgsql-interfaces@postgresql.org Subject: Re: Upgrading the backend's error-message infrastructure References: <9168.1047588660@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/69 X-Sequence-Number: 3818 Why trade 5 characters for a 4 byte integer -- a saving of 1 byte? Is this database designed for embedded applications where RAM is scarce? :) JLL Tom Lane wrote: [...] > Error codes > ----------- > > The SQL spec defines a set of 5-character status codes (called SQLSTATE > values). We'll use these as the language-independent identifiers for > error conditions. There is code space reserved by the spec for > implementation-defined error conditions, which we'll surely need. > > Per spec, each of the five characters in a SQLSTATE code must be a digit > '0'-'9' or an upper-case Latin letter 'A'-'Z'. So it's possible to fit a > SQLSTATE code into a 32-bit integer with some simple encoding conventions. > I propose that we use such a representation in the backend; that is, > instead of passing around strings like "1200D" we pass around integers > formed like ((('1' - '0') << 6) + '2' - '0') << 6 ... This should save > a useful amount of space per elog call site, and it won't obscure the code > noticeably since all the common values will be represented as macro names > anyway, something like > > #define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2','2', '0','1','2') > > We need to do some legwork to figure out what set of > implementation-defined error codes we want. It might make sense to look > and see what other DBMSes are using. > [...]