PostgreSQL Source Code  git master
readfuncs.h File Reference
#include "nodes/nodes.h"
Include dependency graph for readfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

Function Documentation

◆ debackslash()

char* debackslash ( const char *  token,
int  length 
)

Definition at line 213 of file read.c.

214 {
215  char *result = palloc(length + 1);
216  char *ptr = result;
217 
218  while (length > 0)
219  {
220  if (*token == '\\' && length > 1)
221  token++, length--;
222  *ptr++ = *token++;
223  length--;
224  }
225  *ptr = '\0';
226  return result;
227 }
void * palloc(Size size)
Definition: mcxt.c:1068

References palloc().

Referenced by nodeRead().

◆ nodeRead()

void* nodeRead ( const char *  token,
int  tok_len 
)

Definition at line 319 of file read.c.

320 {
321  Node *result;
322  NodeTag type;
323 
324  if (token == NULL) /* need to read a token? */
325  {
326  token = pg_strtok(&tok_len);
327 
328  if (token == NULL) /* end of input */
329  return NULL;
330  }
331 
332  type = nodeTokenType(token, tok_len);
333 
334  switch ((int) type)
335  {
336  case LEFT_BRACE:
337  result = parseNodeString();
338  token = pg_strtok(&tok_len);
339  if (token == NULL || token[0] != '}')
340  elog(ERROR, "did not find '}' at end of input node");
341  break;
342  case LEFT_PAREN:
343  {
344  List *l = NIL;
345 
346  /*----------
347  * Could be an integer list: (i int int ...)
348  * or an OID list: (o int int ...)
349  * or a list of nodes/values: (node node ...)
350  *----------
351  */
352  token = pg_strtok(&tok_len);
353  if (token == NULL)
354  elog(ERROR, "unterminated List structure");
355  if (tok_len == 1 && token[0] == 'i')
356  {
357  /* List of integers */
358  for (;;)
359  {
360  int val;
361  char *endptr;
362 
363  token = pg_strtok(&tok_len);
364  if (token == NULL)
365  elog(ERROR, "unterminated List structure");
366  if (token[0] == ')')
367  break;
368  val = (int) strtol(token, &endptr, 10);
369  if (endptr != token + tok_len)
370  elog(ERROR, "unrecognized integer: \"%.*s\"",
371  tok_len, token);
372  l = lappend_int(l, val);
373  }
374  }
375  else if (tok_len == 1 && token[0] == 'o')
376  {
377  /* List of OIDs */
378  for (;;)
379  {
380  Oid val;
381  char *endptr;
382 
383  token = pg_strtok(&tok_len);
384  if (token == NULL)
385  elog(ERROR, "unterminated List structure");
386  if (token[0] == ')')
387  break;
388  val = (Oid) strtoul(token, &endptr, 10);
389  if (endptr != token + tok_len)
390  elog(ERROR, "unrecognized OID: \"%.*s\"",
391  tok_len, token);
392  l = lappend_oid(l, val);
393  }
394  }
395  else
396  {
397  /* List of other node types */
398  for (;;)
399  {
400  /* We have already scanned next token... */
401  if (token[0] == ')')
402  break;
403  l = lappend(l, nodeRead(token, tok_len));
404  token = pg_strtok(&tok_len);
405  if (token == NULL)
406  elog(ERROR, "unterminated List structure");
407  }
408  }
409  result = (Node *) l;
410  break;
411  }
412  case RIGHT_PAREN:
413  elog(ERROR, "unexpected right parenthesis");
414  result = NULL; /* keep compiler happy */
415  break;
416  case OTHER_TOKEN:
417  if (tok_len == 0)
418  {
419  /* must be "<>" --- represents a null pointer */
420  result = NULL;
421  }
422  else
423  {
424  elog(ERROR, "unrecognized token: \"%.*s\"", tok_len, token);
425  result = NULL; /* keep compiler happy */
426  }
427  break;
428  case T_Integer:
429 
430  /*
431  * we know that the token terminates on a char atoi will stop at
432  */
433  result = (Node *) makeInteger(atoi(token));
434  break;
435  case T_Float:
436  {
437  char *fval = (char *) palloc(tok_len + 1);
438 
439  memcpy(fval, token, tok_len);
440  fval[tok_len] = '\0';
441  result = (Node *) makeFloat(fval);
442  }
443  break;
444  case T_Boolean:
445  result = (Node *) makeBoolean(token[0] == 't');
446  break;
447  case T_String:
448  /* need to remove leading and trailing quotes, and backslashes */
449  result = (Node *) makeString(debackslash(token + 1, tok_len - 2));
450  break;
451  case T_BitString:
452  {
453  char *val = palloc(tok_len);
454 
455  /* skip leading 'b' */
456  memcpy(val, token + 1, tok_len - 1);
457  val[tok_len - 1] = '\0';
458  result = (Node *) makeBitString(val);
459  break;
460  }
461  default:
462  elog(ERROR, "unrecognized node type: %d", (int) type);
463  result = NULL; /* keep compiler happy */
464  break;
465  }
466 
467  return (void *) result;
468 }
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
long val
Definition: informix.c:664
List * lappend(List *list, void *datum)
Definition: list.c:336
List * lappend_int(List *list, int datum)
Definition: list.c:354
List * lappend_oid(List *list, Oid datum)
Definition: list.c:372
NodeTag
Definition: nodes.h:27
@ T_BitString
Definition: nodes.h:312
@ T_Float
Definition: nodes.h:309
@ T_String
Definition: nodes.h:311
@ T_Integer
Definition: nodes.h:308
@ T_Boolean
Definition: nodes.h:310
#define NIL
Definition: pg_list.h:65
unsigned int Oid
Definition: postgres_ext.h:31
#define LEFT_BRACE
Definition: read.c:231
#define OTHER_TOKEN
Definition: read.c:232
static NodeTag nodeTokenType(const char *token, int length)
Definition: read.c:245
const char * pg_strtok(int *length)
Definition: read.c:152
#define LEFT_PAREN
Definition: read.c:230
#define RIGHT_PAREN
Definition: read.c:229
char * debackslash(const char *token, int length)
Definition: read.c:213
void * nodeRead(const char *token, int tok_len)
Definition: read.c:319
Node * parseNodeString(void)
Definition: readfuncs.c:2950
Definition: pg_list.h:51
Definition: nodes.h:574
Boolean * makeBoolean(bool val)
Definition: value.c:49
Float * makeFloat(char *numericStr)
Definition: value.c:37
String * makeString(char *str)
Definition: value.c:63
BitString * makeBitString(char *str)
Definition: value.c:77
Integer * makeInteger(int i)
Definition: value.c:23

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

