Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he2Q4-0007XQ-EW for pgsql-general@arkaria.postgresql.org; Thu, 20 Jun 2019 19:08:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1he2Q3-0004zu-8P for pgsql-general@arkaria.postgresql.org; Thu, 20 Jun 2019 19:08:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he2Q2-0004zn-Rs for pgsql-general@lists.postgresql.org; Thu, 20 Jun 2019 19:08:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1he2Q0-0008N1-LU for pgsql-general@lists.postgresql.org; Thu, 20 Jun 2019 19:08:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5KJ8FTX020184; Thu, 20 Jun 2019 15:08:15 -0400 From: Tom Lane To: "David G. Johnston" cc: Karsten Hilbert , "pgsql-generallists.postgresql.org" Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update In-reply-to: References: <20190620114527.GD30366@hermes.hilbert.loc> <20190620152741.GG30366@hermes.hilbert.loc> <13631.1561047413@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Thu, 20 Jun 2019 11:20:05 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20182.1561057695.1@sss.pgh.pa.us> Date: Thu, 20 Jun 2019 15:08:15 -0400 Message-ID: <20183.1561057695@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" 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