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:2595
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:228
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:664
#define LEFT_PAREN
Definition: read.c:230

◆ parseNodeString()

Node* parseNodeString ( void  )

Definition at line 2595 of file readfuncs.c.

References _readAgg(), _readAggref(), _readAlias(), _readAlternativeSubPlan(), _readAppend(), _readAppendRelInfo(), _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().

2596 {
2597  void *return_value;
2598 
2599  READ_TEMP_LOCALS();
2600 
2601  /* Guard against stack overflow due to overly complex expressions */
2603 
2604  token = pg_strtok(&length);
2605 
2606 #define MATCH(tokname, namelen) \
2607  (length == namelen && memcmp(token, tokname, namelen) == 0)
2608 
2609  if (MATCH("QUERY", 5))
2610  return_value = _readQuery();
2611  else if (MATCH("WITHCHECKOPTION", 15))
2612  return_value = _readWithCheckOption();
2613  else if (MATCH("SORTGROUPCLAUSE", 15))
2614  return_value = _readSortGroupClause();
2615  else if (MATCH("GROUPINGSET", 11))
2616  return_value = _readGroupingSet();
2617  else if (MATCH("WINDOWCLAUSE", 12))
2618  return_value = _readWindowClause();
2619  else if (MATCH("ROWMARKCLAUSE", 13))
2620  return_value = _readRowMarkClause();
2621  else if (MATCH("COMMONTABLEEXPR", 15))
2622  return_value = _readCommonTableExpr();
2623  else if (MATCH("SETOPERATIONSTMT", 16))
2624  return_value = _readSetOperationStmt();
2625  else if (MATCH("ALIAS", 5))
2626  return_value = _readAlias();
2627  else if (MATCH("RANGEVAR", 8))
2628  return_value = _readRangeVar();
2629  else if (MATCH("INTOCLAUSE", 10))
2630  return_value = _readIntoClause();
2631  else if (MATCH("TABLEFUNC", 9))
2632  return_value = _readTableFunc();
2633  else if (MATCH("VAR", 3))
2634  return_value = _readVar();
2635  else if (MATCH("CONST", 5))
2636  return_value = _readConst();
2637  else if (MATCH("PARAM", 5))
2638  return_value = _readParam();
2639  else if (MATCH("AGGREF", 6))
2640  return_value = _readAggref();
2641  else if (MATCH("GROUPINGFUNC", 12))
2642  return_value = _readGroupingFunc();
2643  else if (MATCH("WINDOWFUNC", 10))
2644  return_value = _readWindowFunc();
2645  else if (MATCH("SUBSCRIPTINGREF", 15))
2646  return_value = _readSubscriptingRef();
2647  else if (MATCH("FUNCEXPR", 8))
2648  return_value = _readFuncExpr();
2649  else if (MATCH("NAMEDARGEXPR", 12))
2650  return_value = _readNamedArgExpr();
2651  else if (MATCH("OPEXPR", 6))
2652  return_value = _readOpExpr();
2653  else if (MATCH("DISTINCTEXPR", 12))
2654  return_value = _readDistinctExpr();
2655  else if (MATCH("NULLIFEXPR", 10))
2656  return_value = _readNullIfExpr();
2657  else if (MATCH("SCALARARRAYOPEXPR", 17))
2658  return_value = _readScalarArrayOpExpr();
2659  else if (MATCH("BOOLEXPR", 8))
2660  return_value = _readBoolExpr();
2661  else if (MATCH("SUBLINK", 7))
2662  return_value = _readSubLink();
2663  else if (MATCH("FIELDSELECT", 11))
2664  return_value = _readFieldSelect();
2665  else if (MATCH("FIELDSTORE", 10))
2666  return_value = _readFieldStore();
2667  else if (MATCH("RELABELTYPE", 11))
2668  return_value = _readRelabelType();
2669  else if (MATCH("COERCEVIAIO", 11))
2670  return_value = _readCoerceViaIO();
2671  else if (MATCH("ARRAYCOERCEEXPR", 15))
2672  return_value = _readArrayCoerceExpr();
2673  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2674  return_value = _readConvertRowtypeExpr();
2675  else if (MATCH("COLLATE", 7))
2676  return_value = _readCollateExpr();
2677  else if (MATCH("CASE", 4))
2678  return_value = _readCaseExpr();
2679  else if (MATCH("WHEN", 4))
2680  return_value = _readCaseWhen();
2681  else if (MATCH("CASETESTEXPR", 12))
2682  return_value = _readCaseTestExpr();
2683  else if (MATCH("ARRAY", 5))
2684  return_value = _readArrayExpr();
2685  else if (MATCH("ROW", 3))
2686  return_value = _readRowExpr();
2687  else if (MATCH("ROWCOMPARE", 10))
2688  return_value = _readRowCompareExpr();
2689  else if (MATCH("COALESCE", 8))
2690  return_value = _readCoalesceExpr();
2691  else if (MATCH("MINMAX", 6))
2692  return_value = _readMinMaxExpr();
2693  else if (MATCH("SQLVALUEFUNCTION", 16))
2694  return_value = _readSQLValueFunction();
2695  else if (MATCH("XMLEXPR", 7))
2696  return_value = _readXmlExpr();
2697  else if (MATCH("NULLTEST", 8))
2698  return_value = _readNullTest();
2699  else if (MATCH("BOOLEANTEST", 11))
2700  return_value = _readBooleanTest();
2701  else if (MATCH("COERCETODOMAIN", 14))
2702  return_value = _readCoerceToDomain();
2703  else if (MATCH("COERCETODOMAINVALUE", 19))
2704  return_value = _readCoerceToDomainValue();
2705  else if (MATCH("SETTODEFAULT", 12))
2706  return_value = _readSetToDefault();
2707  else if (MATCH("CURRENTOFEXPR", 13))
2708  return_value = _readCurrentOfExpr();
2709  else if (MATCH("NEXTVALUEEXPR", 13))
2710  return_value = _readNextValueExpr();
2711  else if (MATCH("INFERENCEELEM", 13))
2712  return_value = _readInferenceElem();
2713  else if (MATCH("TARGETENTRY", 11))
2714  return_value = _readTargetEntry();
2715  else if (MATCH("RANGETBLREF", 11))
2716  return_value = _readRangeTblRef();
2717  else if (MATCH("JOINEXPR", 8))
2718  return_value = _readJoinExpr();
2719  else if (MATCH("FROMEXPR", 8))
2720  return_value = _readFromExpr();
2721  else if (MATCH("ONCONFLICTEXPR", 14))
2722  return_value = _readOnConflictExpr();
2723  else if (MATCH("APPENDRELINFO", 13))
2724  return_value = _readAppendRelInfo();
2725  else if (MATCH("RTE", 3))
2726  return_value = _readRangeTblEntry();
2727  else if (MATCH("RANGETBLFUNCTION", 16))
2728  return_value = _readRangeTblFunction();
2729  else if (MATCH("TABLESAMPLECLAUSE", 17))
2730  return_value = _readTableSampleClause();
2731  else if (MATCH("NOTIFY", 6))
2732  return_value = _readNotifyStmt();
2733  else if (MATCH("DEFELEM", 7))
2734  return_value = _readDefElem();
2735  else if (MATCH("DECLARECURSOR", 13))
2736  return_value = _readDeclareCursorStmt();
2737  else if (MATCH("PLANNEDSTMT", 11))
2738  return_value = _readPlannedStmt();
2739  else if (MATCH("PLAN", 4))
2740  return_value = _readPlan();
2741  else if (MATCH("RESULT", 6))
2742  return_value = _readResult();
2743  else if (MATCH("PROJECTSET", 10))
2744  return_value = _readProjectSet();
2745  else if (MATCH("MODIFYTABLE", 11))
2746  return_value = _readModifyTable();
2747  else if (MATCH("APPEND", 6))
2748  return_value = _readAppend();
2749  else if (MATCH("MERGEAPPEND", 11))
2750  return_value = _readMergeAppend();
2751  else if (MATCH("RECURSIVEUNION", 14))
2752  return_value = _readRecursiveUnion();
2753  else if (MATCH("BITMAPAND", 9))
2754  return_value = _readBitmapAnd();
2755  else if (MATCH("BITMAPOR", 8))
2756  return_value = _readBitmapOr();
2757  else if (MATCH("SCAN", 4))
2758  return_value = _readScan();
2759  else if (MATCH("SEQSCAN", 7))
2760  return_value = _readSeqScan();
2761  else if (MATCH("SAMPLESCAN", 10))
2762  return_value = _readSampleScan();
2763  else if (MATCH("INDEXSCAN", 9))
2764  return_value = _readIndexScan();
2765  else if (MATCH("INDEXONLYSCAN", 13))
2766  return_value = _readIndexOnlyScan();
2767  else if (MATCH("BITMAPINDEXSCAN", 15))
2768  return_value = _readBitmapIndexScan();
2769  else if (MATCH("BITMAPHEAPSCAN", 14))
2770  return_value = _readBitmapHeapScan();
2771  else if (MATCH("TIDSCAN", 7))
2772  return_value = _readTidScan();
2773  else if (MATCH("SUBQUERYSCAN", 12))
2774  return_value = _readSubqueryScan();
2775  else if (MATCH("FUNCTIONSCAN", 12))
2776  return_value = _readFunctionScan();
2777  else if (MATCH("VALUESSCAN", 10))
2778  return_value = _readValuesScan();
2779  else if (MATCH("TABLEFUNCSCAN", 13))
2780  return_value = _readTableFuncScan();
2781  else if (MATCH("CTESCAN", 7))
2782  return_value = _readCteScan();
2783  else if (MATCH("NAMEDTUPLESTORESCAN", 19))
2784  return_value = _readNamedTuplestoreScan();
2785  else if (MATCH("WORKTABLESCAN", 13))
2786  return_value = _readWorkTableScan();
2787  else if (MATCH("FOREIGNSCAN", 11))
2788  return_value = _readForeignScan();
2789  else if (MATCH("CUSTOMSCAN", 10))
2790  return_value = _readCustomScan();
2791  else if (MATCH("JOIN", 4))
2792  return_value = _readJoin();
2793  else if (MATCH("NESTLOOP", 8))
2794  return_value = _readNestLoop();
2795  else if (MATCH("MERGEJOIN", 9))
2796  return_value = _readMergeJoin();
2797  else if (MATCH("HASHJOIN", 8))
2798  return_value = _readHashJoin();
2799  else if (MATCH("MATERIAL", 8))
2800  return_value = _readMaterial();
2801  else if (MATCH("SORT", 4))
2802  return_value = _readSort();
2803  else if (MATCH("GROUP", 5))
2804  return_value = _readGroup();
2805  else if (MATCH("AGG", 3))
2806  return_value = _readAgg();
2807  else if (MATCH("WINDOWAGG", 9))
2808  return_value = _readWindowAgg();
2809  else if (MATCH("UNIQUE", 6))
2810  return_value = _readUnique();
2811  else if (MATCH("GATHER", 6))
2812  return_value = _readGather();
2813  else if (MATCH("GATHERMERGE", 11))
2814  return_value = _readGatherMerge();
2815  else if (MATCH("HASH", 4))
2816  return_value = _readHash();
2817  else if (MATCH("SETOP", 5))
2818  return_value = _readSetOp();
2819  else if (MATCH("LOCKROWS", 8))
2820  return_value = _readLockRows();
2821  else if (MATCH("LIMIT", 5))
2822  return_value = _readLimit();
2823  else if (MATCH("NESTLOOPPARAM", 13))
2824  return_value = _readNestLoopParam();
2825  else if (MATCH("PLANROWMARK", 11))
2826  return_value = _readPlanRowMark();
2827  else if (MATCH("PARTITIONPRUNEINFO", 18))
2828  return_value = _readPartitionPruneInfo();
2829  else if (MATCH("PARTITIONEDRELPRUNEINFO", 23))
2830  return_value = _readPartitionedRelPruneInfo();
2831  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
2832  return_value = _readPartitionPruneStepOp();
2833  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
2834  return_value = _readPartitionPruneStepCombine();
2835  else if (MATCH("PLANINVALITEM", 13))
2836  return_value = _readPlanInvalItem();
2837  else if (MATCH("SUBPLAN", 7))
2838  return_value = _readSubPlan();
2839  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2840  return_value = _readAlternativeSubPlan();
2841  else if (MATCH("EXTENSIBLENODE", 14))
2842  return_value = _readExtensibleNode();
2843  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2844  return_value = _readPartitionBoundSpec();
2845  else if (MATCH("PARTITIONRANGEDATUM", 19))
2846  return_value = _readPartitionRangeDatum();
2847  else
2848  {
2849  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2850  return_value = NULL; /* keep compiler quiet */
2851  }
2852 
2853  return (Node *) return_value;
2854 }
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:1380
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1507
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1032
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2100
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:2307
static Result * _readResult(void)
Definition: readfuncs.c:1601
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:2470
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:2412
static AppendRelInfo * _readAppendRelInfo(void)
Definition: readfuncs.c:1356
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2217
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1810
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:295
static Scan * _readScan(void)
Definition: readfuncs.c:1769
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:706
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2349
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1219
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:951
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1898
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1850
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:966
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1913
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2555
static Unique * _readUnique(void)
Definition: readfuncs.c:2248
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1682
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:1831
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1724
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1315
static PartitionedRelPruneInfo * _readPartitionedRelPruneInfo(void)
Definition: readfuncs.c:2423
static Aggref * _readAggref(void)
Definition: readfuncs.c:597
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2085
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1629
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:2193
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1782
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2512
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1959
#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:2125
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:2455
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1929
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:1664
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2525
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2395
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:848
void check_stack_depth(void)
Definition: postgres.c:3288
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:2005
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:881
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2326
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:341
static Limit * _readLimit(void)
Definition: readfuncs.c:2365
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2575
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2285
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:309
static Gather * _readGather(void)
Definition: readfuncs.c:2266
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:58
static Var * _readVar(void)
Definition: readfuncs.c:533
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1795
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2484
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1883
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1187
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1944
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:1528
static NamedTuplestoreScan * _readNamedTuplestoreScan(void)
Definition: readfuncs.c:1975
static Material * _readMaterial(void)
Definition: readfuncs.c:2143
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:999
static Alias * _readAlias(void)
Definition: readfuncs.c:460
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1739
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1282
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1704
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:2441
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:228
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:800
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:2027
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:1473
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1154
static Plan * _readPlan(void)
Definition: readfuncs.c:1588
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1117
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:491
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1492
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2381
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1616
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1868
static Join * _readJoin(void)
Definition: readfuncs.c:2072
static Sort * _readSort(void)
Definition: readfuncs.c:2156
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:899
static Group * _readGroup(void)
Definition: readfuncs.c:2175
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:358
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1990

◆ 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