Referenced by stringToNodeInternal().

◆ parseNodeString()

Node* parseNodeString ( void  )

Definition at line 2950 of file readfuncs.c.

2951 {
2952  void *return_value;
2953 
2954  READ_TEMP_LOCALS();
2955 
2956  /* Guard against stack overflow due to overly complex expressions */
2958 
2959  token = pg_strtok(&length);
2960 
2961 #define MATCH(tokname, namelen) \
2962  (length == namelen && memcmp(token, tokname, namelen) == 0)
2963 
2964  if (MATCH("QUERY", 5))
2965  return_value = _readQuery();
2966  else if (MATCH("WITHCHECKOPTION", 15))
2967  return_value = _readWithCheckOption();
2968  else if (MATCH("SORTGROUPCLAUSE", 15))
2969  return_value = _readSortGroupClause();
2970  else if (MATCH("GROUPINGSET", 11))
2971  return_value = _readGroupingSet();
2972  else if (MATCH("WINDOWCLAUSE", 12))
2973  return_value = _readWindowClause();
2974  else if (MATCH("ROWMARKCLAUSE", 13))
2975  return_value = _readRowMarkClause();
2976  else if (MATCH("CTESEARCHCLAUSE", 15))
2977  return_value = _readCTESearchClause();
2978  else if (MATCH("CTECYCLECLAUSE", 14))
2979  return_value = _readCTECycleClause();
2980  else if (MATCH("COMMONTABLEEXPR", 15))
2981  return_value = _readCommonTableExpr();
2982  else if (MATCH("MERGEWHENCLAUSE", 15))
2983  return_value = _readMergeWhenClause();
2984  else if (MATCH("MERGEACTION", 11))
2985  return_value = _readMergeAction();
2986  else if (MATCH("SETOPERATIONSTMT", 16))
2987  return_value = _readSetOperationStmt();
2988  else if (MATCH("ALIAS", 5))
2989  return_value = _readAlias();
2990  else if (MATCH("RANGEVAR", 8))
2991  return_value = _readRangeVar();
2992  else if (MATCH("INTOCLAUSE", 10))
2993  return_value = _readIntoClause();
2994  else if (MATCH("TABLEFUNC", 9))
2995  return_value = _readTableFunc();
2996  else if (MATCH("VAR", 3))
2997  return_value = _readVar();
2998  else if (MATCH("CONST", 5))
2999  return_value = _readConst();
3000  else if (MATCH("PARAM", 5))
3001  return_value = _readParam();
3002  else if (MATCH("AGGREF", 6))
3003  return_value = _readAggref();
3004  else if (MATCH("GROUPINGFUNC", 12))
3005  return_value = _readGroupingFunc();
3006  else if (MATCH("WINDOWFUNC", 10))
3007  return_value = _readWindowFunc();
3008  else if (MATCH("SUBSCRIPTINGREF", 15))
3009  return_value = _readSubscriptingRef();
3010  else if (MATCH("FUNCEXPR", 8))
3011  return_value = _readFuncExpr();
3012  else if (MATCH("NAMEDARGEXPR", 12))
3013  return_value = _readNamedArgExpr();
3014  else if (MATCH("OPEXPR", 6))
3015  return_value = _readOpExpr();
3016  else if (MATCH("DISTINCTEXPR", 12))
3017  return_value = _readDistinctExpr();
3018  else if (MATCH("NULLIFEXPR", 10))
3019  return_value = _readNullIfExpr();
3020  else if (MATCH("SCALARARRAYOPEXPR", 17))
3021  return_value = _readScalarArrayOpExpr();
3022  else if (MATCH("BOOLEXPR", 8))
3023  return_value = _readBoolExpr();
3024  else if (MATCH("SUBLINK", 7))
3025  return_value = _readSubLink();
3026  else if (MATCH("FIELDSELECT", 11))
3027  return_value = _readFieldSelect();
3028  else if (MATCH("FIELDSTORE", 10))
3029  return_value = _readFieldStore();
3030  else if (MATCH("RELABELTYPE", 11))
3031  return_value = _readRelabelType();
3032  else if (MATCH("COERCEVIAIO", 11))
3033  return_value = _readCoerceViaIO();
3034  else if (MATCH("ARRAYCOERCEEXPR", 15))
3035  return_value = _readArrayCoerceExpr();
3036  else if (MATCH("CONVERTROWTYPEEXPR", 18))
3037  return_value = _readConvertRowtypeExpr();
3038  else if (MATCH("COLLATEEXPR", 11))
3039  return_value = _readCollateExpr();
3040  else if (MATCH("CASEEXPR", 8))
3041  return_value = _readCaseExpr();
3042  else if (MATCH("CASEWHEN", 8))
3043  return_value = _readCaseWhen();
3044  else if (MATCH("CASETESTEXPR", 12))
3045  return_value = _readCaseTestExpr();
3046  else if (MATCH("ARRAYEXPR", 9))
3047  return_value = _readArrayExpr();
3048  else if (MATCH("ROWEXPR", 7))
3049  return_value = _readRowExpr();
3050  else if (MATCH("ROWCOMPAREEXPR", 14))
3051  return_value = _readRowCompareExpr();
3052  else if (MATCH("COALESCEEXPR", 12))
3053  return_value = _readCoalesceExpr();
3054  else if (MATCH("MINMAXEXPR", 10))
3055  return_value = _readMinMaxExpr();
3056  else if (MATCH("SQLVALUEFUNCTION", 16))
3057  return_value = _readSQLValueFunction();
3058  else if (MATCH("XMLEXPR", 7))
3059  return_value = _readXmlExpr();
3060  else if (MATCH("NULLTEST", 8))
3061  return_value = _readNullTest();
3062  else if (MATCH("BOOLEANTEST", 11))
3063  return_value = _readBooleanTest();
3064  else if (MATCH("COERCETODOMAIN", 14))
3065  return_value = _readCoerceToDomain();
3066  else if (MATCH("COERCETODOMAINVALUE", 19))
3067  return_value = _readCoerceToDomainValue();
3068  else if (MATCH("SETTODEFAULT", 12))
3069  return_value = _readSetToDefault();
3070  else if (MATCH("CURRENTOFEXPR", 13))
3071  return_value = _readCurrentOfExpr();
3072  else if (MATCH("NEXTVALUEEXPR", 13))
3073  return_value = _readNextValueExpr();
3074  else if (MATCH("INFERENCEELEM", 13))
3075  return_value = _readInferenceElem();
3076  else if (MATCH("TARGETENTRY", 11))
3077  return_value = _readTargetEntry();
3078  else if (MATCH("RANGETBLREF", 11))
3079  return_value = _readRangeTblRef();
3080  else if (MATCH("JOINEXPR", 8))
3081  return_value = _readJoinExpr();
3082  else if (MATCH("FROMEXPR", 8))
3083  return_value = _readFromExpr();
3084  else if (MATCH("ONCONFLICTEXPR", 14))
3085  return_value = _readOnConflictExpr();
3086  else if (MATCH("APPENDRELINFO", 13))
3087  return_value = _readAppendRelInfo();
3088  else if (MATCH("RANGETBLENTRY", 13))
3089  return_value = _readRangeTblEntry();
3090  else if (MATCH("RANGETBLFUNCTION", 16))
3091  return_value = _readRangeTblFunction();
3092  else if (MATCH("TABLESAMPLECLAUSE", 17))
3093  return_value = _readTableSampleClause();
3094  else if (MATCH("NOTIFYSTMT", 10))
3095  return_value = _readNotifyStmt();
3096  else if (MATCH("DEFELEM", 7))
3097  return_value = _readDefElem();
3098  else if (MATCH("DECLARECURSORSTMT", 17))
3099  return_value = _readDeclareCursorStmt();
3100  else if (MATCH("PLANNEDSTMT", 11))
3101  return_value = _readPlannedStmt();
3102  else if (MATCH("PLAN", 4))
3103  return_value = _readPlan();
3104  else if (MATCH("RESULT", 6))
3105  return_value = _readResult();
3106  else if (MATCH("PROJECTSET", 10))
3107  return_value = _readProjectSet();
3108  else if (MATCH("MODIFYTABLE", 11))
3109  return_value = _readModifyTable();
3110  else if (MATCH("APPEND", 6))
3111  return_value = _readAppend();
3112  else if (MATCH("MERGEAPPEND", 11))
3113  return_value = _readMergeAppend();
3114  else if (MATCH("RECURSIVEUNION", 14))
3115  return_value = _readRecursiveUnion();
3116  else if (MATCH("BITMAPAND", 9))
3117  return_value = _readBitmapAnd();
3118  else if (MATCH("BITMAPOR", 8))
3119  return_value = _readBitmapOr();
3120  else if (MATCH("SCAN", 4))
3121  return_value = _readScan();
3122  else if (MATCH("SEQSCAN", 7))
3123  return_value = _readSeqScan();
3124  else if (MATCH("SAMPLESCAN", 10))
3125  return_value = _readSampleScan();
3126  else if (MATCH("INDEXSCAN", 9))
3127  return_value = _readIndexScan();
3128  else if (MATCH("INDEXONLYSCAN", 13))
3129  return_value = _readIndexOnlyScan();
3130  else if (MATCH("BITMAPINDEXSCAN", 15))
3131  return_value = _readBitmapIndexScan();
3132  else if (MATCH("BITMAPHEAPSCAN", 14))
3133  return_value = _readBitmapHeapScan();
3134  else if (MATCH("TIDSCAN", 7))
3135  return_value = _readTidScan();
3136  else if (MATCH("TIDRANGESCAN", 12))
3137  return_value = _readTidRangeScan();
3138  else if (MATCH("SUBQUERYSCAN", 12))
3139  return_value = _readSubqueryScan();
3140  else if (MATCH("FUNCTIONSCAN", 12))
3141  return_value = _readFunctionScan();
3142  else if (MATCH("VALUESSCAN", 10))
3143  return_value = _readValuesScan();
3144  else if (MATCH("TABLEFUNCSCAN", 13))
3145  return_value = _readTableFuncScan();
3146  else if (MATCH("CTESCAN", 7))
3147  return_value = _readCteScan();
3148  else if (MATCH("NAMEDTUPLESTORESCAN", 19))
3149  return_value = _readNamedTuplestoreScan();
3150  else if (MATCH("WORKTABLESCAN", 13))
3151  return_value = _readWorkTableScan();
3152  else if (MATCH("FOREIGNSCAN", 11))
3153  return_value = _readForeignScan();
3154  else if (MATCH("CUSTOMSCAN", 10))
3155  return_value = _readCustomScan();
3156  else if (MATCH("JOIN", 4))
3157  return_value = _readJoin();
3158  else if (MATCH("NESTLOOP", 8))
3159  return_value = _readNestLoop();
3160  else if (MATCH("MERGEJOIN", 9))
3161  return_value = _readMergeJoin();
3162  else if (MATCH("HASHJOIN", 8))
3163  return_value = _readHashJoin();
3164  else if (MATCH("MATERIAL", 8))
3165  return_value = _readMaterial();
3166  else if (MATCH("MEMOIZE", 7))
3167  return_value = _readMemoize();
3168  else if (MATCH("SORT", 4))
3169  return_value = _readSort();
3170  else if (MATCH("INCREMENTALSORT", 15))
3171  return_value = _readIncrementalSort();
3172  else if (MATCH("GROUP", 5))
3173  return_value = _readGroup();
3174  else if (MATCH("AGG", 3))
3175  return_value = _readAgg();
3176  else if (MATCH("WINDOWAGG", 9))
3177  return_value = _readWindowAgg();
3178  else if (MATCH("UNIQUE", 6))
3179  return_value = _readUnique();
3180  else if (MATCH("GATHER", 6))
3181  return_value = _readGather();
3182  else if (MATCH("GATHERMERGE", 11))
3183  return_value = _readGatherMerge();
3184  else if (MATCH("HASH", 4))
3185  return_value = _readHash();
3186  else if (MATCH("SETOP", 5))
3187  return_value = _readSetOp();
3188  else if (MATCH("LOCKROWS", 8))
3189  return_value = _readLockRows();
3190  else if (MATCH("LIMIT", 5))
3191  return_value = _readLimit();
3192  else if (MATCH("NESTLOOPPARAM", 13))
3193  return_value = _readNestLoopParam();
3194  else if (MATCH("PLANROWMARK", 11))
3195  return_value = _readPlanRowMark();
3196  else if (MATCH("PARTITIONPRUNEINFO", 18))
3197  return_value = _readPartitionPruneInfo();
3198  else if (MATCH("PARTITIONEDRELPRUNEINFO", 23))
3199  return_value = _readPartitionedRelPruneInfo();
3200  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
3201  return_value = _readPartitionPruneStepOp();
3202  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
3203  return_value = _readPartitionPruneStepCombine();
3204  else if (MATCH("PLANINVALITEM", 13))
3205  return_value = _readPlanInvalItem();
3206  else if (MATCH("SUBPLAN", 7))
3207  return_value = _readSubPlan();
3208  else if (MATCH("ALTERNATIVESUBPLAN", 18))
3209  return_value = _readAlternativeSubPlan();
3210  else if (MATCH("EXTENSIBLENODE", 14))
3211  return_value = _readExtensibleNode();
3212  else if (MATCH("PARTITIONBOUNDSPEC", 18))
3213  return_value = _readPartitionBoundSpec();
3214  else if (MATCH("PARTITIONRANGEDATUM", 19))
3215  return_value = _readPartitionRangeDatum();
3216  else if (MATCH("JSONFORMAT", 10))
3217  return_value = _readJsonFormat();
3218  else if (MATCH("JSONRETURNING", 13))
3219  return_value = _readJsonReturning();
3220  else if (MATCH("JSONVALUEEXPR", 13))
3221  return_value = _readJsonValueExpr();
3222  else if (MATCH("JSONCONSTRUCTOREXPR", 19))
3223  return_value = _readJsonConstructorExpr();
3224  else if (MATCH("JSONISPREDICATE", 15))
3225  return_value = _readJsonIsPredicate();
3226  else if (MATCH("JSONBEHAVIOR", 12))
3227  return_value = _readJsonBehavior();
3228  else if (MATCH("JSONEXPR", 8))
3229  return_value = _readJsonExpr();
3230  else if (MATCH("JSONCOERCION", 12))
3231  return_value = _readJsonCoercion();
3232  else if (MATCH("JSONITEMCOERCIONS", 17))
3233  return_value = _readJsonItemCoercions();
3234  else if (MATCH("JSONTABLEPARENT", 15))
3235  return_value = _readJsonTableParent();
3236  else if (MATCH("JSONTABLESIBLING", 16))
3237  return_value = _readJsonTableSibling();
3238  else
3239  {
3240  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
3241  return_value = NULL; /* keep compiler quiet */
3242  }
3243 
3244  return (Node *) return_value;
3245 }
void check_stack_depth(void)
Definition: postgres.c:3500
static MergeAction * _readMergeAction(void)
Definition: readfuncs.c:500
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1806
static JsonCoercion * _readJsonCoercion(void)
Definition: readfuncs.c:1571
static PartitionedRelPruneInfo * _readPartitionedRelPruneInfo(void)
Definition: readfuncs.c:2778
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:1039
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:987
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2825
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:327
static Alias * _readAlias(void)
Definition: readfuncs.c:540
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2736
static PartitionPruneStepOp * _readPartitionPruneStepOp(void)
Definition: readfuncs.c:2796
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1751
static JsonValueExpr * _readJsonValueExpr(void)
Definition: readfuncs.c:1468
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:2767
static Result * _readResult(void)
Definition: readfuncs.c:1879
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2867
static JsonConstructorExpr * _readJsonConstructorExpr(void)
Definition: readfuncs.c:1483
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2930
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:2286
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1257
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:2089
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:1004
static Group * _readGroup(void)
Definition: readfuncs.c:2521
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2564
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:792
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1120
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1275
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1657
static JsonTableParent * _readJsonTableParent(void)
Definition: readfuncs.c:1540
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:953
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:868
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:571
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2676
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:2240
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1155
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1770
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1785
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1370
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1242
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:771
static JsonFormat * _readJsonFormat(void)
Definition: readfuncs.c:1438
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:2018
static Const * _readConst(void)
Definition: readfuncs.c:637
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1383
static Sort * _readSort(void)
Definition: readfuncs.c:2493
static Aggref * _readAggref(void)
Definition: readfuncs.c:680
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1189
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:403
static IncrementalSort * _readIncrementalSort(void)
Definition: readfuncs.c:2506
static AppendRelInfo * _readAppendRelInfo(void)
Definition: readfuncs.c:1633
static Plan * _readPlan(void)
Definition: readfuncs.c:1866
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:551
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:1072
static Scan * _readScan(void)
Definition: readfuncs.c:2048
static Memoize * _readMemoize(void)
Definition: readfuncs.c:2453
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:1023
static Gather * _readGather(void)
Definition: readfuncs.c:2616
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:596
static TidScan * _readTidScan(void)
Definition: readfuncs.c:2163
static CTESearchClause * _readCTESearchClause(void)
Definition: readfuncs.c:419
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1336
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1322
static NamedTuplestoreScan * _readNamedTuplestoreScan(void)
Definition: readfuncs.c:2271
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:728
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2382
static JsonItemCoercions * _readJsonItemCoercions(void)
Definition: readfuncs.c:1587
static Agg * _readAgg(void)
Definition: readfuncs.c:2539
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:2324
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1961
static Var * _readVar(void)
Definition: readfuncs.c:616
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:457
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:2074
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1351
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1418
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:888
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1907
static CTECycleClause * _readCTECycleClause(void)
Definition: readfuncs.c:435
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:376
static JsonReturning * _readJsonReturning(void)
Definition: readfuncs.c:1453
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:2130
static Query * _readQuery(void)
Definition: readfuncs.c:245
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1307
static MergeWhenClause * _readMergeWhenClause(void)
Definition: readfuncs.c:482
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:2061
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2699
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:828
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:711
static JsonIsPredicate * _readJsonIsPredicate()
Definition: readfuncs.c:1609
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:312
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1404
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:298
static Hash * _readHash(void)
Definition: readfuncs.c:2657
static JsonExpr * _readJsonExpr(void)
Definition: readfuncs.c:1517
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2750
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:2110
static JsonBehavior * _readJsonBehavior(void)
Definition: readfuncs.c:1503
static JsonTableSibling * _readJsonTableSibling(void)
Definition: readfuncs.c:1556
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:2810
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2880
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1983
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:1102
static Append * _readAppend(void)
Definition: readfuncs.c:1942
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:2225
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1205
#define MATCH(tokname, namelen)
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:2209
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1291
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2397
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:2148
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:936
static Join * _readJoin(void)
Definition: readfuncs.c:2369
static SubscriptingRef * _readSubscriptingRef(void)
Definition: readfuncs.c:750
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:848
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1894
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2635
static CteScan * _readCteScan(void)
Definition: readfuncs.c:2255
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:518
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:1087
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:969
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1137
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2839
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2910
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1226
static Material * _readMaterial(void)
Definition: readfuncs.c:2440
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:1054
static Param * _readParam(void)
Definition: readfuncs.c:662
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:361
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2422
static SubLink * _readSubLink(void)
Definition: readfuncs.c:914
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:56
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:2193
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:2003
static TidRangeScan * _readTidRangeScan(void)
Definition: readfuncs.c:2178
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:808
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:344
static Unique * _readUnique(void)
Definition: readfuncs.c:2598
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1171
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:2301
static Limit * _readLimit(void)
Definition: readfuncs.c:2715

