PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
readfuncs.h File Reference
#include "nodes/nodes.h"
Include dependency graph for readfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * pg_strtok (int *length)
 
char * debackslash (char *token, int length)
 
void * nodeRead (char *token, int tok_len)
 
NodeparseNodeString (void)
 

Function Documentation

char* debackslash ( char *  token,
int  length 
)

Definition at line 168 of file read.c.

References palloc(), and result.

Referenced by nodeRead().

169 {
170  char *result = palloc(length + 1);
171  char *ptr = result;
172 
173  while (length > 0)
174  {
175  if (*token == '\\' && length > 1)
176  token++, length--;
177  *ptr++ = *token++;
178  length--;
179  }
180  *ptr = '\0';
181  return result;
182 }
int length(const List *list)
Definition: list.c:1271
return result
Definition: formatting.c:1618
void * palloc(Size size)
Definition: mcxt.c:849
void* nodeRead ( char *  token,
int  tok_len 
)

Definition at line 278 of file read.c.

References debackslash(), elog, ERROR, lappend(), lappend_int(), lappend_oid(), LEFT_BRACE, LEFT_PAREN, makeBitString(), makeFloat(), makeInteger(), makeString(), NIL, nodeRead(), nodeTokenType(), NULL, OTHER_TOKEN, palloc(), parseNodeString(), pg_strtok(), result, RIGHT_PAREN, T_BitString, T_Float, T_Integer, T_String, and val.

Referenced by nodeRead(), and stringToNode().

