Skip to content

Fix issue 763 - #796

Merged
gaoxueyu merged 2 commits into
IvorySQL:masterfrom
bigplaice:master
Apr 29, 2025
Merged

gaoxueyu merged 2 commits into
IvorySQL:masterfrom
bigplaice:master

Conversation

@bigplaice

@bigplaice bigplaice commented Apr 25, 2025 •

Copy link
Copy Markdown
Collaborator

Fix issue 763

Summary by CodeRabbit

  • Refactor
    • Updated internal compatibility checks to use revised identifiers for Oracle and PostgreSQL parser modes. This impacts various behaviors related to case handling, system column naming, sequence ownership, anonymous block language defaults, and trigger execution, ensuring consistent mode detection throughout the application.
  • Bug Fixes
    • Improved consistency in Oracle compatibility logic for features such as rowid handling, identifier case transformation, and EXPLAIN ANALYZE output.

@coderabbitai

coderabbitai Bot commented Apr 25, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This change updates conditional checks throughout the codebase to use new symbolic constants for database compatibility modes. Specifically, occurrences of DB_ORACLE are replaced with ORA_PARSER, and DB_PG with PG_PARSER. These updates affect logic related to compatibility-specific behaviors in parsing, case handling, trigger firing, function execution, and other PostgreSQL internals. The changes are isolated to internal logic and do not alter function signatures or exported interfaces.

Changes

File(s) Change Summary
src/backend/catalog/heap.c
src/backend/catalog/namespace.c
Replaced DB_ORACLE with ORA_PARSER in conditional checks for attribute and namespace handling.
src/backend/commands/explain.c Updated compatibility checks from DB_ORACLE to ORA_PARSER for EXPLAIN ANALYZE output logic.
src/backend/commands/functioncmds.c Changed default language selection for anonymous blocks to use ORA_PARSER instead of DB_ORACLE.
src/backend/commands/sequence.c Swapped DB_ORACLE/DB_PG with ORA_PARSER/PG_PARSER in sequence ownership logic.
src/backend/executor/execExprInterp.c Updated XML expression compatibility check from DB_ORACLE to ORA_PARSER.
src/backend/executor/nodeModifyTable.c Changed trigger firing logic to use ORA_PARSER instead of DB_ORACLE.
src/backend/parser/analyze.c Replaced DB_ORACLE/DB_PG with ORA_PARSER/PG_PARSER in update statement parsing.
src/backend/parser/parse_clause.c Updated ROWID option compatibility check to use ORA_PARSER.
src/backend/parser/parse_expr.c Changed type casting logic for ROWID to check for ORA_PARSER.
src/backend/parser/parse_utilcmd.c Updated column name conflict check to use ORA_PARSER.
src/backend/tcop/backend_startup.c Changed case transformation logic for startup packet to use ORA_PARSER.
src/backend/utils/adt/ri_triggers.c Updated identifier quoting to check for ORA_PARSER.
src/backend/utils/adt/varlena.c Changed identifier string splitting logic to use ORA_PARSER.
src/backend/utils/misc/ivy_guc.c Replaced compatibility mode constants with ORA_PARSER/PG_PARSER in GUC assignment/check logic.
src/pl/plisql/src/pl_exec.c Updated record assignment logic to use ORA_PARSER for "rowid" type detection.

Suggested reviewers

  • jiaoshuntian

Poem

In the warren of code where the constants hop,
The parser now wears a brand new top.
ORA_PARSER leads where DB_ORACLE once stood,
While PG_PARSER hops in, as only rabbits could.
With every check and every clause,
The code now follows new parser laws.
🐇 Cheers to the change—hippity-hop, well understood!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/backend/executor/execExprInterp.c (1)

4101-4120: 💡 Verification agent

🧩 Analysis chain

Updated XML update hook check to use ORA_PARSER
This replaces the legacy DB_ORACLE constant with the new ORA_PARSER compatibility mode. Ensure that ORA_PARSER is defined in ora_compatible.h and that all previous DB_ORACLE checks have been removed across the codebase.

Run the following script to verify no residual DB_ORACLE references remain:


🏁 Script executed:

#!/bin/bash
# Description: Search for any remaining DB_ORACLE references
rg -n 'DB_ORACLE' src/backend/executor/execExprInterp.c

Length of output: 55


🏁 Script executed:

