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

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

Function Documentation

◆ debackslash()

char* debackslash ( char *  token,
int  length 
)

Definition at line 169 of file read.c.

References palloc().

Referenced by nodeRead().

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

◆ nodeRead()

void* nodeRead ( char *  token,
int  tok_len 
)

Definition at line 272 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 stringToNode().

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

◆ parseNodeString()

Node* parseNodeString ( void  )

Definition at line 2494 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(), _readNextValueExpr(), _readNotifyStmt(), _readNullIfExpr(), _readNullTest(), _readOnConflictExpr(), _readOpExpr(), _readParam(), _readPartitionBoundSpec(), _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(), _readTableFunc(), _readTableFuncScan(), _readTableSampleClause(), _readTargetEntry(), _readTidScan(), _readUnique(), _readValuesScan(), _readVar(), _readWindowAgg(), _readWindowClause(), _readWindowFunc(), _readWithCheckOption(), _readWorkTableScan(), _readXmlExpr(), elog, ERROR, length(), MATCH, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

2495 {
2496  void *return_value;
2497 
2498  READ_TEMP_LOCALS();
2499 
2500  token = pg_strtok(&length);
2501 
2502 #define MATCH(tokname, namelen) \
2503  (length == namelen && memcmp(token, tokname, namelen) == 0)
2504 
2505  if (MATCH("QUERY", 5))
2506  return_value = _readQuery();
2507  else if (MATCH("WITHCHECKOPTION", 15))
2508  return_value = _readWithCheckOption();
2509  else if (MATCH("SORTGROUPCLAUSE", 15))
2510  return_value = _readSortGroupClause();
2511  else if (MATCH("GROUPINGSET", 11))
2512  return_value = _readGroupingSet();
2513  else if (MATCH("WINDOWCLAUSE", 12))
2514  return_value = _readWindowClause();
2515  else if (MATCH("ROWMARKCLAUSE", 13))
2516  return_value = _readRowMarkClause();
2517  else if (MATCH("COMMONTABLEEXPR", 15))
2518  return_value = _readCommonTableExpr();
2519  else if (MATCH("SETOPERATIONSTMT", 16))
2520  return_value = _readSetOperationStmt();
2521  else if (MATCH("ALIAS", 5))
2522  return_value = _readAlias();
2523  else if (MATCH("RANGEVAR", 8))
2524  return_value = _readRangeVar();
2525  else if (MATCH("INTOCLAUSE", 10))
2526  return_value = _readIntoClause();
2527  else if (MATCH("TABLEFUNC", 9))
2528  return_value = _readTableFunc();
2529  else if (MATCH("VAR", 3))
2530  return_value = _readVar();
2531  else if (MATCH("CONST", 5))
2532  return_value = _readConst();
2533  else if (MATCH("PARAM", 5))
2534  return_value = _readParam();
2535  else if (MATCH("AGGREF", 6))
2536  return_value = _readAggref();
2537  else if (MATCH("GROUPINGFUNC", 12))
2538  return_value = _readGroupingFunc();
2539  else if (MATCH("WINDOWFUNC", 10))
2540  return_value = _readWindowFunc();
2541  else if (MATCH("ARRAYREF", 8))
2542  return_value = _readArrayRef();
2543  else if (MATCH("FUNCEXPR", 8))
2544  return_value = _readFuncExpr();
2545  else if (MATCH("NAMEDARGEXPR", 12))
2546  return_value = _readNamedArgExpr();
2547  else if (MATCH("OPEXPR", 6))
2548  return_value = _readOpExpr();
2549  else if (MATCH("DISTINCTEXPR", 12))
2550  return_value = _readDistinctExpr();
2551  else if (MATCH("NULLIFEXPR", 10))
2552  return_value = _readNullIfExpr();
2553  else if (MATCH("SCALARARRAYOPEXPR", 17))
2554  return_value = _readScalarArrayOpExpr();
2555  else if (MATCH("BOOLEXPR", 8))
2556  return_value = _readBoolExpr();
2557  else if (MATCH("SUBLINK", 7))
2558  return_value = _readSubLink();
2559  else if (MATCH("FIELDSELECT", 11))
2560  return_value = _readFieldSelect();
2561  else if (MATCH("FIELDSTORE", 10))
2562  return_value = _readFieldStore();
2563  else if (MATCH("RELABELTYPE", 11))
2564  return_value = _readRelabelType();
2565  else if (MATCH("COERCEVIAIO", 11))
2566  return_value = _readCoerceViaIO();
2567  else if (MATCH("ARRAYCOERCEEXPR", 15))
2568  return_value = _readArrayCoerceExpr();
2569  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2570  return_value = _readConvertRowtypeExpr();
2571  else if (MATCH("COLLATE", 7))
2572  return_value = _readCollateExpr();
2573  else if (MATCH("CASE", 4))
2574  return_value = _readCaseExpr();
2575  else if (MATCH("WHEN", 4))
2576  return_value = _readCaseWhen();
2577  else if (MATCH("CASETESTEXPR", 12))
2578  return_value = _readCaseTestExpr();
2579  else if (MATCH("ARRAY", 5))
2580  return_value = _readArrayExpr();
2581  else if (MATCH("ROW", 3))
2582  return_value = _readRowExpr();
2583  else if (MATCH("ROWCOMPARE", 10))
2584  return_value = _readRowCompareExpr();
2585  else if (MATCH("COALESCE", 8))
2586  return_value = _readCoalesceExpr();
2587  else if (MATCH("MINMAX", 6))
2588  return_value = _readMinMaxExpr();
2589  else if (MATCH("SQLVALUEFUNCTION", 16))
2590  return_value = _readSQLValueFunction();
2591  else if (MATCH("XMLEXPR", 7))
2592  return_value = _readXmlExpr();
2593  else if (MATCH("NULLTEST", 8))
2594  return_value = _readNullTest();
2595  else if (MATCH("BOOLEANTEST", 11))
2596  return_value = _readBooleanTest();
2597  else if (MATCH("COERCETODOMAIN", 14))
2598  return_value = _readCoerceToDomain();
2599  else if (MATCH("COERCETODOMAINVALUE", 19))
2600  return_value = _readCoerceToDomainValue();
2601  else if (MATCH("SETTODEFAULT", 12))
2602  return_value = _readSetToDefault();
2603  else if (MATCH("CURRENTOFEXPR", 13))
2604  return_value = _readCurrentOfExpr();
2605  else if (MATCH("NEXTVALUEEXPR", 13))
2606  return_value = _readNextValueExpr();
2607  else if (MATCH("INFERENCEELEM", 13))
2608  return_value = _readInferenceElem();
2609  else if (MATCH("TARGETENTRY", 11))
2610  return_value = _readTargetEntry();
2611  else if (MATCH("RANGETBLREF", 11))
2612  return_value = _readRangeTblRef();
2613  else if (MATCH("JOINEXPR", 8))
2614  return_value = _readJoinExpr();
2615  else if (MATCH("FROMEXPR", 8))
2616  return_value = _readFromExpr();
2617  else if (MATCH("ONCONFLICTEXPR", 14))
2618  return_value = _readOnConflictExpr();
2619  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
2620  return_value = _readPartitionPruneStepOp();
2621  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
2622  return_value = _readPartitionPruneStepCombine();
2623  else if (MATCH("PARTITIONPRUNEINFO", 18))
2624  return_value = _readPartitionPruneInfo();
2625  else if (MATCH("RTE", 3))
2626  return_value = _readRangeTblEntry();
2627  else if (MATCH("RANGETBLFUNCTION", 16))
2628  return_value = _readRangeTblFunction();
2629  else if (MATCH("TABLESAMPLECLAUSE", 17))
2630  return_value = _readTableSampleClause();
2631  else if (MATCH("NOTIFY", 6))
2632  return_value = _readNotifyStmt();
2633  else if (MATCH("DEFELEM", 7))
2634  return_value = _readDefElem();
2635  else if (MATCH("DECLARECURSOR", 13))
2636  return_value = _readDeclareCursorStmt();
2637  else if (MATCH("PLANNEDSTMT", 11))
2638  return_value = _readPlannedStmt();
2639  else if (MATCH("PLAN", 4))
2640  return_value = _readPlan();
2641  else if (MATCH("RESULT", 6))
2642  return_value = _readResult();
2643  else if (MATCH("PROJECTSET", 10))
2644  return_value = _readProjectSet();
2645  else if (MATCH("MODIFYTABLE", 11))
2646  return_value = _readModifyTable();
2647  else if (MATCH("APPEND", 6))
2648  return_value = _readAppend();
2649  else if (MATCH("MERGEAPPEND", 11))
2650  return_value = _readMergeAppend();
2651  else if (MATCH("RECURSIVEUNION", 14))
2652  return_value = _readRecursiveUnion();
2653  else if (MATCH("BITMAPAND", 9))
2654  return_value = _readBitmapAnd();
2655  else if (MATCH("BITMAPOR", 8))
2656  return_value = _readBitmapOr();
2657  else if (MATCH("SCAN", 4))
2658  return_value = _readScan();
2659  else if (MATCH("SEQSCAN", 7))
2660  return_value = _readSeqScan();
2661  else if (MATCH("SAMPLESCAN", 10))
2662  return_value = _readSampleScan();
2663  else if (MATCH("INDEXSCAN", 9))
2664  return_value = _readIndexScan();
2665  else if (MATCH("INDEXONLYSCAN", 13))
2666  return_value = _readIndexOnlyScan();
2667  else if (MATCH("BITMAPINDEXSCAN", 15))
2668  return_value = _readBitmapIndexScan();
2669  else if (MATCH("BITMAPHEAPSCAN", 14))
2670  return_value = _readBitmapHeapScan();
2671  else if (MATCH("TIDSCAN", 7))
2672  return_value = _readTidScan();
2673  else if (MATCH("SUBQUERYSCAN", 12))
2674  return_value = _readSubqueryScan();
2675  else if (MATCH("FUNCTIONSCAN", 12))
2676  return_value = _readFunctionScan();
2677  else if (MATCH("VALUESSCAN", 10))
2678  return_value = _readValuesScan();
2679  else if (MATCH("TABLEFUNCSCAN", 13))
2680  return_value = _readTableFuncScan();
2681  else if (MATCH("CTESCAN", 7))
2682  return_value = _readCteScan();
2683  else if (MATCH("WORKTABLESCAN", 13))
2684  return_value = _readWorkTableScan();
2685  else if (MATCH("FOREIGNSCAN", 11))
2686  return_value = _readForeignScan();
2687  else if (MATCH("CUSTOMSCAN", 10))
2688  return_value = _readCustomScan();
2689  else if (MATCH("JOIN", 4))
2690  return_value = _readJoin();
2691  else if (MATCH("NESTLOOP", 8))
2692  return_value = _readNestLoop();
2693  else if (MATCH("MERGEJOIN", 9))
2694  return_value = _readMergeJoin();
2695  else if (MATCH("HASHJOIN", 8))
2696  return_value = _readHashJoin();
2697  else if (MATCH("MATERIAL", 8))
2698  return_value = _readMaterial();
2699  else if (MATCH("SORT", 4))
2700  return_value = _readSort();
2701  else if (MATCH("GROUP", 5))
2702  return_value = _readGroup();
2703  else if (MATCH("AGG", 3))
2704  return_value = _readAgg();
2705  else if (MATCH("WINDOWAGG", 9))
2706  return_value = _readWindowAgg();
2707  else if (MATCH("UNIQUE", 6))
2708  return_value = _readUnique();
2709  else if (MATCH("GATHER", 6))
2710  return_value = _readGather();
2711  else if (MATCH("GATHERMERGE", 11))
2712  return_value = _readGatherMerge();
2713  else if (MATCH("HASH", 4))
2714  return_value = _readHash();
2715  else if (MATCH("SETOP", 5))
2716  return_value = _readSetOp();
2717  else if (MATCH("LOCKROWS", 8))
2718  return_value = _readLockRows();
2719  else if (MATCH("LIMIT", 5))
2720  return_value = _readLimit();
2721  else if (MATCH("NESTLOOPPARAM", 13))
2722  return_value = _readNestLoopParam();
2723  else if (MATCH("PLANROWMARK", 11))
2724  return_value = _readPlanRowMark();
2725  else if (MATCH("PLANINVALITEM", 13))
2726  return_value = _readPlanInvalItem();
2727  else if (MATCH("SUBPLAN", 7))
2728  return_value = _readSubPlan();
2729  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2730  return_value = _readAlternativeSubPlan();
2731  else if (MATCH("EXTENSIBLENODE", 14))
2732  return_value = _readExtensibleNode();
2733  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2734  return_value = _readPartitionBoundSpec();
2735  else if (MATCH("PARTITIONRANGEDATUM", 19))
2736  return_value = _readPartitionRangeDatum();
2737  else
2738  {
2739  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2740  return_value = NULL; /* keep compiler quiet */
2741  }
2742 
2743  return (Node *) return_value;
2744 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1124
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1281
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:458
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1382
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1492
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1018
int length(const List *list)
Definition: list.c:1333
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2064
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1069
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:387
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:671
static Hash * _readHash(void)
Definition: readfuncs.c:2263
char * pg_strtok(int *length)
Definition: read.c:108
static Result * _readResult(void)
Definition: readfuncs.c:1582
static Query * _readQuery(void)
Definition: readfuncs.c:235
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1035
static Param * _readParam(void)
Definition: readfuncs.c:565
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2369
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:1358
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2176
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1789
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:283
static Scan * _readScan(void)
Definition: readfuncs.c:1748
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:692
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2303
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1205
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:937
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1877
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1829
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:952
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1892
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2454
static Unique * _readUnique(void)
Definition: readfuncs.c:2205
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1663
Definition: nodes.h:517
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:629
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:361
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:708
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1810
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1703
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1301
static Aggref * _readAggref(void)
Definition: readfuncs.c:583
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2049
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1610
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1220
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:728
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:902
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1249
static Agg * _readAgg(void)
Definition: readfuncs.c:2153
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1761
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2411
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1938
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:612
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1155
static SubLink * _readSubLink(void)
Definition: readfuncs.c:812
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2089
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:1346
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1908
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:921
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1315
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:748
static Append * _readAppend(void)
Definition: readfuncs.c:1645
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2424
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2349
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:834
static ArrayRef * _readArrayRef(void)
Definition: readfuncs.c:651
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:970
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1087
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1969
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:867
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2281
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:329
static Limit * _readLimit(void)
Definition: readfuncs.c:2319
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2474
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2241
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:297
static Gather * _readGather(void)
Definition: readfuncs.c:2222
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:53
static Var * _readVar(void)
Definition: readfuncs.c:519
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1774
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2383
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1862
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1173
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1923
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:500
static Const * _readConst(void)
Definition: readfuncs.c:540
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:425
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1509
static Material * _readMaterial(void)
Definition: readfuncs.c:2104
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:985
static Alias * _readAlias(void)
Definition: readfuncs.c:447
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1718
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1268
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1684
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:851
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1053
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1189
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:312
static PartitionPruneStepOp * _readPartitionPruneStepOp(void)
Definition: readfuncs.c:1332
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1234
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:768
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:786
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1991
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:403
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:1000
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1458
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1140
static Plan * _readPlan(void)
Definition: readfuncs.c:1569
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1103
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:478
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1477
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2335
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1597
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1847
static Join * _readJoin(void)
Definition: readfuncs.c:2036
static Sort * _readSort(void)
Definition: readfuncs.c:2117
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:885
static Group * _readGroup(void)
Definition: readfuncs.c:2136
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:346
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1954

◆ pg_strtok()

char* pg_strtok ( int *  length)

Definition at line 108 of file read.c.

References pg_strtok_ptr.

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

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