On Tue, Jan 25, 2000 at 12:23:15PM -0500, Tom Lane wrote:
> "Hiroshi Inoue" <Inoue@tpf.co.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
<selecttarget 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@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005