Skip to content

refactor rowid codes#922

Merged
gaoxueyu merged 2 commits intoIvorySQL:IVORY_REL_5_STABLEfrom
yuanyl630:IVORY_REL_5_STABLE
Oct 17, 2025
Merged

refactor rowid codes#922
gaoxueyu merged 2 commits intoIvorySQL:IVORY_REL_5_STABLEfrom
yuanyl630:IVORY_REL_5_STABLE

Conversation

@yuanyl630
Copy link
Copy Markdown
Collaborator

@yuanyl630 yuanyl630 commented Oct 15, 2025

Summary by CodeRabbit

  • New Features

    • Introduced Oracle-compatible ROWID and UROWID data types with implicit casts between them.
    • Added a configurable option to automatically add a ROWID column when creating new tables (disabled by default).
    • Enabled installation of the UUID generation extension when not already present.
  • Documentation

    • Clarified descriptions and comments for ROWID behavior and compatibility.
    • Improved guidance in examples/tests to avoid naming conflicts and correct terminology.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds Oracle-compatible ROWID/UROWID composite types with implicit casts and installs uuid-ossp in preload_ora_misc.sql. Introduces a new boolean GUC ivorysql.default_with_rowids (USERSET, default false). Updates comments in heap.c, htup_details.h, tablefunc SQL, and Oracle test SQL. parse_utilcmd.c receives formatting-only edits.

Changes

Cohort / File(s) Summary of changes
Oracle ROWID types and casts
contrib/ivorysql_ora/preload_ora_misc.sql
Adds types sys.rowid (rowoid OID, rowno bigint) and sys.urowid (rowoid OID, rowno bigint); creates implicit INOUT casts between them; installs uuid-ossp extension if missing; updates comments.
GUC: default_with_rowids
src/backend/utils/misc/ivy_guc.c
Adds config_bool ivorysql.default_with_rowids (PGC_USERSET, default false, DEVELOPER_OPTIONS, hidden flags); clarifies description string.
ROWID documentation/comments
src/backend/catalog/heap.c, src/include/access/htup_details.h, contrib/tablefunc/sql/ivy_tablefunc.sql, src/oracle_test/regress/sql/ora_rowid.sql
Refines comments/descriptions around Oracle-compatible ROWID pseudo-column; fixes typos; clarifies use of orarowid in tablefunc example; no functional changes.
Parser formatting
src/backend/parser/parse_utilcmd.c
Whitespace and minor comment/style adjustments only.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • OreoYang

Poem

A nibble of types, a sprinkle of casts,
I thump my paws—new ROWIDs amassed.
A hidden GUC, quietly set,
Tables may sprout IDs yet.
Docs brushed clean, tests tidied too—
Carrot-shaped kudos to all of you! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The pull request title "refactor rowid codes" is related to the changeset, as the modifications do involve rowid-related code across multiple files. However, the title is vague and uses imprecise terminology that mischaracterizes the changes. The modifications primarily involve adding new types (sys.rowid, sys.urowid), creating casts between them, adding a new GUC parameter, and updating documentation and comments—these are feature additions and documentation improvements rather than structural refactoring of existing code. The term "refactor" is misleading in this context, and "codes" is overly generic, making it unclear what the main objective or scope of the change actually is. Consider revising the title to more accurately describe the primary changes, such as "Add ROWID and UROWID types with implicit casts" or "Add Oracle-compatible ROWID types and GUC parameter" to clearly convey what is being added and modified rather than using the imprecise term "refactor," which typically implies restructuring without behavioral change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 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.

@bigplaice
Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7d0b3a and 6b077e2.

