PostgreSQL Source Code  git master
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

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

Function Documentation

◆ debackslash()

char* debackslash ( const char *  token,
int  length 
)

Definition at line 213 of file read.c.

References palloc().

Referenced by nodeRead().

214 {
215  char *result = palloc(length + 1);
216  char *ptr = result;
217 
218  while (length > 0)
219  {
220  if (*token == '\\' && length > 1)
221  token++, length--;
222  *ptr++ = *token++;
223  length--;
224  }
225  *ptr = '\0';
226  return result;
227 }
void * palloc(Size size)
Definition: mcxt.c:949

◆ nodeRead()

void* nodeRead ( const char *  token,
int  tok_len 
)

Definition at line 316 of file read.c.

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

Referenced by nodeRead(), and stringToNodeInternal().

317 {
318  Node *result;
319  NodeTag type;
320 
321  if (token == NULL) /* need to read a token? */
322  {
323  token = pg_strtok(&tok_len);
324 
325  if (token == NULL) /* end of input */
326  return NULL;
327  }
328 
329  type = nodeTokenType(token, tok_len);
330 
331  switch ((int) type)
332  {
333  case LEFT_BRACE:
334  result = parseNodeString();
335  token = pg_strtok(&tok_len);
336  if (token == NULL || token[0] != '}')
337  elog(ERROR, "did not find '}' at end of input node");
338  break;
339  case LEFT_PAREN:
340  {
341  List *l = NIL;
342 
343  /*----------
344  * Could be an integer list: (i int int ...)
345  * or an OID list: (o int int ...)
346  * or a list of nodes/values: (node node ...)
347  *----------
348  */
349  token = pg_strtok(&tok_len);
350  if (token == NULL)
351  elog(ERROR, "unterminated List structure");
352  if (tok_len == 1 && token[0] == 'i')
353  {
354  /* List of integers */
355  for (;;)
356  {
357  int val;
358  char *endptr;
359 
360  token = pg_strtok(&tok_len);
361  if (token == NULL)
362  elog(ERROR, "unterminated List structure");
363  if (token[0] == ')')
364  break;
365  val = (int) strtol(token, &endptr, 10);
366  if (endptr != token + tok_len)
367  elog(ERROR, "unrecognized integer: \"%.*s\"",
368  tok_len, token);
369  l = lappend_int(l, val);
370  }
371  }
372  else if (tok_len == 1 && token[0] == 'o')
373  {
374  /* List of OIDs */
375  for (;;)
376  {
377  Oid val;
378  char *endptr;
379 
380  token = pg_strtok(&tok_len);
381  if (token == NULL)
382  elog(ERROR, "unterminated List structure");
383  if (token[0] == ')')
384  break;
385  val = (Oid) strtoul(token, &endptr, 10);
386  if (endptr != token + tok_len)
387  elog(ERROR, "unrecognized OID: \"%.*s\"",
388  tok_len, token);
389  l = lappend_oid(l, val);
390  }
391  }
392  else
393  {
394  /* List of other node types */
395  for (;;)
396  {
397  /* We have already scanned next token... */
398  if (token[0] == ')')
399  break;
400  l = lappend(l, nodeRead(token, tok_len));
401  token = pg_strtok(&tok_len);
402  if (token == NULL)
403  elog(ERROR, "unterminated List structure");
404  }
405  }
406  result = (Node *) l;
407  break;
408  }
409  case RIGHT_PAREN:
410  elog(ERROR, "unexpected right parenthesis");
411  result = NULL; /* keep compiler happy */
412  break;
413  case OTHER_TOKEN:
414  if (tok_len == 0)
415  {
416  /* must be "<>" --- represents a null pointer */
417  result = NULL;
418  }
419  else
420  {
421  elog(ERROR, "unrecognized token: \"%.*s\"", tok_len, token);
422  result = NULL; /* keep compiler happy */
423  }
424  break;
425  case T_Integer:
426 
427  /*
428  * we know that the token terminates on a char atoi will stop at
429  */
430  result = (Node *) makeInteger(atoi(token));
431  break;
432  case T_Float:
433  {
434  char *fval = (char *) palloc(tok_len + 1);
435 
436  memcpy(fval, token, tok_len);
437  fval[tok_len] = '\0';
438  result = (Node *) makeFloat(fval);
439  }
440  break;
441  case T_String:
442  /* need to remove leading and trailing quotes, and backslashes */
443  result = (Node *) makeString(debackslash(token + 1, tok_len - 2));
444  break;
445  case T_BitString:
446  {
447  char *val = palloc(tok_len);
448 
449  /* skip leading 'b' */
450  memcpy(val, token + 1, tok_len - 1);
451  val[tok_len - 1] = '\0';
452  result = (Node *) makeBitString(val);
453  break;
454  }
455  default:
456  elog(ERROR, "unrecognized node type: %d", (int) type);
457  result = NULL; /* keep compiler happy */
458  break;
459  }
460 
461  return (void *) result;
462 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:65
Definition: nodes.h:525
unsigned int Oid
Definition: postgres_ext.h:31
NodeTag
Definition: nodes.h:26
List * lappend_oid(List *list, Oid datum)
Definition: list.c:358
#define ERROR
Definition: elog.h:43
void * nodeRead(const char *token, int tok_len)
Definition: read.c:316
#define RIGHT_PAREN
Definition: read.c:229
char * debackslash(const char *token, int length)
Definition: read.c:213
Value * makeBitString(char *str)
Definition: value.c:68
List * lappend_int(List *list, int datum)
Definition: list.c:340
List * lappend(List *list, void *datum)
Definition: list.c:322
Value * makeInteger(int i)
Definition: value.c:23
Value * makeFloat(char *numericStr)
Definition: value.c:38
#define LEFT_BRACE
Definition: read.c:231
Node * parseNodeString(void)
Definition: readfuncs.c:2562
static NodeTag nodeTokenType(const char *token, int length)
Definition: read.c:245
Definition: nodes.h:289
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:226
const char * pg_strtok(int *length)
Definition: read.c:152
#define OTHER_TOKEN
Definition: read.c:232
Definition: pg_list.h:50
long val
Definition: informix.c:684
#define LEFT_PAREN
Definition: read.c:230

◆ parseNodeString()

Node* parseNodeString ( void  )

Definition at line 2562 of file readfuncs.c.

References _readAgg(), _readAggref(), _readAlias(), _readAlternativeSubPlan(), _readAppend(), _readArrayCoerceExpr(), _readArrayExpr(), _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(), _readNamedTuplestoreScan(), _readNestLoop(), _readNestLoopParam(), _readNextValueExpr(), _readNotifyStmt(), _readNullIfExpr(), _readNullTest(), _readOnConflictExpr(), _readOpExpr(), _readParam(), _readPartitionBoundSpec(), _readPartitionedRelPruneInfo(), _readPartitionPruneInfo(), _readPartitionPruneStepCombine(), _readPartitionPruneStepOp(), _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(), _readSubscriptingRef(), _readTableFunc(), _readTableFuncScan(), _readTableSampleClause(), _readTargetEntry(), _readTidScan(), _readUnique(), _readValuesScan(), _readVar(), _readWindowAgg(), _readWindowClause(), _readWindowFunc(), _readWithCheckOption(), _readWorkTableScan(), _readXmlExpr(), check_stack_depth(), elog, ERROR, MATCH, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

2563 {
2564  void *return_value;
2565 
2566  READ_TEMP_LOCALS();
2567 
2568  /* Guard against stack overflow due to overly complex expressions */
2570 
2571  token = pg_strtok(&length);
2572 
2573 #define MATCH(tokname, namelen) \
2574  (length == namelen && memcmp(token, tokname, namelen) == 0)
2575 
2576  if (MATCH("QUERY", 5))
2577  return_value = _readQuery();
2578  else if (MATCH("WITHCHECKOPTION", 15))
2579  return_value = _readWithCheckOption();
2580  else if (MATCH("SORTGROUPCLAUSE", 15))
2581  return_value = _readSortGroupClause();
2582  else if (MATCH("GROUPINGSET", 11))
2583  return_value = _readGroupingSet();
2584  else if (MATCH("WINDOWCLAUSE", 12))
2585  return_value = _readWindowClause();
2586  else if (MATCH("ROWMARKCLAUSE", 13))
2587  return_value = _readRowMarkClause();
2588  else if (MATCH("COMMONTABLEEXPR", 15))
2589  return_value = _readCommonTableExpr();
2590  else if (MATCH("SETOPERATIONSTMT", 16))
2591  return_value = _readSetOperationStmt();
2592  else if (MATCH("ALIAS", 5))
2593  return_value = _readAlias();
2594  else if (MATCH("RANGEVAR", 8))
2595  return_value = _readRangeVar();
2596  else if (MATCH("INTOCLAUSE", 10))
2597  return_value = _readIntoClause();
2598  else if (MATCH("TABLEFUNC", 9))
2599  return_value = _readTableFunc();
2600  else if (MATCH("VAR", 3))
2601  return_value = _readVar();
2602  else if (MATCH("CONST", 5))
2603  return_value = _readConst();
2604  else if (MATCH("PARAM", 5))
2605  return_value = _readParam();
2606  else if (MATCH("AGGREF", 6))
2607  return_value = _readAggref();
2608  else if (MATCH("GROUPINGFUNC", 12))
2609  return_value = _readGroupingFunc();
2610  else if (MATCH("WINDOWFUNC", 10))
2611  return_value = _readWindowFunc();
2612  else if (MATCH("SUBSCRIPTINGREF", 15))
2613  return_value = _readSubscriptingRef();
2614  else if (MATCH("FUNCEXPR", 8))
2615  return_value = _readFuncExpr();
2616  else if (MATCH("NAMEDARGEXPR", 12))
2617  return_value = _readNamedArgExpr();
2618  else if (MATCH("OPEXPR", 6))
2619  return_value = _readOpExpr();
2620  else if (MATCH("DISTINCTEXPR", 12))
2621  return_value = _readDistinctExpr();
2622  else if (MATCH("NULLIFEXPR", 10))
2623  return_value = _readNullIfExpr();
2624  else if (MATCH("SCALARARRAYOPEXPR", 17))
2625  return_value = _readScalarArrayOpExpr();
2626  else if (MATCH("BOOLEXPR", 8))
2627  return_value = _readBoolExpr();
2628  else if (MATCH("SUBLINK", 7))
2629  return_value = _readSubLink();
2630  else if (MATCH("FIELDSELECT", 11))
2631  return_value = _readFieldSelect();
2632  else if (MATCH("FIELDSTORE", 10))
2633  return_value = _readFieldStore();
2634  else if (MATCH("RELABELTYPE", 11))
2635  return_value = _readRelabelType();
2636  else if (MATCH("COERCEVIAIO", 11))
2637  return_value = _readCoerceViaIO();
2638  else if (MATCH("ARRAYCOERCEEXPR", 15))
2639  return_value = _readArrayCoerceExpr();
2640  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2641  return_value = _readConvertRowtypeExpr();
2642  else if (MATCH("COLLATE", 7))
2643  return_value = _readCollateExpr();
2644  else if (MATCH("CASE", 4))
2645  return_value = _readCaseExpr();
2646  else if (MATCH("WHEN", 4))
2647  return_value = _readCaseWhen();
2648  else if (MATCH("CASETESTEXPR", 12))
2649  return_value = _readCaseTestExpr();
2650  else if (MATCH("ARRAY", 5))
2651  return_value = _readArrayExpr();
2652  else if (MATCH("ROW", 3))
2653  return_value = _readRowExpr();
2654  else if (MATCH("ROWCOMPARE", 10))
2655  return_value = _readRowCompareExpr();
2656  else if (MATCH("COALESCE", 8))
2657  return_value = _readCoalesceExpr();
2658  else if (MATCH("MINMAX", 6))
2659  return_value = _readMinMaxExpr();
2660  else if (MATCH("SQLVALUEFUNCTION", 16))
2661  return_value = _readSQLValueFunction();
2662  else if (MATCH("XMLEXPR", 7))
2663  return_value = _readXmlExpr();
2664  else if (MATCH("NULLTEST", 8))
2665  return_value = _readNullTest();
2666  else if (MATCH("BOOLEANTEST", 11))
2667  return_value = _readBooleanTest();
2668  else if (MATCH("COERCETODOMAIN", 14))
2669  return_value = _readCoerceToDomain();
2670  else if (MATCH("COERCETODOMAINVALUE", 19))
2671  return_value = _readCoerceToDomainValue();
2672  else if (MATCH("SETTODEFAULT", 12))
2673  return_value = _readSetToDefault();
2674  else if (MATCH("CURRENTOFEXPR", 13))
2675  return_value = _readCurrentOfExpr();
2676  else if (MATCH("NEXTVALUEEXPR", 13))
2677  return_value = _readNextValueExpr();
2678  else if (MATCH("INFERENCEELEM", 13))
2679  return_value = _readInferenceElem();
2680  else if (MATCH("TARGETENTRY", 11))
2681  return_value = _readTargetEntry();
2682  else if (MATCH("RANGETBLREF", 11))
2683  return_value = _readRangeTblRef();
2684  else if (MATCH("JOINEXPR", 8))
2685  return_value = _readJoinExpr();
2686  else if (MATCH("FROMEXPR", 8))
2687  return_value = _readFromExpr();
2688  else if (MATCH("ONCONFLICTEXPR", 14))
2689  return_value = _readOnConflictExpr();
2690  else if (MATCH("RTE", 3))
2691  return_value = _readRangeTblEntry();
2692  else if (MATCH("RANGETBLFUNCTION", 16))
2693  return_value = _readRangeTblFunction();
2694  else if (MATCH("TABLESAMPLECLAUSE", 17))
2695  return_value = _readTableSampleClause();
2696  else if (MATCH("NOTIFY", 6))
2697  return_value = _readNotifyStmt();
2698  else if (MATCH("DEFELEM", 7))
2699  return_value = _readDefElem();
2700  else if (MATCH("DECLARECURSOR", 13))
2701  return_value = _readDeclareCursorStmt();
2702  else if (MATCH("PLANNEDSTMT", 11))
2703  return_value = _readPlannedStmt();
2704  else if (MATCH("PLAN", 4))
2705  return_value = _readPlan();
2706  else if (MATCH("RESULT", 6))
2707  return_value = _readResult();
2708  else if (MATCH("PROJECTSET", 10))
2709  return_value = _readProjectSet();
2710  else if (MATCH("MODIFYTABLE", 11))
2711  return_value = _readModifyTable();
2712  else if (MATCH("APPEND", 6))
2713  return_value = _readAppend();
2714  else if (MATCH("MERGEAPPEND", 11))
2715  return_value = _readMergeAppend();
2716  else if (MATCH("RECURSIVEUNION", 14))
2717  return_value = _readRecursiveUnion();
2718  else if (MATCH("BITMAPAND", 9))
2719  return_value = _readBitmapAnd();
2720  else if (MATCH("BITMAPOR", 8))
2721  return_value = _readBitmapOr();
2722  else if (MATCH("SCAN", 4))
2723  return_value = _readScan();
2724  else if (MATCH("SEQSCAN", 7))
2725  return_value = _readSeqScan();
2726  else if (MATCH("SAMPLESCAN", 10))
2727  return_value = _readSampleScan();
2728  else if (MATCH("INDEXSCAN", 9))
2729  return_value = _readIndexScan();
2730  else if (MATCH("INDEXONLYSCAN", 13))
2731  return_value = _readIndexOnlyScan();
2732  else if (MATCH("BITMAPINDEXSCAN", 15))
2733  return_value = _readBitmapIndexScan();
2734  else if (MATCH("BITMAPHEAPSCAN", 14))
2735  return_value = _readBitmapHeapScan();
2736  else if (MATCH("TIDSCAN", 7))
2737  return_value = _readTidScan();
2738  else if (MATCH("SUBQUERYSCAN", 12))
2739  return_value = _readSubqueryScan();
2740  else if (MATCH("FUNCTIONSCAN", 12))
2741  return_value = _readFunctionScan();
2742  else if (MATCH("VALUESSCAN", 10))
2743  return_value = _readValuesScan();
2744  else if (MATCH("TABLEFUNCSCAN", 13))
2745  return_value = _readTableFuncScan();
2746  else if (MATCH("CTESCAN", 7))
2747  return_value = _readCteScan();
2748  else if (MATCH("NAMEDTUPLESTORESCAN", 19))
2749  return_value = _readNamedTuplestoreScan();
2750  else if (MATCH("WORKTABLESCAN", 13))
2751  return_value = _readWorkTableScan();
2752  else if (MATCH("FOREIGNSCAN", 11))
2753  return_value = _readForeignScan();
2754  else if (MATCH("CUSTOMSCAN", 10))
2755  return_value = _readCustomScan();
2756  else if (MATCH("JOIN", 4))
2757  return_value = _readJoin();
2758  else if (MATCH("NESTLOOP", 8))
2759  return_value = _readNestLoop();
2760  else if (MATCH("MERGEJOIN", 9))
2761  return_value = _readMergeJoin();
2762  else if (MATCH("HASHJOIN", 8))
2763  return_value = _readHashJoin();
2764  else if (MATCH("MATERIAL", 8))
2765  return_value = _readMaterial();
2766  else if (MATCH("SORT", 4))
2767  return_value = _readSort();
2768  else if (MATCH("GROUP", 5))
2769  return_value = _readGroup();
2770  else if (MATCH("AGG", 3))
2771  return_value = _readAgg();
2772  else if (MATCH("WINDOWAGG", 9))
2773  return_value = _readWindowAgg();
2774  else if (MATCH("UNIQUE", 6))
2775  return_value = _readUnique();
2776  else if (MATCH("GATHER", 6))
2777  return_value = _readGather();
2778  else if (MATCH("GATHERMERGE", 11))
2779  return_value = _readGatherMerge();
2780  else if (MATCH("HASH", 4))
2781  return_value = _readHash();
2782  else if (MATCH("SETOP", 5))
2783  return_value = _readSetOp();
2784  else if (MATCH("LOCKROWS", 8))
2785  return_value = _readLockRows();
2786  else if (MATCH("LIMIT", 5))
2787  return_value = _readLimit();
2788  else if (MATCH("NESTLOOPPARAM", 13))
2789  return_value = _readNestLoopParam();
2790  else if (MATCH("PLANROWMARK", 11))
2791  return_value = _readPlanRowMark();
2792  else if (MATCH("PARTITIONPRUNEINFO", 18))
2793  return_value = _readPartitionPruneInfo();
2794  else if (MATCH("PARTITIONEDRELPRUNEINFO", 23))
2795  return_value = _readPartitionedRelPruneInfo();
2796  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
2797  return_value = _readPartitionPruneStepOp();
2798  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
2799  return_value = _readPartitionPruneStepCombine();
2800  else if (MATCH("PLANINVALITEM", 13))
2801  return_value = _readPlanInvalItem();
2802  else if (MATCH("SUBPLAN", 7))
2803  return_value = _readSubPlan();
2804  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2805  return_value = _readAlternativeSubPlan();
2806  else if (MATCH("EXTENSIBLENODE", 14))
2807  return_value = _readExtensibleNode();
2808  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2809  return_value = _readPartitionBoundSpec();
2810  else if (MATCH("PARTITIONRANGEDATUM", 19))
2811  return_value = _readPartitionRangeDatum();
2812  else
2813  {
2814  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2815  return_value = NULL; /* keep compiler quiet */
2816  }
2817 
2818  return (Node *) return_value;
2819 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1138
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1295
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:471
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1353
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1477
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1032
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2067
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1083
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:399
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:685
static Hash * _readHash(void)
Definition: readfuncs.c:2274
static Result * _readResult(void)
Definition: readfuncs.c:1570
static Query * _readQuery(void)
Definition: readfuncs.c:247
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1049
static Param * _readParam(void)
Definition: readfuncs.c:579
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2437
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:2379
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2184
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1777
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:295
static Scan * _readScan(void)
Definition: readfuncs.c:1736
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:706
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2316
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1219
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:951
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1865
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1817
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:966
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1880
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2522
static Unique * _readUnique(void)
Definition: readfuncs.c:2215
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1650
Definition: nodes.h:525
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:643
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:373
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:722
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1798
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1691
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1315
static PartitionedRelPruneInfo * _readPartitionedRelPruneInfo(void)
Definition: readfuncs.c:2390
static Aggref * _readAggref(void)
Definition: readfuncs.c:597
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2052
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1598
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1234
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:742
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:916
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1263
static Agg * _readAgg(void)
Definition: readfuncs.c:2160
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1749
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2479
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1926
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:626
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1169
static SubLink * _readSubLink(void)
Definition: readfuncs.c:826
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2092
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:2422
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1896
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:935
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1329
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:762
static Append * _readAppend(void)
Definition: readfuncs.c:1633
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2492
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2362
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:848
void check_stack_depth(void)
Definition: postgres.c:3262
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:984
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1101
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1972
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:881
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2293
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:341
static Limit * _readLimit(void)
Definition: readfuncs.c:2332
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2542
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2252
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:309
static Gather * _readGather(void)
Definition: readfuncs.c:2233
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:58
static Var * _readVar(void)
Definition: readfuncs.c:533
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1762
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2451
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1850
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1187
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1911
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:513
static Const * _readConst(void)
Definition: readfuncs.c:554
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:438
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1498
static NamedTuplestoreScan * _readNamedTuplestoreScan(void)
Definition: readfuncs.c:1942
static Material * _readMaterial(void)
Definition: readfuncs.c:2110
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:999
static Alias * _readAlias(void)
Definition: readfuncs.c:460
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1706
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1282
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1671
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:865
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1067
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1203
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:324
static PartitionPruneStepOp * _readPartitionPruneStepOp(void)
Definition: readfuncs.c:2408
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1248
static SubscriptingRef * _readSubscriptingRef(void)
Definition: readfuncs.c:665
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:782
#define elog(elevel,...)
Definition: elog.h:226
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:800
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1994
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:415
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:1014
const char * pg_strtok(int *length)
Definition: read.c:152
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1443
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1154
static Plan * _readPlan(void)
Definition: readfuncs.c:1557
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1117
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:491
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1462
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2348
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1585
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1835
static Join * _readJoin(void)
Definition: readfuncs.c:2039
static Sort * _readSort(void)
Definition: readfuncs.c:2123
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:899
static Group * _readGroup(void)
Definition: readfuncs.c:2142
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:358
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1957

◆ pg_strtok()

const char* pg_strtok ( int *  length)

Definition at line 152 of file read.c.

References pg_strtok_ptr.

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

153 {
154  const char *local_str; /* working pointer to string */
155  const char *ret_str; /* start of token to return */
156 
157  local_str = pg_strtok_ptr;
158 
159  while (*local_str == ' ' || *local_str == '\n' || *local_str == '\t')
160  local_str++;
161 
162  if (*local_str == '\0')
163  {
164  *length = 0;
165  pg_strtok_ptr = local_str;
166  return NULL; /* no more tokens */
167  }
168 
169  /*
170  * Now pointing at start of next token.
171  */
172  ret_str = local_str;
173 
174  if (*local_str == '(' || *local_str == ')' ||
175  *local_str == '{' || *local_str == '}')
176  {
177  /* special 1-character token */
178  local_str++;
179  }
180  else
181  {
182  /* Normal token, possibly containing backslashes */
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 != '}')
188  {
189  if (*local_str == '\\' && local_str[1] != '\0')
190  local_str += 2;
191  else
192  local_str++;
193  }
194  }
195 
196  *length = local_str - ret_str;
197 
198  /* Recognize special case for "empty" token */
199  if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>')
200  *length = 0;
201 
202  pg_strtok_ptr = local_str;
203 
204  return ret_str;
205 }
static const char * pg_strtok_ptr
Definition: read.c:31