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(), and result.

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
return result
Definition: formatting.c:1633
void * palloc(Size size)
Definition: mcxt.c:849
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(), NULL, OTHER_TOKEN, palloc(), parseNodeString(), pg_strtok(), result, 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:509
return result
Definition: formatting.c:1633
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
#define NULL
Definition: c.h:229
Node * parseNodeString(void)
Definition: readfuncs.c:2408
Definition: nodes.h:283
void * palloc(Size size)
Definition: mcxt.c:849
#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 2408 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(), _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, NULL, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

2409 {
2410  void *return_value;
2411 
2412  READ_TEMP_LOCALS();
2413 
2414  token = pg_strtok(&length);
2415 
2416 #define MATCH(tokname, namelen) \
2417  (length == namelen && memcmp(token, tokname, namelen) == 0)
2418 
2419  if (MATCH("QUERY", 5))
2420  return_value = _readQuery();
2421  else if (MATCH("WITHCHECKOPTION", 15))
2422  return_value = _readWithCheckOption();
2423  else if (MATCH("SORTGROUPCLAUSE", 15))
2424  return_value = _readSortGroupClause();
2425  else if (MATCH("GROUPINGSET", 11))
2426  return_value = _readGroupingSet();
2427  else if (MATCH("WINDOWCLAUSE", 12))
2428  return_value = _readWindowClause();
2429  else if (MATCH("ROWMARKCLAUSE", 13))
2430  return_value = _readRowMarkClause();
2431  else if (MATCH("COMMONTABLEEXPR", 15))
2432  return_value = _readCommonTableExpr();
2433  else if (MATCH("SETOPERATIONSTMT", 16))
2434  return_value = _readSetOperationStmt();
2435  else if (MATCH("ALIAS", 5))
2436  return_value = _readAlias();
2437  else if (MATCH("RANGEVAR", 8))
2438  return_value = _readRangeVar();
2439  else if (MATCH("INTOCLAUSE", 10))
2440  return_value = _readIntoClause();
2441  else if (MATCH("TABLEFUNC", 9))
2442  return_value = _readTableFunc();
2443  else if (MATCH("VAR", 3))
2444  return_value = _readVar();
2445  else if (MATCH("CONST", 5))
2446  return_value = _readConst();
2447  else if (MATCH("PARAM", 5))
2448  return_value = _readParam();
2449  else if (MATCH("AGGREF", 6))
2450  return_value = _readAggref();
2451  else if (MATCH("GROUPINGFUNC", 12))
2452  return_value = _readGroupingFunc();
2453  else if (MATCH("WINDOWFUNC", 10))
2454  return_value = _readWindowFunc();
2455  else if (MATCH("ARRAYREF", 8))
2456  return_value = _readArrayRef();
2457  else if (MATCH("FUNCEXPR", 8))
2458  return_value = _readFuncExpr();
2459  else if (MATCH("NAMEDARGEXPR", 12))
2460  return_value = _readNamedArgExpr();
2461  else if (MATCH("OPEXPR", 6))
2462  return_value = _readOpExpr();
2463  else if (MATCH("DISTINCTEXPR", 12))
2464  return_value = _readDistinctExpr();
2465  else if (MATCH("NULLIFEXPR", 10))
2466  return_value = _readNullIfExpr();
2467  else if (MATCH("SCALARARRAYOPEXPR", 17))
2468  return_value = _readScalarArrayOpExpr();
2469  else if (MATCH("BOOLEXPR", 8))
2470  return_value = _readBoolExpr();
2471  else if (MATCH("SUBLINK", 7))
2472  return_value = _readSubLink();
2473  else if (MATCH("FIELDSELECT", 11))
2474  return_value = _readFieldSelect();
2475  else if (MATCH("FIELDSTORE", 10))
2476  return_value = _readFieldStore();
2477  else if (MATCH("RELABELTYPE", 11))
2478  return_value = _readRelabelType();
2479  else if (MATCH("COERCEVIAIO", 11))
2480  return_value = _readCoerceViaIO();
2481  else if (MATCH("ARRAYCOERCEEXPR", 15))
2482  return_value = _readArrayCoerceExpr();
2483  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2484  return_value = _readConvertRowtypeExpr();
2485  else if (MATCH("COLLATE", 7))
2486  return_value = _readCollateExpr();
2487  else if (MATCH("CASE", 4))
2488  return_value = _readCaseExpr();
2489  else if (MATCH("WHEN", 4))
2490  return_value = _readCaseWhen();
2491  else if (MATCH("CASETESTEXPR", 12))
2492  return_value = _readCaseTestExpr();
2493  else if (MATCH("ARRAY", 5))
2494  return_value = _readArrayExpr();
2495  else if (MATCH("ROW", 3))
2496  return_value = _readRowExpr();
2497  else if (MATCH("ROWCOMPARE", 10))
2498  return_value = _readRowCompareExpr();
2499  else if (MATCH("COALESCE", 8))
2500  return_value = _readCoalesceExpr();
2501  else if (MATCH("MINMAX", 6))
2502  return_value = _readMinMaxExpr();
2503  else if (MATCH("SQLVALUEFUNCTION", 16))
2504  return_value = _readSQLValueFunction();
2505  else if (MATCH("XMLEXPR", 7))
2506  return_value = _readXmlExpr();
2507  else if (MATCH("NULLTEST", 8))
2508  return_value = _readNullTest();
2509  else if (MATCH("BOOLEANTEST", 11))
2510  return_value = _readBooleanTest();
2511  else if (MATCH("COERCETODOMAIN", 14))
2512  return_value = _readCoerceToDomain();
2513  else if (MATCH("COERCETODOMAINVALUE", 19))
2514  return_value = _readCoerceToDomainValue();
2515  else if (MATCH("SETTODEFAULT", 12))
2516  return_value = _readSetToDefault();
2517  else if (MATCH("CURRENTOFEXPR", 13))
2518  return_value = _readCurrentOfExpr();
2519  else if (MATCH("INFERENCEELEM", 13))
2520  return_value = _readInferenceElem();
2521  else if (MATCH("TARGETENTRY", 11))
2522  return_value = _readTargetEntry();
2523  else if (MATCH("RANGETBLREF", 11))
2524  return_value = _readRangeTblRef();
2525  else if (MATCH("JOINEXPR", 8))
2526  return_value = _readJoinExpr();
2527  else if (MATCH("FROMEXPR", 8))
2528  return_value = _readFromExpr();
2529  else if (MATCH("ONCONFLICTEXPR", 14))
2530  return_value = _readOnConflictExpr();
2531  else if (MATCH("RTE", 3))
2532  return_value = _readRangeTblEntry();
2533  else if (MATCH("RANGETBLFUNCTION", 16))
2534  return_value = _readRangeTblFunction();
2535  else if (MATCH("TABLESAMPLECLAUSE", 17))
2536  return_value = _readTableSampleClause();
2537  else if (MATCH("NOTIFY", 6))
2538  return_value = _readNotifyStmt();
2539  else if (MATCH("DEFELEM", 7))
2540  return_value = _readDefElem();
2541  else if (MATCH("DECLARECURSOR", 13))
2542  return_value = _readDeclareCursorStmt();
2543  else if (MATCH("PLANNEDSTMT", 11))
2544  return_value = _readPlannedStmt();
2545  else if (MATCH("PLAN", 4))
2546  return_value = _readPlan();
2547  else if (MATCH("RESULT", 6))
2548  return_value = _readResult();
2549  else if (MATCH("PROJECTSET", 10))
2550  return_value = _readProjectSet();
2551  else if (MATCH("MODIFYTABLE", 11))
2552  return_value = _readModifyTable();
2553  else if (MATCH("APPEND", 6))
2554  return_value = _readAppend();
2555  else if (MATCH("MERGEAPPEND", 11))
2556  return_value = _readMergeAppend();
2557  else if (MATCH("RECURSIVEUNION", 14))
2558  return_value = _readRecursiveUnion();
2559  else if (MATCH("BITMAPAND", 9))
2560  return_value = _readBitmapAnd();
2561  else if (MATCH("BITMAPOR", 8))
2562  return_value = _readBitmapOr();
2563  else if (MATCH("SCAN", 4))
2564  return_value = _readScan();
2565  else if (MATCH("SEQSCAN", 7))
2566  return_value = _readSeqScan();
2567  else if (MATCH("SAMPLESCAN", 10))
2568  return_value = _readSampleScan();
2569  else if (MATCH("INDEXSCAN", 9))
2570  return_value = _readIndexScan();
2571  else if (MATCH("INDEXONLYSCAN", 13))
2572  return_value = _readIndexOnlyScan();
2573  else if (MATCH("BITMAPINDEXSCAN", 15))
2574  return_value = _readBitmapIndexScan();
2575  else if (MATCH("BITMAPHEAPSCAN", 14))
2576  return_value = _readBitmapHeapScan();
2577  else if (MATCH("TIDSCAN", 7))
2578  return_value = _readTidScan();
2579  else if (MATCH("SUBQUERYSCAN", 12))
2580  return_value = _readSubqueryScan();
2581  else if (MATCH("FUNCTIONSCAN", 12))
2582  return_value = _readFunctionScan();
2583  else if (MATCH("VALUESSCAN", 10))
2584  return_value = _readValuesScan();
2585  else if (MATCH("TABLEFUNCSCAN", 13))
2586  return_value = _readTableFuncScan();
2587  else if (MATCH("CTESCAN", 7))
2588  return_value = _readCteScan();
2589  else if (MATCH("WORKTABLESCAN", 13))
2590  return_value = _readWorkTableScan();
2591  else if (MATCH("FOREIGNSCAN", 11))
2592  return_value = _readForeignScan();
2593  else if (MATCH("CUSTOMSCAN", 10))
2594  return_value = _readCustomScan();
2595  else if (MATCH("JOIN", 4))
2596  return_value = _readJoin();
2597  else if (MATCH("NESTLOOP", 8))
2598  return_value = _readNestLoop();
2599  else if (MATCH("MERGEJOIN", 9))
2600  return_value = _readMergeJoin();
2601  else if (MATCH("HASHJOIN", 8))
2602  return_value = _readHashJoin();
2603  else if (MATCH("MATERIAL", 8))
2604  return_value = _readMaterial();
2605  else if (MATCH("SORT", 4))
2606  return_value = _readSort();
2607  else if (MATCH("GROUP", 5))
2608  return_value = _readGroup();
2609  else if (MATCH("AGG", 3))
2610  return_value = _readAgg();
2611  else if (MATCH("WINDOWAGG", 9))
2612  return_value = _readWindowAgg();
2613  else if (MATCH("UNIQUE", 6))
2614  return_value = _readUnique();
2615  else if (MATCH("GATHER", 6))
2616  return_value = _readGather();
2617  else if (MATCH("GATHERMERGE", 11))
2618  return_value = _readGatherMerge();
2619  else if (MATCH("HASH", 4))
2620  return_value = _readHash();
2621  else if (MATCH("SETOP", 5))
2622  return_value = _readSetOp();
2623  else if (MATCH("LOCKROWS", 8))
2624  return_value = _readLockRows();
2625  else if (MATCH("LIMIT", 5))
2626  return_value = _readLimit();
2627  else if (MATCH("NESTLOOPPARAM", 13))
2628  return_value = _readNestLoopParam();
2629  else if (MATCH("PLANROWMARK", 11))
2630  return_value = _readPlanRowMark();
2631  else if (MATCH("PLANINVALITEM", 13))
2632  return_value = _readPlanInvalItem();
2633  else if (MATCH("SUBPLAN", 7))
2634  return_value = _readSubPlan();
2635  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2636  return_value = _readAlternativeSubPlan();
2637  else if (MATCH("EXTENSIBLENODE", 14))
2638  return_value = _readExtensibleNode();
2639  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2640  return_value = _readPartitionBoundSpec();
2641  else if (MATCH("PARTITIONRANGEDATUM", 19))
2642  return_value = _readPartitionRangeDatum();
2643  else
2644  {
2645  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2646  return_value = NULL; /* keep compiler quiet */
2647  }
2648 
2649  return (Node *) return_value;
2650 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1112
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1255
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:445
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1313
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1423
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1006
int length(const List *list)
Definition: list.c:1271
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:1991
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1057
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:374
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:658
static Hash * _readHash(void)
Definition: readfuncs.c:2181
char * pg_strtok(int *length)
Definition: read.c:107
static Result * _readResult(void)
Definition: readfuncs.c:1512
static Query * _readQuery(void)
Definition: readfuncs.c:227
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1023
static Param * _readParam(void)
Definition: readfuncs.c:552
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2286
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2103
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1716
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:275
static Scan * _readScan(void)
Definition: readfuncs.c:1675
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:679
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2220
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1193
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:925
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1804
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1756
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:940
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1819
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2371
static Unique * _readUnique(void)
Definition: readfuncs.c:2127
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1590
Definition: nodes.h:509
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:616
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:353
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:695
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1737
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1630
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1275
static Aggref * _readAggref(void)
Definition: readfuncs.c:570
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:1976
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1540
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:715
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:889
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1223
static Agg * _readAgg(void)
Definition: readfuncs.c:2080
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1688
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2328
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1865
#define ERROR
Definition: elog.h:43
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:599
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1143
static SubLink * _readSubLink(void)
Definition: readfuncs.c:799
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2016
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1835
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:909
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1289
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:735
static Append * _readAppend(void)
Definition: readfuncs.c:1574
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2341
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2266
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:821
static ArrayRef * _readArrayRef(void)
Definition: readfuncs.c:638
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:958
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1075
#define MATCH(tokname, namelen)
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1896
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:854
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2198
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:321
static Limit * _readLimit(void)
Definition: readfuncs.c:2236
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2388
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2161
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:289
static Gather * _readGather(void)
Definition: readfuncs.c:2144
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:52
static Var * _readVar(void)
Definition: readfuncs.c:506
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1701
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2300
#define NULL
Definition: c.h:229
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1789
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1161
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1850
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:487
static Const * _readConst(void)
Definition: readfuncs.c:527
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:412
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1440
static Material * _readMaterial(void)
Definition: readfuncs.c:2031
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:973
static Alias * _readAlias(void)
Definition: readfuncs.c:434
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1645
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1242
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1611
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:838
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1041
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1177
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:304
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1208
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:755
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:773
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1918
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:390
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:988
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1389
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1128
static Plan * _readPlan(void)
Definition: readfuncs.c:1499
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1091
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:465
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1408
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2252
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1527
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1774
static Join * _readJoin(void)
Definition: readfuncs.c:1963
static Sort * _readSort(void)
Definition: readfuncs.c:2044
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:872
static Group * _readGroup(void)
Definition: readfuncs.c:2063
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:338
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1881
char* pg_strtok ( int *  length)

Definition at line 107 of file read.c.

References NULL, and 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
#define NULL
Definition: c.h:229