Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Marko Tiikkaja
Hi, SET syntax for INSERT was brought up a few years ago here: http://www.postgresql.org/message-id/2c5ef4e30908251010s46d9d566m1da21357891ba...@mail.gmail.com From the discussion it seems that one committer was against, one committer was not against, and one committer saw something good in

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Robert Haas
On Thu, Jan 14, 2016 at 3:25 PM, Tom Lane wrote: > "David G. Johnston" writes: >> On Thu, Jan 14, 2016 at 1:07 PM, Tom Lane wrote: >>> Vitaly Burovoy writes: You can't now do something like

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Pavel Stehule
2016-01-14 20:09 GMT+01:00 Marko Tiikkaja : > On 2016-01-14 8:06 PM, Pavel Stehule wrote: > >> Probably there is less risk than 7 years ago, but still creating own >> syntax >> isn't the best idea. This is syntactic sugar only and different from ANSi >> SQL or common standard. >> >

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Pavel Stehule
2016-01-14 19:51 GMT+01:00 Robert Haas : > On Thu, Jan 14, 2016 at 12:13 PM, Marko Tiikkaja wrote: > > SET syntax for INSERT was brought up a few years ago here: > > >

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Marc Mamin
>SET syntax for INSERT was brought up a few years ago here: >http://www.postgresql.org/message-id/2c5ef4e30908251010s46d9d566m1da21357891ba...@mail.gmail.com >What do we think? +1 this would save comments in long queries. and usindg AS as style helper as suggested in the old post has its caveat:

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Marko Tiikkaja
On 2016-01-14 8:06 PM, Pavel Stehule wrote: Probably there is less risk than 7 years ago, but still creating own syntax isn't the best idea. This is syntactic sugar only and different from ANSi SQL or common standard. So is RETURNING, UPSERT, PL/PgSQL and many other useful features. .m --

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Vitaly Burovoy
On 1/14/16, Tom Lane wrote: > Pavel Stehule writes: Probably there is less risk than 7 years ago, but still creating own syntax isn't the best idea. This is syntactic sugar only and different from ANSi SQL or common standard. > > It's

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Marko Tiikkaja
On 2016-01-14 20:50, Vitaly Burovoy wrote: On 1/14/16, Tom Lane wrote: Assume a table with an int-array column, and consider INSERT INTO foo SET arraycol[2] = 7, arraycol[4] = 11; Right part is a column name, not an expression. Isn't it? So "arraycol[2]" is not possible

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Vitaly Burovoy
On 1/14/16, Tom Lane wrote: > Vitaly Burovoy writes: >> On 1/14/16, Tom Lane wrote: >>> It's more than syntactic sugar; you are going to have to invent >>> semantics, >>> as well, because it's less than clear what partial-field

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Tom Lane
"David G. Johnston" writes: > On Thu, Jan 14, 2016 at 1:07 PM, Tom Lane wrote: >> Vitaly Burovoy writes: >>> You can't now do something like >>> INSERT INTO foo (arraycol[2], arraycol[4]) VALUES(7, 11); >> Hm ...

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Robert Haas
On Thu, Jan 14, 2016 at 12:13 PM, Marko Tiikkaja wrote: > SET syntax for INSERT was brought up a few years ago here: > http://www.postgresql.org/message-id/2c5ef4e30908251010s46d9d566m1da21357891ba...@mail.gmail.com > > From the discussion it seems that one committer was against,

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Tom Lane
Pavel Stehule writes: >>> Probably there is less risk than 7 years ago, but still creating own >>> syntax isn't the best idea. This is syntactic sugar only and different >>> from ANSi SQL or common standard. It's more than syntactic sugar; you are going to have to invent

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Tom Lane
Vitaly Burovoy writes: > On 1/14/16, Tom Lane wrote: >> It's more than syntactic sugar; you are going to have to invent semantics, >> as well, because it's less than clear what partial-field assignments >> should do. >> >> Assume a table with an

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Andrew Dunstan
On 01/14/2016 03:00 PM, Marko Tiikkaja wrote: On 2016-01-14 20:50, Vitaly Burovoy wrote: On 1/14/16, Tom Lane wrote: Assume a table with an int-array column, and consider INSERT INTO foo SET arraycol[2] = 7, arraycol[4] = 11; Right part is a column name, not an

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread David G. Johnston
On Thu, Jan 14, 2016 at 1:07 PM, Tom Lane wrote: > Vitaly Burovoy writes: > > On 1/14/16, Tom Lane wrote: > >> It's more than syntactic sugar; you are going to have to invent > semantics, > >> as well, because it's less than

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread David G. Johnston
On Thu, Jan 14, 2016 at 1:25 PM, Tom Lane wrote: > "David G. Johnston" writes: > > On Thu, Jan 14, 2016 at 1:07 PM, Tom Lane wrote: > >> Vitaly Burovoy writes: > >>> You can't now do something like >

Re: [HACKERS] SET syntax in INSERT

2016-01-14 Thread Marko Tiikkaja
On 2016-01-14 20:33, Tom Lane wrote: Pavel Stehule writes: Probably there is less risk than 7 years ago, but still creating own syntax isn't the best idea. This is syntactic sugar only and different from ANSi SQL or common standard. It's more than syntactic sugar;

[HACKERS] SET syntax in INSERT

2009-08-25 Thread Rob Wultsch
Given the recent discussion of DELETE syntax on JOINS I thought it might be interesting to bring a bit MySQL syntax that is in somewhat widespread use, generally create somewhat cleaner code and I imagine would not break much if implemented. MySQL allows INSERTs of the form: INSERT INTO t SET

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Pavel Stehule
2009/8/25 Rob Wultsch wult...@gmail.com: Given the recent discussion of DELETE syntax on JOINS  I thought it might be interesting to bring a bit MySQL syntax that is in somewhat widespread use, generally create somewhat cleaner code and I imagine would not break much if implemented. MySQL

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Heikki Linnakangas
Pavel Stehule wrote: 2009/8/25 Rob Wultsch wult...@gmail.com: Given the recent discussion of DELETE syntax on JOINS I thought it might be interesting to bring a bit MySQL syntax that is in somewhat widespread use, generally create somewhat cleaner code and I imagine would not break much if

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Rob Wultsch
On Tue, Aug 25, 2009 at 10:36 AM, Pavel Stehulepavel.steh...@gmail.com wrote: 2009/8/25 Rob Wultsch wult...@gmail.com: Given the recent discussion of DELETE syntax on JOINS  I thought it might be interesting to bring a bit MySQL syntax that is in somewhat widespread use, generally create

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Pavel Stehule
For an insert with many columns or with large value this syntax can significantly improve readability. So it wasn't invented here, so what? I don't see a downside to allowing this syntax other than MySQL used it first, and there are multiple upsides (readability, easier transitions).

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Andrew Dunstan
Rob Wultsch wrote: -1 PostgreSQL isn't MySQL! For an insert with many columns or with large value this syntax can significantly improve readability. So it wasn't invented here, so what? I don't see a downside to allowing this syntax other than MySQL used it first, and there are

Re: [HACKERS] SET syntax in INSERT

2009-08-25 Thread Alvaro Herrera
Heikki Linnakangas escribió: I do understand the point, though - it's much easier to edit and debug long statements when the value is close to the column name. I find that the INSERT .. SELECT makes that a lot nicer: INSERT INTO t