#!/bin/bash
# Search for any remaining DB_ORACLE references across the entire repository
rg -n 'DB_ORACLE'

# Locate the ora_compatible.h file and verify that ORA_PARSER is defined
file=$(fd -t f ora_compatible.h | head -n1)
echo "Inspecting: $file"
rg -n 'ORA_PARSER' "$file"

Length of output: 4132


Replace all remaining DB_ORACLE checks with ORA_PARSER for consistency
ORA_PARSER is correctly defined in src/include/utils/ora_compatible.h (line 33), but there are still many residual DB_ORACLE references across the codebase. Please update or remove these to use the new ORA_PARSER mode.

Key locations to address (run rg -n 'DB_ORACLE' for the full list):

  • src/oracle_fe_utils/ora_string_utils.c:158
  • src/fe_utils/string_utils.c:70
  • src/backend/access/transam/xlog.c:5442
  • src/backend/utils/misc/guc_funcs.c:100, 208
  • src/backend/utils/misc/ivy_guc.c:53, 55, 381, 406, 417
  • src/backend/utils/adt/varlena.c:1921, 2189, 2284
  • src/backend/postmaster/postmaster.c:1170, 1321
  • src/backend/parser/parse_expr.c:1962, 2276, 2281
  • src/backend/parser/parse_clause.c:3921
  • src/backend/oracle_parser/ora_scan.l:931
  • Various psql, initdb, pg_dump, pg_resetwal and bootstrap files

After updating, rerun:

rg -n 'DB_ORACLE'

to confirm no legacy references remain.

🧹 Nitpick comments (2)
src/backend/parser/parse_clause.c (1)

3923-3926: Update comment to reflect ORA_PARSER constant
The comment above the fallback still references DB_ORACLE, but the code now checks ORA_PARSER. Please update the comment for consistency and to avoid confusion.

Apply this diff:

- * ROWID option was not specified, so use default GUC value,
- * but this GUC only valid in DB_ORACLE model
+ * ROWID option was not specified, so use default GUC value,
+ * but this GUC only valid in ORA_PARSER mode
src/backend/catalog/namespace.c (1)

4328-4329: ORA_PARSER substitution is correct; typo in inline comment
The condition properly replaces the old DB_ORACLE check with ORA_PARSER, aligning with the new compatibility-mode names.
Nit: please correct the inline comment from
/* IvorySQL: case sensitive indentify */
to
/* IvorySQL: case-sensitive identifier handling */
for clarity and correct spelling.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eebe0bd and 137f2d1.

📒 Files selected for processing (16)
  • src/backend/catalog/heap.c (1 hunks)
  • src/backend/catalog/namespace.c (1 hunks)
  • src/backend/commands/explain.c (3 hunks)
  • src/backend/commands/functioncmds.c (1 hunks)
  • src/backend/commands/sequence.c (2 hunks)
  • src/backend/executor/execExprInterp.c (1 hunks)
  • src/backend/executor/nodeModifyTable.c (1 hunks)
  • src/backend/parser/analyze.c (3 hunks)
  • src/backend/parser/parse_clause.c (1 hunks)
  • src/backend/parser/parse_expr.c (1 hunks)
  • src/backend/parser/parse_utilcmd.c (1 hunks)
  • src/backend/tcop/backend_startup.c (2 hunks)
  • src/backend/utils/adt/ri_triggers.c (1 hunks)
  • src/backend/utils/adt/varlena.c (2 hunks)
  • src/backend/utils/misc/ivy_guc.c (3 hunks)
  • src/pl/plisql/src/pl_exec.c (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: contrib_regression
  • GitHub Check: oracle_regression (ubuntu-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: pg_regression (ubuntu-latest)
  • GitHub Check: oracle_pg_regression (ubuntu-latest)
  • GitHub Check: meson_build (ubuntu-latest)
🔇 Additional comments (26)
src/backend/utils/misc/ivy_guc.c (4)

376-376: Changes to compatibility mode check look good

The symbolic constant DB_ORACLE has been replaced with ORA_PARSER to use a more specific parser-related identifier, which better reflects the compatibility mode being checked.


384-384: Consistent use of parser-specific identifiers

This is part of the same pattern of replacing database compatibility constants with more specific parser identifiers throughout the codebase.


420-421: Appropriate replacement of compatibility constant

The change from DB_ORACLE to ORA_PARSER is consistent with other changes and better specifies that this is about the parser mode specifically.


430-430: Consistent constant replacement

Replacing DB_PG with PG_PARSER maintains consistency with the other changes throughout the codebase.

src/backend/utils/adt/ri_triggers.c (1)

1882-1882: Oracle compatibility check updated correctly

Changed from DB_ORACLE to ORA_PARSER to align with the more specific parser compatibility constant used elsewhere in the codebase.

src/backend/commands/functioncmds.c (5)

610-610: Database compatibility check updated properly

The symbolic constant DB_ORACLE has been replaced with ORA_PARSER in the condition that handles Oracle's "deterministic" equivalent to PostgreSQL's "volatility" attribute.


629-629: Oracle compatibility check updated

Good replacement of DB_ORACLE with ORA_PARSER for the check handling Oracle's "authid" equivalent to PostgreSQL's "security" attribute.


677-677: Consistent renaming of compatibility constant

The change from DB_ORACLE to ORA_PARSER maintains consistency with the other changes in the codebase.


976-977: Oracle security context default properly updated

Updated the compatibility check for setting the default security context for plisql functions.


2480-2484: Default language selection updated correctly

Changed the condition that determines the default language for anonymous code blocks from DB_ORACLE to ORA_PARSER, maintaining the same behavior where "plisql" is the default in Oracle mode and "plpgsql" otherwise.

src/backend/tcop/backend_startup.c (2)

774-774: Consistent compatibility mode constant update.

The change from DB_ORACLE to ORA_PARSER for compatibility check is part of a broader update to use more specific constants across the codebase for parser mode checking.


827-827: Consistent compatibility mode constant update.

The change from DB_ORACLE to ORA_PARSER maintains the same logical behavior while using the more specific identifier for Oracle parser compatibility mode.

src/backend/parser/parse_utilcmd.c (1)

306-306: Consistent compatibility mode constant update.

The change from DB_ORACLE to ORA_PARSER aligns with the symbolic constant standardization across the codebase. This maintains the same behavior for detecting "rowid" column name conflicts in Oracle compatibility mode.

src/pl/plisql/src/pl_exec.c (1)

7466-7473:

Details

❓ Verification inconclusive

Ensure correct Oracle compatibility check
The condition now uses the new ORA_PARSER macro instead of the old DB_ORACLE, aligning with the updated compatibility-mode identifiers. Please verify that:

  1. compatible_db is set to ORA_PARSER in all relevant contexts before this check.
  2. There are no remaining uses of DB_ORACLE in this file that could cause inconsistent behavior.

Run this script to confirm no DB_ORACLE references remain in this file:


🏁 Script executed:

#!/bin/bash
# Description: Search for obsolete compatibility macro in pl_exec.c
rg -n "DB_ORACLE" src/pl/plisql/src/pl_exec.c

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Verify ORA_PARSER usage and 'compatible_db' assignments in pl_exec.c

# Confirm no remaining DB_ORACLE references
rg -n "DB_ORACLE" src/pl/plisql/src/pl_exec.c

# List all uses of the new ORA_PARSER macro
rg -n "ORA_PARSER" src/pl/plisql/src/pl_exec.c

# Check where compatible_db is assigned or compared
rg -n "compatible_db" src/pl/plisql/src/pl_exec.c

Length of output: 302


🏁 Script executed:

#!/bin/bash
# Search for assignments of ORA_PARSER to compatible_db across the repository
rg -n "compatible_db\s*=\s*ORA_PARSER" .

Length of output: 42


Verify compatible_db initialization for ORA_PARSER usage
I checked src/pl/plisql/src/pl_exec.c and across the repo:

  • No remaining DB_ORACLE references in pl_exec.c.
  • Only one ORA_PARSER check at line 7446:
    if (compatible_db == ORA_PARSER && (rec->datatype->typoid == ROWIDOID || …
    
  • No direct assignment of compatible_db = ORA_PARSER found anywhere.

Please confirm that compatible_db is properly initialized or set to ORA_PARSER before this conditional, or add the necessary assignment to ensure this branch can ever be taken.

src/backend/commands/sequence.c (2)

2455-2457: Compatibility mode constant updated correctly.

The change from DB_ORACLE to ORA_PARSER is part of a broader refactor to use more precise parser-specific constants throughout the codebase. This helps clarify that the compatibility setting is specifically related to the parser behavior rather than general database compatibility.


2464-2472: Compatibility mode constant updated correctly.

The change from DB_PG to PG_PARSER maintains consistency with the updated naming convention for compatibility mode constants. This change aligns with the broader refactoring effort to make compatibility checks more specific to parser behavior.

src/backend/catalog/heap.c (1)

501-502: Compatibility mode constant updated appropriately.

The code correctly updates from DB_ORACLE to ORA_PARSER in the condition that checks whether to skip the system attribute name collision check for the "rowid" attribute name. This is part of a systematic update to use parser-specific constants throughout the codebase.

src/backend/utils/adt/varlena.c (2)

3922-3930: Use ORA_PARSER in GUC list splitting logic
Updated condition correctly gates case transformation under Oracle compatibility mode (ORA_PARSER) when both enable_case_switch and identifier_case_switch == INTERCHANGE are true. This mirrors the change in SplitIdentifierString.


3575-3583:

Details

✅ Verification successful

Use ORA_PARSER instead of DB_ORACLE to guard Oracle-compatibility behavior
The updated condition correctly checks compatible_db == ORA_PARSER (Oracle syntax compatibility mode) before applying case-switch logic on quoted identifiers. This aligns with the broader refactor replacing DB_ORACLE with ORA_PARSER for parser-mode semantics. Please ensure that ORA_PARSER is defined and documented in utils/ora_compatible.h and that elsewhere in this module no residual checks still use DB_ORACLE.

Run:

to confirm no lingering uses of DB_ORACLE.


🏁 Script executed:

rg -n "compatible_db == .*DB_ORACLE" src/backend/utils/adt/varlena.c

Length of output: 70


ORA_PARSER conditional validated
I ran rg -n "compatible_db == .*DB_ORACLE" src/backend/utils/adt/varlena.c and found no matches, confirming there are no leftover DB_ORACLE checks in that file. With ORA_PARSER defined and documented in utils/ora_compatible.h, the quoted‐identifier case‐switch logic is correctly guarded.

src/backend/parser/analyze.c (2)

2465-2465: Compatibility constant renamed correctly.

The compatibility check now uses the symbolic constant ORA_PARSER instead of the previous DB_ORACLE, which aligns with the new naming convention used throughout the codebase.


2603-2603: Compatibility constant renamed correctly.

The compatibility check now uses the symbolic constant PG_PARSER instead of the previous DB_PG, which is consistent with the renaming pattern throughout the codebase.

src/backend/commands/explain.c (3)

4349-4350: Correct replacement of DB_ORACLE with ORA_PARSER for merge skipped-path assertion.

The assertion guarding skipped_path >= 0 now correctly checks against ORA_PARSER instead of the old DB_ORACLE constant, matching the updated compatibility-mode enum. This ensures that Oracle-compat mode skips the assertion.


4366-4367: Skip printing "skipped" tuples in Oracle mode.

The new guard if (compatible_db != ORA_PARSER) wrapped around appendStringInfo aligns text-format output with PostgreSQL behavior only. In Oracle-compat mode the "skipped" field is intentionally hidden.


4376-4378: Omit JSON "Tuples Skipped" property for ORA_PARSER.

The JSON export now conditionally omits the "Tuples Skipped" property when compatible_db == ORA_PARSER. This matches the text output change and maintains consistent behavior across formats.

src/backend/executor/nodeModifyTable.c (1)

3590-3613: Replace DB_ORACLE with ORA_PARSER to drive MERGE trigger ordering

The updated branch condition now checks compatible_db == ORA_PARSER instead of the old DB_ORACLE. In the ORA_PARSER path, AFTER STATEMENT triggers for MERGE fire in Oracle’s expected order (UPDATE → DELETE → INSERT), while the else branch retains the original PostgreSQL default order (DELETE → UPDATE → INSERT). The utils/ora_compatible.h include ensures ORA_PARSER is defined.

This aligns with the wider refactor to use parser-mode constants. Everything looks correct.

src/backend/parser/parse_expr.c (1)

1110-1110: Appropriate constant name change for better semantics.

The change from DB_ORACLE to ORA_PARSER improves naming precision, using a parser-specific identifier rather than a more general database identifier. This is consistent with similar changes throughout the codebase to better represent Oracle parser compatibility mode.

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.

2 participants