@@ -267,3 +267,83 @@ misleading success response code is not my idea of proper behavior.
267267regards, tom lane
268268
269269
270+ From owner-pgsql-hackers@hub.org Mon Jan 24 23:46:25 2000
271+ Received: from hub.org (hub.org [216.126.84.1])
272+ by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id XAA25453
273+ for <pgman@candle.pha.pa.us>; Mon, 24 Jan 2000 23:46:24 -0500 (EST)
274+ Received: from localhost (majordom@localhost)
275+ by hub.org (8.9.3/8.9.3) with SMTP id XAA81794;
276+ Mon, 24 Jan 2000 23:01:22 -0500 (EST)
277+ (envelope-from owner-pgsql-hackers)
278+ Received: by hub.org (bulk_mailer v1.5); Mon, 24 Jan 2000 22:59:46 -0500
279+ Received: (from majordom@localhost)
280+ by hub.org (8.9.3/8.9.3) id WAA80721
281+ for pgsql-hackers-outgoing; Mon, 24 Jan 2000 22:58:59 -0500 (EST)
282+ (envelope-from owner-pgsql-hackers@postgreSQL.org)
283+ Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2])
284+ by hub.org (8.9.3/8.9.3) with ESMTP id WAA80619
285+ for <pgsql-hackers@postgreSQL.org>; Mon, 24 Jan 2000 22:58:33 -0500 (EST)
286+ (envelope-from tgl@sss.pgh.pa.us)
287+ Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
288+ by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id WAA11576;
289+ Mon, 24 Jan 2000 22:57:12 -0500 (EST)
290+ To: Don Baccus <dhogaza@pacifier.com>
291+ cc: "Hiroshi Inoue" <Inoue@tpf.co.jp>, "Peter Eisentraut" <peter_e@gmx.net>,
292+ "PostgreSQL Development" <pgsql-hackers@postgreSQL.org>
293+ Subject: Re: [HACKERS] Happy column dropping
294+ In-reply-to: <3.0.1.32.20000124184137.01069490@mail.pacifier.com>
295+ References: <001001bf66d7$b531ba00$2801007e@tpf.co.jp> <001001bf66d7$b531ba00$2801007e@tpf.co.jp> <3.0.1.32.20000124184137.01069490@mail.pacifier.com>
296+ Comments: In-reply-to Don Baccus <dhogaza@pacifier.com>
297+ message dated "Mon, 24 Jan 2000 18:41:37 -0800"
298+ Date: Mon, 24 Jan 2000 22:57:12 -0500
299+ Message-ID: <11573.948772632@sss.pgh.pa.us>
300+ From: Tom Lane <tgl@sss.pgh.pa.us>
301+ Sender: owner-pgsql-hackers@postgreSQL.org
302+ Status: RO
303+
304+ Don Baccus <dhogaza@pacifier.com> writes:
305+ > Just a reality check for my learning of the internals. Out of curiousity
306+ > I coincidently have spent the last hour looking to see how add column's
307+ > implemented. It doesn't appear to do anything other than the new attribute
308+ > to the proper system table. heap_getattr() just returns null if you ask
309+ > for an attribute past the end of the tuple.
310+
311+ > This would appear to be (at least one reason) why you can't add a "not null"
312+ > constraint to a column you're adding to an existing relation, or set the
313+ > new column to some non-null default value.
314+
315+ > Correct? (again, to see if my eyeballs and brain are working in synch
316+ > tonight)
317+
318+ Yup, that's about the size of it. ADD COLUMN doesn't actually touch the
319+ table itself, so it can only add a column that's initially all NULLs.
320+ And even this depends on some uncomfortable assumptions about the
321+ robustness of heap_getattr(). I have always wondered whether it works
322+ if you ADD COLUMN a 33'rd column (or anything that is just past the
323+ next padding boundary for the null-values bitmap).
324+
325+ Another problem with it is seen when you do a recursive ADD COLUMN in
326+ an inheritance tree. The added column has the first free column number
327+ in each table, which generally means that it has different numbers in
328+ the children than in the parent. There are some kluges to make this
329+ sort-of-work for simple cases, but a lot of stuff fails unpleasantly
330+ --- Chris Bitmead can show you some scars from that, IIRC.
331+
332+ > Does your comment imply that it's planned to change this, i.e. actually
333+ > add the new column to each tuple in the relation rather than use the
334+ > existing, somewhat elegant hack?
335+
336+ That's what I would like to see: all the children should have the
337+ same column numbers for all columns that they inherit from the parent.
338+
339+ (Now, this would mean not only physically altering the tuples of
340+ the children, but also renumbering their added columns, which has
341+ implications on stored rules and triggers and so forth. It'd be
342+ painful, no doubt about it. Still, I'd rather pay the price in the
343+ seldom-used ADD COLUMN case than try to deal with out-of-sync column
344+ numbers in many other, more commonly exercised, code paths.)
345+
346+ regards, tom lane
347+
348+ ************
349+