Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Patches > Re: [HACKERS] [...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3692 of 3917
Post > Topic >>

Re: [HACKERS] [GENERAL] psql \pset pager

by bruce@[EMAIL PROTECTED] (Bruce Momjian) May 6, 2008 at 10:34 PM

--ELM1210127657-27620-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="US-ASCII"

Tom Lane wrote:
> Bruce Momjian <bruce@[EMAIL PROTECTED]
> writes:
> > Tom Lane wrote:
> >> If we're going to change it, we should make it match GUC's
parse_bool,
> >> which has had some actual thought put into it.
> 
> > Good idea.  Do I copy the C code into /psql or somehow share the
> > function?
> 
> Just copy it --- it's not large enough to be worth doing something like
> inventing a /****t module for, and besides it's not clear that you want
> exactly the same API.

Patch attached and applied.

-- 
  Bruce Momjian  <bruce@[EMAIL PROTECTED]
>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

--ELM1210127657-27620-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/x-diff
Content-Disposition: inline; filename="/rtmp/diff"

Index: src/bin/psql/variables.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/variables.c,v
retrieving revision 1.28
diff -c -c -r1.28 variables.c
*** src/bin/psql/variables.c	1 Jan 2008 19:45:56 -0000	1.28
--- src/bin/psql/variables.c	7 May 2008 02:10:55 -0000
***************
*** 48,68 ****
  	return NULL;
  }
  
  bool
! ParseVariableBool(const char *val)
  {
! 	if (val == NULL)
  		return false;			/* not set -> assume "off" */
- 	if (pg_strcasecmp(val, "off") == 0)
- 		return false;			/* accept "off" or "OFF" as true */
  
! 	/*
! 	 * for backwards compatibility, anything except "off" or "OFF" is taken
as
! 	 * "true"
! 	 */
  	return true;
  }
  
  /*
   * 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
--- 48,95 ----
  	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
! ParseVariableBool(const char *value)
  {
! 	size_t		len;
! 
! 	if (value == NULL)
  		return false;			/* not set -> assume "off" */
  
! 	len = strlen(value);
! 
! 	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;
  }
  
+ 
  /*
   * 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

--ELM1210127657-27620-0_
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-patches mailing list (pgsql-patches@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

--ELM1210127657-27620-0_--
 




 1 Posts in Topic:
Re: [HACKERS] [GENERAL] psql \pset pager
bruce@[EMAIL PROTECTED]   2008-05-06 22:34:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 12:27:29 CDT 2008.