Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c98c9114
Commit
c98c9114
authored
Dec 02, 2008
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor code embellishments.
parent
a1feb90e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
50 deletions
+43
-50
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+43
-50
No files found.
src/backend/utils/misc/guc.c
View file @
c98c9114
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.48
1 2008/11/21 20:14:27 mha
Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.48
2 2008/12/02 02:00:32 alvherre
Exp $
*
*
*--------------------------------------------------------------------
*--------------------------------------------------------------------
*/
*/
...
@@ -4382,16 +4382,17 @@ parse_real(const char *value, double *result)
...
@@ -4382,16 +4382,17 @@ parse_real(const char *value, double *result)
const
char
*
const
char
*
config_enum_lookup_by_value
(
struct
config_enum
*
record
,
int
val
)
config_enum_lookup_by_value
(
struct
config_enum
*
record
,
int
val
)
{
{
const
struct
config_enum_entry
*
entry
=
record
->
options
;
const
struct
config_enum_entry
*
entry
;
while
(
entry
&&
entry
->
name
)
for
(
entry
=
record
->
options
;
entry
&&
entry
->
name
;
entry
++
)
{
{
if
(
entry
->
val
==
val
)
if
(
entry
->
val
==
val
)
return
entry
->
name
;
return
entry
->
name
;
entry
++
;
}
}
elog
(
ERROR
,
"could not find enum option %d for %s"
,
elog
(
ERROR
,
"could not find enum option %d for %s"
,
val
,
record
->
gen
.
name
);
val
,
record
->
gen
.
name
);
return
NULL
;
/* silence compiler */
return
NULL
;
/* silence compiler */
}
}
...
@@ -4400,32 +4401,30 @@ config_enum_lookup_by_value(struct config_enum *record, int val)
...
@@ -4400,32 +4401,30 @@ config_enum_lookup_by_value(struct config_enum *record, int val)
* (case-insensitive).
* (case-insensitive).
* If the enum option is found, sets the retval value and returns
* If the enum option is found, sets the retval value and returns
* true. If it's not found, return FALSE and retval is set to 0.
* true. If it's not found, return FALSE and retval is set to 0.
*
*/
*/
bool
bool
config_enum_lookup_by_name
(
struct
config_enum
*
record
,
const
char
*
value
,
int
*
retval
)
config_enum_lookup_by_name
(
struct
config_enum
*
record
,
const
char
*
value
,
int
*
retval
)
{
{
const
struct
config_enum_entry
*
entry
=
record
->
options
;
const
struct
config_enum_entry
*
entry
;
if
(
retval
)
for
(
entry
=
record
->
options
;
entry
&&
entry
->
name
;
entry
++
)
*
retval
=
0
;
/* suppress compiler warning */
while
(
entry
&&
entry
->
name
)
{
{
if
(
pg_strcasecmp
(
value
,
entry
->
name
)
==
0
)
if
(
pg_strcasecmp
(
value
,
entry
->
name
)
==
0
)
{
{
*
retval
=
entry
->
val
;
*
retval
=
entry
->
val
;
return
TRUE
;
return
TRUE
;
}
}
entry
++
;
}
}
*
retval
=
0
;
return
FALSE
;
return
FALSE
;
}
}
/*
/*
* Return a list of all available options for an enum, excluding
* Return a list of all available options for an enum, excluding
* hidden ones, separated by
", " (comma-space)
.
* hidden ones, separated by
the given separator
.
* If prefix is non-NULL, it is added before the first enum value.
* If prefix is non-NULL, it is added before the first enum value.
* If suffix is non-NULL, it is added to the end of the string.
* If suffix is non-NULL, it is added to the end of the string.
*/
*/
...
@@ -4433,39 +4432,23 @@ static char *
...
@@ -4433,39 +4432,23 @@ static char *
config_enum_get_options
(
struct
config_enum
*
record
,
const
char
*
prefix
,
config_enum_get_options
(
struct
config_enum
*
record
,
const
char
*
prefix
,
const
char
*
suffix
,
const
char
*
separator
)
const
char
*
suffix
,
const
char
*
separator
)
{
{
const
struct
config_enum_entry
*
entry
=
record
->
options
;
const
struct
config_enum_entry
*
entry
;
int
len
=
0
;
StringInfoData
retstr
;
char
*
hintmsg
;
int
seplen
;
if
(
!
entry
||
!
entry
->
name
)
return
NULL
;
/* Should not happen */
while
(
entry
&&
entry
->
name
)
initStringInfo
(
&
retstr
);
{
appendStringInfoString
(
&
retstr
,
prefix
);
if
(
!
entry
->
hidden
)
len
+=
strlen
(
entry
->
name
)
+
strlen
(
separator
);
entry
++
;
}
hintmsg
=
palloc
(
len
+
strlen
(
prefix
)
+
strlen
(
suffix
)
+
2
);
strcpy
(
hintmsg
,
prefix
);
entry
=
record
->
options
;
seplen
=
strlen
(
separator
)
;
while
(
entry
&&
entry
->
name
)
for
(
entry
=
record
->
options
;
entry
&&
entry
->
name
;
entry
++
)
{
{
if
(
!
entry
->
hidden
)
if
(
!
entry
->
hidden
)
{
{
strcat
(
hintmsg
,
entry
->
name
);
appendStringInfoString
(
&
retstr
,
entry
->
name
);
strcat
(
hintmsg
,
separator
);
appendBinaryStringInfo
(
&
retstr
,
separator
,
seplen
);
}
}
entry
++
;
}
}
len
=
strlen
(
hintmsg
);
/*
/*
* All the entries may have been hidden, leaving the string empty
* All the entries may have been hidden, leaving the string empty
* if no prefix was given. This indicates a broken GUC setup, since
* if no prefix was given. This indicates a broken GUC setup, since
...
@@ -4473,13 +4456,16 @@ config_enum_get_options(struct config_enum *record, const char *prefix,
...
@@ -4473,13 +4456,16 @@ config_enum_get_options(struct config_enum *record, const char *prefix,
* to make sure we don't write to invalid memory instead of actually
* to make sure we don't write to invalid memory instead of actually
* trying to do something smart with it.
* trying to do something smart with it.
*/
*/
if
(
len
>=
strlen
(
separator
))
if
(
retstr
.
len
>=
seplen
)
{
/* Replace final separator */
/* Replace final separator */
hintmsg
[
len
-
strlen
(
separator
)]
=
'\0'
;
retstr
.
data
[
retstr
.
len
-
seplen
]
=
'\0'
;
retstr
.
len
-=
seplen
;
}
strcat
(
hintmsg
,
suffix
);
appendStringInfoString
(
&
retstr
,
suffix
);
return
hintmsg
;
return
retstr
.
data
;
}
}
/*
/*
...
@@ -5047,7 +5033,11 @@ set_config_option(const char *name, const char *value,
...
@@ -5047,7 +5033,11 @@ set_config_option(const char *name, const char *value,
{
{
if
(
!
config_enum_lookup_by_name
(
conf
,
value
,
&
newval
))
if
(
!
config_enum_lookup_by_name
(
conf
,
value
,
&
newval
))
{
{
char
*
hintmsg
=
config_enum_get_options
(
conf
,
"Available values: "
,
"."
,
", "
);
char
*
hintmsg
;
hintmsg
=
config_enum_get_options
(
conf
,
"Available values: "
,
"."
,
", "
);
ereport
(
elevel
,
ereport
(
elevel
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
...
@@ -6253,13 +6243,16 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
...
@@ -6253,13 +6243,16 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
/* enumvals */
/* enumvals */
/* NOTE! enumvals with double quotes in them are not supported! */
/* NOTE! enumvals with double quotes in them are not supported! */
values
[
11
]
=
config_enum_get_options
((
struct
config_enum
*
)
conf
,
"{
\"
"
,
"
\"
}"
,
"
\"
,
\"
"
);
values
[
11
]
=
config_enum_get_options
((
struct
config_enum
*
)
conf
,
"{
\"
"
,
"
\"
}"
,
"
\"
,
\"
"
);
/* boot_val */
/* boot_val */
values
[
12
]
=
pstrdup
(
config_enum_lookup_by_value
(
lconf
,
lconf
->
boot_val
));
values
[
12
]
=
pstrdup
(
config_enum_lookup_by_value
(
lconf
,
lconf
->
boot_val
));
/* reset_val */
/* reset_val */
values
[
13
]
=
pstrdup
(
config_enum_lookup_by_value
(
lconf
,
lconf
->
reset_val
));
values
[
13
]
=
pstrdup
(
config_enum_lookup_by_value
(
lconf
,
lconf
->
reset_val
));
}
}
break
;
break
;
...
@@ -6672,8 +6665,8 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
...
@@ -6672,8 +6665,8 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
struct
config_enum
*
conf
=
(
struct
config_enum
*
)
record
;
struct
config_enum
*
conf
=
(
struct
config_enum
*
)
record
;
int
newval
;
int
newval
;
return
config_enum_lookup_by_name
(
conf
,
newvalue
,
&
newval
)
return
config_enum_lookup_by_name
(
conf
,
newvalue
,
&
newval
)
&&
&&
*
conf
->
variable
==
newval
;
*
conf
->
variable
==
newval
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment