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:529
unsigned int Oid
Definition: postgres_ext.h:31
NodeTag
Definition: nodes.h:26
List * lappend_oid(List *list, Oid datum)
Definition: list.c:357
#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:339
List * lappend(List *list, void *datum)
Definition: list.c:321
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:2629
static NodeTag nodeTokenType(const char *token, int length)
Definition: read.c:245
Definition: nodes.h:292
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:214
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 2629 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(), _readIncrementalSort(), _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().

2630 {
2631  void *return_value;
2632 
2633  READ_TEMP_LOCALS();
2634 
2635  /* Guard against stack overflow due to overly complex expressions */
2637 
2638  token = pg_strtok(&length);
2639 
2640 #define MATCH(tokname, namelen) \
2641  (length == namelen && memcmp(token, tokname, namelen) == 0)
2642 
2643  if (MATCH("QUERY", 5))
2644  return_value = _readQuery();
2645  else if (MATCH("WITHCHECKOPTION", 15))
2646  return_value = _readWithCheckOption();
2647  else if (MATCH("SORTGROUPCLAUSE", 15))
2648  return_value = _readSortGroupClause();
2649  else if (MATCH("GROUPINGSET", 11))
2650  return_value = _readGroupingSet();
2651  else if (MATCH("WINDOWCLAUSE", 12))
2652  return_value = _readWindowClause();
2653  else if (MATCH("ROWMARKCLAUSE", 13))
2654  return_value = _readRowMarkClause();
2655  else if (MATCH("COMMONTABLEEXPR", 15))
2656  return_value = _readCommonTableExpr();
2657  else if (MATCH("SETOPERATIONSTMT", 16))
2658  return_value = _readSetOperationStmt();
2659  else if (MATCH("ALIAS", 5))
2660  return_value = _readAlias();
2661  else if (MATCH("RANGEVAR", 8))
2662  return_value = _readRangeVar();
2663  else if (MATCH("INTOCLAUSE", 10))
2664  return_value = _readIntoClause();
2665  else if (MATCH("TABLEFUNC", 9))
2666  return_value = _readTableFunc();
2667  else if (MATCH("VAR", 3))
2668  return_value = _readVar();
2669  else if (MATCH("CONST", 5))
2670  return_value = _readConst();
2671  else if (MATCH("PARAM", 5))
2672  return_value = _readParam();
2673  else if (MATCH("AGGREF", 6))
2674  return_value = _readAggref();
2675  else if (MATCH("GROUPINGFUNC", 12))
2676  return_value = _readGroupingFunc();
2677  else if (MATCH("WINDOWFUNC", 10))
2678  return_value = _readWindowFunc();
2679  else if (MATCH("SUBSCRIPTINGREF", 15))
2680  return_value = _readSubscriptingRef();
2681  else if (MATCH("FUNCEXPR", 8))
2682  return_value = _readFuncExpr();
2683  else if (MATCH("NAMEDARGEXPR", 12))
2684  return_value = _readNamedArgExpr();
2685  else if (MATCH("OPEXPR", 6))
2686  return_value = _readOpExpr();
2687  else if (MATCH("DISTINCTEXPR", 12))
2688  return_value = _readDistinctExpr();
2689  else if (MATCH("NULLIFEXPR", 10))
2690  return_value = _readNullIfExpr();
2691  else if (MATCH("SCALARARRAYOPEXPR", 17))
2692  return_value = _readScalarArrayOpExpr();
2693  else if (MATCH("BOOLEXPR", 8))
2694  return_value = _readBoolExpr();
2695  else if (MATCH("SUBLINK", 7))
2696  return_value = _readSubLink();
2697  else if (MATCH("FIELDSELECT", 11))
2698  return_value = _readFieldSelect();
2699  else if (MATCH("FIELDSTORE", 10))
2700  return_value = _readFieldStore();
2701  else if (MATCH("RELABELTYPE", 11))
2702  return_value = _readRelabelType();
2703  else if (MATCH("COERCEVIAIO", 11))
2704  return_value = _readCoerceViaIO();
2705  else if (MATCH("ARRAYCOERCEEXPR", 15))
2706  return_value = _readArrayCoerceExpr();
2707  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2708  return_value = _readConvertRowtypeExpr();
2709  else if (MATCH("COLLATE", 7))
2710  return_value = _readCollateExpr();
2711  else if (MATCH("CASE", 4))
2712  return_value = _readCaseExpr();
2713  else if (MATCH("WHEN", 4))
2714  return_value = _readCaseWhen();
2715  else if (MATCH("CASETESTEXPR", 12))
2716  return_value = _readCaseTestExpr();
2717  else if (MATCH("ARRAY", 5))
2718  return_value = _readArrayExpr();
2719  else if (MATCH("ROW", 3))
2720  return_value = _readRowExpr();
2721  else if (MATCH("ROWCOMPARE", 10))
2722  return_value = _readRowCompareExpr();
2723  else if (MATCH("COALESCE", 8))
2724  return_value = _readCoalesceExpr();
2725  else if (MATCH("MINMAX", 6))
2726  return_value = _readMinMaxExpr();
2727  else if (MATCH("SQLVALUEFUNCTION", 16))
2728  return_value = _readSQLValueFunction();
2729  else if (MATCH("XMLEXPR", 7))
2730  return_value = _readXmlExpr();
2731  else if (MATCH("NULLTEST", 8))
2732  return_value = _readNullTest();
2733  else if (MATCH("BOOLEANTEST", 11))
2734  return_value = _readBooleanTest();
2735  else if (MATCH("COERCETODOMAIN", 14))
2736  return_value = _readCoerceToDomain();
2737  else if (MATCH("COERCETODOMAINVALUE", 19))
2738  return_value = _readCoerceToDomainValue();
2739  else if (MATCH("SETTODEFAULT", 12))
2740  return_value = _readSetToDefault();
2741  else if (MATCH("CURRENTOFEXPR", 13))
2742  return_value = _readCurrentOfExpr();
2743  else if (MATCH("NEXTVALUEEXPR", 13))
2744  return_value = _readNextValueExpr();
2745  else if (MATCH("INFERENCEELEM", 13))
2746  return_value = _readInferenceElem();
2747  else if (MATCH("TARGETENTRY", 11))
2748  return_value = _readTargetEntry();
2749  else if (MATCH("RANGETBLREF", 11))
2750  return_value = _readRangeTblRef();
2751  else if (MATCH("JOINEXPR", 8))
2752  return_value = _readJoinExpr();
2753  else if (MATCH("FROMEXPR", 8))
2754  return_value = _readFromExpr();
2755  else if (MATCH("ONCONFLICTEXPR", 14))
2756  return_value = _readOnConflictExpr();
2757  else if (MATCH("APPENDRELINFO", 13))
2758  return_value = _readAppendRelInfo();
2759  else if (MATCH("RTE", 3))
2760  return_value = _readRangeTblEntry();
2761  else if (MATCH("RANGETBLFUNCTION", 16))
2762  return_value = _readRangeTblFunction();
2763  else if (MATCH("TABLESAMPLECLAUSE", 17))
2764  return_value = _readTableSampleClause();
2765  else if (MATCH("NOTIFY", 6))
2766  return_value = _readNotifyStmt();
2767  else if (MATCH("DEFELEM", 7))
2768  return_value = _readDefElem();
2769  else if (MATCH("DECLARECURSOR", 13))
2770  return_value = _readDeclareCursorStmt();
2771  else if (MATCH("PLANNEDSTMT", 11))
2772  return_value = _readPlannedStmt();
2773  else if (MATCH("PLAN", 4))
2774  return_value = _readPlan();
2775  else if (MATCH("RESULT", 6))
2776  return_value = _readResult();
2777  else if (MATCH("PROJECTSET", 10))
2778  return_value = _readProjectSet();
2779  else if (MATCH("MODIFYTABLE", 11))
2780  return_value = _readModifyTable();
2781  else if (MATCH("APPEND", 6))
2782  return_value = _readAppend();
2783  else if (MATCH("MERGEAPPEND", 11))
2784  return_value = _readMergeAppend();
2785  else if (MATCH("RECURSIVEUNION", 14))
2786  return_value = _readRecursiveUnion();
2787  else if (MATCH("BITMAPAND", 9))
2788  return_value = _readBitmapAnd();
2789  else if (MATCH("BITMAPOR", 8))
2790  return_value = _readBitmapOr();
2791  else if (MATCH("SCAN", 4))
2792  return_value = _readScan();
2793  else if (MATCH("SEQSCAN", 7))
2794  return_value = _readSeqScan();
2795  else if (MATCH("SAMPLESCAN", 10))
2796  return_value = _readSampleScan();
2797  else if (MATCH("INDEXSCAN", 9))
2798  return_value = _readIndexScan();
2799  else if (MATCH("INDEXONLYSCAN", 13))
2800  return_value = _readIndexOnlyScan();
2801  else if (MATCH("BITMAPINDEXSCAN", 15))
2802  return_value = _readBitmapIndexScan();
2803  else if (MATCH("BITMAPHEAPSCAN", 14))
2804  return_value = _readBitmapHeapScan();
2805  else if (MATCH("TIDSCAN", 7))
2806  return_value = _readTidScan();
2807  else if (MATCH("SUBQUERYSCAN", 12))
2808  return_value = _readSubqueryScan();
2809  else if (MATCH("FUNCTIONSCAN", 12))
2810  return_value = _readFunctionScan();
2811  else if (MATCH("VALUESSCAN", 10))
2812  return_value = _readValuesScan();
2813  else if (MATCH("TABLEFUNCSCAN", 13))
2814  return_value = _readTableFuncScan();
2815  else if (MATCH("CTESCAN", 7))
2816  return_value = _readCteScan();
2817  else if (MATCH("NAMEDTUPLESTORESCAN", 19))
2818  return_value = _readNamedTuplestoreScan();
2819  else if (MATCH("WORKTABLESCAN", 13))
2820  return_value = _readWorkTableScan();
2821  else if (MATCH("FOREIGNSCAN", 11))
2822  return_value = _readForeignScan();
2823  else if (MATCH("CUSTOMSCAN", 10))
2824  return_value = _readCustomScan();
2825  else if (MATCH("JOIN", 4))
2826  return_value = _readJoin();
2827  else if (MATCH("NESTLOOP", 8))
2828  return_value = _readNestLoop();
2829  else if (MATCH("MERGEJOIN", 9))
2830  return_value = _readMergeJoin();
2831  else if (MATCH("HASHJOIN", 8))
2832  return_value = _readHashJoin();
2833  else if (MATCH("MATERIAL", 8))
2834  return_value = _readMaterial();
2835  else if (MATCH("SORT", 4))
2836  return_value = _readSort();
2837  else if (MATCH("INCREMENTALSORT", 15))
2838  return_value = _readIncrementalSort();
2839  else if (MATCH("GROUP", 5))
2840  return_value = _readGroup();
2841  else if (MATCH("AGG", 3))
2842  return_value = _readAgg();
2843  else if (MATCH("WINDOWAGG", 9))
2844  return_value = _readWindowAgg();
2845  else if (MATCH("UNIQUE", 6))
2846  return_value = _readUnique();
2847  else if (MATCH("GATHER", 6))
2848  return_value = _readGather();
2849  else if (MATCH("GATHERMERGE", 11))
2850  return_value = _readGatherMerge();
2851  else if (MATCH("HASH", 4))
2852  return_value = _readHash();
2853  else if (MATCH("SETOP", 5))
2854  return_value = _readSetOp();
2855  else if (MATCH("LOCKROWS", 8))
2856  return_value = _readLockRows();
2857  else if (MATCH("LIMIT", 5))
2858  return_value = _readLimit();
2859  else if (MATCH("NESTLOOPPARAM", 13))
2860  return_value = _readNestLoopParam();
2861  else if (MATCH("PLANROWMARK", 11))
2862  return_value = _readPlanRowMark();
2863  else if (MATCH("PARTITIONPRUNEINFO", 18))
2864  return_value = _readPartitionPruneInfo();
2865  else if (MATCH("PARTITIONEDRELPRUNEINFO", 23))
2866  return_value = _readPartitionedRelPruneInfo();
2867  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
2868  return_value = _readPartitionPruneStepOp();
2869  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
2870  return_value = _readPartitionPruneStepCombine();
2871  else if (MATCH("PLANINVALITEM", 13))
2872  return_value = _readPlanInvalItem();
2873  else if (MATCH("SUBPLAN", 7))
2874  return_value = _readSubPlan();
2875  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2876  return_value = _readAlternativeSubPlan();
2877  else if (MATCH("EXTENSIBLENODE", 14))
2878  return_value = _readExtensibleNode();
2879  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2880  return_value = _readPartitionBoundSpec();
2881  else if (MATCH("PARTITIONRANGEDATUM", 19))
2882  return_value = _readPartitionRangeDatum();
2883  else
2884  {
2885  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2886  return_value = NULL; /* keep compiler quiet */
2887  }
2888 
2889  return (Node *) return_value;
2890 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1139
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1296
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:472
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1381
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1508
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1033
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2101
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1084
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:400
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:686
static Hash * _readHash(void)
Definition: readfuncs.c:2336
static Result * _readResult(void)
Definition: readfuncs.c:1602
static Query * _readQuery(void)
Definition: readfuncs.c:247
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1050
static Param * _readParam(void)
Definition: readfuncs.c:580
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2504
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:2446
static AppendRelInfo * _readAppendRelInfo(void)
Definition: readfuncs.c:1357
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2246
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1811
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:296
static Scan * _readScan(void)
Definition: readfuncs.c:1770
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:707
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2378
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1220
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:952
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1899
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1851
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:967
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1914
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2589
static Unique * _readUnique(void)
Definition: readfuncs.c:2277
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1683
Definition: nodes.h:529
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:644
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:374
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:723
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1832
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1725
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1316
static PartitionedRelPruneInfo * _readPartitionedRelPruneInfo(void)
Definition: readfuncs.c:2457
static Aggref * _readAggref(void)
Definition: readfuncs.c:598
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2086
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1630
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1235
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:743
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:917
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1264
static Agg * _readAgg(void)
Definition: readfuncs.c:2221
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1783
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2546
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1960
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:627
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1170
static SubLink * _readSubLink(void)
Definition: readfuncs.c:827
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2126
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:2489
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1930
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:936
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1330
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:763
static Append * _readAppend(void)
Definition: readfuncs.c:1665
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2559
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2429
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:849
void check_stack_depth(void)
Definition: postgres.c:3312
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:985
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1102
static IncrementalSort * _readIncrementalSort(void)
Definition: readfuncs.c:2188
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:2006
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:882
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2355
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:342
static Limit * _readLimit(void)
Definition: readfuncs.c:2394
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2609
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2314
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:310
static Gather * _readGather(void)
Definition: readfuncs.c:2295
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:58
static Var * _readVar(void)
Definition: readfuncs.c:534
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1796
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2518
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1884
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1188
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1945
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:514
static Const * _readConst(void)
Definition: readfuncs.c:555
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:439
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1529
static NamedTuplestoreScan * _readNamedTuplestoreScan(void)
Definition: readfuncs.c:1976
static Material * _readMaterial(void)
Definition: readfuncs.c:2144
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:1000
static Alias * _readAlias(void)
Definition: readfuncs.c:461
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1740
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1283
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1705
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:866
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1068
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1204
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:325
static PartitionPruneStepOp * _readPartitionPruneStepOp(void)
Definition: readfuncs.c:2475
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1249
static SubscriptingRef * _readSubscriptingRef(void)
Definition: readfuncs.c:666
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:783
#define elog(elevel,...)
Definition: elog.h:214
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:801
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:2028
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:416
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:1015
const char * pg_strtok(int *length)
Definition: read.c:152
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1474
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1155
static Plan * _readPlan(void)
Definition: readfuncs.c:1589
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1118
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:492
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1493
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2415
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1617
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1869
static Join * _readJoin(void)
Definition: readfuncs.c:2073
static Sort * _readSort(void)
Definition: readfuncs.c:2175
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:900
static Group * _readGroup(void)
Definition: readfuncs.c:2203
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:359
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1991

◆ 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