Skip to content

Comments

Add support for 'ONLY' in Index creation dialog. #6386#9643

Open
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-6386
Open

Add support for 'ONLY' in Index creation dialog. #6386#9643
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-6386

Conversation

@RohitBhati8269
Copy link
Contributor

@RohitBhati8269 RohitBhati8269 commented Feb 18, 2026

Summary by CodeRabbit

  • New Features

    • Added "Only Table?" toggle to the index creation form (create mode only); disabled in schema view and when the target table is not partitioned.
    • Index creation now honors this toggle by adding ONLY to the ON clause when enabled.
  • Refactor

    • Reorganized the "With" section placement/grouping in the index form for clearer layout.
  • Documentation

    • Updated index dialog docs with descriptions for the new options and a With-tab illustration.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Walkthrough

Adds an "Only Table?" switch to the Index UI and threads its value into CREATE INDEX templates so the ON clause conditionally includes ONLY when the switch is set.

Changes

Cohort / File(s) Summary
UI Schema
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js
Added public boolean indisonly (default false) to IndexSchema. Inserted a create-mode switch control labeled "Only Table?" (disabled in schema view or when target table is not partitioned). Reordered/regrouped the With block around the new control.
SQL Templates
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/11_plus/create.sql, .../13_plus/create.sql, .../15_plus/create.sql
Modified CREATE INDEX templates to conditionally prepend ONLY before the qualified table reference when data.indisonly is true; otherwise unchanged.
Documentation
docs/en_US/index_dialog.rst
Added option descriptions (Only Table?, Unique?, NULLs not distinct?, Clustered?, Concurrent build?, Constraint) and added/relocated With tab note and image; removed duplicated occurrences later in the document.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant User
participant UI as "Index UI"
participant Tmpl as "SQL Template Renderer"
participant DB as "Postgres DB"
User->>UI: Open Index dialog / toggle "Only Table?" switch
UI->>UI: set data.indisonly = true/false
User->>UI: Submit Create Index
UI->>Tmpl: render CREATE INDEX with data (includes indisonly)
Tmpl->>Tmpl: if indisonly -> include ONLY before schema.table
Tmpl->>DB: execute rendered CREATE INDEX SQL
DB-->>Tmpl: execution result
Tmpl-->>UI: return result
UI-->>User: show success/error

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • anilsahoo20
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately summarizes the main change: adding support for the 'ONLY' modifier in PostgreSQL index creation through the pgAdmin dialog interface.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js`:
- Around line 528-535: The indisonly control currently allows being set together
with isconcurrent which produces invalid SQL; update the indisonly field
definition (the disabled callback for indexSchemaObj.node_info) to include deps:
['isconcurrent'] and return true when state.isconcurrent is truthy (preventing
ONLY when CONCURRENTLY is selected), and additionally add a mutual-exclusion
check in the form validate() (or in the index creation validator) to reject the
combination of state.isconcurrent and state.indisonly with a clear validation
error; reference the indisonly field's disabled callback, deps:
['isconcurrent'], state.isconcurrent, and the validate() function to implement
both the UI disable and the validation guard.
- Around line 526-536: The 'indisonly' field in the index field definition is
missing a PostgreSQL version guard; update the field object (id: 'indisonly'
within the index UI schema) to include min_version: 110000 so the switch is only
shown/active for PG >= 11 connections (consistent with other guarded fields like
'deduplicate_items' and 'indnullsnotdistinct'), leaving the existing disabled
and helpMessage logic intact and using indexSchemaObj.node_info for context as
before.
- Line 535: Update the helpMessage for the ONLY option in index.ui.js (the
helpMessage property) to explicitly state that using ONLY creates the index only
on that table and the resulting index is initially marked INVALID; also mention
that the index becomes valid once matching indexes exist on partitions (e.g.,
via ALTER INDEX ... ATTACH PARTITION). Modify the gettext string accordingly so
users know the index won't be usable immediately and how it can be made valid.

@RohitBhati8269 RohitBhati8269 force-pushed the GH-6386 branch 2 times, most recently from d158209 to ab48397 Compare February 19, 2026 07:30
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js`:
- Around line 526-537: Update the inline comment above the indisonly switch to
correctly state that ONLY applies to partitioned tables (not inherited tables):
locate the block defining the control with id 'indisonly' (uses
indexSchemaObj.node_info and disabled: () => inSchema(indexSchemaObj.node_info)
|| !indexSchemaObj.node_info?.table?.is_partitioned) and replace the comment
text to: "ONLY is only applicable to partitioned tables".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/en_US/index_dialog.rst (1)

