34 #ifdef WRITE_READ_PARSE_PLAN_TREES
35 bool restore_location_fields =
false;
51 const char *save_strtok;
52 #ifdef WRITE_READ_PARSE_PLAN_TREES
53 bool save_restore_location_fields;
69 #ifdef WRITE_READ_PARSE_PLAN_TREES
70 save_restore_location_fields = restore_location_fields;
71 restore_location_fields = restore_loc_fields;
78 #ifdef WRITE_READ_PARSE_PLAN_TREES
79 restore_location_fields = save_restore_location_fields;
94 #ifdef WRITE_READ_PARSE_PLAN_TREES
97 stringToNodeWithLocations(
const char *
str)
154 const char *local_str;
159 while (*local_str ==
' ' || *local_str ==
'\n' || *local_str ==
'\t')
162 if (*local_str ==
'\0')
174 if (*local_str ==
'(' || *local_str ==
')' ||
175 *local_str ==
'{' || *local_str ==
'}')
183 while (*local_str !=
'\0' &&
184 *local_str !=
' ' && *local_str !=
'\n' &&
185 *local_str !=
'\t' &&
186 *local_str !=
'(' && *local_str !=
')' &&
187 *local_str !=
'{' && *local_str !=
'}')
189 if (*local_str ==
'\\' && local_str[1] !=
'\0')
196 *length = local_str - ret_str;
199 if (*length == 2 && ret_str[0] ==
'<' && ret_str[1] ==
'>')
215 char *result =
palloc(length + 1);
220 if (*token ==
'\\' && length > 1)
229 #define RIGHT_PAREN (1000000 + 1)
230 #define LEFT_PAREN (1000000 + 2)
231 #define LEFT_BRACE (1000000 + 3)
232 #define OTHER_TOKEN (1000000 + 4)
256 if (*numptr ==
'+' || *numptr ==
'-')
258 if ((numlen > 0 && isdigit((
unsigned char) *numptr)) ||
259 (numlen > 1 && *numptr ==
'.' && isdigit((
unsigned char) numptr[1])))
270 (void)
strtoint(token, &endptr, 10);
271 if (endptr != token + length || errno == ERANGE)
280 else if (*token ==
'(')
282 else if (*token ==
')')
284 else if (*token ==
'{')
286 else if ((length == 4 && strncmp(token,
"true", 4) == 0) ||
287 (length == 5 && strncmp(token,
"false", 5) == 0))
289 else if (*token ==
'"' && length > 1 && token[length - 1] ==
'"')
291 else if (*token ==
'b')
339 if (token == NULL || token[0] !=
'}')
340 elog(
ERROR,
"did not find '}' at end of input node");
354 elog(
ERROR,
"unterminated List structure");
355 if (tok_len == 1 && token[0] ==
'i')
365 elog(
ERROR,
"unterminated List structure");
368 val = (int) strtol(token, &endptr, 10);
369 if (endptr != token + tok_len)
370 elog(
ERROR,
"unrecognized integer: \"%.*s\"",
375 else if (tok_len == 1 && token[0] ==
'o')
385 elog(
ERROR,
"unterminated List structure");
388 val = (
Oid) strtoul(token, &endptr, 10);
389 if (endptr != token + tok_len)
390 elog(
ERROR,
"unrecognized OID: \"%.*s\"",
406 elog(
ERROR,
"unterminated List structure");
413 elog(
ERROR,
"unexpected right parenthesis");
424 elog(
ERROR,
"unrecognized token: \"%.*s\"", tok_len, token);
437 char *fval = (
char *)
palloc(tok_len + 1);
439 memcpy(fval, token, tok_len);
440 fval[tok_len] =
'\0';
456 memcpy(
val, token + 1, tok_len - 1);
457 val[tok_len - 1] =
'\0';
467 return (
void *) result;
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)