Re: [HACKERS] Updating column on row update

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Thom Brown <thombrown(at)gmail(dot)com>, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Updating column on row update
Date: 2009-11-23 05:05:22
Message-ID: 4B0A1812.30708@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
> [ thinks for awhile... ] Actually, CREATE LANGUAGE is unique among
> creation commands in that the common cases have no parameters, at least
> not since we added pg_pltemplate. So you could imagine defining CINE
> for a language as disallowing any parameters and having these semantics:
> * language not present -> create from template
> * language present, matches template -> OK, do nothing
> * language present, does not match template -> report error
> This would meet the objection of not being sure what the state is
> after successful execution of the command. It doesn't scale to any
> other object type, but is it worth doing for this one type?
>
>

I seriously doubt it. The only reason I could see for such a thing would
be to make it orthogonal with other CINE commands.

Part of the motivation for allowing inline blocks was to allow for
conditional logic. So you can do things like:

DO $$

begin
if not exists (select 1 from pg_tables where schemaname = 'foo'
and tablename = 'bar') then
create table foo.bar (x int, y text);
end if;
end;

$$;

It's a bit more verbose (maybe someone can streamline it) but it does
give you CINE (for whatever flavor of CINE you want), as well as lots
more complex possibilities than we can conceivably build into SQL.

cheers

andrew

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-11-23 05:19:14 Re: [HACKERS] Updating column on row update
Previous Message Bino Oetomo 2009-11-23 04:52:10 Re: How is the right query for this condition ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-11-23 05:19:14 Re: [HACKERS] Updating column on row update
Previous Message Tom Lane 2009-11-23 04:38:50 Re: [HACKERS] Updating column on row update