10-12: ⚠️ Potential issue | 🟡 Minor

Intro tab list is missing the new With tab.

The introductory sentence still lists only three tabs but a fourth "With" tab has been added (documented at line 69).

📝 Proposed fix
-The *Index* dialog organizes the development of a index through the following
-dialog tabs: *General*, *Definition*, and *Columns*. The *SQL* tab displays the SQL code
-generated by dialog selections.
+The *Index* dialog organizes the development of an index through the following
+dialog tabs: *General*, *Definition*, *With*, and *Columns*. The *SQL* tab displays the SQL code
+generated by dialog selections.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en_US/index_dialog.rst` around lines 10 - 12, The intro sentence for the
"Index" dialog currently lists only the three tabs "General", "Definition", and
"Columns" (and mentions "SQL") but omits the newly added "With" tab; update that
sentence in the "Index dialog" description so the tab list includes "With"
(e.g., "General, Definition, Columns, With" and then "SQL" as currently
described) to match the later documentation where the "With" tab is documented.
🧹 Nitpick comments (1)
docs/en_US/index_dialog.rst (1)

54-55: Consider noting that "Only Table?" is exclusive to partitioned tables.

The UI disables this switch for non-partitioned tables, but the docs don't explain the restriction. Users who see it greyed out will have no guidance.

📝 Suggested wording addition
 * Move the switch next to *Only Table?* to the *Yes* position to create the index
-  only on the parent table without recursing to its partitions. The default is *No*.
+  only on the parent table without recursing to its partitions. The default is *No*.
+  This option is only enabled for partitioned tables.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en_US/index_dialog.rst` around lines 54 - 55, The docs mention the "Only
Table?" switch but don't say it's only relevant for partitioned tables; update
the index_dialog.rst text around the "Only Table?" explanation to add a brief
sentence that this option is only applicable to partitioned tables and the UI
disables (greys out) the switch for non-partitioned tables so users understand
why they may see it inactive; reference the existing phrasing "Only Table?" and
the sentence about default being "No" and insert the note immediately after that
sentence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/en_US/index_dialog.rst`:
- Around line 10-12: The intro sentence for the "Index" dialog currently lists
only the three tabs "General", "Definition", and "Columns" (and mentions "SQL")
but omits the newly added "With" tab; update that sentence in the "Index dialog"
description so the tab list includes "With" (e.g., "General, Definition,
Columns, With" and then "SQL" as currently described) to match the later
documentation where the "With" tab is documented.

---

Nitpick comments:
In `@docs/en_US/index_dialog.rst`:
- Around line 54-55: The docs mention the "Only Table?" switch but don't say
it's only relevant for partitioned tables; update the index_dialog.rst text
around the "Only Table?" explanation to add a brief sentence that this option is
only applicable to partitioned tables and the UI disables (greys out) the switch
for non-partitioned tables so users understand why they may see it inactive;
reference the existing phrasing "Only Table?" and the sentence about default
being "No" and insert the note immediately after that sentence.

@RohitBhati8269 RohitBhati8269 changed the title Add support for 'ONLY' predicate in Index creation dialog. #6386 Add support for 'ONLY' in Index creation dialog. #6386 Feb 20, 2026
@RohitBhati8269
Copy link
Contributor Author

@anilsahoo20 As per my findings, the predicate functionality for partial indexes already exists in pgAdmin4.
The field is called "Constraint" in the UI and stored as indconstraint.

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.

1 participant