Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0bc726d

Browse files
committed
Make GetConfigOption/GetConfigOptionResetString return "" for NULL.
As per the preceding commit, GUC APIs generally expose NULL-valuedstring variables as empty strings. Extend that policy toGetConfigOption() and GetConfigOptionResetString(), eliminatinga crash hazard for unwary callers, as well as a fundamentalambiguity in GetConfigOption()'s API.No back-patch, since this is an API change and conceivably somebodysomewhere is depending on this corner case.Xing Guo, Aleksander Alekseev, Tom LaneDiscussion:https://postgr.es/m/CACpMh+AyDx5YUpPaAgzVwC1d8zfOL4JoD-uyFDnNSa1z0EsDQQ@mail.gmail.com
1 parent7704a1a commit0bc726d

File tree

1 file changed

+5
-4
lines changed
  • src/backend/utils/misc

1 file changed

+5
-4
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,8 +4215,7 @@ SetConfigOption(const char *name, const char *value,
42154215
/*
42164216
* Fetch the current value of the option `name', as a string.
42174217
*
4218-
* If the option doesn't exist, return NULL if missing_ok is true (NOTE that
4219-
* this cannot be distinguished from a string variable with a NULL value!),
4218+
* If the option doesn't exist, return NULL if missing_ok is true,
42204219
* otherwise throw an ereport and don't return.
42214220
*
42224221
* If restrict_privileged is true, we also enforce that only superusers and
@@ -4259,7 +4258,8 @@ GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
42594258
returnbuffer;
42604259

42614260
casePGC_STRING:
4262-
return*((structconfig_string*)record)->variable;
4261+
return*((structconfig_string*)record)->variable ?
4262+
*((structconfig_string*)record)->variable :"";
42634263

42644264
casePGC_ENUM:
42654265
returnconfig_enum_lookup_by_value((structconfig_enum*)record,
@@ -4306,7 +4306,8 @@ GetConfigOptionResetString(const char *name)
43064306
returnbuffer;
43074307

43084308
casePGC_STRING:
4309-
return ((structconfig_string*)record)->reset_val;
4309+
return ((structconfig_string*)record)->reset_val ?
4310+
((structconfig_string*)record)->reset_val :"";
43104311

43114312
casePGC_ENUM:
43124313
returnconfig_enum_lookup_by_value((structconfig_enum*)record,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp