Re: Upgrading the backend's error-message infrastructure

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Upgrading the backend's error-message infrastructure
Date: 2003-03-13 21:42:45
Message-ID: 3E70FB55.68CEDE4@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

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.
>
[...]

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2003-03-13 21:46:31 Re: Roadmap for FE/BE protocol redesign
Previous Message Neil Conway 2003-03-13 21:39:31 Re: Upgrading the backend's error-message infrastructure

Browse pgsql-interfaces by date

  From Date Subject
Next Message Hiroshi Inoue 2003-03-13 21:46:31 Re: Roadmap for FE/BE protocol redesign
Previous Message Neil Conway 2003-03-13 21:39:31 Re: Upgrading the backend's error-message infrastructure