Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruCwv-003ULc-Eq for pgsql-general@arkaria.postgresql.org; Tue, 09 Apr 2024 14:59:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ruCwu-006H7o-Du for pgsql-general@arkaria.postgresql.org; Tue, 09 Apr 2024 14:59:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruCwu-006H7G-35 for pgsql-general@lists.postgresql.org; Tue, 09 Apr 2024 14:59:48 +0000 Received: from sm-r-014-dus.org-dns.com ([84.19.1.233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ruCwn-0002MY-I5 for pgsql-general@lists.postgresql.org; Tue, 09 Apr 2024 14:59:47 +0000 Received: from smarthost-dus.org-dns.com (localhost [127.0.0.1]) by smarthost-dus.org-dns.com (Postfix) with ESMTP id BF4C3A1F17 for ; Tue, 9 Apr 2024 16:59:39 +0200 (CEST) Received: by smarthost-dus.org-dns.com (Postfix, from userid 1001) id B3266A1F3C; Tue, 9 Apr 2024 16:59:39 +0200 (CEST) X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_50,KAM_INFOUSMEBIZ, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from ha01s018.org-dns.com (ha01s018.org-dns.com [62.108.32.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smarthost-dus.org-dns.com (Postfix) with ESMTPS id 40AC3A1F17 for ; Tue, 9 Apr 2024 16:59:39 +0200 (CEST) Authentication-Results: ha01s018.org-dns.com; spf=pass (sender IP is 79.233.131.2) smtp.mailfrom=thiemo@gelassene-pferde.biz smtp.helo=[192.168.2.190] Received-SPF: pass (ha01s018.org-dns.com: connection is authenticated) Message-ID: Date: Tue, 9 Apr 2024 16:59:38 +0200 MIME-Version: 1.0 To: "pgsql-general@lists.postgresql.org" From: Thiemo Kellner Subject: [Code: 0, SQL State: 0A000] when "typing" from pg_catalog Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-PPP-Message-ID: <171267477910.644.11832155135773024733@ha01s018.org-dns.com> X-PPP-Vhost: gelassene-pferde.biz X-POWERED-BY: wint.global - AV:CLEAN SPAM:OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi I have the following function code. When trying to install, it gives me [Code: 0, SQL State: 0A000] FEHLER: Verweise auf andere Datenbanken sind nicht implementiert: pg_catalog.pg_roles.rolname Position: 298 [Script position: 334 - 361] To the best of my knowledge, pg_catalog is a schema not a database, like information_schema. Am I missing something? And why is it not allowed to type from the catalogue? I presume, this example is rather academic due to the name type. Kind regards Thiemo create or replace function GRANT_SELECTS() returns void language plpgsql as $body$ declare C_SCHEMA_NAME constant INFORMATION_SCHEMA.SCHEMATA.SCHEMA_NAME%type := 'snowrunner'; -- C_ROLE_NAME constant name := C_ROLE_NAME constant PG_CATALOG.PG_ROLES.ROLNAME := 'snowrunner_reader'; V_SQL_STATEMENT text; begin -- Check the existance of the schema perform 1 from INFORMATION_SCHEMA.SCHEMATA where SCHEMA_NAME = C_SCHEMA_NAME; if not found then raise exception 'Schema "%s" does not exist!', C_SCHEMA_NAME; end if; -- Check the existance of the role perform 1 from PG_CATALOG.PG_ROLES where ROLNAME = C_ROLE_NAME; if not found then raise exception 'Role "%s" does not exist!', C_ROLE_NAME; end if; -- Issue grants V_SQL_STATEMENT := format('grant select on all tables in schema %i to %i', C_SCHEMA_NAME, C_ROLE_NAME); raise info '%', V_SQL_STATEMENT; execute V_SQL_STATEMENT; V_SQL_STATEMENT := format('grant select on all views in schema %i to %i', C_SCHEMA_NAME, C_ROLE_NAME); raise info '%', V_SQL_STATEMENT; execute V_SQL_STATEMENT; V_SQL_STATEMENT := format('grant select on all materialized views in schema %i to %i', C_SCHEMA_NAME, C_ROLE_NAME); raise info '%', V_SQL_STATEMENT; execute V_SQL_STATEMENT; commit; return; end; $body$;