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

Go to the source code of this file.

Functions

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

Function Documentation

char* debackslash ( char *  token,
int  length 
)

Definition at line 168 of file read.c.

References palloc().

Referenced by nodeRead().

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

Definition at line 278 of file read.c.

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

Referenced by nodeRead(), and stringToNode().

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

Definition at line 2432 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(), _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().

2433 {
2434  void *return_value;
2435 
2436  READ_TEMP_LOCALS();
2437 
2438  token = pg_strtok(&length);
2439 
2440 #define MATCH(tokname, namelen) \
2441  (length == namelen && memcmp(token, tokname, namelen) == 0)
2442 
2443  if (MATCH("QUERY", 5))
2444  return_value = _readQuery();
2445  else if (MATCH("WITHCHECKOPTION", 15))
2446  return_value = _readWithCheckOption();
2447  else if (MATCH("SORTGROUPCLAUSE", 15))
2448  return_value = _readSortGroupClause();
2449  else if (MATCH("GROUPINGSET", 11))
2450  return_value = _readGroupingSet();
2451  else if (MATCH("WINDOWCLAUSE", 12))
2452  return_value = _readWindowClause();
2453  else if (MATCH("ROWMARKCLAUSE", 13))
2454  return_value = _readRowMarkClause();
2455  else if (MATCH("COMMONTABLEEXPR", 15))
2456  return_value = _readCommonTableExpr();
2457  else if (MATCH("SETOPERATIONSTMT", 16))
2458  return_value = _readSetOperationStmt();
2459  else if (MATCH("ALIAS", 5))
2460  return_value = _readAlias();
2461  else if (MATCH("RANGEVAR", 8))
2462  return_value = _readRangeVar();
2463  else if (MATCH("INTOCLAUSE", 10))
2464  return_value = _readIntoClause();
2465  else if (MATCH("TABLEFUNC", 9))
2466  return_value = _readTableFunc();
2467  else if (MATCH("VAR", 3))
2468  return_value = _readVar();
2469  else if (MATCH("CONST", 5))
2470  return_value = _readConst();
2471  else if (MATCH("PARAM", 5))
2472  return_value = _readParam();
2473  else if (MATCH("AGGREF", 6))
2474  return_value = _readAggref();
2475  else if (MATCH("GROUPINGFUNC", 12))
2476  return_value = _readGroupingFunc();
2477  else if (MATCH("WINDOWFUNC", 10))
2478  return_value = _readWindowFunc();
2479  else if (MATCH("ARRAYREF", 8))
2480  return_value = _readArrayRef();
2481  else if (MATCH("FUNCEXPR", 8))
2482  return_value = _readFuncExpr();
2483  else if (MATCH("NAMEDARGEXPR", 12))
2484  return_value = _readNamedArgExpr();
2485  else if (MATCH("OPEXPR", 6))
2486  return_value = _readOpExpr();
2487  else if (MATCH("DISTINCTEXPR", 12))
2488  return_value = _readDistinctExpr();
2489  else if (MATCH("NULLIFEXPR", 10))
2490  return_value = _readNullIfExpr();
2491  else if (MATCH("SCALARARRAYOPEXPR", 17))
2492  return_value = _readScalarArrayOpExpr();
2493  else if (MATCH("BOOLEXPR", 8))
2494  return_value = _readBoolExpr();
2495  else if (MATCH("SUBLINK", 7))
2496  return_value = _readSubLink();
2497  else if (MATCH("FIELDSELECT", 11))
2498  return_value = _readFieldSelect();
2499  else if (MATCH("FIELDSTORE", 10))
2500  return_value = _readFieldStore();
2501  else if (MATCH("RELABELTYPE", 11))
2502  return_value = _readRelabelType();
2503  else if (MATCH("COERCEVIAIO", 11))
2504  return_value = _readCoerceViaIO();
2505  else if (MATCH("ARRAYCOERCEEXPR", 15))
2506  return_value = _readArrayCoerceExpr();
2507  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2508  return_value = _readConvertRowtypeExpr();
2509  else if (MATCH("COLLATE", 7))
2510  return_value = _readCollateExpr();
2511  else if (MATCH("CASE", 4))
2512  return_value = _readCaseExpr();
2513  else if (MATCH("WHEN", 4))
2514  return_value = _readCaseWhen();
2515  else if (MATCH("CASETESTEXPR", 12))
2516  return_value = _readCaseTestExpr();
2517  else if (MATCH("ARRAY", 5))
2518  return_value = _readArrayExpr();
2519  else if (MATCH("ROW", 3))
2520  return_value = _readRowExpr();
2521  else if (MATCH("ROWCOMPARE", 10))
2522  return_value = _readRowCompareExpr();
2523  else if (MATCH("COALESCE", 8))
2524  return_value = _readCoalesceExpr();
2525  else if (MATCH("MINMAX", 6))
2526  return_value = _readMinMaxExpr();
2527  else if (MATCH("SQLVALUEFUNCTION", 16))
2528  return_value = _readSQLValueFunction();
2529  else if (MATCH("XMLEXPR", 7))
2530  return_value = _readXmlExpr();
2531  else if (MATCH("NULLTEST", 8))
2532  return_value = _readNullTest();
2533  else if (MATCH("BOOLEANTEST", 11))
2534  return_value = _readBooleanTest();
2535  else if (MATCH("COERCETODOMAIN", 14))
2536  return_value = _readCoerceToDomain();
2537  else if (MATCH("COERCETODOMAINVALUE", 19))
2538  return_value = _readCoerceToDomainValue();
2539  else if (MATCH("SETTODEFAULT", 12))
2540  return_value = _readSetToDefault();
2541  else if (MATCH("CURRENTOFEXPR", 13))
2542  return_value = _readCurrentOfExpr();
2543  else if (MATCH("NEXTVALUEEXPR", 13))
2544  return_value = _readNextValueExpr();
2545  else if (MATCH("INFERENCEELEM", 13))
2546  return_value = _readInferenceElem();
2547  else if (MATCH("TARGETENTRY", 11))
2548  return_value = _readTargetEntry();
2549  else if (MATCH("RANGETBLREF", 11))
2550  return_value = _readRangeTblRef();
2551  else if (MATCH("JOINEXPR", 8))
2552  return_value = _readJoinExpr();
2553  else if (MATCH("FROMEXPR", 8))
2554  return_value = _readFromExpr();
2555  else if (MATCH("ONCONFLICTEXPR", 14))
2556  return_value = _readOnConflictExpr();
2557  else if (MATCH("RTE", 3))
2558  return_value = _readRangeTblEntry();
2559  else if (MATCH("RANGETBLFUNCTION", 16))
2560  return_value = _readRangeTblFunction();
2561  else if (MATCH("TABLESAMPLECLAUSE", 17))
2562  return_value = _readTableSampleClause();
2563  else if (MATCH("NOTIFY", 6))
2564  return_value = _readNotifyStmt();
2565  else if (MATCH("DEFELEM", 7))
2566  return_value = _readDefElem();
2567  else if (MATCH("DECLARECURSOR", 13))
2568  return_value = _readDeclareCursorStmt();
2569  else if (MATCH("PLANNEDSTMT", 11))
2570  return_value = _readPlannedStmt();
2571  else if (MATCH("PLAN", 4))
2572  return_value = _readPlan();
2573  else if (MATCH("RESULT", 6))
2574  return_value = _readResult();
2575  else if (MATCH("PROJECTSET", 10))
2576  return_value = _readProjectSet();
2577  else if (MATCH("MODIFYTABLE", 11))
2578  return_value = _readModifyTable();
2579  else if (MATCH("APPEND", 6))
2580  return_value = _readAppend();
2581  else if (MATCH("MERGEAPPEND", 11))
2582  return_value = _readMergeAppend();
2583  else if (MATCH("RECURSIVEUNION", 14))
2584  return_value = _readRecursiveUnion();
2585  else if (MATCH("BITMAPAND", 9))
2586  return_value = _readBitmapAnd();
2587  else if (MATCH("BITMAPOR", 8))
2588  return_value = _readBitmapOr();
2589  else if (MATCH("SCAN", 4))
2590  return_value = _readScan();
2591  else if (MATCH("SEQSCAN", 7))
2592  return_value = _readSeqScan();
2593  else if (MATCH("SAMPLESCAN", 10))
2594  return_value = _readSampleScan();
2595  else if (MATCH("INDEXSCAN", 9))
2596  return_value = _readIndexScan();
2597  else if (MATCH("INDEXONLYSCAN", 13))
2598  return_value = _readIndexOnlyScan();
2599  else if (MATCH("BITMAPINDEXSCAN", 15))
2600  return_value = _readBitmapIndexScan();
2601  else if (MATCH("BITMAPHEAPSCAN", 14))
2602  return_value = _readBitmapHeapScan();
2603  else if (MATCH("TIDSCAN", 7))
2604  return_value = _readTidScan();
2605  else if (MATCH("SUBQUERYSCAN", 12))
2606  return_value = _readSubqueryScan();
2607  else if (MATCH("FUNCTIONSCAN", 12))
2608  return_value = _readFunctionScan();
2609  else if (MATCH("VALUESSCAN", 10))
2610  return_value = _readValuesScan();
2611  else if (MATCH("TABLEFUNCSCAN", 13))
2612  return_value = _readTableFuncScan();
2613  else if (MATCH("CTESCAN", 7))
2614  return_value = _readCteScan();
2615  else if (MATCH("WORKTABLESCAN", 13))
2616  return_value = _readWorkTableScan();
2617  else if (MATCH("FOREIGNSCAN", 11))
2618  return_value = _readForeignScan();
2619  else if (MATCH("CUSTOMSCAN", 10))
2620  return_value = _readCustomScan();
2621  else if (MATCH("JOIN", 4))
2622  return_value = _readJoin();
2623  else if (MATCH("NESTLOOP", 8))
2624  return_value = _readNestLoop();
2625  else if (MATCH("MERGEJOIN", 9))
2626  return_value = _readMergeJoin();
2627  else if (MATCH("HASHJOIN", 8))
2628  return_value = _readHashJoin();
2629  else if (MATCH("MATERIAL", 8))
2630  return_value = _readMaterial();
2631  else if (MATCH("SORT", 4))
2632  return_value = _readSort();
2633  else if (MATCH("GROUP", 5))
2634  return_value = _readGroup();
2635  else if (MATCH("AGG", 3))
2636  return_value = _readAgg();
2637  else if (MATCH("WINDOWAGG", 9))
2638  return_value = _readWindowAgg();
2639  else if (MATCH("UNIQUE", 6))
2640  return_value = _readUnique();
2641  else if (MATCH("GATHER", 6))
2642  return_value = _readGather();
2643  else if (MATCH("GATHERMERGE", 11))
2644  return_value = _readGatherMerge();
2645  else if (MATCH("HASH", 4))
2646  return_value = _readHash();
2647  else if (MATCH("SETOP", 5))
2648  return_value = _readSetOp();
2649  else if (MATCH("LOCKROWS", 8))
2650  return_value = _readLockRows();
2651  else if (MATCH("LIMIT", 5))
2652  return_value = _readLimit();
2653  else if (MATCH("NESTLOOPPARAM", 13))
2654  return_value = _readNestLoopParam();
2655  else if (MATCH("PLANROWMARK", 11))
2656  return_value = _readPlanRowMark();
2657  else if (MATCH("PLANINVALITEM", 13))
2658  return_value = _readPlanInvalItem();
2659  else if (MATCH("SUBPLAN", 7))
2660  return_value = _readSubPlan();
2661  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2662  return_value = _readAlternativeSubPlan();
2663  else if (MATCH("EXTENSIBLENODE", 14))
2664  return_value = _readExtensibleNode();
2665  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2666  return_value = _readPartitionBoundSpec();
2667  else if (MATCH("PARTITIONRANGEDATUM", 19))
2668  return_value = _readPartitionRangeDatum();
2669  else
2670  {
2671  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2672  return_value = NULL; /* keep compiler quiet */
2673  }
2674 
2675  return (Node *) return_value;
2676 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1119
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1276
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:453
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1334
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1444
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1013
int length(const List *list)
Definition: list.c:1271
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2012
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1064
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:382
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:666
static Hash * _readHash(void)
Definition: readfuncs.c:2204
char * pg_strtok(int *length)
Definition: read.c:107
static Result * _readResult(void)
Definition: readfuncs.c:1533
static Query * _readQuery(void)
Definition: readfuncs.c:235
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1030
static Param * _readParam(void)
Definition: readfuncs.c:560
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2309
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2124
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1737
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:283
static Scan * _readScan(void)
Definition: readfuncs.c:1696
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:687
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2243
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1200
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:932
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1825
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1777
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:947
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1840
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2394
static Unique * _readUnique(void)
Definition: readfuncs.c:2148
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1611
Definition: nodes.h:510
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:624
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:361
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:703
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1758
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1651
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1296
static Aggref * _readAggref(void)
Definition: readfuncs.c:578
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:1997
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1561
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1215
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:723
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:897
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1244
static Agg * _readAgg(void)
Definition: readfuncs.c:2101
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1709
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2351
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1886
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:607
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1150
static SubLink * _readSubLink(void)
Definition: readfuncs.c:807
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2037
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1856
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:916
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1310
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:743
static Append * _readAppend(void)
Definition: readfuncs.c:1595
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2364
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2289
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:829
static ArrayRef * _readArrayRef(void)
Definition: readfuncs.c:646
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:965
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1082
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1917
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:862
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2221
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:329
static Limit * _readLimit(void)
Definition: readfuncs.c:2259
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2412
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2183
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:297
static Gather * _readGather(void)
Definition: readfuncs.c:2165
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:53
static Var * _readVar(void)
Definition: readfuncs.c:514
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1722
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2323
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1810
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1168
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1871
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:495
static Const * _readConst(void)
Definition: readfuncs.c:535
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:420
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1461
static Material * _readMaterial(void)
Definition: readfuncs.c:2052
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:980
static Alias * _readAlias(void)
Definition: readfuncs.c:442
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1666
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1263
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1632
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:846
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1048
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1184
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:312
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1229
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:763
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:781
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1939
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:398
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:995
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1410
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1135
static Plan * _readPlan(void)
Definition: readfuncs.c:1520
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1098
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:473
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1429
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2275
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1548
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1795
static Join * _readJoin(void)
Definition: readfuncs.c:1984
static Sort * _readSort(void)
Definition: readfuncs.c:2065
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:880
static Group * _readGroup(void)
Definition: readfuncs.c:2084
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:346
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1902
char* pg_strtok ( int *  length)

Definition at line 107 of file read.c.

References pg_strtok_ptr.

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

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