Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyhuq-000198-P1 for pgsql-general@arkaria.postgresql.org; Wed, 21 Mar 2018 17:52:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eyhup-00056l-Pj for pgsql-general@arkaria.postgresql.org; Wed, 21 Mar 2018 17:52:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyhup-00056b-EL for pgsql-general@lists.postgresql.org; Wed, 21 Mar 2018 17:52:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyhum-0002rU-TW for pgsql-general@postgresql.org; Wed, 21 Mar 2018 17:52:46 +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 w2LHqf7P024105; Wed, 21 Mar 2018 13:52:41 -0400 From: Tom Lane To: Louis Battuello cc: "David G. Johnston" , "pgsql-general@postgresql.org" Subject: Re: Foreign Key Validation after Reference Table Ownership Change In-reply-to: <15ABBD1A-BCD6-400F-8F95-62E295A93C7A@etasseo.com> References: <20180321083033.f495bf0537e129b62c3edf58e37f64ff.23347c6e15.mailapi@email02.godaddy.com> <23491.1521653956@sss.pgh.pa.us> <15ABBD1A-BCD6-400F-8F95-62E295A93C7A@etasseo.com> Comments: In-reply-to Louis Battuello message dated "Wed, 21 Mar 2018 13:48:15 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <24103.1521654761.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 21 Mar 2018 13:52:41 -0400 Message-ID: <24104.1521654761@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Louis Battuello writes: >> The point is you can't resolve a name like "schema_1.something" unless >> you have USAGE on schema_1. So the RI-checking query, which is run as >> the owner of the table, fails at parse time. > That certainly makes sense for user_2 that owns the reference table and = is blocked by not having usage on the reference table=E2=80=99s schema. > But, user_1 owns both schemas and has usage on both but no longer owns t= he reference table in one schema. Why is user_1=E2=80=99s insert on the re= ferencing table failing? Is the validation of the FK no longer done as use= r_1? Exactly, it's done as the owner of the referencing table. (I don't recall whether that's uniformly true for all types of FK-enforcement queries, but evidently it's true for this case.) regards, tom lane