Skip to content

Fix/remove v5 warnings#1190

Merged
gaoxueyu merged 6 commits into
IvorySQL:IVORY_REL_5_STABLEfrom
yasir-hussain-shah:fix/remove-v5-warnings
Feb 14, 2026
Merged

Fix/remove v5 warnings#1190
gaoxueyu merged 6 commits into
IvorySQL:IVORY_REL_5_STABLEfrom
yasir-hussain-shah:fix/remove-v5-warnings

Conversation

@yasir-hussain-shah
Copy link
Copy Markdown
Contributor

@yasir-hussain-shah yasir-hussain-shah commented Feb 10, 2026

This PR fixes all the warnings in IVORY_REL_5_STABLE branch.

Summary by CodeRabbit

  • Bug Fixes

    • Ensure timing baseline initializes correctly for accurate elapsed-time reporting.
    • Fix string copy to guarantee null-termination and avoid unterminated name handling.
  • Refactor

    • Streamlined function-removal and return-type validation logic for clarity.
    • Simplified control flow in variable initialization/assignment to make match/error paths clearer.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Initialize psql timing baseline and simplify PL/PLiSQL control flow: set timing baseline in ExecQueryUsingCursor; replace flag-based matches with early returns/assertions in PL/PLiSQL package and subprocedure helpers; ensure memcpy copy in varlena string handling includes explicit NUL terminator.

Changes

Cohort / File(s) Summary
psql timing
src/bin/psql/common.c
Added INSTR_TIME_SET_ZERO(before) in ExecQueryUsingCursor to initialize timing baseline so elapsed_msec starts from zero when timing is enabled.
PL/PLiSQL — package logic
src/pl/plisql/src/pl_package.c
In plisql_remove_function_references added an existence guard and early return/assertion before decrementing use_count; removed pre/post-length capture and related assertions. In plisql_subproc_should_change_return_type removed separate found flag and use result directly when detecting OUT/INOUT parameters.
PL/PLiSQL — subproc helpers
src/pl/plisql/src/pl_subproc_function.c
In plsql_init_glovalvar_from_stack and plsql_assign_out_glovalvar_from_stack removed local match flag; functions now return immediately on successful match and assert/error if no match found, preserving behavior with simpler control flow.
Varlena string handling
src/backend/utils/adt/varlena.c
Replaced strncpy-style in-place overwrite with memcpy and added explicit NUL terminator in SplitGUCList to guarantee null-termination when copy length equals source length.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jiaoshuntian
  • NotHimmel

Poem

🐇 I nibble bugs with whiskered care,

Timers reset, flags float in air.
Early returns, tidy and spry,
Strings end proper — no stray byte to cry.
A little hop, the tests comply.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/remove v5 warnings' accurately reflects the main objective of the pull request, which addresses and fixes warnings in the IVORY_REL_5_STABLE branch across multiple source files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into IVORY_REL_5_STABLE

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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
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: 1

🤖 Fix all issues with AI agents
In `@src/pl/plisql/src/pl_package.c`:
- Around line 2732-2737: The code currently assumes via Assert that func is in
psource->source.funclist before removing it and decrementing
psource->source.use_count; replace that ASSERT-only protection with a runtime
check: call list_member_ptr(psource->source.funclist, func) and only perform
list_delete_ptr(psource->source.funclist, (void *) func) and
psource->source.use_count-- when the check returns true, otherwise skip the
delete/decrement (and optionally log or elog a warning/error) to avoid underflow
and use-after-free; refer to PLiSQL_package, psource, funclist, use_count,
list_member_ptr, list_delete_ptr and func to locate the change.
🧹 Nitpick comments (1)
src/bin/psql/common.c (1)

2897-2899: Use INSTR_TIME_SET_ZERO() for consistency with the opaque instr_time API.

On Line 2898, before.ticks = 0 directly accesses struct fields. The instr_time type is documented as opaque and should only be manipulated via provided macros. Using INSTR_TIME_SET_ZERO(before) maintains API abstraction and is consistent with the same function's initialization pattern at lines 1456 and 1676.

🔧 Suggested fix
 *elapsed_msec = 0;
-before.ticks = 0;
+INSTR_TIME_SET_ZERO(before);

Comment thread src/pl/plisql/src/pl_package.c
@jiaoshuntian
Copy link
Copy Markdown
Collaborator

Thanks for cleaning up the code warnings.

@gaoxueyu gaoxueyu merged commit 30527cc into IvorySQL:IVORY_REL_5_STABLE Feb 14, 2026
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

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants