Re: [HACKERS] create database doesn't work well in MULTIBYTE mode

From: Peter Eisentraut <e99re41(at)DoCS(dot)UU(dot)SE>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] create database doesn't work well in MULTIBYTE mode
Date: 2000-02-18 14:47:05
Message-ID: Pine.GSO.4.02A.10002181535130.4777-100000@Krokodil.DoCS.UU.SE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 18 Feb 2000, Thomas Lockhart wrote:

> ...
> #ifdef MULTIBYTE
> n->encoding = $6;
> #else
> n->encoding = 0;
> #endif
> ...
>
> where in fact if MULTIBYTE is not enabled and $6 is non-empty, the $6
> production never returns!

It will if you write ENCODING = DEFAULT.

Also, the rule you're looking at also covers the case CREATE DATABASE WITH
LOCATION (no ENCODING clause given). In that case, with MULTIBYTE on, $6
will be set to GetTemplateEncoding() in the create_opt_encoding: /*EMPTY*/
rule. With MULTIBYTE off, you must set encoding to 0, because that's the
default SQL_ASCII encoding, and the createdb() function (where this all
ends up), does no further interpretation on the encoding at all. Either
way you read it, I still think the previous code is completely correct as
it stands.

> So, why does the createdb_opt_encoding ($6 above) bother trying to
> return "-1" when MULTIBYTE is disabled, when that -1 is ignored and
> replaced with a zero anyway? Is it acceptable to return -1, as the $6
> production does, or should it really be returning the zero which is
> passed along??

Two reasons: First, it's better to have some rule than none at all, I
thunk. Second, if someone mucks with the code and somehow we have a -1
encoding the database, we know exactly what went wrong. If you feel so
inclined, you can change it to a zero, but after all the code works
perfectly.

--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2000-02-18 14:48:46 Re: [HACKERS] Date/time types: big change
Previous Message Peter Eisentraut 2000-02-18 14:29:34 Re: [HACKERS] Date/time types: big changeu