mirror of
https://github.com/postgres/postgres.git
synced 2025-07-23 03:21:12 +03:00
Change the parser to convert SQL "position" and "substring" syntax to
position() and substring() functions, so that it works transparently for bit types as well. Alias the text functions appropriately. Add position() for bit types. Add new constant node T_BitString that represents literals of the form B'1001 and pass those to zpbit type.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.127 2000/10/26 21:35:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.128 2000/10/31 10:22:10 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2511,6 +2511,7 @@ _copyValue(Value *from)
|
||||
break;
|
||||
case T_Float:
|
||||
case T_String:
|
||||
case T_BitString:
|
||||
newnode->val.str = pstrdup(from->val.str);
|
||||
break;
|
||||
default:
|
||||
@ -2703,6 +2704,7 @@ copyObject(void *from)
|
||||
case T_Integer:
|
||||
case T_Float:
|
||||
case T_String:
|
||||
case T_BitString:
|
||||
retval = _copyValue(from);
|
||||
break;
|
||||
case T_List:
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.77 2000/10/18 16:16:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.78 2000/10/31 10:22:10 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1719,6 +1719,7 @@ _equalValue(Value *a, Value *b)
|
||||
return a->val.ival == b->val.ival;
|
||||
case T_Float:
|
||||
case T_String:
|
||||
case T_BitString:
|
||||
return strcmp(a->val.str, b->val.str) == 0;
|
||||
default:
|
||||
break;
|
||||
@ -1874,6 +1875,7 @@ equal(void *a, void *b)
|
||||
case T_Integer:
|
||||
case T_Float:
|
||||
case T_String:
|
||||
case T_BitString:
|
||||
retval = _equalValue(a, b);
|
||||
break;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.35 2000/10/05 19:11:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.36 2000/10/31 10:22:10 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* XXX a few of the following functions are duplicated to handle
|
||||
@ -70,6 +70,23 @@ makeString(char *str)
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* makeBitString
|
||||
*
|
||||
* Caller is responsible for passing a palloc'd string.
|
||||
*/
|
||||
Value *
|
||||
makeBitString(char *str)
|
||||
{
|
||||
Value *v = makeNode(Value);
|
||||
|
||||
v->type = T_BitString;
|
||||
v->val.str = str;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lcons
|
||||
*
|
||||
|
@ -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.129 2000/10/26 21:35:48 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.130 2000/10/31 10:22:10 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -20,10 +20,10 @@
|
||||
* representation plus some other information (string length, etc.)
|
||||
*
|
||||
*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "access/heapam.h"
|
||||
#include "access/htup.h"
|
||||
#include "catalog/pg_type.h"
|
||||
@ -1352,6 +1352,9 @@ _outValue(StringInfo str, Value *value)
|
||||
_outToken(str, value->val.str);
|
||||
appendStringInfo(str, "\" ");
|
||||
break;
|
||||
case T_BitString:
|
||||
appendStringInfo(str, " B%s ", value->val.str);
|
||||
break;
|
||||
default:
|
||||
elog(NOTICE, "_outValue: don't know how to print type %d ",
|
||||
value->type);
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.23 2000/06/14 18:17:32 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.24 2000/10/31 10:22:10 petere Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -17,11 +17,11 @@
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/readfuncs.h"
|
||||
|
||||
@ -184,7 +184,7 @@ debackslash(char *token, int length)
|
||||
* nodeTokenType -
|
||||
* returns the type of the node token contained in token.
|
||||
* It returns one of the following valid NodeTags:
|
||||
* T_Integer, T_Float, T_String
|
||||
* T_Integer, T_Float, T_String, T_BitString
|
||||
* and some of its own:
|
||||
* RIGHT_PAREN, LEFT_PAREN, PLAN_SYM, AT_SYMBOL, ATOM_TOKEN
|
||||
*
|
||||
@ -236,6 +236,8 @@ nodeTokenType(char *token, int length)
|
||||
retval = AT_SYMBOL;
|
||||
else if (*token == '\"' && length > 1 && token[length - 1] == '\"')
|
||||
retval = T_String;
|
||||
else if (*token == 'B')
|
||||
retval = T_BitString;
|
||||
else
|
||||
retval = ATOM_TOKEN;
|
||||
return retval;
|
||||
@ -346,6 +348,15 @@ nodeRead(bool read_car_only)
|
||||
this_value = (Node *) makeString(debackslash(token + 1, tok_len - 2));
|
||||
make_dotted_pair_cell = true;
|
||||
break;
|
||||
case T_BitString:
|
||||
{
|
||||
char * val = palloc(tok_len);
|
||||
/* skip leading 'B'*/
|
||||
strncpy(val, token + 1, tok_len - 1);
|
||||
val[tok_len - 1] = '\0';
|
||||
this_value = (Node *) makeBitString(val);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "nodeRead: Bad type %d", type);
|
||||
this_value = NULL; /* keep compiler happy */
|
||||
|
Reference in New Issue
Block a user