Skip to content

fix: clean existing warnings for Clang -Werror - #1451

Merged
gaoxueyu merged 6 commits into
IvorySQL:masterfrom
messere1:codex/fix-clang-werror-warnings
Aug 24, 2026
Merged

gaoxueyu merged 6 commits into
IvorySQL:masterfrom
messere1:codex/fix-clang-werror-warnings

Conversation

@messere1

@messere1 messere1 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • always initialize timestamp parse state in the three-argument Oracle timestamp functions
  • make the package parser's intentional enum/pointer round-trip explicit through uintptr_t
  • make PostgreSQL/Oracle prompt enum conversions explicit in psql

Motivation

Related to #1221 and #1386.

Switching the Clang job to make COPT="-Werror" exposed existing Clang 18 diagnostics:

  • -Wsometimes-uninitialized
  • -Wvoid-pointer-to-enum-cast
  • -Wenum-conversion

The timestamp change fixes the actual uninitialized path instead of suppressing the warning. The remaining changes document existing representation conversions without changing their logic.

Validation

  • CC=clang-18 CXX=clang++-18 ./configure --enable-nls ...
  • make -j2 COPT="-Werror" - passed
  • GitHub Actions for d60a5eadf84144443fe6608f44071fc7ff04903f - all 7 checks passed:
    • build
    • meson_build
    • pg_regression
    • oracle_regression
    • oracle_pg_regression
    • contrib_regression
    • policy

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of Oracle-compatible timestamp parsing when an empty NLS parameter is supplied.
    • Ensured TO_TIMESTAMP and TO_TIMESTAMP_TZ return consistent results whether the optional NLS parameter is omitted or explicitly empty.
    • Improved reliability when processing Oracle interactive prompts and package function calls.
  • Tests

    • Added coverage for fractional-second and time-zone timestamp formats with empty NLS parameters.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 09c19c1a-49e8-41b3-a0e4-4598e1a4cba7

📥 Commits

Reviewing files that changed from the base of the PR and between 5946834 and ab761c1.

📒 Files selected for processing (5)
  • contrib/ivorysql_ora/expected/datatype_and_func_bugs.out
  • contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql
  • src/backend/parser/parse_package.c
  • src/bin/psql/mainloop.c
  • src/pl/plisql/src/pl_package.c
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/bin/psql/mainloop.c
  • src/pl/plisql/src/pl_package.c
  • contrib/ivorysql_ora/expected/datatype_and_func_bugs.out
  • contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql
  • src/backend/parser/parse_package.c

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


📝 Walkthrough

Walkthrough

The change adds explicit casts at Oracle package and prompt-status boundaries. It also adds regression assertions for timestamp parsing with an empty NLS parameter.

Changes

Oracle compatibility updates

Layer / File(s) Summary
Package resolution cast boundaries
src/backend/parser/parse_package.c, src/pl/plisql/src/pl_package.c
Package return values use uintptr_t before conversion to FuncDetailCode or void *.
Interactive prompt status casts
src/bin/psql/mainloop.c
Oracle prompt status assignments and prompt retrieval arguments use explicit enum casts.
Timestamp parsing assertions
contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql, contrib/ivorysql_ora/expected/datatype_and_func_bugs.out
Assertions compare timestamp parsing with an empty nlsparam against parsing without that argument.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ab761

This localized change fixes Clang warning paths and makes existing conversions explicit, with the reported build and regression checks passing; no actionable merge-blocking risk remains.

🚥 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 summarizes the main change: fixing existing Clang warnings exposed by -Werror.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@messere1
messere1 marked this pull request as ready for review July 20, 2026 10:19
Copilot AI review requested due to automatic review settings July 20, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hs-liuxh

Copy link
Copy Markdown
Collaborator

Thanks for your contribution! I will review it as soon as possible.

@hs-liuxh

Copy link
Copy Markdown
Collaborator

This PR is highly valuable. Not only does it eliminate Clang compilation warnings, but the modifications to datetime_datatype_functions.c also fix an actual bug. This bug occurs when an empty string is passed as the third argument to the sys.to_timestamp(text, text, text) and sys.to_timestamp_tz(text, text, text) functions.

Since the current test cases do not trigger the code path for this bug, could you please add the relevant test cases to contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql?

@messere1

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I added regression cases for both three-argument functions in datatype_and_func_bugs.sql. The tests use pg_catalog.repeat('x', 0) to construct a non-NULL zero-length text value, because an empty string literal is converted to NULL before reaching these STRICT functions in Oracle mode. All CI checks now pass, including oracle_regression.

messere1 added 4 commits July 29, 2026 15:22
The three-argument timestamp functions accept nlsparam for compatibility but do not interpret it. Parse the input unconditionally so the timestamp fields are always initialized before conversion.

Assisted-by: OpenAI:gpt-5
Route the package parser enum through uintptr_t and explicitly cast between the PostgreSQL and Oracle prompt enums. This documents the existing representation conversions and keeps Clang's -Wenum-conversion and -Wvoid-pointer-to-enum-cast clean.

Assisted-by: OpenAI:gpt-5
@messere1
messere1 force-pushed the codex/fix-clang-werror-warnings branch from 4d9e7d2 to d9e6119 Compare July 29, 2026 08:08

@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.

🧹 Nitpick comments (1)
contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql (1)

5-19: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the parsed values independently.

These checks only verify that the three-argument calls match the two-argument calls. Add an assertion against known expected timestamp values as well, so a shared regression in both paths cannot make the test pass.

As per path instructions, SQL tests should ensure comprehensive feature coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql` around lines 5 - 19,
Update the two timestamp regression checks around sys.to_timestamp and
sys.to_timestamp_tz to assert each parsed result independently against its known
expected timestamp value, in addition to comparing three-argument and
two-argument calls. Preserve coverage of the empty nlsparam behavior while
preventing identical regressions in both call paths from passing unnoticed.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql`:
- Around line 5-19: Update the two timestamp regression checks around
sys.to_timestamp and sys.to_timestamp_tz to assert each parsed result
independently against its known expected timestamp value, in addition to
comparing three-argument and two-argument calls. Preserve coverage of the empty
nlsparam behavior while preventing identical regressions in both call paths from
passing unnoticed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ada5a490-c865-432f-9c2a-0156eaf5b4c4

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9e7d2 and d9e6119.

📒 Files selected for processing (3)
  • contrib/ivorysql_ora/expected/datatype_and_func_bugs.out
  • contrib/ivorysql_ora/sql/datatype_and_func_bugs.sql
  • contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c
🚧 Files skipped from review as they are similar to previous changes (2)
  • contrib/ivorysql_ora/expected/datatype_and_func_bugs.out
  • contrib/ivorysql_ora/src/builtin_functions/datetime_datatype_functions.c

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@gaoxueyu
gaoxueyu merged commit cfe77c1 into IvorySQL:master Aug 24, 2026
7 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