Change internal string representation of BitString node to include a

leading 'b', as it appears to be more convenient this way for the input
and node functions.
This commit is contained in:
Peter Eisentraut 2000-10-31 13:59:53 +00:00
parent 0c0dde6176
commit 0babf31640
3 changed files with 9 additions and 7 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.130 2000/10/31 10:22:10 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.131 2000/10/31 13:59:52 petere Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@ -1353,7 +1353,8 @@ _outValue(StringInfo str, Value *value)
appendStringInfo(str, "\" ");
break;
case T_BitString:
appendStringInfo(str, " B%s ", value->val.str);
/* internal representation already has leading 'b' */
appendStringInfo(str, " %s ", value->val.str);
break;
default:
elog(NOTICE, "_outValue: don't know how to print type %d ",

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.24 2000/10/31 10:22:10 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.25 2000/10/31 13:59:52 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -236,7 +236,7 @@ nodeTokenType(char *token, int length)
retval = AT_SYMBOL;
else if (*token == '\"' && length > 1 && token[length - 1] == '\"')
retval = T_String;
else if (*token == 'B')
else if (*token == 'b')
retval = T_BitString;
else
retval = ATOM_TOKEN;
@ -351,7 +351,7 @@ nodeRead(bool read_car_only)
case T_BitString:
{
char * val = palloc(tok_len);
/* skip leading 'B'*/
/* skip leading 'b'*/
strncpy(val, token + 1, tok_len - 1);
val[tok_len - 1] = '\0';
this_value = (Node *) makeBitString(val);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.80 2000/10/31 10:22:11 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.81 2000/10/31 13:59:53 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -282,10 +282,11 @@ other .
{xbitstart} {
BEGIN(xbit);
startlit();
addlit("b", 1);
}
<xbit>{xbitstop} {
BEGIN(INITIAL);
if (literalbuf[strspn(literalbuf, "01")] != '\0')
if (literalbuf[strspn(literalbuf + 1, "01") + 1] != '\0')
elog(ERROR, "invalid bit string input: '%s'",
literalbuf);
yylval.str = literalbuf;