#34326·yugabyte-db

[YSQL] ALTER TABLE ... SET SCHEMA pg_catalog bypasses system catalog modification protection

Author: jinhui-laiCreated Sep 28, 2026Updated Sep 29, 2026
Labelskind/bugarea/ysqlpriority/mediumstatus/awaiting-triage

Jira Link: DB-23874

Description

YugabyteDB prevents users from creating tables directly in the pg_catalog schema, reporting that system catalog modifications are disallowed. However, this restriction can be bypassed using ALTER TABLE ... SET SCHEMA. A user can first create a table in the default schema and then move it into pg_catalog. The operation succeeds, allowing a user-defined table to be placed in a protected system schema.

Reproduction

sql
-- ysqlsh (15.12-YB-2026.1.1.2-b0)
Type "help" for help.

CREATE TABLE pg_catalog.t (i int);
-- ERROR:  permission denied to create "pg_catalog.t"
-- DETAIL:  System catalog modifications are currently disallowed.
CREATE TABLE t (i int);
-- CREATE TABLE
ALTER TABLE t SET schema pg_catalog;
-- ALTER TABLE
\dS+ t
--                                           Table "pg_catalog.t"
--  Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats tar get | Description 
-- --------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
--  i      | integer |           |          |         | plain   |             |              | 
-- Replica Identity: ???
-- Access method: heap

DROP TABLE pg_catalog.t;
-- DROP TABLE

Actual behavior

Although direct table creation in pg_catalog is prohibited, ALTER TABLE ... SET SCHEMA pg_catalog succeeds. The table is successfully moved into the protected system schema and can subsequently be dropped. This allows users to bypass the restriction on creating user-defined objects in pg_catalog.

sql
ALTER TABLE t SET schema pg_catalog;
-- ALTER TABLE
\dS+ t
--                                           Table "pg_catalog.t"
--  Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats tar get | Description 
-- --------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
--  i      | integer |           |          |         | plain   |             |              | 
-- Replica Identity: ???
-- Access method: heap

DROP TABLE pg_catalog.t;
-- DROP TABLE

Expected behavior

YugabyteDB should consistently enforce system schema protection across DDL operations. ALTER TABLE ... SET SCHEMA pg_catalog should be rejected under the same restrictions that prevent direct table creation in pg_catalog, rather than allowing a user-defined table to be moved into the protected schema.

Environment

  • DBMS: YugabyteDB
  • Version: 15.12-YB-2026.1.1.2-b0
  • OS: Ubuntu 22.04

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.