Skip to content

refactor case conversion feature#932

Merged
gaoxueyu merged 3 commits intoIvorySQL:IVORY_REL_5_STABLEfrom
yuanyl630:IVORY_REL_5_STABLE
Oct 27, 2025
Merged

refactor case conversion feature#932
gaoxueyu merged 3 commits intoIvorySQL:IVORY_REL_5_STABLEfrom
yuanyl630:IVORY_REL_5_STABLE

Conversation

@yuanyl630
Copy link
Copy Markdown
Collaborator

@yuanyl630 yuanyl630 commented Oct 24, 2025

Summary by CodeRabbit

  • Documentation

    • Updated comments and messages across backend modules for clearer, consistent wording around case-sensitive identifier support and related descriptions.
    • Clarified parameter comment text (e.g., "lowcase" → "lowercase").
  • Chores

    • Fixed typos and spelling inconsistencies (e.g., "identifer" → "identifier", "transfor" → "transform").
    • Minor formatting and whitespace adjustments with no behavioral impact.
    • Improved input-safety when composing control-file paths.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

This PR makes editorial and safety improvements: comment and string corrections across multiple files related to IvorySQL identifier case handling, minor whitespace tidy-ups, and replaces sprintf with snprintf when building control-file paths in xlog.c to improve input safety. No behavioral changes to public APIs.

Changes

Cohort / File(s) Summary
Transam & control-file path safety
src/backend/access/transam/xlog.c
Updated comments/headers wording for IvorySQL case-sensitive identifier support; replaced sprintf with snprintf when composing control-file paths; minor whitespace edits.
Namespace & scanner / identifier transforms
src/backend/catalog/namespace.c, src/backend/parser/scansup.c, src/port/identifier_alpha_transfor.c
Clarified and corrected inline comments and docstrings (e.g., "case-sensitive identifier support", "transform"); reworded rationale for downcasing behavior; no logic changes.
Startup / initdb comments
src/backend/tcop/backend_startup.c, src/bin/initdb/initdb.c
Rewrote Oracle-compatibility comments for clarity; minor whitespace adjustments around initialization calls; no semantic changes.
GUC strings & test SQL
src/backend/utils/misc/ivy_guc.c, src/oracle_test/regress/sql/case_conversion.sql
Fixed typos in gettext string (identiferidentifier, quotequotes) and updated test comment wording from "lowcase" to "lowercase".

Sequence Diagram(s)

(omitted — changes are editorial and a safety switch from sprintf to snprintf; control flow is unchanged)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • gaoxueyu
  • NotHimmel

Poem

🐰
I nibbled commas, fixed a name,
Replaced a call that wasn't tame,
Cleaned the text and left code true,
Safe paths now built — a careful chew,
Tiny hops, a tidy frame. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The PR title "refactor case conversion feature" is generic and vague, failing to convey the actual nature of the changes. The pull request consists primarily of comment clarifications, typo fixes (e.g., "transfor" to "transform", "identifer" to "identifier"), documentation updates, formatting adjustments, and minor safety improvements like switching from sprintf to snprintf. While the title does refer to the case conversion feature that's being changed, it significantly overstates the scope by using the term "refactor," which typically implies substantial code restructuring rather than the predominantly cosmetic improvements and documentation fixes present in this changeset. A reader scanning the history would not understand from this title what was actually modified. Consider revising the title to more accurately reflect the actual changes, such as "Clean up case conversion comments, fix typos, and improve safety" or "Update identifier handling documentation and fix misspellings" to give reviewers and future maintainers a clearer picture of what this PR accomplishes without overstating the scope of changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddf201c and 15a4c9d.

📒 Files selected for processing (1)
  • src/backend/parser/scansup.c (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: oracle_pg_regression (ubuntu-latest)
  • GitHub Check: oracle_regression (ubuntu-latest)
  • GitHub Check: pg_regression (ubuntu-latest)
  • GitHub Check: meson_build (ubuntu-latest)
  • GitHub Check: contrib_regression
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (1)
src/backend/parser/scansup.c (1)

59-63: Comment now correctly describes the implementation.

The updated comment accurately reflects that the code uses tolower() for high-bit characters (line 71-72) and an ASCII-only approach for 7-bit characters (lines 69-70). This resolves the inconsistency flagged in the previous 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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/backend/access/transam/xlog.c (2)

5443-5444: Prevent buffer overflow when composing control path

pathname is a fixed 1 KB buffer, but make_absolute_path() can return arbitrarily long strings. sprintf() will happily overrun pathname, leading to memory corruption. Use a bounded call (snprintf), and validate the result before proceeding.

-	sprintf(pathname,"%s/%s",configdir,XLOG_CONTROL_FILE);
+	if (snprintf(pathname, sizeof(pathname), "%s/%s", configdir, XLOG_CONTROL_FILE) >= sizeof(pathname))
+	{
+		fprintf(stderr, _("control file path is too long\n"));
+		return -1;
+	}

5455-5505: Close the descriptor and validate the ControlFileData read

When read() fails or returns a short count, the current code returns -1 without closing fd, leaking the descriptor. It also accepts short reads as success, which will propagate garbage into confile. Always close the file on every exit path and require sizeof(ControlFileData) bytes before using the contents. Apply the same fixes in both helpers.

-	len = read(fd, &confile, sizeof(ControlFileData));
-	if (len < 0)
-	{
-		fprintf(stderr, _("could not read file \"%s\": %s\n"),
-			pathname, strerror(errno));
-
-		return -1;
-	}
-	close(fd);
+	len = read(fd, &confile, sizeof(ControlFileData));
+	if (len != sizeof(ControlFileData))
+	{
+		if (len < 0)
+			fprintf(stderr, _("could not read file \"%s\": %s\n"), pathname, strerror(errno));
+		else
+			fprintf(stderr, _("could not read file \"%s\": unexpected EOF\n"), pathname);
+		close(fd);
+		return -1;
+	}
+	close(fd);
src/bin/initdb/initdb.c (1)

3695-3703: Don't free the shared username buffer
username and effective_user are aliases whenever -U isn’t supplied, so freeing the original pointer leaves effective_user dangling. We still print effective_user later (for example, in the “owned by user …” notice), which turns into a use-after-free in that common flow. Please keep the original buffer alive when effective_user is sharing it, and only release it when username owns it exclusively.

-		char *lowerusername = username;
-		username = down_character(username, strlen(username));
-		free(lowerusername);
+		bool reuse_effective = (username == effective_user);
+		char *lowered = down_character(username, strlen(username));
+
+		if (!reuse_effective)
+			pg_free(username);
+
+		username = lowered;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c53c1c4 and 83050ec.

⛔ Files ignored due to path filters (3)
  • src/oracle_test/regress/expected/case_conversion.out is excluded by !**/*.out
  • src/oracle_test/regress/expected/case_conversion_1.out is excluded by !**/*.out
  • src/oracle_test/regress/expected/case_conversion_2.out is excluded by !**/*.out
📒 Files selected for processing (8)
  • src/backend/access/transam/xlog.c (3 hunks)
  • src/backend/catalog/namespace.c (1 hunks)
  • src/backend/parser/scansup.c (1 hunks)
  • src/backend/tcop/backend_startup.c (2 hunks)
  • src/backend/utils/misc/ivy_guc.c (1 hunks)
  • src/bin/initdb/initdb.c (2 hunks)
  • src/oracle_test/regress/sql/case_conversion.sql (1 hunks)
  • src/port/identifier_alpha_transfor.c (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: oracle_pg_regression (ubuntu-latest)
  • GitHub Check: oracle_regression (ubuntu-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: contrib_regression
  • GitHub Check: pg_regression (ubuntu-latest)
  • GitHub Check: meson_build (ubuntu-latest)
🔇 Additional comments (4)
src/oracle_test/regress/sql/case_conversion.sql (1)

6-6: Terminology consistency improvement.

The comment now uses the standard "lowercase" spelling, aligning with the actual GUC parameter value defined in src/backend/utils/misc/ivy_guc.c (line 82: {"lowercase", LOWERCASE, false}). This improves documentation clarity and consistency.

src/backend/utils/misc/ivy_guc.c (1)

118-122: Documentation polish: typo correction and grammar improvement.

The description string has been corrected for spelling and grammar. This improves the professional presentation of the GUC parameter documentation that users will encounter when querying configuration options.

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

800-800: Clearer comment for Oracle compatibility logic.

The comment now explicitly describes the purpose of the block: transforming identifiers for Oracle compatibility. This improves code readability for future maintainers.


853-853: Consistent comment for parallel user identifier transformation.

Mirrors the improvement at line 800, providing parallel clarity for user identifier case conversion within the Oracle compatibility context.

Comment thread src/backend/parser/scansup.c
@bigplaice
Copy link
Copy Markdown
Collaborator

no comments.

@gaoxueyu gaoxueyu merged commit 6c3f5fb into IvorySQL:IVORY_REL_5_STABLE Oct 27, 2025
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