References _readAgg(), _readAggref(), _readAlias(), _readAlternativeSubPlan(), _readAppend(), _readAppendRelInfo(), _readArrayCoerceExpr(), _readArrayExpr(), _readBitmapAnd(), _readBitmapHeapScan(), _readBitmapIndexScan(), _readBitmapOr(), _readBooleanTest(), _readBoolExpr(), _readCaseExpr(), _readCaseTestExpr(), _readCaseWhen(), _readCoalesceExpr(), _readCoerceToDomain(), _readCoerceToDomainValue(), _readCoerceViaIO(), _readCollateExpr(), _readCommonTableExpr(), _readConst(), _readConvertRowtypeExpr(), _readCTECycleClause(), _readCteScan(), _readCTESearchClause(), _readCurrentOfExpr(), _readCustomScan(), _readDeclareCursorStmt(), _readDefElem(), _readDistinctExpr(), _readExtensibleNode(), _readFieldSelect(), _readFieldStore(), _readForeignScan(), _readFromExpr(), _readFuncExpr(), _readFunctionScan(), _readGather(), _readGatherMerge(), _readGroup(), _readGroupingFunc(), _readGroupingSet(), _readHash(), _readHashJoin(), _readIncrementalSort(), _readIndexOnlyScan(), _readIndexScan(), _readInferenceElem(), _readIntoClause(), _readJoin(), _readJoinExpr(), _readJsonBehavior(), _readJsonCoercion(), _readJsonConstructorExpr(), _readJsonExpr(), _readJsonFormat(), _readJsonIsPredicate(), _readJsonItemCoercions(), _readJsonReturning(), _readJsonTableParent(), _readJsonTableSibling(), _readJsonValueExpr(), _readLimit(), _readLockRows(), _readMaterial(), _readMemoize(), _readMergeAction(), _readMergeAppend(), _readMergeJoin(), _readMergeWhenClause(), _readMinMaxExpr(), _readModifyTable(), _readNamedArgExpr(), _readNamedTuplestoreScan(), _readNestLoop(), _readNestLoopParam(), _readNextValueExpr(), _readNotifyStmt(), _readNullIfExpr(), _readNullTest(), _readOnConflictExpr(), _readOpExpr(), _readParam(), _readPartitionBoundSpec(), _readPartitionedRelPruneInfo(), _readPartitionPruneInfo(), _readPartitionPruneStepCombine(), _readPartitionPruneStepOp(), _readPartitionRangeDatum(), _readPlan(), _readPlanInvalItem(), _readPlannedStmt(), _readPlanRowMark(), _readProjectSet(), _readQuery(), _readRangeTblEntry(), _readRangeTblFunction(), _readRangeTblRef(), _readRangeVar(), _readRecursiveUnion(), _readRelabelType(), _readResult(), _readRowCompareExpr(), _readRowExpr(), _readRowMarkClause(), _readSampleScan(), _readScalarArrayOpExpr(), _readScan(), _readSeqScan(), _readSetOp(), _readSetOperationStmt(), _readSetToDefault(), _readSort(), _readSortGroupClause(), _readSQLValueFunction(), _readSubLink(), _readSubPlan(), _readSubqueryScan(), _readSubscriptingRef(), _readTableFunc(), _readTableFuncScan(), _readTableSampleClause(), _readTargetEntry(), _readTidRangeScan(), _readTidScan(), _readUnique(), _readValuesScan(), _readVar(), _readWindowAgg(), _readWindowClause(), _readWindowFunc(), _readWithCheckOption(), _readWorkTableScan(), _readXmlExpr(), check_stack_depth(), elog, ERROR, MATCH, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