279 {
280  Node *result;
281  NodeTag type;
282 
283  if (token == NULL) /* need to read a token? */
284  {
285  token = pg_strtok(&tok_len);
286 
287  if (token == NULL) /* end of input */
288  return NULL;
289  }
290 
291  type = nodeTokenType(token, tok_len);
292 
293  switch ((int) type)
294  {
295  case LEFT_BRACE:
296  result = parseNodeString();
297  token = pg_strtok(&tok_len);
298  if (token == NULL || token[0] != '}')
299  elog(ERROR, "did not find '}' at end of input node");
300  break;
301  case LEFT_PAREN:
302  {
303  List *l = NIL;
304 
305  /*----------
306  * Could be an integer list: (i int int ...)
307  * or an OID list: (o int int ...)
308  * or a list of nodes/values: (node node ...)
309  *----------
310  */
311  token = pg_strtok(&tok_len);
312  if (token == NULL)
313  elog(ERROR, "unterminated List structure");
314  if (tok_len == 1 && token[0] == 'i')
315  {
316  /* List of integers */
317  for (;;)
318  {
319  int val;
320  char *endptr;
321 
322  token = pg_strtok(&tok_len);
323  if (token == NULL)
324  elog(ERROR, "unterminated List structure");
325  if (token[0] == ')')
326  break;
327  val = (int) strtol(token, &endptr, 10);
328  if (endptr != token + tok_len)
329  elog(ERROR, "unrecognized integer: \"%.*s\"",
330  tok_len, token);
331  l = lappend_int(l, val);
332  }
333  }
334  else if (tok_len == 1 && token[0] == 'o')
335  {
336  /* List of OIDs */
337  for (;;)
338  {
339  Oid val;
340  char *endptr;
341 
342  token = pg_strtok(&tok_len);
343  if (token == NULL)
344  elog(ERROR, "unterminated List structure");
345  if (token[0] == ')')
346  break;
347  val = (Oid) strtoul(token, &endptr, 10);
348  if (endptr != token + tok_len)
349  elog(ERROR, "unrecognized OID: \"%.*s\"",
350  tok_len, token);
351  l = lappend_oid(l, val);
352  }
353  }
354  else
355  {
356  /* List of other node types */
357  for (;;)
358  {
359  /* We have already scanned next token... */
360  if (token[0] == ')')
361  break;
362  l = lappend(l, nodeRead(token, tok_len));
363  token = pg_strtok(&tok_len);
364  if (token == NULL)
365  elog(ERROR, "unterminated List structure");
366  }
367  }
368  result = (Node *) l;
369  break;
370  }
371  case RIGHT_PAREN:
372  elog(ERROR, "unexpected right parenthesis");
373  result = NULL; /* keep compiler happy */
374  break;
375  case OTHER_TOKEN:
376  if (tok_len == 0)
377  {
378  /* must be "<>" --- represents a null pointer */
379  result = NULL;
380  }
381  else
382  {
383  elog(ERROR, "unrecognized token: \"%.*s\"", tok_len, token);
384  result = NULL; /* keep compiler happy */
385  }
386  break;
387  case T_Integer:
388 
389  /*
390  * we know that the token terminates on a char atol will stop at
391  */
392  result = (Node *) makeInteger(atol(token));
393  break;
394  case T_Float:
395  {
396  char *fval = (char *) palloc(tok_len + 1);
397 
398  memcpy(fval, token, tok_len);
399  fval[tok_len] = '\0';
400  result = (Node *) makeFloat(fval);
401  }
402  break;
403  case T_String:
404  /* need to remove leading and trailing quotes, and backslashes */
405  result = (Node *) makeString(debackslash(token + 1, tok_len - 2));
406  break;
407  case T_BitString:
408  {
409  char *val = palloc(tok_len);
410 
411  /* skip leading 'b' */
412  memcpy(val, token + 1, tok_len - 1);
413  val[tok_len - 1] = '\0';
414  result = (Node *) makeBitString(val);
415  break;
416  }
417  default:
418  elog(ERROR, "unrecognized node type: %d", (int) type);
419  result = NULL; /* keep compiler happy */
420  break;
421  }
422 
423  return (void *) result;
424 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:69
char * pg_strtok(int *length)
Definition: read.c:107
Definition: nodes.h:509
return result
Definition: formatting.c:1618
void * nodeRead(char *token, int tok_len)
Definition: read.c:278
unsigned int Oid
Definition: postgres_ext.h:31
NodeTag
Definition: nodes.h:26
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
static NodeTag nodeTokenType(char *token, int length)
Definition: read.c:200
Value * makeInteger(long i)
Definition: value.c:23
#define ERROR
Definition: elog.h:43
#define RIGHT_PAREN
Definition: read.c:184
Value * makeBitString(char *str)
Definition: value.c:68
char * debackslash(char *token, int length)
Definition: read.c:168
List * lappend_int(List *list, int datum)
Definition: list.c:146
List * lappend(List *list, void *datum)
Definition: list.c:128
Value * makeFloat(char *numericStr)
Definition: value.c:38
#define LEFT_BRACE
Definition: read.c:186
#define NULL
Definition: c.h:229
Node * parseNodeString(void)
Definition: readfuncs.c:2406
Definition: nodes.h:283
void * palloc(Size size)
Definition: mcxt.c:849
#define elog
Definition: elog.h:219
#define OTHER_TOKEN
Definition: read.c:187
Definition: pg_list.h:45
long val
Definition: informix.c:689
#define LEFT_PAREN
Definition: read.c:185
Node* parseNodeString ( void  )

Definition at line 2406 of file readfuncs.c.

References _readAgg(), _readAggref(), _readAlias(), _readAlternativeSubPlan(), _readAppend(), _readArrayCoerceExpr(), _readArrayExpr(), _readArrayRef(), _readBitmapAnd(), _readBitmapHeapScan(), _readBitmapIndexScan(), _readBitmapOr(), _readBooleanTest(), _readBoolExpr(), _readCaseExpr(), _readCaseTestExpr(), _readCaseWhen(), _readCoalesceExpr(), _readCoerceToDomain(), _readCoerceToDomainValue(), _readCoerceViaIO(), _readCollateExpr(), _readCommonTableExpr(), _readConst(), _readConvertRowtypeExpr(), _readCteScan(), _readCurrentOfExpr(), _readCustomScan(), _readDeclareCursorStmt(), _readDefElem(), _readDistinctExpr(), _readExtensibleNode(), _readFieldSelect(), _readFieldStore(), _readForeignScan(), _readFromExpr(), _readFuncExpr(), _readFunctionScan(), _readGather(), _readGatherMerge(), _readGroup(), _readGroupingFunc(), _readGroupingSet(), _readHash(), _readHashJoin(), _readIndexOnlyScan(), _readIndexScan(), _readInferenceElem(), _readIntoClause(), _readJoin(), _readJoinExpr(), _readLimit(), _readLockRows(), _readMaterial(), _readMergeAppend(), _readMergeJoin(), _readMinMaxExpr(), _readModifyTable(), _readNamedArgExpr(), _readNestLoop(), _readNestLoopParam(), _readNotifyStmt(), _readNullIfExpr(), _readNullTest(), _readOnConflictExpr(), _readOpExpr(), _readParam(), _readPartitionBoundSpec(), _readPartitionRangeDatum(), _readPlan(), _readPlanInvalItem(), _readPlannedStmt(), _readPlanRowMark(), _readProjectSet(), _readQuery(), _readRangeTblEntry(), _readRangeTblFunction(), _readRangeTblRef(), _readRangeVar(), _readRecursiveUnion(), _readRelabelType(), _readResult(), _readRowCompareExpr(), _readRowExpr(), _readRowMarkClause(), _readSampleScan(), _readScalarArrayOpExpr(), _readScan(), _readSeqScan(), _readSetOp(), _readSetOperationStmt(), _readSetToDefault(), _readSort(), _readSortGroupClause(), _readSQLValueFunction(), _readSubLink(), _readSubPlan(), _readSubqueryScan(), _readTableFunc(), _readTableFuncScan(), _readTableSampleClause(), _readTargetEntry(), _readTidScan(), _readUnique(), _readValuesScan(), _readVar(), _readWindowAgg(), _readWindowClause(), _readWindowFunc(), _readWithCheckOption(), _readWorkTableScan(), _readXmlExpr(), elog, ERROR, length(), MATCH, NULL, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

2407 {
2408  void *return_value;
2409 
2410  READ_TEMP_LOCALS();
2411 
2412  token = pg_strtok(&length);
2413 
2414 #define MATCH(tokname, namelen) \
2415  (length == namelen && memcmp(token, tokname, namelen) == 0)
2416 
2417  if (MATCH("QUERY", 5))
2418  return_value = _readQuery();
2419  else if (MATCH("WITHCHECKOPTION", 15))
2420  return_value = _readWithCheckOption();
2421  else if (MATCH("SORTGROUPCLAUSE", 15))
2422  return_value = _readSortGroupClause();
2423  else if (MATCH("GROUPINGSET", 11))
2424  return_value = _readGroupingSet();
2425  else if (MATCH("WINDOWCLAUSE", 12))
2426  return_value = _readWindowClause();
2427  else if (MATCH("ROWMARKCLAUSE", 13))
2428  return_value = _readRowMarkClause();
2429  else if (MATCH("COMMONTABLEEXPR", 15))
2430  return_value = _readCommonTableExpr();
2431  else if (MATCH("SETOPERATIONSTMT", 16))
2432  return_value = _readSetOperationStmt();
2433  else if (MATCH("ALIAS", 5))
2434  return_value = _readAlias();
2435  else if (MATCH("RANGEVAR", 8))
2436  return_value = _readRangeVar();
2437  else if (MATCH("INTOCLAUSE", 10))
2438  return_value = _readIntoClause();
2439  else if (MATCH("TABLEFUNC", 9))
2440  return_value = _readTableFunc();
2441  else if (MATCH("VAR", 3))
2442  return_value = _readVar();
2443  else if (MATCH("CONST", 5))
2444  return_value = _readConst();
2445  else if (MATCH("PARAM", 5))
2446  return_value = _readParam();
2447  else if (MATCH("AGGREF", 6))
2448  return_value = _readAggref();
2449  else if (MATCH("GROUPINGFUNC", 12))
2450  return_value = _readGroupingFunc();
2451  else if (MATCH("WINDOWFUNC", 10))
2452  return_value = _readWindowFunc();
2453  else if (MATCH("ARRAYREF", 8))
2454  return_value = _readArrayRef();
2455  else if (MATCH("FUNCEXPR", 8))
2456  return_value = _readFuncExpr();
2457  else if (MATCH("NAMEDARGEXPR", 12))
2458  return_value = _readNamedArgExpr();
2459  else if (MATCH("OPEXPR", 6))
2460  return_value = _readOpExpr();
2461  else if (MATCH("DISTINCTEXPR", 12))
2462  return_value = _readDistinctExpr();
2463  else if (MATCH("NULLIFEXPR", 10))
2464  return_value = _readNullIfExpr();
2465  else if (MATCH("SCALARARRAYOPEXPR", 17))
2466  return_value = _readScalarArrayOpExpr();
2467  else if (MATCH("BOOLEXPR", 8))
2468  return_value = _readBoolExpr();
2469  else if (MATCH("SUBLINK", 7))
2470  return_value = _readSubLink();
2471  else if (MATCH("FIELDSELECT", 11))
2472  return_value = _readFieldSelect();
2473  else if (MATCH("FIELDSTORE", 10))
2474  return_value = _readFieldStore();
2475  else if (MATCH("RELABELTYPE", 11))
2476  return_value = _readRelabelType();
2477  else if (MATCH("COERCEVIAIO", 11))
2478  return_value = _readCoerceViaIO();
2479  else if (MATCH("ARRAYCOERCEEXPR", 15))
2480  return_value = _readArrayCoerceExpr();
2481  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2482  return_value = _readConvertRowtypeExpr();
2483  else if (MATCH("COLLATE", 7))
2484  return_value = _readCollateExpr();
2485  else if (MATCH("CASE", 4))
2486  return_value = _readCaseExpr();
2487  else if (MATCH("WHEN", 4))
2488  return_value = _readCaseWhen();
2489  else if (MATCH("CASETESTEXPR", 12))
2490  return_value = _readCaseTestExpr();
2491  else if (MATCH("ARRAY", 5))
2492  return_value = _readArrayExpr();
2493  else if (MATCH("ROW", 3))
2494  return_value = _readRowExpr();
2495  else if (MATCH("ROWCOMPARE", 10))
2496  return_value = _readRowCompareExpr();
2497  else if (MATCH("COALESCE", 8))
2498  return_value = _readCoalesceExpr();
2499  else if (MATCH("MINMAX", 6))
2500  return_value = _readMinMaxExpr();
2501  else if (MATCH("SQLVALUEFUNCTION", 16))
2502  return_value = _readSQLValueFunction();
2503  else if (MATCH("XMLEXPR", 7))
2504  return_value = _readXmlExpr();
2505  else if (MATCH("NULLTEST", 8))
2506  return_value = _readNullTest();
2507  else if (MATCH("BOOLEANTEST", 11))
2508  return_value = _readBooleanTest();
2509  else if (MATCH("COERCETODOMAIN", 14))
2510  return_value = _readCoerceToDomain();
2511  else if (MATCH("COERCETODOMAINVALUE", 19))
2512  return_value = _readCoerceToDomainValue();
2513  else if (MATCH("SETTODEFAULT", 12))
2514  return_value = _readSetToDefault();
2515  else if (MATCH("CURRENTOFEXPR", 13))
2516  return_value = _readCurrentOfExpr();
2517  else if (MATCH("INFERENCEELEM", 13))
2518  return_value = _readInferenceElem();
2519  else if (MATCH("TARGETENTRY", 11))
2520  return_value = _readTargetEntry();
2521  else if (MATCH("RANGETBLREF", 11))
2522  return_value = _readRangeTblRef();
2523  else if (MATCH("JOINEXPR", 8))
2524  return_value = _readJoinExpr();
2525  else if (MATCH("FROMEXPR", 8))
2526  return_value = _readFromExpr();
2527  else if (MATCH("ONCONFLICTEXPR", 14))
2528  return_value = _readOnConflictExpr();
2529  else if (MATCH("RTE", 3))
2530  return_value = _readRangeTblEntry();
2531  else if (MATCH("RANGETBLFUNCTION", 16))
2532  return_value = _readRangeTblFunction();
2533  else if (MATCH("TABLESAMPLECLAUSE", 17))
2534  return_value = _readTableSampleClause();
2535  else if (MATCH("NOTIFY", 6))
2536  return_value = _readNotifyStmt();
2537  else if (MATCH("DEFELEM", 7))
2538  return_value = _readDefElem();
2539  else if (MATCH("DECLARECURSOR", 13))
2540  return_value = _readDeclareCursorStmt();
2541  else if (MATCH("PLANNEDSTMT", 11))
2542  return_value = _readPlannedStmt();
2543  else if (MATCH("PLAN", 4))
2544  return_value = _readPlan();
2545  else if (MATCH("RESULT", 6))
2546  return_value = _readResult();
2547  else if (MATCH("PROJECTSET", 10))
2548  return_value = _readProjectSet();
2549  else if (MATCH("MODIFYTABLE", 11))
2550  return_value = _readModifyTable();
2551  else if (MATCH("APPEND", 6))
2552  return_value = _readAppend();
2553  else if (MATCH("MERGEAPPEND", 11))
2554  return_value = _readMergeAppend();
2555  else if (MATCH("RECURSIVEUNION", 14))
2556  return_value = _readRecursiveUnion();
2557  else if (MATCH("BITMAPAND", 9))
2558  return_value = _readBitmapAnd();
2559  else if (MATCH("BITMAPOR", 8))
2560  return_value = _readBitmapOr();
2561  else if (MATCH("SCAN", 4))
2562  return_value = _readScan();
2563  else if (MATCH("SEQSCAN", 7))
2564  return_value = _readSeqScan();
2565  else if (MATCH("SAMPLESCAN", 10))
2566  return_value = _readSampleScan();
2567  else if (MATCH("INDEXSCAN", 9))
2568  return_value = _readIndexScan();
2569  else if (MATCH("INDEXONLYSCAN", 13))
2570  return_value = _readIndexOnlyScan();
2571  else if (MATCH("BITMAPINDEXSCAN", 15))
2572  return_value = _readBitmapIndexScan();
2573  else if (MATCH("BITMAPHEAPSCAN", 14))
2574  return_value = _readBitmapHeapScan();
2575  else if (MATCH("TIDSCAN", 7))
2576  return_value = _readTidScan();
2577  else if (MATCH("SUBQUERYSCAN", 12))
2578  return_value = _readSubqueryScan();
2579  else if (MATCH("FUNCTIONSCAN", 12))
2580  return_value = _readFunctionScan();
2581  else if (MATCH("VALUESSCAN", 10))
2582  return_value = _readValuesScan();
2583  else if (MATCH("TABLEFUNCSCAN", 13))
2584  return_value = _readTableFuncScan();
2585  else if (MATCH("CTESCAN", 7))
2586  return_value = _readCteScan();
2587  else if (MATCH("WORKTABLESCAN", 13))
2588  return_value = _readWorkTableScan();
2589  else if (MATCH("FOREIGNSCAN", 11))
2590  return_value = _readForeignScan();
2591  else if (MATCH("CUSTOMSCAN", 10))
2592  return_value = _readCustomScan();
2593  else if (MATCH("JOIN", 4))
2594  return_value = _readJoin();
2595  else if (MATCH("NESTLOOP", 8))
2596  return_value = _readNestLoop();
2597  else if (MATCH("MERGEJOIN", 9))
2598  return_value = _readMergeJoin();
2599  else if (MATCH("HASHJOIN", 8))
2600  return_value = _readHashJoin();
2601  else if (MATCH("MATERIAL", 8))
2602  return_value = _readMaterial();
2603  else if (MATCH("SORT", 4))
2604  return_value = _readSort();
2605  else if (MATCH("GROUP", 5))
2606  return_value = _readGroup();
2607  else if (MATCH("AGG", 3))
2608  return_value = _readAgg();
2609  else if (MATCH("WINDOWAGG", 9))
2610  return_value = _readWindowAgg();
2611  else if (MATCH("UNIQUE", 6))
2612  return_value = _readUnique();
2613  else if (MATCH("GATHER", 6))
2614  return_value = _readGather();
2615  else if (MATCH("GATHERMERGE", 11))
2616  return_value = _readGatherMerge();
2617  else if (MATCH("HASH", 4))
2618  return_value = _readHash();
2619  else if (MATCH("SETOP", 5))
2620  return_value = _readSetOp();
2621  else if (MATCH("LOCKROWS", 8))
2622  return_value = _readLockRows();
2623  else if (MATCH("LIMIT", 5))
2624  return_value = _readLimit();
2625  else if (MATCH("NESTLOOPPARAM", 13))
2626  return_value = _readNestLoopParam();
2627  else if (MATCH("PLANROWMARK", 11))
2628  return_value = _readPlanRowMark();
2629  else if (MATCH("PLANINVALITEM", 13))
2630  return_value = _readPlanInvalItem();
2631  else if (MATCH("SUBPLAN", 7))
2632  return_value = _readSubPlan();
2633  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2634  return_value = _readAlternativeSubPlan();
2635  else if (MATCH("EXTENSIBLENODE", 14))
2636  return_value = _readExtensibleNode();
2637  else if (MATCH("PARTITIONBOUND", 14))
2638  return_value = _readPartitionBoundSpec();
2639  else if (MATCH("PARTRANGEDATUM", 14))
2640  return_value = _readPartitionRangeDatum();
2641  else
2642  {
2643  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2644  return_value = NULL; /* keep compiler quiet */
2645  }
2646 
2647  return (Node *) return_value;
2648 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1113
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1256
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:445
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1314
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1423
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1007
int length(const List *list)
Definition: list.c:1271
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:1989
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1058
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:374
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:659
static Hash * _readHash(void)
Definition: readfuncs.c:2179
char * pg_strtok(int *length)
Definition: read.c:107
static Result * _readResult(void)
Definition: readfuncs.c:1511
static Query * _readQuery(void)
Definition: readfuncs.c:227
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1024
static Param * _readParam(void)
Definition: readfuncs.c:553
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2286
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2101
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1714
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:275
static Scan * _readScan(void)
Definition: readfuncs.c:1673
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:680
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2220
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1194
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:926
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1802
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1754
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:941
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1817
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2371
static Unique * _readUnique(void)
Definition: readfuncs.c:2125
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1588
Definition: nodes.h:509
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:617
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:353
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:696
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1735
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1628
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1276
static Aggref * _readAggref(void)
Definition: readfuncs.c:571
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:1974
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1539
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:716
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:890
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1224
static Agg * _readAgg(void)
Definition: readfuncs.c:2078
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1686
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2328
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1863
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:600
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1144
static SubLink * _readSubLink(void)
Definition: readfuncs.c:800
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2014
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1833
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:910
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1290
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:736
static Append * _readAppend(void)
Definition: readfuncs.c:1572
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2341
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2266
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:822
static ArrayRef * _readArrayRef(void)
Definition: readfuncs.c:639
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:959
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1076
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1894
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:855
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2198
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:321
static Limit * _readLimit(void)
Definition: readfuncs.c:2236
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2387
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2159
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:289
static Gather * _readGather(void)
Definition: readfuncs.c:2142
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:52
static Var * _readVar(void)
Definition: readfuncs.c:507
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1699
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2300
#define NULL
Definition: c.h:229
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1787
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1162
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1848
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:488
static Const * _readConst(void)
Definition: readfuncs.c:528
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:412
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1440
static Material * _readMaterial(void)
Definition: readfuncs.c:2029
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:974
static Alias * _readAlias(void)
Definition: readfuncs.c:434
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1643
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1243
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1609
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:839
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1042
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1178
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:304
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1209
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:756
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:774
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1916
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:390
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:989
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1389
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1129
static Plan * _readPlan(void)
Definition: readfuncs.c:1498
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1092
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:466
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1408
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2252
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1526
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1772
static Join * _readJoin(void)
Definition: readfuncs.c:1961
static Sort * _readSort(void)
Definition: readfuncs.c:2042
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:873
static Group * _readGroup(void)
Definition: readfuncs.c:2061
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:338
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1879
char* pg_strtok ( int *  length)

Definition at line 107 of file read.c.

References NULL, and pg_strtok_ptr.

Referenced by _readBitmapset(), _readBoolExpr(), _readConst(), _readCustomScan(), _readExtensibleNode(), nodeRead(), parseNodeString(), readAttrNumberCols(), readBoolCols(), readDatum(), readIntCols(), and readOidCols().

108 {
109  char *local_str; /* working pointer to string */
110  char *ret_str; /* start of token to return */
111 
112  local_str = pg_strtok_ptr;
113 
114  while (*local_str == ' ' || *local_str == '\n' || *local_str == '\t')
115  local_str++;
116 
117  if (*local_str == '\0')
118  {
119  *length = 0;
120  pg_strtok_ptr = local_str;
121  return NULL; /* no more tokens */
122  }
123 
124  /*
125  * Now pointing at start of next token.
126  */
127  ret_str = local_str;
128 
129  if (*local_str == '(' || *local_str == ')' ||
130  *local_str == '{' || *local_str == '}')
131  {
132  /* special 1-character token */
133  local_str++;
134  }
135  else
136  {
137  /* Normal token, possibly containing backslashes */
138  while (*local_str != '\0' &&
139  *local_str != ' ' && *local_str != '\n' &&
140  *local_str != '\t' &&
141  *local_str != '(' && *local_str != ')' &&
142  *local_str != '{' && *local_str != '}')
143  {
144  if (*local_str == '\\' && local_str[1] != '\0')
145  local_str += 2;
146  else
147  local_str++;
148  }
149  }
150 
151  *length = local_str - ret_str;
152 
153  /* Recognize special case for "empty" token */
154  if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>')
155  *length = 0;
156 
157  pg_strtok_ptr = local_str;
158 
159  return ret_str;
160 }
int length(const List *list)
Definition: list.c:1271
static char * pg_strtok_ptr
Definition: read.c:30
#define NULL
Definition: c.h:229