pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: srivastava.adi24@gmail.com
Subject: BUG #16462: Update Statement destructive behaviour with joins
Date: Tue, 26 May 2020 11:28:28 +0000
Message-ID: <16462-7160938c9c2989d9@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16462
Logged by:          Aditya Srivastava
Email address:      srivastava.adi24@gmail.com
PostgreSQL version: 9.6.2
Operating system:   MAC OSX
Description:        

Let's say I have a table orange and a temp table temp, and i want to update
the records after joining the columns in temp table. I used the following
syntax to update the records which ended up updating the entire table
"orange".

       UPDATE orange
           SET fruit_flag = 'okay'
            FROM temp as t
                   INNER JOIN portal_users p on t.fruit_id = p.fruit_id 
            WHERE p.id = '123';

I know that the correct syntax should be the following but judging from the
destructive nature of this query i honestly feel we should throw validation
error if the above syntax is not correct.


UPDATE orange
SET fruit_flag = 'okay'
FROM temp t
WHERE t.fruit_id = orange.fruit_id 

Thanks in advance.



view thread (3+ messages)  latest in thread

Message-ID: <16462-7160938c9c2989d9@postgresql.org>
Permalink:  ../16462-7160938c9c2989d9@postgresql.org/
Also on:    postgresql.org/message-id/16462-7160938c9c2989d9@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, srivastava.adi24@gmail.com
  Subject: Re: BUG #16462: Update Statement destructive behaviour with joins
  In-Reply-To: <16462-7160938c9c2989d9@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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