◆ pg_strtok()

const char* pg_strtok ( int *  length)

Definition at line 152 of file read.c.

153 {
154  const char *local_str; /* working pointer to string */
155  const char *ret_str; /* start of token to return */
156 
157  local_str = pg_strtok_ptr;
158 
159  while (*local_str == ' ' || *local_str == '\n' || *local_str == '\t')
160  local_str++;
161 
162  if (*local_str == '\0')
163  {
164  *length = 0;
165  pg_strtok_ptr = local_str;
166  return NULL; /* no more tokens */
167  }
168 
169  /*
170  * Now pointing at start of next token.
171  */
172  ret_str = local_str;
173 
174  if (*local_str == '(' || *local_str == ')' ||
175  *local_str == '{' || *local_str == '}')
176  {
177  /* special 1-character token */
178  local_str++;
179  }
180  else
181  {
182  /* Normal token, possibly containing backslashes */
183  while (*local_str != '\0' &&
184  *local_str != ' ' && *local_str != '\n' &&
185  *local_str != '\t' &&
186  *local_str != '(' && *local_str != ')' &&
187  *local_str != '{' && *local_str != '}')
188  {
189  if (*local_str == '\\' && local_str[1] != '\0')
190  local_str += 2;
191  else
192  local_str++;
193  }
194  }
195 
196  *length = local_str - ret_str;
197 
198  /* Recognize special case for "empty" token */
199  if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>')
200  *length = 0;
201 
202  pg_strtok_ptr = local_str;
203 
204  return ret_str;
205 }
static const char * pg_strtok_ptr
Definition: read.c:31

References pg_strtok_ptr.

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