Re: Happy column adding (was RE: [HACKERS] Happy column dropping)

From: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Date: 2000-01-25 18:29:07
Message-ID: 20000125122907.F423@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 25, 2000 at 12:23:15PM -0500, Tom Lane wrote:
> "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> writes:
> >>>> Even default is not allowed in ADD COLUMN now.
> >>
> >> It's not a matter of *allowed*, it's a parsing deficiency. The fact that
> >> there was a default declared gets silently ignored.
>
> > IIRC,there were some reason that default for new column had been rejected.
>
> Well, yeah: wouldn't you expect that "ADD COLUMN x DEFAULT 42" would
> cause every row currently existing in the table to acquire x = 42,
> rather than x = NULL? In fact that would *have* to happen to allow
> constraints to be added; consider ADD COLUMN x DEFAULT 42 NOT NULL.

Actually, no I wouldn't expect it. That's mixing DDL and DML in one
statement. I expect the ALTER command to be pure DDL, and the UPDATE
to be pure DML.

For a detailed brain dump as I thought about this, see my reply to Don Baccus,
one message up. ;-)

Yes, I know the standard isn't that pure: SELECT INTO, for example. Hmm,
is SELECT INTO standard? <FX: Ross grovels through the draft standard text...>

Ouch, reading standards always makes my brain hurt. Especially how you
have to read them upside down. Turns out SELECT INTO is in the standard,
but not the way we implement it.

13.5 <select statement: single row>

Function

Retrieve values from a specified row of a table.

Format

<select statement: single row> ::=
SELECT [ <set quantifier> ] <select list>
INTO <select target list>
<table expression>

<select target list> ::=
<target specification> [ { <comma> <target specification> }... ]

and in section 6.2:

<target specification> ::=
<parameter specification>
| <variable specification>

<simple target specification> ::=
<parameter name>
| <embedded variable name>

<parameter specification> ::=
<parameter name> [ <indicator parameter> ]

and in section 5.4:

<parameter name> ::= <colon> <identifier>

So, it looks like SELECT INTO is a single row query that fills variables,
either parameters or embedded, not a combined 'create this table and
fill it' command. Oops!

Ross

--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-01-25 18:49:01 Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Previous Message Ross J. Reedstrom 2000-01-25 17:44:53 Re: Happy column adding (was RE: [HACKERS] Happy column dropping)