Re: Help with ADD COLUMN - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Help with ADD COLUMN
Date
Msg-id 3488.1038172606@sss.pgh.pa.us
Whole thread Raw
In response to Re: Help with ADD COLUMN  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
>> Basically you wanna do an "UPDATE tab SET col = <default expr>".  I'd
>> suggest letting the existing machinery handle as much of that as
>> possible.

> Using SPI calls?

I wouldn't use SPI; it introduces way too many variables --- besides
which, you already have the default in internal form, why would you want
to deparse and reparse it?

I'd look into building a parsetree for an UPDATE statement and
feeding that to the executor.

An interesting question: should the rewriter be allowed to get its hands
on the thing, or not?  I'm not sure it'd be a good idea to fire rules
for such an operation.  For that matter, perhaps we don't want to fire
triggers either --- just how close should this come to being like a regular
UPDATE?

It would probably net out to not a lot of code to do a heapscan,
heap_modify_tuple, etc if we decide that not firing rules/triggers
is more appropriate behavior.  I'm not sure.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Help with ADD COLUMN
Next
From: Tom Lane
Date:
Subject: Re: Using the same condition twice