Skip to content

Fix invalid SQL from index TABLESPACE clause on partitioned tables - #10342

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10341-partition-index-tablespace
Open

Fix invalid SQL from index TABLESPACE clause on partitioned tables#10342
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10341-partition-index-tablespace

Conversation

@dpage

@dpage dpage commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • PostgreSQL rejects an explicit TABLESPACE clause naming the database's own default tablespace when the index belongs to a partitioned table (cannot specify default tablespace for partitioned relations), so the SQL pgAdmin generated for a new index on a partitioned table could not be executed whenever the Tablespace field was left at its default (pg_default).
  • The index_constraint and exclusion_constraint create.sql templates already guard against emitting this redundant clause (data.spcname != "pg_default"); this extends the same guard to the plain index create.sql templates (default and 15_plus buckets).
  • Updated all affected fixture files under indexes/tests/{default,15_plus} to match the corrected output.

Test plan

  • Added test_create_sql_partitioned_tablespace.py, a DB-free unit test rendering the templates directly and asserting the redundant clause is omitted while an explicit non-default tablespace is still emitted.
  • regression/runtests.py --pkg browser.server_groups.servers.databases.schemas.tables.indexes.tests — 49/49 passing.
  • regression/runtests.py --pkg browser.server_groups.servers.databases.schemas.tables.tests — 113/113 passing (no regression in the parent Tables SQL, which embeds indexes).
  • Verified against a live PostgreSQL 18 server that CREATE INDEX ... TABLESPACE pg_default on a partitioned table errors, while a real non-default tablespace works fine.

Closes #10341

PostgreSQL rejects an explicit TABLESPACE clause naming the database's
own default tablespace when the index is on a partitioned table
('cannot specify default tablespace for partitioned relations'), so
the SQL pgAdmin generated for a new index could not be executed
against a partitioned table whenever no non-default tablespace was
chosen. The index_constraint and exclusion_constraint create.sql
templates already guard against emitting this redundant clause;
extend the same guard to the plain index create.sql templates.

Closes pgadmin-org#10341
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 52 minutes.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c10ead4e-8485-4127-9691-ab03583d9927

📥 Commits

Reviewing files that changed from the base of the PR and between bc58657 and 62813eb.

📒 Files selected for processing (35)
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/alter_index_no_depends.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/alter_name_fillfactor_comment.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/alter_reset_fillfactor_cluster.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_asc_null_first.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_asc_null_first_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_asc_null_last.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_asc_null_last_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_desc_null_first.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_desc_null_first_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_desc_null_last.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_btree_desc_null_last_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_index_with_ext.msql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/create_index_with_ext.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/alter_expr_statistics.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/alter_index_no_depends.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/alter_name_fillfactor_comment.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/alter_reset_fillfactor_cluster.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_asc_null_first.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_asc_null_first_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_asc_null_last.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_asc_null_last_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_desc_null_first.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_desc_null_first_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_desc_null_last.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_desc_null_last_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_expr_asc_null_last.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_btree_expr_asc_null_last_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_hash_index.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_hash_index_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_index_with_ext.msql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_index_with_ext.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/create_unnamed_hash_index_msql.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/test_create_sql_partitioned_tablespace.py
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/15_plus/create.sql
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/default/create.sql

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated SQL for indexes invalid for partitioned tables

1 participant