From:
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To:
Gregory Stark <stark(at)enterprisedb(dot)com>
Cc:
"Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org,
"Bruce Momjian" <bruce(at)momjian(dot)us>, "David Fetter" <david(at)fetter(dot)org>
Subject:
Re: Macros for typtype (was Re: Arrays of Complex Types)
Date:
2007-04-01 18:31:41
Message-ID:
15686.1175452301@sss.pgh.pa.us (view raw or flat )
Thread:
2007-03-02 23:40:16 from David Fetter <david(at)fetter(dot)org>
2007-03-02 23:59:50 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-03 00:42:14 from "Andrew Dunstan" <andrew(at)dunslane(dot)net>
2007-03-03 13:14:57 from Martijn van Oosterhout <kleptog(at)svana(dot)org>
2007-03-03 14:06:11 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-03-03 17:25:23 from David Fetter <david(at)fetter(dot)org>
2007-03-03 17:45:32 from Gregory Stark <stark(at)enterprisedb(dot)com>
2007-03-04 00:48:38 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-03-06 21:05:56 from David Fetter <david(at)fetter(dot)org>
2007-03-06 21:14:07 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-06 21:17:41 from David Fetter <david(at)fetter(dot)org>
2007-03-06 21:24:36 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-06 21:27:12 from David Fetter <david(at)fetter(dot)org>
2007-03-26 01:31:58 from David Fetter <david(at)fetter(dot)org>
2007-03-26 02:18:14 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-27 18:08:44 from David Fetter <david(at)fetter(dot)org>
2007-03-27 19:39:04 from David Fetter <david(at)fetter(dot)org>
2007-03-27 21:04:39 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-03-28 07:05:24 from Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
2007-03-28 16:57:38 from David Fetter <david(at)fetter(dot)org>
2007-03-28 17:11:05 from Alvaro Herrera <alvherre(at)commandprompt(dot)com>
2007-03-28 17:33:56 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-03-28 18:48:57 from David Fetter <david(at)fetter(dot)org>
2007-03-28 17:35:54 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-28 19:15:20 from Gregory Stark <stark(at)enterprisedb(dot)com>
2007-03-28 19:24:26 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-28 19:41:07 from David Fetter <david(at)fetter(dot)org>
2007-03-30 20:23:58 from David Fetter <david(at)fetter(dot)org>
2007-03-30 21:08:42 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-31 23:10:08 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-03-31 23:13:20 from Bruce Momjian <bruce(at)momjian(dot)us>
2007-03-31 23:36:21 from David Fetter <david(at)fetter(dot)org>
2007-03-31 23:58:34 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-01 00:22:18 from David Fetter <david(at)fetter(dot)org>
2007-04-01 00:28:54 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2007-04-01 02:31:26 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-01 07:40:09 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2007-04-01 07:50:07 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-01 08:15:29 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2007-04-01 09:36:39 from Gregory Stark <stark(at)enterprisedb(dot)com>
2007-04-01 10:04:06 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2007-04-01 18:31:41 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-01 20:18:57 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2007-04-02 04:11:08 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-02 20:10:05 from David Fetter <david(at)fetter(dot)org>
2007-04-03 00:28:15 from Bruce Momjian <bruce(at)momjian(dot)us>
2007-04-03 02:01:44 from Alvaro Herrera <alvherre(at)commandprompt(dot)com>
2007-04-03 06:10:13 from David Fetter <david(at)fetter(dot)org>
2007-04-03 06:30:07 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-03 13:29:23 from David Fetter <david(at)fetter(dot)org>
2007-04-03 14:20:44 from Bruce Momjian <bruce(at)momjian(dot)us>
2007-04-08 22:47:44 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-08 23:08:38 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-08 23:32:22 from David Fetter <david(at)fetter(dot)org>
2007-04-08 23:36:17 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-09 00:09:59 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-09 00:35:53 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-09 00:41:06 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-09 01:53:46 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-09 02:24:23 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-09 14:14:41 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-09 14:40:49 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-04-09 16:39:36 from David Fetter <david(at)fetter(dot)org>
2007-04-09 19:57:34 from Martijn van Oosterhout <kleptog(at)svana(dot)org>
2007-04-09 20:07:16 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-04-09 21:12:24 from Martijn van Oosterhout <kleptog(at)svana(dot)org>
2007-05-06 17:33:47 from Andrew Dunstan <andrew(at)dunslane(dot)net>
2007-05-06 17:47:32 from David Fetter <david(at)fetter(dot)org>
2007-05-11 18:27:49 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2007-05-11 20:19:51 from "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Lists:
pgsql-hackers pgsql-patches
Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> We could use enum {} to define the labels and then make a rule that
> all actual variables should be declared using "char" rather than
> declaring them as "enum typtype". But I fear somebody would get that
> wrong some day.
Yeah, that seems to me to be just asking for trouble.
> On the other hand it I don't really think it would cause any problems
> if people stored their typtypes in integers. Except for the actual
> FormData_pg_* structures the precise alignment doesn't actually matter
> for anything does it?
The layout of the FormData struct is exactly the sticking point. If the
compiler makes the size or alignment of a struct field different from
what the tuple packing/unpacking code does for the corresponding column
type, we've got big trouble.
As for Peter's claim that the storage of an enum field is always int,
I think the C spec says otherwise. In 6.7.2.2 of C99 I see
[#4] Each enumerated type shall be compatible with an
integer type. The choice of type is
implementation-defined, 97) but shall be capable of
representing the values of all the members of the
enumeration. The enumerated type is incomplete until after
the } that terminates the list of enumerator declarations.
97) An implementation may delay the choice of which integer
type until all enumeration constants have been seen.
It seems clear to me that this authorizes, but *does not require*,
the compiler to store an enum field in a byte or short instead of
an int when all the declared values will fit. So if we tried to
do this, we'd have the problem of needing compiler-specific data
type information entered in pg_type.
Perhaps all C compilers do this alike, but how would we know?
Anyway the possible gain seems not worth the risk to me.
regards, tom lane
In response to
Responses
pgsql-hackers by date
Next :From: Tom LaneDate: 2007-04-01 19:08:28
Subject : Re: Last minute mini-proposal (I know, Iknow)forPQexecf()
Previous :From : Andrew - SupernewsDate : 2007-04-01 15:44:17
Subject : Re: Bug in UTF8-Validation Code?
pgsql-patches by date
Next :From: Tom LaneDate: 2007-04-01 18:42:52
Subject : Re: Current enums patch
Previous :From : Magnus HaganderDate : 2007-04-01 17:40:55
Subject : Re: Blocked post