pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14327: UPSERT requires full path to column
3+ messages / 3 participants
[nested] [flat]

* BUG #14327: UPSERT requires full path to column
@ 2016-09-19 08:06  egor.pugin@gmail.com
  0 siblings, 1 reply; 3+ messages in thread

From: egor.pugin@gmail.com @ 2016-09-19 08:06 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14327
Logged by:          Egor Pugin
Email address:      egor.pugin@gmail.com
PostgreSQL version: 9.5.4
Operating system:   win10
Description:        

Hi,

I've noticed upsert query won't work if I do not write 'schema.TABLE.column'
instead of simple 'column' in 'on conflict do update set' query.

Working:

insert into statistics."MostPopularDependencies"
(id, indirect, downloads_week)
values ($1, $2, 1)
on conflict (id, indirect) do update
set downloads_week = statistics."MostPopularDependencies".downloads_week +
1
where statistics."MostPopularDependencies".id = $1 and
statistics."MostPopularDependencies".indirect = $2;

Not working:

insert into statistics."MostPopularDependencies"
(id, indirect, downloads_week)
values ($1, $2, 1)
on conflict
(id, indirect) -- also w/out this, it does not work too, but isn't it
optional element?
do update
set downloads_week = downloads_week + 1
where id = $1 and indirect = $2;




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14327: UPSERT requires full path to column
@ 2016-09-19 10:06  Peter Geoghegan <pg@heroku.com>
  parent: egor.pugin@gmail.com
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Geoghegan @ 2016-09-19 10:06 UTC (permalink / raw)
  To: egor.pugin@gmail.com; +Cc: pgsql-bugs

On Mon, Sep 19, 2016 at 1:06 AM,  <egor.pugin@gmail.com> wrote:
> I've noticed upsert query won't work if I do not write 'schema.TABLE.column'
> instead of simple 'column' in 'on conflict do update set' query.

Use an alias. e.g.:

INSERT INTO statistics."MostPopularDependencies" as mpd ...

You can then reference columns using mpd.downloads_week, etc

-- 
Peter Geoghegan


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14327: UPSERT requires full path to column
@ 2016-09-19 10:08  Egor Pugin <egor.pugin@gmail.com>
  parent: Peter Geoghegan <pg@heroku.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Egor Pugin @ 2016-09-19 10:08 UTC (permalink / raw)
  To: Peter Geoghegan <pg@heroku.com>; +Cc: pgsql-bugs

Thanks!
But is this expected behavior and not a bug?

On 19 September 2016 at 13:06, Peter Geoghegan <pg@heroku.com> wrote:
> On Mon, Sep 19, 2016 at 1:06 AM,  <egor.pugin@gmail.com> wrote:
>> I've noticed upsert query won't work if I do not write 'schema.TABLE.column'
>> instead of simple 'column' in 'on conflict do update set' query.
>
> Use an alias. e.g.:
>
> INSERT INTO statistics."MostPopularDependencies" as mpd ...
>
> You can then reference columns using mpd.downloads_week, etc
>
> --
> Peter Geoghegan



-- 
Egor Pugin


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-09-19 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 08:06 BUG #14327: UPSERT requires full path to column egor.pugin@gmail.com
2016-09-19 10:06 ` Peter Geoghegan <pg@heroku.com>
2016-09-19 10:08   ` Egor Pugin <egor.pugin@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox