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.98.2) (envelope-from ) id 1xR5j1-00000000fn7-3CNY for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:43 +0000 Received: from localhost ([127.0.0.1]:44524 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR5iz-0000000AE14-1q0H for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:41202) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR5PA-00000009z1i-2A4V for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 10:18:12 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR5P6-00000000RSa-26nz for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 10:18:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=O6jwLGciEFW/B86+jle6WR0fwUBVM05YJurQN0JR878=; b=vT/4WMmguGBn4H4pA1rVV16Mmf MXRC1T8mQ4VgsF4YT4Vt5dI5xfGkqdbVmpbtchchXlSvAP12MUZg2cn1If+n9FnuKZZIDGXt9W52K rZOLl49hgLejlbCAZ6sXQnGL0g7cgzjsHSuXG2ohrc+WVWOS0nxglXghzwySH4kkBm/H+MJrD/egv BgHM0fBhJgok54n7YIUZrWB4UHoBZZBxqIPBH7pryh67QjqLB5PlTy1AtFtjALuIP08NSyKmE/44h OILQkF+EMSJriFVsRSrP8dE+81dBppNcu4yg0rvqj/9A0SwTpA5dFbEANOLsIFGGYFLi4gDLw4rbP l1mYqe7w==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR5P2-00000000ynU-33N0 for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 10:18:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR5P1-00000002anz-0LVL for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 10:18:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19874: CREATE SCHEMA view binds same-named table in pg_temp and fails To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1548140642@qq.com Reply-To: 1548140642@qq.com, pgsql-bugs@lists.postgresql.org Date: Wed, 11 Nov 2026 10:17:19 +0000 Message-ID: <19874-1ade7299b36bdc5f@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19874 Logged by: Milo Email address: 1548140642@qq.com PostgreSQL version: 18.6 Operating system: Linux/amd64 Description: =20 CREATE SCHEMA fails when it creates a table and a view over that table while pg_temp already contains a table with the same name. PostgreSQL treats the view as temporary and then rejects it because the target schema is permanent. The compound statement should create a permanent view whose query binds to the table created in the new schema. After inserting the value new-schema into that table, selecting from the view should return new-schema. How to repeat: \set ON_ERROR_STOP off DROP SCHEMA IF EXISTS app_data CASCADE; DROP TABLE IF EXISTS items; CREATE TEMP TABLE items(marker text); INSERT INTO items VALUES ('temporary'); CREATE SCHEMA app_data CREATE TABLE items(marker text) CREATE VIEW item_view AS SELECT marker FROM items; INSERT INTO app_data.items VALUES ('new-schema'); SELECT c.relkind, n.nspname FROM pg_class AS c JOIN pg_namespace AS n ON n.oid =3D c.relnamespace WHERE c.relname =3D 'item_view' ORDER BY n.nspname; SELECT * FROM app_data.item_view; DROP SCHEMA IF EXISTS app_data CASCADE; DROP TABLE IF EXISTS items; The relevant client output was: CREATE TABLE INSERT 0 1 psql:reproducer.sql:11: NOTICE: view "item_view" will be a temporary view psql:reproducer.sql:11: ERROR: cannot create temporary relation in non-temporary schema psql:reproducer.sql:13: ERROR: relation "app_data.items" does not exist LINE 1: INSERT INTO app_data.items VALUES ('new-schema'); ^ relkind | nspname ---------+--------- (0 rows) psql:reproducer.sql:21: ERROR: relation "app_data.item_view" does not exist LINE 1: SELECT * FROM app_data.item_view; ^ psql:reproducer.sql:23: NOTICE: schema "app_data" does not exist, skipping DROP SCHEMA DROP TABLE The notice and first error show that the unqualified items reference inside the view query resolved to the temporary table. Failure of the compound statement removes app_data atomically, which accounts for the later missing-relation errors. The issue was reproduced on PostgreSQL 18.6 on Linux/amd64. This occurs when a compound CREATE SCHEMA statement creates a view over another object in that statement while pg_temp contains an object with the referenced name.