refactor case conversion feature#932
Conversation
WalkthroughThis 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 Changes
Sequence Diagram(s)(omitted — changes are editorial and a safety switch from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (1)
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. Comment |
There was a problem hiding this comment.
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
pathnameis a fixed 1 KB buffer, butmake_absolute_path()can return arbitrarily long strings.sprintf()will happily overrunpathname, 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 readWhen
read()fails or returns a short count, the current code returns-1without closingfd, leaking the descriptor. It also accepts short reads as success, which will propagate garbage intoconfile. Always close the file on every exit path and requiresizeof(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
usernameandeffective_userare aliases whenever-Uisn’t supplied, so freeing the original pointer leaveseffective_userdangling. We still printeffective_userlater (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 wheneffective_useris sharing it, and only release it whenusernameowns 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
⛔ Files ignored due to path filters (3)
src/oracle_test/regress/expected/case_conversion.outis excluded by!**/*.outsrc/oracle_test/regress/expected/case_conversion_1.outis excluded by!**/*.outsrc/oracle_test/regress/expected/case_conversion_2.outis 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.
|
no comments. |
Summary by CodeRabbit
Documentation
Chores