Re: patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...)

From: "Pavlo Baron" <pb(at)pbit(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...)
Date: 2001-12-27 16:19:51
Message-ID: 009501c18ef2$539f4060$6500a8c0@bw1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> "Pavlo Baron" <pb(at)pbit(dot)org> writes:
> > 3. gram.y - here I added a rule for the DEFAULT-element in the
target_list
> > used for the INSERT-statement. It now replaces DEFAULT by an anti-thing
like
> > "@default" because I couldn't find out were it fails if I leave DEFAULT
> > unchainged. If smb. knows a way to do it I'll drop this @default
>

Tom Lane writes:
> This would break
> INSERT INTO foo(textcolumn) VALUES ('@default')
> which I find hardly acceptable.
>
> The only way to do it without breaking valid data entries is to
> introduce a new parse node type to represent a DEFAULT placeholder.

I know what you mean and I hope to know where to do it. I thought, there
could be some similar cases handled a similar way. I'll try to implement
providing a new parse node type to represent a DEFAULT placeholder.

Tom Lane writes:
>
> I also wonder what's going to happen if I write DEFAULT in a SELECT's
> targetlist, which is possible given where you made the grammar change.

I also thought about it, but maybe I tested a wrong statement. Could you
give me an example on what you mean would possibly appear funny? a
select-statement...
Maybe I don't understand what the targetlist means in the case of the select
statement. I tried smth. like "select f1, f2 from tab1;". I think, "f1, f2"
is a targetlist and if I try to use DEFAULT in the list, a parser error is
generated as it was before I put my changes.
I could specify a new targetlist branch used only in the case of the INSERT
statement, and that's what I had before I minimized my code to that what you
see now. I think, I see a way to declare a rule only used with the INSERT
statement, but I couldn't find any problem caused by using default in the
targetlist of the SELECT stmt. What should we do?

rgds
Pavlo Baron

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Scott Royston 2001-12-27 20:37:14 Implicit cast of literal in SQL statements
Previous Message Tom Lane 2001-12-27 15:26:40 Re: Problem with TOAST column corruption