35 #ifdef DEBUG_NODE_TESTS_ENABLED
36 bool restore_location_fields =
false;
52 const char *save_strtok;
53 #ifdef DEBUG_NODE_TESTS_ENABLED
54 bool save_restore_location_fields;
70 #ifdef DEBUG_NODE_TESTS_ENABLED
71 save_restore_location_fields = restore_location_fields;
72 restore_location_fields = restore_loc_fields;
79 #ifdef DEBUG_NODE_TESTS_ENABLED
80 restore_location_fields = save_restore_location_fields;
95 #ifdef DEBUG_NODE_TESTS_ENABLED
98 stringToNodeWithLocations(
const char *
str)
155 const char *local_str;
160 while (*local_str ==
' ' || *local_str ==
'\n' || *local_str ==
'\t')
163 if (*local_str ==
'\0')
175 if (*local_str ==
'(' || *local_str ==
')' ||
176 *local_str ==
'{' || *local_str ==
'}')
184 while (*local_str !=
'\0' &&
185 *local_str !=
' ' && *local_str !=
'\n' &&
186 *local_str !=
'\t' &&
187 *local_str !=
'(' && *local_str !=
')' &&
188 *local_str !=
'{' && *local_str !=
'}')
190 if (*local_str ==
'\\' && local_str[1] !=
'\0')
197 *length = local_str - ret_str;
200 if (*length == 2 && ret_str[0] ==
'<' && ret_str[1] ==
'>')
216 char *result =
palloc(length + 1);
221 if (*
token ==
'\\' && length > 1)
230 #define RIGHT_PAREN (1000000 + 1)
231 #define LEFT_PAREN (1000000 + 2)
232 #define LEFT_BRACE (1000000 + 3)
233 #define OTHER_TOKEN (1000000 + 4)
257 if (*numptr ==
'+' || *numptr ==
'-')
259 if ((numlen > 0 && isdigit((
unsigned char) *numptr)) ||
260 (numlen > 1 && *numptr ==
'.' && isdigit((
unsigned char) numptr[1])))
271 (void)
strtoint(numptr, &endptr, 10);
272 if (endptr !=
token + length || errno == ERANGE)
281 else if (*
token ==
'(')
283 else if (*
token ==
')')
285 else if (*
token ==
'{')
287 else if ((length == 4 && strncmp(
token,
"true", 4) == 0) ||
288 (length == 5 && strncmp(
token,
"false", 5) == 0))
290 else if (*
token ==
'"' && length > 1 &&
token[length - 1] ==
'"')
293 retval = T_BitString;
341 elog(
ERROR,
"did not find '}' at end of input node");
357 elog(
ERROR,
"unterminated List structure");
358 if (tok_len == 1 &&
token[0] ==
'i')
368 elog(
ERROR,
"unterminated List structure");
371 val = (int) strtol(
token, &endptr, 10);
372 if (endptr !=
token + tok_len)
373 elog(
ERROR,
"unrecognized integer: \"%.*s\"",
379 else if (tok_len == 1 &&
token[0] ==
'o')
389 elog(
ERROR,
"unterminated List structure");
393 if (endptr !=
token + tok_len)
394 elog(
ERROR,
"unrecognized OID: \"%.*s\"",
400 else if (tok_len == 1 &&
token[0] ==
'x')
410 elog(
ERROR,
"unterminated List structure");
414 if (endptr !=
token + tok_len)
415 elog(
ERROR,
"unrecognized Xid: \"%.*s\"",
421 else if (tok_len == 1 &&
token[0] ==
'b')
433 elog(
ERROR,
"unterminated Bitmapset structure");
434 if (tok_len == 1 &&
token[0] ==
')')
436 val = (int) strtol(
token, &endptr, 10);
437 if (endptr !=
token + tok_len)
438 elog(
ERROR,
"unrecognized integer: \"%.*s\"",
442 result = (
Node *) bms;
455 elog(
ERROR,
"unterminated List structure");
462 elog(
ERROR,
"unexpected right parenthesis");
486 char *fval = (
char *)
palloc(tok_len + 1);
488 memcpy(fval,
token, tok_len);
489 fval[tok_len] =
'\0';
510 return (
void *) result;
Bitmapset * bms_add_member(Bitmapset *a, int x)
List * lappend_xid(List *list, TransactionId datum)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
static NodeTag nodeTokenType(const char *token, int length)
const char * pg_strtok(int *length)
static void * stringToNodeInternal(const char *str, bool restore_loc_fields)
char * debackslash(const char *token, int length)
void * stringToNode(const char *str)
void * nodeRead(const char *token, int tok_len)
static const char * pg_strtok_ptr
Node * parseNodeString(void)
int strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
Boolean * makeBoolean(bool val)
Float * makeFloat(char *numericStr)
String * makeString(char *str)
BitString * makeBitString(char *str)
Integer * makeInteger(int i)