⛔ Files ignored due to path filters (1)
  • contrib/tablefunc/expected/ivy_tablefunc.out is excluded by !**/*.out
📒 Files selected for processing (7)
  • contrib/ivorysql_ora/preload_ora_misc.sql (1 hunks)
  • contrib/tablefunc/sql/ivy_tablefunc.sql (1 hunks)
  • src/backend/catalog/heap.c (1 hunks)
  • src/backend/parser/parse_utilcmd.c (12 hunks)
  • src/backend/utils/misc/ivy_guc.c (1 hunks)
  • src/include/access/htup_details.h (1 hunks)
  • src/oracle_test/regress/sql/ora_rowid.sql (2 hunks)
🔇 Additional comments (6)
src/backend/catalog/heap.c (1)

231-233: LGTM! Documentation improvement.

The enhanced comment provides better clarity about the Oracle ROWID pseudo-column's purpose and Oracle compatibility, which improves code maintainability.

src/backend/utils/misc/ivy_guc.c (1)

190-209: LGTM! Clear documentation for the new GUC parameter.

The comment block and updated description effectively explain the purpose of ivorysql.default_with_rowids. The grammatical improvements make the description more professional.

src/oracle_test/regress/sql/ora_rowid.sql (2)

2-2: LGTM! Improved header comment.

The updated header comment provides clearer terminology by using "Oracle-Compatible ROWID Pseudo-Column", which is more precise and consistent with the terminology used throughout the codebase.


114-114: LGTM! Typo corrections.

Fixed spelling errors:

  • "clearup" → "cleanup" (Line 114)
  • "CTEATE TABLE" → "CREATE TABLE" (Line 119)

These corrections improve the test file's clarity and professionalism.

Also applies to: 119-119

contrib/ivorysql_ora/preload_ora_misc.sql (2)

9-17: LGTM! Well-structured ROWID/UROWID types.

The composite type definitions and bidirectional implicit casts correctly implement Oracle-compatible ROWID functionality. The identical structure for both types with WITH INOUT casts is appropriate for Oracle compatibility where UROWID is a universal version of ROWID.


19-22: uuid-ossp addition appears unrelated to ROWID functionality.

The grep search found no usage of uuid-ossp functions (uuid_generate_v1, uuid_generate_v5, sys_guid, etc.) in any ROWID-related code. The CREATE EXTENSION IF NOT EXISTS "uuid-ossp" line in lines 19–22 appears logically disconnected from the Oracle compatibility casts for ROWID on lines 1–17.

This extension should either be:

  1. Confirmed as required for Oracle compatibility (with clarification added to the PR description), or
  2. Moved to a separate commit/PR.

Comment on lines 411 to 417
relnamelist = list_make3(makeString(snamespace),
makeString(cxt.relation->relname),
makeString(sname));
makeString(cxt.relation->relname),
makeString(sname));

altseqstmt->options = list_make1(makeDefElem("owned_by",
(Node *) relnamelist, -1));
(Node *) relnamelist, -1));
cxt.alist = lappend(cxt.alist, altseqstmt);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix OWNED BY target column in rowid sequence setup.

ALTER SEQUENCE schema.table_rowid_seq OWNED BY schema.table.table_rowid_seq will run because the third identifier comes from sname, i.e., the sequence name. The table has no column of that name, so the ALTER will error out and the table creation fails. The third element must be the ROWID column name (e.g., "rowid"), not the sequence name. Please adjust the relnamelist accordingly.

Apply this diff to correct the relnamelist:

-       relnamelist = list_make3(makeString(snamespace),
-                                 makeString(cxt->relation->relname),
-                                 makeString(sname));
+       relnamelist = list_make3(makeString(snamespace),
+                                 makeString(cxt->relation->relname),
+                                 makeString("rowid"));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
relnamelist = list_make3(makeString(snamespace),
makeString(cxt.relation->relname),
makeString(sname));
makeString(cxt.relation->relname),
makeString(sname));
altseqstmt->options = list_make1(makeDefElem("owned_by",
(Node *) relnamelist, -1));
(Node *) relnamelist, -1));
cxt.alist = lappend(cxt.alist, altseqstmt);
relnamelist = list_make3(makeString(snamespace),
makeString(cxt.relation->relname),
makeString("rowid"));
altseqstmt->options = list_make1(makeDefElem("owned_by",
(Node *) relnamelist, -1));
cxt.alist = lappend(cxt.alist, altseqstmt);

Comment on lines 3834 to 3838
relnamelist = list_make3(makeString(snamespace),
makeString(cxt.relation->relname),
makeString(sname));
makeString(cxt.relation->relname),
makeString(sname));

altseqstmt->options = list_make1(makeDefElem("owned_by",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Also fix OWNED BY clause in ALTER TABLE path.

The same issue occurs here: relnamelist uses the sequence name (sname) as the column identifier, so the generated ALTER SEQUENCE ... OWNED BY still targets a non-existent column. Update this block to pass the ROWID column name instead.

-                       relnamelist = list_make3(makeString(snamespace),
-                                                 makeString(cxt->relation->relname),
-                                                 makeString(sname));
+                       relnamelist = list_make3(makeString(snamespace),
+                                                 makeString(cxt->relation->relname),
+                                                 makeString("rowid"));

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/backend/parser/parse_utilcmd.c around lines 3834-3838, relnamelist is
currently built with makeString(sname) and the ALTER SEQUENCE OWNED BY option
also references the sequence name as the column; replace those uses with the
table's ROWID column name. Specifically, change the third element in relnamelist
from makeString(sname) to makeString(cxt.rowidcol) (or the exact field holding
the ROWID column name) and ensure the owned_by option is set to refer to that
same ROWID column name instead of sname so ALTER SEQUENCE ... OWNED BY targets
the correct column.

@bigplaice
Copy link
Copy Markdown
Collaborator

no comments, proceed.

@gaoxueyu gaoxueyu merged commit c53c1c4 into IvorySQL:IVORY_REL_5_STABLE Oct 17, 2025
6 checks passed
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.

4 participants