Insert ... (a, b, DEFAULT, c, d);

Started by Rod Taylorover 24 years ago5 messagespatches
Jump to latest
#1Rod Taylor
rbt@rbt.ca

Adds inserts with defaults.

Insert regression test will be required for other insert specific stuff

ie. INSERT values (), (), ()...

Any column set to DEFAULT is dropped in analyze.c while transforming the
insert statement.

Attachments:

insert.patchtext/plain; charset=ISO-8859-1; name=insert.patchDownload+75-27
insert.outtext/plain; charset=ISO-8859-1; name=insert.outDownload
insert.sqltext/x-sql; charset=ISO-8859-1; name=insert.sqlDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rod Taylor (#1)
Re: Insert ... (a, b, DEFAULT, c, d);

Rod Taylor <rbt@zort.ca> writes:

Adds inserts with defaults.

A few gripes about this ---

* You can't simply invent a node type without creating any support code
for it. See backend/nodes/. copyfuncs and equalfuncs are *required*
functionality; infuncs/outfuncs are somewhat more negotiable. For a
node type that never gets past parse analysis it's okay to omit infuncs,
and you can get away with omitting outfuncs too.

* I find it really ugly (not to say fragile) to overload resjunk with
this meaning. The best solution would be to restructure the calling
conventions for transformTargetList to fix the problem of not being able
to access all the lists that need to be updated. Failing that, my
inclination would be to pass back the unaltered InsertDefault node
(instead of a Resdom) as part of transformTargetList's result list; then
an IsA test in transformInsertStmt would work to detect which entries
are real.

regards, tom lane

#3Rod Taylor
rbt@rbt.ca
In reply to: Rod Taylor (#1)
Re: Insert ... (a, b, DEFAULT, c, d);

Added Copy and Equal nodes -- although InsertDefault doesn't actually
have any contents.

Opted for method b as transformTargetList is used in a number of other
places which are unaffected. Making them work around the calling
conventions for a single place seemed silly.

Previously attached insert.out and insert.sql are the same.

--
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Rod Taylor" <rbt@zort.ca>
Cc: <pgsql-patches@postgresql.org>
Sent: Saturday, March 30, 2002 2:06 PM
Subject: Re: [PATCHES] Insert ... (a, b, DEFAULT, c, d);

Rod Taylor <rbt@zort.ca> writes:

Adds inserts with defaults.

A few gripes about this ---

* You can't simply invent a node type without creating any support

code

for it. See backend/nodes/. copyfuncs and equalfuncs are

*required*

functionality; infuncs/outfuncs are somewhat more negotiable. For a
node type that never gets past parse analysis it's okay to omit

infuncs,

and you can get away with omitting outfuncs too.

* I find it really ugly (not to say fragile) to overload resjunk

with

this meaning. The best solution would be to restructure the calling
conventions for transformTargetList to fix the problem of not being

able

to access all the lists that need to be updated. Failing that, my
inclination would be to pass back the unaltered InsertDefault node
(instead of a Resdom) as part of transformTargetList's result list;

then

an IsA test in transformInsertStmt would work to detect which

entries

are real.

regards, tom lane

---------------------------(end of

broadcast)---------------------------

Show quoted text

TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Attachments:

insert.patchapplication/octet-stream; name=insert.patchDownload+89-23
insert.outapplication/octet-stream; name=insert.outDownload
insert.sqlapplication/octet-stream; name=insert.sqlDownload
#4Bruce Momjian
bruce@momjian.us
In reply to: Rod Taylor (#3)
Re: Insert ... (a, b, DEFAULT, c, d);

Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Rod Taylor wrote:

Added Copy and Equal nodes -- although InsertDefault doesn't actually
have any contents.

Opted for method b as transformTargetList is used in a number of other
places which are unaffected. Making them work around the calling
conventions for a single place seemed silly.

Previously attached insert.out and insert.sql are the same.

--
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Rod Taylor" <rbt@zort.ca>
Cc: <pgsql-patches@postgresql.org>
Sent: Saturday, March 30, 2002 2:06 PM
Subject: Re: [PATCHES] Insert ... (a, b, DEFAULT, c, d);

Rod Taylor <rbt@zort.ca> writes:

Adds inserts with defaults.

A few gripes about this ---

* You can't simply invent a node type without creating any support

code

for it. See backend/nodes/. copyfuncs and equalfuncs are

*required*

functionality; infuncs/outfuncs are somewhat more negotiable. For a
node type that never gets past parse analysis it's okay to omit

infuncs,

and you can get away with omitting outfuncs too.

* I find it really ugly (not to say fragile) to overload resjunk

with

this meaning. The best solution would be to restructure the calling
conventions for transformTargetList to fix the problem of not being

able

to access all the lists that need to be updated. Failing that, my
inclination would be to pass back the unaltered InsertDefault node
(instead of a Resdom) as part of transformTargetList's result list;

then

an IsA test in transformInsertStmt would work to detect which

entries

are real.

regards, tom lane

---------------------------(end of

broadcast)---------------------------

TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#5Bruce Momjian
bruce@momjian.us
In reply to: Rod Taylor (#3)
Re: Insert ... (a, b, DEFAULT, c, d);

Patch applied. Thanks.

---------------------------------------------------------------------------

Rod Taylor wrote:

Added Copy and Equal nodes -- although InsertDefault doesn't actually
have any contents.

Opted for method b as transformTargetList is used in a number of other
places which are unaffected. Making them work around the calling
conventions for a single place seemed silly.

Previously attached insert.out and insert.sql are the same.

--
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Rod Taylor" <rbt@zort.ca>
Cc: <pgsql-patches@postgresql.org>
Sent: Saturday, March 30, 2002 2:06 PM
Subject: Re: [PATCHES] Insert ... (a, b, DEFAULT, c, d);

Rod Taylor <rbt@zort.ca> writes:

Adds inserts with defaults.

A few gripes about this ---

* You can't simply invent a node type without creating any support

code

for it. See backend/nodes/. copyfuncs and equalfuncs are

*required*

functionality; infuncs/outfuncs are somewhat more negotiable. For a
node type that never gets past parse analysis it's okay to omit

infuncs,

and you can get away with omitting outfuncs too.

* I find it really ugly (not to say fragile) to overload resjunk

with

this meaning. The best solution would be to restructure the calling
conventions for transformTargetList to fix the problem of not being

able

to access all the lists that need to be updated. Failing that, my
inclination would be to pass back the unaltered InsertDefault node
(instead of a Resdom) as part of transformTargetList's result list;

then

an IsA test in transformInsertStmt would work to detect which

entries

are real.

regards, tom lane

---------------------------(end of

broadcast)---------------------------

TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026