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 1gHSxl-0006DV-N7 for pgsql-admin@arkaria.postgresql.org; Tue, 30 Oct 2018 12:17:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHSxj-0007G3-At for pgsql-admin@arkaria.postgresql.org; Tue, 30 Oct 2018 12:17:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHSxi-0007Ez-W1 for pgsql-admin@lists.postgresql.org; Tue, 30 Oct 2018 12:17:35 +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 1gHSxf-0006qE-KL for pgsql-admin@postgresql.org; Tue, 30 Oct 2018 12:17:32 +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 w9UCHEPI020192; Tue, 30 Oct 2018 08:17:14 -0400 From: Tom Lane To: Axel Rau cc: Laurenz Albe , pgsql-admin@postgresql.org Subject: Re: Getting fancy errors when accessing information_schema on 10.5 In-reply-to: <44D4C7B1-0DCF-4166-9DB8-B5D75EB2985E@Chaos1.DE> References: <4880e067723cefc1dc2e08a117f96de26ae0f797.camel@cybertec.at> <44D4C7B1-0DCF-4166-9DB8-B5D75EB2985E@Chaos1.DE> Comments: In-reply-to Axel Rau message dated "Tue, 30 Oct 2018 12:32:08 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <20190.1540901834.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 30 Oct 2018 08:17:14 -0400 Message-ID: <20191.1540901834@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Axel Rau writes: >> Am 30.10.2018 um 08:42 schrieb Laurenz Albe : >> Could you run EXPLAIN on the query and tell us the execution plan? > EXPLAIN SELECT sequence_name AS relname, sequence_schema AS schemaname > FROM information_schema.sequences > WHERE sequence_schema NOT LIKE 'pg\_%' AND sequence_schema !=3D 'informa= tion_schema'; > ... > -> Seq Scan on pg_class c (cost=3D0.00..28.56 row= s=3D22 width=3D72) > Filter: ((pg_has_role(relowner, 'USAGE'::text= ) OR has_sequence_privilege(oid, 'SELECT, UPDATE, USAGE'::text)) AND (relk= ind =3D 'S'::"char")) Well, there's the problem: for some reason the planner is deciding to execute the privilege test before the relkind check. >> Perhaps this is some fancy kind of catalog corruption=E2=80=A6 > Maybe, as this does not happen with another instance. It doesn't happen for me either. Looking at the planner code, it seems like the relkind check should happen first because it'd be cheaper than the OR condition. Have you perhaps messed with the cost attributed to pg_has_role(), has_sequence_privilege(), or chareq()? You could investigate with, eg, select oid::regprocedure, procost from pg_proc where proname =3D 'has_sequence_privilege'; regards, tom lane