pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update
Date: Thu, 20 Jun 2019 15:08:15 -0400
Message-ID: <20183.1561057695@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwYLfTQLnB4a1DPDcRT1xApWoupDwjcDbxsW48Vq5h-47A@mail.gmail.com>
References: <CAO8wz8QdKRTJUnW--AZ2N-BvJAemS+P9=Sr7zUbkO+wmAmA7LQ@mail.gmail.com>
	<b2afcfd3-a2c2-9bdc-3e62-a28392f0b8f6@aklaver.com>
	<CADT4RqDYLKWxxHejU2ZE6Wmveo8x09Zf8aw4pdT-=0uU82Us=Q@mail.gmail.com>
	<20190620114527.GD30366@hermes.hilbert.loc>
	<CADT4RqB8ZdqRguV05JdXpSr6dwK3azcebu0c_4Eg0ADnUtK=tg@mail.gmail.com>
	<20190620152741.GG30366@hermes.hilbert.loc>
	<13631.1561047413@sss.pgh.pa.us>
	<CAKFQuwYLfTQLnB4a1DPDcRT1xApWoupDwjcDbxsW48Vq5h-47A@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Just to be clear here, the OP provided the following query example:

> test=# update person set email = null;
> ERROR:  null value in column "email" violates not-null constraint
> DETAIL:  Failing row contains (william, denton, null).

> The presence of william and denton in the error detail was because the user
> updating the table has select access on first and last name.  If they did
> not those fields would not have been part of the error message?  I'm not in
> a position to experiment right now but what does/should it show in the
> restrictive case?

regression=# create user joe;
CREATE ROLE
test=# create table person(first text, last text, email text not null);
CREATE TABLE
test=# grant select(email),update(email) on person to joe;
GRANT
test=# insert into person values('william','denton','wd40@gmail.com');
INSERT 0 1
test=# \c - joe
You are now connected to database "test" as user "joe".
test=> update person set email = null;
psql: ERROR:  null value in column "email" violates not-null constraint
DETAIL:  Failing row contains (email) = (null).

The DETAIL in this case would be the same whether joe had select(email)
privilege or not; the email value is considered OK to report since it
came from the query not the table.

			regards, tom lane





view thread (22+ messages)  latest in thread

Message-ID: <20183.1561057695@sss.pgh.pa.us>
Permalink:  ../20183.1561057695@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20183.1561057695@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, Karsten.Hilbert@gmx.net
  Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update
  In-Reply-To: <20183.1561057695@sss.pgh.pa.us>
  References: <CAO8wz8QdKRTJUnW--AZ2N-BvJAemS+P9=Sr7zUbkO+wmAmA7LQ@mail.gmail.com> <b2afcfd3-a2c2-9bdc-3e62-a28392f0b8f6@aklaver.com> <CADT4RqDYLKWxxHejU2ZE6Wmveo8x09Zf8aw4pdT-=0uU82Us=Q@mail.gmail.com> <20190620114527.GD30366@hermes.hilbert.loc> <CADT4RqB8ZdqRguV05JdXpSr6dwK3azcebu0c_4Eg0ADnUtK=tg@mail.gmail.com> <20190620152741.GG30366@hermes.hilbert.loc> <13631.1561047413@sss.pgh.pa.us> <CAKFQuwYLfTQLnB4a1DPDcRT1xApWoupDwjcDbxsW48Vq5h-47A@mail.gmail.com> <20183.1561057695@sss.pgh.pa.us>

* 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