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:1618
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:522
return result
Definition: formatting.c:1618
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:2395
Definition: nodes.h:296
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 2395 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().

2396 {
2397  void *return_value;
2398 
2399  READ_TEMP_LOCALS();
2400 
2401  token = pg_strtok(&length);
2402 
2403 #define MATCH(tokname, namelen) \
2404  (length == namelen && memcmp(token, tokname, namelen) == 0)
2405 
2406  if (MATCH("QUERY", 5))
2407  return_value = _readQuery();
2408  else if (MATCH("WITHCHECKOPTION", 15))
2409  return_value = _readWithCheckOption();
2410  else if (MATCH("SORTGROUPCLAUSE", 15))
2411  return_value = _readSortGroupClause();
2412  else if (MATCH("GROUPINGSET", 11))
2413  return_value = _readGroupingSet();
2414  else if (MATCH("WINDOWCLAUSE", 12))
2415  return_value = _readWindowClause();
2416  else if (MATCH("ROWMARKCLAUSE", 13))
2417  return_value = _readRowMarkClause();
2418  else if (MATCH("COMMONTABLEEXPR", 15))
2419  return_value = _readCommonTableExpr();
2420  else if (MATCH("SETOPERATIONSTMT", 16))
2421  return_value = _readSetOperationStmt();
2422  else if (MATCH("ALIAS", 5))
2423  return_value = _readAlias();
2424  else if (MATCH("RANGEVAR", 8))
2425  return_value = _readRangeVar();
2426  else if (MATCH("INTOCLAUSE", 10))
2427  return_value = _readIntoClause();
2428  else if (MATCH("TABLEFUNC", 9))
2429  return_value = _readTableFunc();
2430  else if (MATCH("VAR", 3))
2431  return_value = _readVar();
2432  else if (MATCH("CONST", 5))
2433  return_value = _readConst();
2434  else if (MATCH("PARAM", 5))
2435  return_value = _readParam();
2436  else if (MATCH("AGGREF", 6))
2437  return_value = _readAggref();
2438  else if (MATCH("GROUPINGFUNC", 12))
2439  return_value = _readGroupingFunc();
2440  else if (MATCH("WINDOWFUNC", 10))
2441  return_value = _readWindowFunc();
2442  else if (MATCH("ARRAYREF", 8))
2443  return_value = _readArrayRef();
2444  else if (MATCH("FUNCEXPR", 8))
2445  return_value = _readFuncExpr();
2446  else if (MATCH("NAMEDARGEXPR", 12))
2447  return_value = _readNamedArgExpr();
2448  else if (MATCH("OPEXPR", 6))
2449  return_value = _readOpExpr();
2450  else if (MATCH("DISTINCTEXPR", 12))
2451  return_value = _readDistinctExpr();
2452  else if (MATCH("NULLIFEXPR", 10))
2453  return_value = _readNullIfExpr();
2454  else if (MATCH("SCALARARRAYOPEXPR", 17))
2455  return_value = _readScalarArrayOpExpr();
2456  else if (MATCH("BOOLEXPR", 8))
2457  return_value = _readBoolExpr();
2458  else if (MATCH("SUBLINK", 7))
2459  return_value = _readSubLink();
2460  else if (MATCH("FIELDSELECT", 11))
2461  return_value = _readFieldSelect();
2462  else if (MATCH("FIELDSTORE", 10))
2463  return_value = _readFieldStore();
2464  else if (MATCH("RELABELTYPE", 11))
2465  return_value = _readRelabelType();
2466  else if (MATCH("COERCEVIAIO", 11))
2467  return_value = _readCoerceViaIO();
2468  else if (MATCH("ARRAYCOERCEEXPR", 15))
2469  return_value = _readArrayCoerceExpr();
2470  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2471  return_value = _readConvertRowtypeExpr();
2472  else if (MATCH("COLLATE", 7))
2473  return_value = _readCollateExpr();
2474  else if (MATCH("CASE", 4))
2475  return_value = _readCaseExpr();
2476  else if (MATCH("WHEN", 4))
2477  return_value = _readCaseWhen();
2478  else if (MATCH("CASETESTEXPR", 12))
2479  return_value = _readCaseTestExpr();
2480  else if (MATCH("ARRAY", 5))
2481  return_value = _readArrayExpr();
2482  else if (MATCH("ROW", 3))
2483  return_value = _readRowExpr();
2484  else if (MATCH("ROWCOMPARE", 10))
2485  return_value = _readRowCompareExpr();
2486  else if (MATCH("COALESCE", 8))
2487  return_value = _readCoalesceExpr();
2488  else if (MATCH("MINMAX", 6))
2489  return_value = _readMinMaxExpr();
2490  else if (MATCH("SQLVALUEFUNCTION", 16))
2491  return_value = _readSQLValueFunction();
2492  else if (MATCH("XMLEXPR", 7))
2493  return_value = _readXmlExpr();
2494  else if (MATCH("NULLTEST", 8))
2495  return_value = _readNullTest();
2496  else if (MATCH("BOOLEANTEST", 11))
2497  return_value = _readBooleanTest();
2498  else if (MATCH("COERCETODOMAIN", 14))
2499  return_value = _readCoerceToDomain();
2500  else if (MATCH("COERCETODOMAINVALUE", 19))
2501  return_value = _readCoerceToDomainValue();
2502  else if (MATCH("SETTODEFAULT", 12))
2503  return_value = _readSetToDefault();
2504  else if (MATCH("CURRENTOFEXPR", 13))
2505  return_value = _readCurrentOfExpr();
2506  else if (MATCH("INFERENCEELEM", 13))
2507  return_value = _readInferenceElem();
2508  else if (MATCH("TARGETENTRY", 11))
2509  return_value = _readTargetEntry();
2510  else if (MATCH("RANGETBLREF", 11))
2511  return_value = _readRangeTblRef();
2512  else if (MATCH("JOINEXPR", 8))
2513  return_value = _readJoinExpr();
2514  else if (MATCH("FROMEXPR", 8))
2515  return_value = _readFromExpr();
2516  else if (MATCH("ONCONFLICTEXPR", 14))
2517  return_value = _readOnConflictExpr();
2518  else if (MATCH("RTE", 3))
2519  return_value = _readRangeTblEntry();
2520  else if (MATCH("RANGETBLFUNCTION", 16))
2521  return_value = _readRangeTblFunction();
2522  else if (MATCH("TABLESAMPLECLAUSE", 17))
2523  return_value = _readTableSampleClause();
2524  else if (MATCH("NOTIFY", 6))
2525  return_value = _readNotifyStmt();
2526  else if (MATCH("DEFELEM", 7))
2527  return_value = _readDefElem();
2528  else if (MATCH("DECLARECURSOR", 13))
2529  return_value = _readDeclareCursorStmt();
2530  else if (MATCH("PLANNEDSTMT", 11))
2531  return_value = _readPlannedStmt();
2532  else if (MATCH("PLAN", 4))
2533  return_value = _readPlan();
2534  else if (MATCH("RESULT", 6))
2535  return_value = _readResult();
2536  else if (MATCH("PROJECTSET", 10))
2537  return_value = _readProjectSet();
2538  else if (MATCH("MODIFYTABLE", 11))
2539  return_value = _readModifyTable();
2540  else if (MATCH("APPEND", 6))
2541  return_value = _readAppend();
2542  else if (MATCH("MERGEAPPEND", 11))
2543  return_value = _readMergeAppend();
2544  else if (MATCH("RECURSIVEUNION", 14))
2545  return_value = _readRecursiveUnion();
2546  else if (MATCH("BITMAPAND", 9))
2547  return_value = _readBitmapAnd();
2548  else if (MATCH("BITMAPOR", 8))
2549  return_value = _readBitmapOr();
2550  else if (MATCH("SCAN", 4))
2551  return_value = _readScan();
2552  else if (MATCH("SEQSCAN", 7))
2553  return_value = _readSeqScan();
2554  else if (MATCH("SAMPLESCAN", 10))
2555  return_value = _readSampleScan();
2556  else if (MATCH("INDEXSCAN", 9))
2557  return_value = _readIndexScan();
2558  else if (MATCH("INDEXONLYSCAN", 13))
2559  return_value = _readIndexOnlyScan();
2560  else if (MATCH("BITMAPINDEXSCAN", 15))
2561  return_value = _readBitmapIndexScan();
2562  else if (MATCH("BITMAPHEAPSCAN", 14))
2563  return_value = _readBitmapHeapScan();
2564  else if (MATCH("TIDSCAN", 7))
2565  return_value = _readTidScan();
2566  else if (MATCH("SUBQUERYSCAN", 12))
2567  return_value = _readSubqueryScan();
2568  else if (MATCH("FUNCTIONSCAN", 12))
2569  return_value = _readFunctionScan();
2570  else if (MATCH("VALUESSCAN", 10))
2571  return_value = _readValuesScan();
2572  else if (MATCH("TABLEFUNCSCAN", 13))
2573  return_value = _readTableFuncScan();
2574  else if (MATCH("CTESCAN", 7))
2575  return_value = _readCteScan();
2576  else if (MATCH("WORKTABLESCAN", 13))
2577  return_value = _readWorkTableScan();
2578  else if (MATCH("FOREIGNSCAN", 11))
2579  return_value = _readForeignScan();
2580  else if (MATCH("CUSTOMSCAN", 10))
2581  return_value = _readCustomScan();
2582  else if (MATCH("JOIN", 4))
2583  return_value = _readJoin();
2584  else if (MATCH("NESTLOOP", 8))
2585  return_value = _readNestLoop();
2586  else if (MATCH("MERGEJOIN", 9))
2587  return_value = _readMergeJoin();
2588  else if (MATCH("HASHJOIN", 8))
2589  return_value = _readHashJoin();
2590  else if (MATCH("MATERIAL", 8))
2591  return_value = _readMaterial();
2592  else if (MATCH("SORT", 4))
2593  return_value = _readSort();
2594  else if (MATCH("GROUP", 5))
2595  return_value = _readGroup();
2596  else if (MATCH("AGG", 3))
2597  return_value = _readAgg();
2598  else if (MATCH("WINDOWAGG", 9))
2599  return_value = _readWindowAgg();
2600  else if (MATCH("UNIQUE", 6))
2601  return_value = _readUnique();
2602  else if (MATCH("GATHER", 6))
2603  return_value = _readGather();
2604  else if (MATCH("GATHERMERGE", 11))
2605  return_value = _readGatherMerge();
2606  else if (MATCH("HASH", 4))
2607  return_value = _readHash();
2608  else if (MATCH("SETOP", 5))
2609  return_value = _readSetOp();
2610  else if (MATCH("LOCKROWS", 8))
2611  return_value = _readLockRows();
2612  else if (MATCH("LIMIT", 5))
2613  return_value = _readLimit();
2614  else if (MATCH("NESTLOOPPARAM", 13))
2615  return_value = _readNestLoopParam();
2616  else if (MATCH("PLANROWMARK", 11))
2617  return_value = _readPlanRowMark();
2618  else if (MATCH("PLANINVALITEM", 13))
2619  return_value = _readPlanInvalItem();
2620  else if (MATCH("SUBPLAN", 7))
2621  return_value = _readSubPlan();
2622  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2623  return_value = _readAlternativeSubPlan();
2624  else if (MATCH("EXTENSIBLENODE", 14))
2625  return_value = _readExtensibleNode();
2626  else if (MATCH("PARTITIONBOUND", 14))
2627  return_value = _readPartitionBoundSpec();
2628  else if (MATCH("PARTRANGEDATUM", 14))
2629  return_value = _readPartitionRangeDatum();
2630  else
2631  {
2632  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2633  return_value = NULL; /* keep compiler quiet */
2634  }
2635 
2636  return (Node *) return_value;
2637 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1112
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1255
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:444
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1313
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1415
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1006
int length(const List *list)
Definition: list.c:1271
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:1979
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1057
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:373
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:658
static Hash * _readHash(void)
Definition: readfuncs.c:2168
char * pg_strtok(int *length)
Definition: read.c:107
static Result * _readResult(void)
Definition: readfuncs.c:1502
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:2275
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2090
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1705
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:274
static Scan * _readScan(void)
Definition: readfuncs.c:1664
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:679
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2209
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1193
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:925
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1793
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1745
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:940
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1808
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2360
static Unique * _readUnique(void)
Definition: readfuncs.c:2114
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1579
Definition: nodes.h:522
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:616
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:352
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:695
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1726
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1619
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1275
static Aggref * _readAggref(void)
Definition: readfuncs.c:570
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:1964
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1530
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:2067
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1677
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2317
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1854
#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:2003
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1824
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:1563
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2330
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2255
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:1885
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:854
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2187
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:320
static Limit * _readLimit(void)
Definition: readfuncs.c:2225
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2376
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2148
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:288
static Gather * _readGather(void)
Definition: readfuncs.c:2131
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:52
static Var * _readVar(void)
Definition: readfuncs.c:506
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1690
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2289
#define NULL
Definition: c.h:229
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1778
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1161
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1839
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:487
static Const * _readConst(void)
Definition: readfuncs.c:527
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:411
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1432
static Material * _readMaterial(void)
Definition: readfuncs.c:2018
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:973
static Alias * _readAlias(void)
Definition: readfuncs.c:433
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1634
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1242
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1600
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:303
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:1907
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:389
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:988
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1381
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1128
static Plan * _readPlan(void)
Definition: readfuncs.c:1489
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1091
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:465
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1400
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2241
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1517
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1763
static Join * _readJoin(void)
Definition: readfuncs.c:1951
static Sort * _readSort(void)
Definition: readfuncs.c:2031
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:872
static Group * _readGroup(void)
Definition: readfuncs.c:2050
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:337
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1870
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