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
0f5651a9
Commit
0f5651a9
authored
May 07, 2008
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have boolean pset values checked against typical boolean values, rather
than only 'off'.
parent
053948ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
src/bin/psql/variables.c
src/bin/psql/variables.c
+36
-9
No files found.
src/bin/psql/variables.c
View file @
0f5651a9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.2
8 2008/01/01 19:45:56
momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.2
9 2008/05/07 02:33:52
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "common.h"
#include "common.h"
...
@@ -48,21 +48,48 @@ GetVariable(VariableSpace space, const char *name)
...
@@ -48,21 +48,48 @@ GetVariable(VariableSpace space, const char *name)
return
NULL
;
return
NULL
;
}
}
/*
* Try to interpret value as boolean value. Valid values are: true,
* false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
*/
bool
bool
ParseVariableBool
(
const
char
*
val
)
ParseVariableBool
(
const
char
*
val
ue
)
{
{
if
(
val
==
NULL
)
size_t
len
;
if
(
value
==
NULL
)
return
false
;
/* not set -> assume "off" */
return
false
;
/* not set -> assume "off" */
if
(
pg_strcasecmp
(
val
,
"off"
)
==
0
)
return
false
;
/* accept "off" or "OFF" as true */
/*
len
=
strlen
(
value
);
* for backwards compatibility, anything except "off" or "OFF" is taken as
* "true"
if
(
pg_strncasecmp
(
value
,
"true"
,
len
)
==
0
)
*/
return
true
;
else
if
(
pg_strncasecmp
(
value
,
"false"
,
len
)
==
0
)
return
false
;
else
if
(
pg_strncasecmp
(
value
,
"yes"
,
len
)
==
0
)
return
true
;
else
if
(
pg_strncasecmp
(
value
,
"no"
,
len
)
==
0
)
return
false
;
/* 'o' is not unique enough */
else
if
(
pg_strncasecmp
(
value
,
"on"
,
(
len
>
2
?
len
:
2
))
==
0
)
return
true
;
else
if
(
pg_strncasecmp
(
value
,
"off"
,
(
len
>
2
?
len
:
2
))
==
0
)
return
false
;
else
if
(
pg_strcasecmp
(
value
,
"1"
)
==
0
)
return
true
;
else
if
(
pg_strcasecmp
(
value
,
"0"
)
==
0
)
return
false
;
else
{
/* NULL is treated as false, so a non-matching value is 'true' */
psql_error
(
"unrecognized boolean value; assuming
\"
on
\"
.
\n
"
);
return
true
;
}
/* suppress compiler warning */
return
true
;
return
true
;
}
}
/*
/*
* Read numeric variable, or defaultval if it is not set, or faultval if its
* Read numeric variable, or defaultval if it is not set, or faultval if its
* value is not a valid numeric string. If allowtrail is false, this will
* value is not a valid numeric string. If allowtrail is false, this will
...
...
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