Skip to content

fix: use transaction start timestamp for sys.current_date() - #1994

Open
89799969 wants to merge 1 commit into
IvorySQL:masterfrom
89799969:fix/current-date-transaction-timestamp
Open

fix: use transaction start timestamp for sys.current_date()#1994
89799969 wants to merge 1 commit into
IvorySQL:masterfrom
89799969:fix/current-date-transaction-timestamp

Conversation

@89799969

@89799969 89799969 commented Sep 11, 2026

Copy link
Copy Markdown

Summary

Fixes #1697

sys.current_date() is declared STABLE, but ora_current_date() evaluated GetCurrentTimestamp() (wall clock). Two calls in one statement can therefore disagree after pg_sleep, which diverges from Oracle and PostgreSQL CURRENT_DATE.

ora_current_timestamp / ora_local_timestamp in the same file already use GetCurrentTransactionStartTimestamp(). This aligns ora_current_date with them.

Change

`c
// contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c

  • TimestampTz timestamp = GetCurrentTimestamp();
  • TimestampTz timestamp = GetCurrentTransactionStartTimestamp();
    `

sysdate() intentionally keeps wall-clock behavior (Oracle SYSDATE is volatile) and is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Updated CURRENT_DATE behavior to consistently reflect the transaction start time rather than the current wall-clock time.

sys.current_date() is marked STABLE but evaluated GetCurrentTimestamp()
(wall clock), so two calls in one statement can differ after pg_sleep.
ora_current_timestamp and ora_local_timestamp already use
GetCurrentTransactionStartTimestamp(); align current_date with them
and with PostgreSQL/Oracle STABLE CURRENT_DATE semantics.

Fixes IvorySQL#1697
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d50492ed-b66e-4f1d-9abb-ba87e6128a95

📥 Commits

Reviewing files that changed from the base of the PR and between 03b24b1 and 527516f.

📒 Files selected for processing (1)
  • contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

ora_current_date now uses the transaction start timestamp. Repeated calls within one transaction return a stable date instead of reading the wall-clock timestamp for each call.

Changes

Current date stability

Layer / File(s) Summary
Use transaction start timestamp
contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c
ora_current_date now uses GetCurrentTransactionStartTimestamp() instead of GetCurrentTimestamp().

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: bigplaice

Merge Risk: ⚪ Minimal · up to 52751

The update makes current-date results stable within a transaction as intended and is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating sys.current_date() to use the transaction start timestamp.
Linked Issues check ✅ Passed The PR addresses #1697. It changes ora_current_date to use GetCurrentTransactionStartTimestamp(). Repeated calls therefore use the transaction start timestamp instead of the wall-clock timestamp, …
Out of Scope Changes check ✅ Passed The reviewed change contains one source-line update in contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c. The update changes only the timestamp source for ora_current_date, …
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@hanjianqiao

Copy link
Copy Markdown
Collaborator

Thanks for your PR!

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.

sys.current_date() is not STABLE

2 participants