Skip to content

Fix compiler warnings in timing and function removal code#1191

Merged
gaoxueyu merged 9 commits intoIvorySQL:masterfrom
yasir-hussain-shah:fix/fix-master-warnings
Feb 14, 2026
Merged

Fix compiler warnings in timing and function removal code#1191
gaoxueyu merged 9 commits intoIvorySQL:masterfrom
yasir-hussain-shah:fix/fix-master-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 master branch introduced in recent months.

Summary by CodeRabbit

  • Refactor
    • Internal cleanup and reorganization of local declarations and loop/control flow to improve clarity and maintainability.
  • Bug Fix
    • Ensure timing accumulator is reliably initialized to avoid stale timing state.
    • Improve string handling to guarantee proper termination of transformed identifiers, avoiding potential truncation or corruption.

No changes to public interfaces or user-facing behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Consolidated local declarations and adjusted control flow/assertions in several PL/PLiSQL functions; initialized a timing accumulator base in psql; switched a string copy to memcpy with explicit null termination. No exported/public API signatures changed. (≈40 words)

Changes

Cohort / File(s) Summary
DBMS utility dlsym lookups
contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
Consolidated multiple successive dlsym pointer declarations into a single scoped void *fn reused for lookups; retained existing error checks and lookup sequence.
Executor result slot
src/backend/executor/nodeResult.c
Separated declaration and assignment for TupleTableSlot *result (moved declaration earlier, assignment retained in non-done path).
psql timing init
src/bin/psql/common.c
Initialized timing accumulator base with INSTR_TIME_SET_ZERO(before) immediately after resetting elapsed_msec.
PL/PLiSQL package handling
src/pl/plisql/src/pl_package.c
Removed pre-length capture and removal-length assertion in plisql_remove_function_references; changed assertion in plisql_subproc_should_change_return_type from tracking var to Assert(result).
PL/PLiSQL subproc stack & globals
src/pl/plisql/src/pl_subproc_function.c
Reworked parent-match loop to return immediately on successful match (removed per-iteration match tracking and break); changed final assertions to fail when no match found.
Identifier downcasing copy
src/backend/utils/adt/varlena.c
Replaced strncpy with memcpy for downcased identifier copy and explicitly appended a null terminator to ensure proper C-string termination.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jiaoshuntian
  • OreoYang

Poem

🐇 I hopped through lines both short and long,

Scoped a pointer, set a timer strong,
I nulled the tail where strings might roam,
Loops now exit straight for home,
A tidy nibble, then I’m gone.

🚥 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 accurately reflects the primary focus of the changes: fixing compiler warnings related to timing initialization and function removal assertions across multiple 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 master

✏️ 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. 🎉


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

🤖 Fix all issues with AI agents
In `@contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c`:
- Line 69: The variable `fn` is declared outside the WIN32 guard and will be
unused on Windows; move the declaration of `fn` back inside the `#ifndef WIN32`
block (or, alternatively, add a suppression like `(void) fn;` under `#ifdef
WIN32` or use a compiler unused attribute) so Windows builds do not get an
unused-variable warning—update the declaration near where `fn` is first used in
the guarded code (referencing the `fn` identifier in this file).

In `@src/bin/psql/common.c`:
- Line 2863: The code sets the instr_time variable `before` by directly
assigning `before.ticks = 0;`, which couples to the internal representation;
replace that direct member access with the provided macro call
`INSTR_TIME_SET_ZERO(before)` to match other uses (e.g., DescribeQuery and
ExecQueryAndProcessResults) and avoid fragile direct `.ticks` manipulation.
🧹 Nitpick comments (1)
src/pl/plisql/src/pl_subproc_function.c (1)

3045-3050: Assert(false) is a no-op in production builds — consider elog(ERROR, …) for defense-in-depth.

If the loop in plsql_init_glovalvar_from_stack (and the identical pattern in plsql_assign_out_glovalvar_from_stack at line 3079) ever fails to find a matching parent frame in a non-assert build, execution silently falls through and the global variable is left uninitialized. An explicit elog(ERROR, "could not find parent frame for datum %d", dno) would surface the problem instead of hiding it.

Suggested change
-	Assert(false);
-	return;
+	elog(ERROR, "could not find parent frame for datum %d", dno);

Apply the same pattern at line 3079.

Comment thread contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c Outdated
Comment thread src/bin/psql/common.c Outdated
@yasir-hussain-shah yasir-hussain-shah changed the title Fix/fix master warnings Fix compiler warnings in timing and function removal code Feb 10, 2026
@jiaoshuntian
Copy link
Copy Markdown
Collaborator

Great quality improvement!

@gaoxueyu gaoxueyu merged commit 97f1790 into IvorySQL:master 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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants