Skip to content

fix: ALTER ... SET ... TO DEFAULT 可绕过新限制 - #1372

Merged
gaoxueyu merged 3 commits into
IvorySQL:masterfrom
enkilee:fix-pgdbrolesetting
Jun 30, 2026
Merged

gaoxueyu merged 3 commits into
IvorySQL:masterfrom
enkilee:fix-pgdbrolesetting

Conversation

@enkilee

@enkilee enkilee commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

fix issue #1374

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for role- and database-level setting changes so unsupported options can’t be saved with ALTER ... SET or RESET.
    • Updated error messaging to clearly reference both SET and RESET.
  • Tests
    • Added regression coverage ensuring ivorysql.compatible_mode cannot be persisted or reset via role-level ALTER ... SET/RESET.

src/backend/catalog/pg_db_role_setting.c 仅在 valuestr != NULL 时检查
GUC_DISALLOW_IN_DB_ROLE_SETTING, 修复并添加测试
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f9c7fd6f-92ff-4be4-beee-09c5ddddc1ea

📥 Commits

Reviewing files that changed from the base of the PR and between facfa2a and 2d48992.

📒 Files selected for processing (1)
  • src/oracle_test/regress/expected/psql.out
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/oracle_test/regress/expected/psql.out

📝 Walkthrough

Walkthrough

AlterSetting now blocks GUC_DISALLOW_IN_DB_ROLE_SETTING options for RESET as well as SET, and the regression suite adds ALTER ROLE cases for ivorysql.compatible_mode covering SET, SET TO default, and RESET.

Changes

GUC_DISALLOW_IN_DB_ROLE_SETTING Guard Fix

Layer / File(s) Summary
AlterSetting guard condition
src/backend/catalog/pg_db_role_setting.c
Replaces the old valuestr != NULL gate with a check for non-VAR_RESET_ALL statements and a non-NULL name, and updates the error text to reference SET/RESET.
Regression tests for compatible_mode persistence
src/oracle_test/regress/sql/psql.sql, src/oracle_test/regress/expected/psql.out
Adds role-level SET, SET TO default, and RESET coverage for ivorysql.compatible_mode, asserting the expected FEATURE_NOT_SUPPORTED errors and hint text.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • IvorySQL/IvorySQL#1363: Directly modifies the same AlterSetting function in pg_db_role_setting.c to enforce GUC_DISALLOW_IN_DB_ROLE_SETTING for ivorysql.compatible_mode.

Suggested reviewers

  • jiaoshuntian

🐇 A reset tried to sneak on by,
but SET and RESET got a stern reply.
The role stood still, the hint rang clear,
“Not here, not now” was all it’d hear.
Hop, hop — the guard now knows the way!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly matches the fix for ALTER ... SET ... TO DEFAULT bypassing the new restriction.
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.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/oracle_test/regress/sql/psql.sql (1)

1364-1368: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a positive RESET ALL regression for the new exemption.

This block locks in the three rejected forms, but the C change also makes VAR_RESET_ALL the one allowed branch. A small ALTER ROLE ... RESET ALL case would keep that exception covered too. As per path instructions, "Test SQL files. Ensure comprehensive coverage of features."

🤖 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 `@src/oracle_test/regress/sql/psql.sql` around lines 1364 - 1368, Add a
positive regression case for the new ALTER ROLE RESET ALL exemption in psql.sql,
since the current block only covers the rejected compatible_mode variants.
Update the surrounding regress_psql_cm_role sequence to include a successful
ALTER ROLE ... RESET ALL check so the VAR_RESET_ALL branch in the compatibility
handling is exercised alongside the existing rejected forms. Keep the test close
to the current regress_psql_cm_role statements so the coverage stays easy to
find and maintain.

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.

Inline comments:
In `@src/backend/catalog/pg_db_role_setting.c`:
- Around line 41-45: The error message in pg_db_role_setting’s handling of the
role/database setting statement is too specific to SET, but this path now also
covers RESET. Update the ereport in the pg_db_role_setting logic (using
setstmt->kind if needed) so the errmsg is command-agnostic and applies to both
ALTER USER/ROLE/DATABASE SET and RESET, while keeping the existing hint behavior
consistent.

---

Nitpick comments:
In `@src/oracle_test/regress/sql/psql.sql`:
- Around line 1364-1368: Add a positive regression case for the new ALTER ROLE
RESET ALL exemption in psql.sql, since the current block only covers the
rejected compatible_mode variants. Update the surrounding regress_psql_cm_role
sequence to include a successful ALTER ROLE ... RESET ALL check so the
VAR_RESET_ALL branch in the compatibility handling is exercised alongside the
existing rejected forms. Keep the test close to the current regress_psql_cm_role
statements so the coverage stays easy to find and maintain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3120ad7c-9ac7-4e9b-bdcd-f32fe1357a5f

📥 Commits

Reviewing files that changed from the base of the PR and between 173039a and b7479cf.

📒 Files selected for processing (3)
  • src/backend/catalog/pg_db_role_setting.c
  • src/oracle_test/regress/expected/psql.out
  • src/oracle_test/regress/sql/psql.sql

@jiaoshuntian

jiaoshuntian commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

@bigplaice will follow up.

@bigplaice

Copy link
Copy Markdown
Collaborator

Thanks for the patch! Basically looks good to me.
Please solve the regression test failure. @enkilee

@enkilee

enkilee commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the patch! Basically looks good to me. Please solve the regression test failure. @enkilee

@bigplaice already done.

@bigplaice bigplaice left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no more comments.

@gaoxueyu
gaoxueyu merged commit 6467152 into IvorySQL:master Jun 30, 2026
8 checks passed
hs-liuxh pushed a commit to hs-liuxh/IvorySQL that referenced this pull request Sep 2, 2026
fix: ALTER ... SET ... TO DEFAULT 可绕过新限制
(cherry picked from commit 6467152)
hs-liuxh pushed a commit to hs-liuxh/IvorySQL that referenced this pull request Sep 2, 2026
fix: ALTER ... SET ... TO DEFAULT 可绕过新限制
(cherry picked from commit 6467152)
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