mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Make boolean support more like that in postgresql.conf
This commit is contained in:
27
config.c
27
config.c
@@ -746,36 +746,45 @@ repmgr_atoi(const char *value, const char *config_item, ItemList *error_list, in
|
|||||||
* Interpret a parameter value as a boolean. Currently accepts:
|
* Interpret a parameter value as a boolean. Currently accepts:
|
||||||
*
|
*
|
||||||
* - true/false
|
* - true/false
|
||||||
* - 0/1
|
* - 1/0
|
||||||
* - on/off
|
* - on/off
|
||||||
*
|
* - yes/no
|
||||||
|
|
||||||
* Returns 'false' if unable to determine the booleanness of the value
|
* Returns 'false' if unable to determine the booleanness of the value
|
||||||
* and adds an entry to the error list, which will result in the program
|
* and adds an entry to the error list, which will result in the program
|
||||||
* erroring out before it proceeds to do anything.
|
* erroring out before it proceeds to do anything.
|
||||||
*
|
*
|
||||||
* TODO: make this work like in postgresql.conf
|
* TODO: accept "any unambiguous prefix of one of these" as per postgresql.conf:
|
||||||
|
*
|
||||||
|
* https://www.postgresql.org/docs/current/static/config-setting.html
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
parse_bool(const char *s, const char *config_item, ItemList *error_list)
|
parse_bool(const char *s, const char *config_item, ItemList *error_list)
|
||||||
{
|
{
|
||||||
PQExpBufferData errors;
|
PQExpBufferData errors;
|
||||||
|
|
||||||
if (strcmp(s, "0") == 0)
|
if (strcasecmp(s, "0") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(s, "1") == 0)
|
if (strcasecmp(s, "1") == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (strcmp(s, "false") == 0)
|
if (strcasecmp(s, "false") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(s, "true") == 0)
|
if (strcasecmp(s, "true") == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (strcmp(s, "off") == 0)
|
if (strcasecmp(s, "off") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(s, "on") == 0)
|
if (strcasecmp(s, "on") == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (strcasecmp(s, "no") == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (strcasecmp(s, "yes") == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
initPQExpBuffer(&errors);
|
initPQExpBuffer(&errors);
|
||||||
|
|||||||
Reference in New Issue
Block a user