patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...) - Mailing list pgsql-hackers

From Pavlo Baron
Subject patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...)
Date
Msg-id 003001c18ec6$752e6c50$6500a8c0@bw1
Whole thread Raw
Responses Re: patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...)
List pgsql-hackers
hello hackers

here is the patch for the INSERT INTO t VALUES (..., DEFAULT, ...) from the
current TODO list.
It's my first patch so please forgive me if it's not the best solution - I'm
now learning about the codebase and this implementation really hunted me
through some deep and dark places...
Your comments on how to do it right or what is additionally to do are
welcome, of course

Well, here how it works:

1. only 3 files are related, all from the src/backend/parser
2. my comments are all beginning with "pavlo (pb@pbit.org)"
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
4. parse_coerce.c - coerce_type - here I faked the standard handling failing
when it tries to convert the @default-string
5. parse_target.c - updateTargetListEntry - here the @default-string is
handled. I just look up if there is a default value for the column and use
it instead of the @default place holder
6. I tested it with psql
7. I tested it under Sun Solaris8 SPARC and FreeBSD 4.0 Intel
8. I used "cvs diff > patch" to diff changes

Please let me know if it's ok or if some changes must be done.



rgds
Pavlo Baron

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Problem with TOAST column corruption
Next
From: Tom Lane
Date:
Subject: Re: patch: INSERT INTO t VALUES (a, b, ..., DEFAULT, ...)