Skip to content

sql: SHOW CREATE TABLE to include the table's RLS policies #136753

Closed
@spilchen

Description

When SHOW CREATE TABLE is executed on a table with row-level security (RLS), the generated DDL should include the CREATE POLICY statements for those policies, appearing immediately after the column definitions.

It should look like the following:

SHOW CREATE TABLE t1;

 table_name |                      create_statement
-------------+--------------------------------------------------------------
  t1         | CREATE TABLE public.t1 (
             |     rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
             |     CONSTRAINT t1_pkey PRIMARY KEY (rowid ASC)
             | );
             | ALTER TABLE public.t1 ENABLE ROW LEVEL SECURITY;             
             | CREATE POLICY p1 on public.t1;
             | CREATE POLICY p2 on public.t1
(1 row)

The \d command is similar to SHOW CREATE TABLE, but is a separate codepath. Updating of that is handled in a separate issue. See CRDB-46367: sql: \d command to include RLS policies

Jira issue: CRDB-45229

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-sql-privilegesSQL privilege handling and permission checks.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)target-release-25.2.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions