Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
readfuncs.c File Reference
#include "postgres.h"
#include <math.h>
#include "miscadmin.h"
#include "nodes/bitmapset.h"
#include "nodes/readfuncs.h"
#include "readfuncs.funcs.c"
#include "readfuncs.switch.c"
Include dependency graph for readfuncs.c:

Go to the source code of this file.

Macros

#define READ_LOCALS_NO_FIELDS(nodeTypeName)    nodeTypeName *local_node = makeNode(nodeTypeName)
 
#define READ_TEMP_LOCALS()
 
#define READ_LOCALS(nodeTypeName)
 
#define READ_INT_FIELD(fldname)
 
#define READ_UINT_FIELD(fldname)
 
#define READ_INT64_FIELD(fldname)
 
#define READ_UINT64_FIELD(fldname)
 
#define READ_LONG_FIELD(fldname)
 
#define READ_OID_FIELD(fldname)
 
#define READ_CHAR_FIELD(fldname)
 
#define READ_ENUM_FIELD(fldname, enumtype)
 
#define READ_FLOAT_FIELD(fldname)
 
#define READ_BOOL_FIELD(fldname)
 
#define READ_STRING_FIELD(fldname)
 
#define READ_LOCATION_FIELD(fldname)
 
#define READ_NODE_FIELD(fldname)
 
#define READ_BITMAPSET_FIELD(fldname)
 
#define READ_ATTRNUMBER_ARRAY(fldname, len)
 
#define READ_OID_ARRAY(fldname, len)
 
#define READ_INT_ARRAY(fldname, len)
 
#define READ_BOOL_ARRAY(fldname, len)
 
#define READ_DONE()    return local_node
 
#define atoui(x)   ((unsigned int) strtoul((x), NULL, 10))
 
#define strtobool(x)   ((*(x) == 't') ? true : false)
 
#define MATCH(tokname, namelen)    (length == namelen && memcmp(token, tokname, namelen) == 0)
 
#define READ_SCALAR_ARRAY(fnname, datatype, convfunc)
 

Functions

static char * nullable_string (const char *token, int length)
 
static Bitmapset_readBitmapset (void)
 
BitmapsetreadBitmapset (void)
 
static Const_readConst (void)
 
static BoolExpr_readBoolExpr (void)
 
static A_Const_readA_Const (void)
 
static RangeTblEntry_readRangeTblEntry (void)
 
static A_Expr_readA_Expr (void)
 
static ExtensibleNode_readExtensibleNode (void)
 
NodeparseNodeString (void)
 
Datum readDatum (bool typbyval)
 

Macro Definition Documentation

◆ atoui

#define atoui (   x)    ((unsigned int) strtoul((x), NULL, 10))

Definition at line 183 of file readfuncs.c.

◆ MATCH

#define MATCH (   tokname,
  namelen 
)     (length == namelen && memcmp(token, tokname, namelen) == 0)

◆ READ_ATTRNUMBER_ARRAY

#define READ_ATTRNUMBER_ARRAY (   fldname,
  len 
)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = readAttrNumberCols(len)
int16 * readAttrNumberCols(int numCols)
const void size_t len
const char * pg_strtok(int *length)
Definition: read.c:153

Definition at line 153 of file readfuncs.c.

◆ READ_BITMAPSET_FIELD

#define READ_BITMAPSET_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
(void) token; /* in case not used elsewhere */ \
local_node->fldname = _readBitmapset()
static Bitmapset * _readBitmapset(void)
Definition: readfuncs.c:209

Definition at line 147 of file readfuncs.c.

◆ READ_BOOL_ARRAY

#define READ_BOOL_ARRAY (   fldname,
  len 
)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = readBoolCols(len)
bool * readBoolCols(int numCols)

Definition at line 168 of file readfuncs.c.

◆ READ_BOOL_FIELD

#define READ_BOOL_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = strtobool(token)
#define strtobool(x)
Definition: readfuncs.c:185

Definition at line 115 of file readfuncs.c.

◆ READ_CHAR_FIELD

#define READ_CHAR_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
/* avoid overhead of calling debackslash() for one char */ \
local_node->fldname = (length == 0) ? '\0' : (token[0] == '\\' ? token[1] : token[0])

Definition at line 96 of file readfuncs.c.

◆ READ_DONE

#define READ_DONE ( )     return local_node

Definition at line 173 of file readfuncs.c.

◆ READ_ENUM_FIELD

#define READ_ENUM_FIELD (   fldname,
  enumtype 
)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = (enumtype) atoi(token)

Definition at line 103 of file readfuncs.c.

◆ READ_FLOAT_FIELD

#define READ_FLOAT_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = atof(token)

Definition at line 109 of file readfuncs.c.

◆ READ_INT64_FIELD

#define READ_INT64_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = strtoi64(token, NULL, 10)

Definition at line 72 of file readfuncs.c.

◆ READ_INT_ARRAY

#define READ_INT_ARRAY (   fldname,
  len 
)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = readIntCols(len)
int * readIntCols(int numCols)

Definition at line 163 of file readfuncs.c.

◆ READ_INT_FIELD

#define READ_INT_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = atoi(token)

Definition at line 60 of file readfuncs.c.

◆ READ_LOCALS

#define READ_LOCALS (   nodeTypeName)
Value:
READ_LOCALS_NO_FIELDS(nodeTypeName); \
READ_TEMP_LOCALS()
#define READ_LOCALS_NO_FIELDS(nodeTypeName)
Definition: readfuncs.c:46

Definition at line 55 of file readfuncs.c.

◆ READ_LOCALS_NO_FIELDS

#define READ_LOCALS_NO_FIELDS (   nodeTypeName)     nodeTypeName *local_node = makeNode(nodeTypeName)

Definition at line 46 of file readfuncs.c.

◆ READ_LOCATION_FIELD

#define READ_LOCATION_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
(void) token; /* in case not used elsewhere */ \
local_node->fldname = -1 /* set field to "unknown" */

Definition at line 133 of file readfuncs.c.

◆ READ_LONG_FIELD

#define READ_LONG_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = atol(token)

Definition at line 84 of file readfuncs.c.

◆ READ_NODE_FIELD

#define READ_NODE_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
(void) token; /* in case not used elsewhere */ \
local_node->fldname = nodeRead(NULL, 0)
void * nodeRead(const char *token, int tok_len)
Definition: read.c:320

Definition at line 141 of file readfuncs.c.

◆ READ_OID_ARRAY

#define READ_OID_ARRAY (   fldname,
  len 
)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
local_node->fldname = readOidCols(len)
Oid * readOidCols(int numCols)

Definition at line 158 of file readfuncs.c.

◆ READ_OID_FIELD

#define READ_OID_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = atooid(token)
#define atooid(x)
Definition: postgres_ext.h:43

Definition at line 90 of file readfuncs.c.

◆ READ_SCALAR_ARRAY

#define READ_SCALAR_ARRAY (   fnname,
  datatype,
  convfunc 
)
Value:
datatype * \
fnname(int numCols) \
{ \
datatype *vals; \
READ_TEMP_LOCALS(); \
token = pg_strtok(&length); \
if (token == NULL) \
elog(ERROR, "incomplete scalar array"); \
if (length == 0) \
return NULL; /* it was "<>", so return NULL pointer */ \
if (length != 1 || token[0] != '(') \
elog(ERROR, "unrecognized token: \"%.*s\"", length, token); \
vals = (datatype *) palloc(numCols * sizeof(datatype)); \
for (int i = 0; i < numCols; i++) \
{ \
token = pg_strtok(&length); \
if (token == NULL || token[0] == ')') \
elog(ERROR, "incomplete scalar array"); \
vals[i] = convfunc(token); \
} \
token = pg_strtok(&length); \
if (token == NULL || length != 1 || token[0] != ')') \
elog(ERROR, "incomplete scalar array"); \
return vals; \
}
#define ERROR
Definition: elog.h:39
int i
Definition: isn.c:77
void * palloc(Size size)
Definition: mcxt.c:1365

Definition at line 661 of file readfuncs.c.

◆ READ_STRING_FIELD

#define READ_STRING_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = nullable_string(token, length)
static char * nullable_string(const char *token, int length)
Definition: readfuncs.c:188

Definition at line 121 of file readfuncs.c.

◆ READ_TEMP_LOCALS

#define READ_TEMP_LOCALS ( )
Value:
const char *token; \
int length
#define token
Definition: indent_globs.h:126

Definition at line 50 of file readfuncs.c.

◆ READ_UINT64_FIELD

#define READ_UINT64_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = strtou64(token, NULL, 10)

Definition at line 78 of file readfuncs.c.

◆ READ_UINT_FIELD

#define READ_UINT_FIELD (   fldname)
Value:
token = pg_strtok(&length); /* skip :fldname */ \
token = pg_strtok(&length); /* get field value */ \
local_node->fldname = atoui(token)
#define atoui(x)
Definition: readfuncs.c:183

Definition at line 66 of file readfuncs.c.

◆ strtobool

#define strtobool (   x)    ((*(x) == 't') ? true : false)

Definition at line 185 of file readfuncs.c.

Function Documentation

◆ _readA_Const()

static A_Const * _readA_Const ( void  )
static

Definition at line 310 of file readfuncs.c.

311{
313
314 /* We expect either NULL or :val here */
315 token = pg_strtok(&length);
316 if (length == 4 && strncmp(token, "NULL", 4) == 0)
317 local_node->isnull = true;
318 else
319 {
320 union ValUnion *tmp = nodeRead(NULL, 0);
321
322 /* To forestall valgrind complaints, copy only the valid data */
323 switch (nodeTag(tmp))
324 {
325 case T_Integer:
326 memcpy(&local_node->val, tmp, sizeof(Integer));
327 break;
328 case T_Float:
329 memcpy(&local_node->val, tmp, sizeof(Float));
330 break;
331 case T_Boolean:
332 memcpy(&local_node->val, tmp, sizeof(Boolean));
333 break;
334 case T_String:
335 memcpy(&local_node->val, tmp, sizeof(String));
336 break;
337 case T_BitString:
338 memcpy(&local_node->val, tmp, sizeof(BitString));
339 break;
340 default:
341 elog(ERROR, "unrecognized node type: %d",
342 (int) nodeTag(tmp));
343 break;
344 }
345 }
346
347 READ_LOCATION_FIELD(location);
348
349 READ_DONE();
350}
#define elog(elevel,...)
Definition: elog.h:226
#define nodeTag(nodeptr)
Definition: nodes.h:139
#define READ_LOCATION_FIELD(fldname)
Definition: readfuncs.c:133
#define READ_LOCALS(nodeTypeName)
Definition: readfuncs.c:55
#define READ_DONE()
Definition: readfuncs.c:173
Definition: value.h:56
Definition: value.h:48
Definition: value.h:29
Definition: value.h:64

References elog, ERROR, nodeRead(), nodeTag, pg_strtok(), READ_DONE, READ_LOCALS, and READ_LOCATION_FIELD.

◆ _readA_Expr()

static A_Expr * _readA_Expr ( void  )
static

Definition at line 448 of file readfuncs.c.

449{
451
452 token = pg_strtok(&length);
453
454 if (length == 3 && strncmp(token, "ANY", 3) == 0)
455 {
456 local_node->kind = AEXPR_OP_ANY;
458 }
459 else if (length == 3 && strncmp(token, "ALL", 3) == 0)
460 {
461 local_node->kind = AEXPR_OP_ALL;
463 }
464 else if (length == 8 && strncmp(token, "DISTINCT", 8) == 0)
465 {
466 local_node->kind = AEXPR_DISTINCT;
468 }
469 else if (length == 12 && strncmp(token, "NOT_DISTINCT", 12) == 0)
470 {
471 local_node->kind = AEXPR_NOT_DISTINCT;
473 }
474 else if (length == 6 && strncmp(token, "NULLIF", 6) == 0)
475 {
476 local_node->kind = AEXPR_NULLIF;
478 }
479 else if (length == 2 && strncmp(token, "IN", 2) == 0)
480 {
481 local_node->kind = AEXPR_IN;
483 }
484 else if (length == 4 && strncmp(token, "LIKE", 4) == 0)
485 {
486 local_node->kind = AEXPR_LIKE;
488 }
489 else if (length == 5 && strncmp(token, "ILIKE", 5) == 0)
490 {
491 local_node->kind = AEXPR_ILIKE;
493 }
494 else if (length == 7 && strncmp(token, "SIMILAR", 7) == 0)
495 {
496 local_node->kind = AEXPR_SIMILAR;
498 }
499 else if (length == 7 && strncmp(token, "BETWEEN", 7) == 0)
500 {
501 local_node->kind = AEXPR_BETWEEN;
503 }
504 else if (length == 11 && strncmp(token, "NOT_BETWEEN", 11) == 0)
505 {
506 local_node->kind = AEXPR_NOT_BETWEEN;
508 }
509 else if (length == 11 && strncmp(token, "BETWEEN_SYM", 11) == 0)
510 {
511 local_node->kind = AEXPR_BETWEEN_SYM;
513 }
514 else if (length == 15 && strncmp(token, "NOT_BETWEEN_SYM", 15) == 0)
515 {
516 local_node->kind = AEXPR_NOT_BETWEEN_SYM;
518 }
519 else if (length == 5 && strncmp(token, ":name", 5) == 0)
520 {
521 local_node->kind = AEXPR_OP;
522 local_node->name = nodeRead(NULL, 0);
523 }
524 else
525 elog(ERROR, "unrecognized A_Expr kind: \"%.*s\"", length, token);
526
527 READ_NODE_FIELD(lexpr);
528 READ_NODE_FIELD(rexpr);
529 READ_LOCATION_FIELD(rexpr_list_start);
530 READ_LOCATION_FIELD(rexpr_list_end);
531 READ_LOCATION_FIELD(location);
532
533 READ_DONE();
534}
@ AEXPR_BETWEEN
Definition: parsenodes.h:340
@ AEXPR_NULLIF
Definition: parsenodes.h:335
@ AEXPR_NOT_DISTINCT
Definition: parsenodes.h:334
@ AEXPR_BETWEEN_SYM
Definition: parsenodes.h:342
@ AEXPR_NOT_BETWEEN_SYM
Definition: parsenodes.h:343
@ AEXPR_ILIKE
Definition: parsenodes.h:338
@ AEXPR_IN
Definition: parsenodes.h:336
@ AEXPR_NOT_BETWEEN
Definition: parsenodes.h:341
@ AEXPR_DISTINCT
Definition: parsenodes.h:333
@ AEXPR_SIMILAR
Definition: parsenodes.h:339
@ AEXPR_LIKE
Definition: parsenodes.h:337
@ AEXPR_OP
Definition: parsenodes.h:330
@ AEXPR_OP_ANY
Definition: parsenodes.h:331
@ AEXPR_OP_ALL
Definition: parsenodes.h:332
#define READ_NODE_FIELD(fldname)
Definition: readfuncs.c:141
const char * name

References AEXPR_BETWEEN, AEXPR_BETWEEN_SYM, AEXPR_DISTINCT, AEXPR_ILIKE, AEXPR_IN, AEXPR_LIKE, AEXPR_NOT_BETWEEN, AEXPR_NOT_BETWEEN_SYM, AEXPR_NOT_DISTINCT, AEXPR_NULLIF, AEXPR_OP, AEXPR_OP_ALL, AEXPR_OP_ANY, AEXPR_SIMILAR, elog, ERROR, name, nodeRead(), pg_strtok(), READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, and READ_NODE_FIELD.

◆ _readBitmapset()

static Bitmapset * _readBitmapset ( void  )
static

Definition at line 209 of file readfuncs.c.

210{
211 Bitmapset *result = NULL;
212
214
215 token = pg_strtok(&length);
216 if (token == NULL)
217 elog(ERROR, "incomplete Bitmapset structure");
218 if (length != 1 || token[0] != '(')
219 elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
220
221 token = pg_strtok(&length);
222 if (token == NULL)
223 elog(ERROR, "incomplete Bitmapset structure");
224 if (length != 1 || token[0] != 'b')
225 elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
226
227 for (;;)
228 {
229 int val;
230 char *endptr;
231
232 token = pg_strtok(&length);
233 if (token == NULL)
234 elog(ERROR, "unterminated Bitmapset structure");
235 if (length == 1 && token[0] == ')')
236 break;
237 val = (int) strtol(token, &endptr, 10);
238 if (endptr != token + length)
239 elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
240 result = bms_add_member(result, val);
241 }
242
243 return result;
244}
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:815
long val
Definition: informix.c:689
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:50

References bms_add_member(), elog, ERROR, pg_strtok(), READ_TEMP_LOCALS, and val.

Referenced by readBitmapset().

◆ _readBoolExpr()

static BoolExpr * _readBoolExpr ( void  )
static

Definition at line 287 of file readfuncs.c.

288{
290
291 /* do-it-yourself enum representation */
292 token = pg_strtok(&length); /* skip :boolop */
293 token = pg_strtok(&length); /* get field value */
294 if (length == 3 && strncmp(token, "and", 3) == 0)
295 local_node->boolop = AND_EXPR;
296 else if (length == 2 && strncmp(token, "or", 2) == 0)
297 local_node->boolop = OR_EXPR;
298 else if (length == 3 && strncmp(token, "not", 3) == 0)
299 local_node->boolop = NOT_EXPR;
300 else
301 elog(ERROR, "unrecognized boolop \"%.*s\"", length, token);
302
304 READ_LOCATION_FIELD(location);
305
306 READ_DONE();
307}
@ AND_EXPR
Definition: primnodes.h:950
@ OR_EXPR
Definition: primnodes.h:950
@ NOT_EXPR
Definition: primnodes.h:950

References AND_EXPR, generate_unaccent_rules::args, elog, ERROR, NOT_EXPR, OR_EXPR, pg_strtok(), READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, and READ_NODE_FIELD.

◆ _readConst()

static Const * _readConst ( void  )
static

Definition at line 265 of file readfuncs.c.

266{
268
269 READ_OID_FIELD(consttype);
270 READ_INT_FIELD(consttypmod);
271 READ_OID_FIELD(constcollid);
272 READ_INT_FIELD(constlen);
273 READ_BOOL_FIELD(constbyval);
274 READ_BOOL_FIELD(constisnull);
275 READ_LOCATION_FIELD(location);
276
277 token = pg_strtok(&length); /* skip :constvalue */
278 if (local_node->constisnull)
279 token = pg_strtok(&length); /* skip "<>" */
280 else
281 local_node->constvalue = readDatum(local_node->constbyval);
282
283 READ_DONE();
284}
#define READ_INT_FIELD(fldname)
Definition: readfuncs.c:60
#define READ_OID_FIELD(fldname)
Definition: readfuncs.c:90
Datum readDatum(bool typbyval)
Definition: readfuncs.c:600
#define READ_BOOL_FIELD(fldname)
Definition: readfuncs.c:115

References pg_strtok(), READ_BOOL_FIELD, READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_LOCATION_FIELD, READ_OID_FIELD, and readDatum().

◆ _readExtensibleNode()

static ExtensibleNode * _readExtensibleNode ( void  )
static

Definition at line 537 of file readfuncs.c.

538{
539 const ExtensibleNodeMethods *methods;
540 ExtensibleNode *local_node;
541 const char *extnodename;
542
544
545 token = pg_strtok(&length); /* skip :extnodename */
546 token = pg_strtok(&length); /* get extnodename */
547
548 extnodename = nullable_string(token, length);
549 if (!extnodename)
550 elog(ERROR, "extnodename has to be supplied");
551 methods = GetExtensibleNodeMethods(extnodename, false);
552
553 local_node = (ExtensibleNode *) newNode(methods->node_size,
554 T_ExtensibleNode);
555 local_node->extnodename = extnodename;
556
557 /* deserialize the private fields */
558 methods->nodeRead(local_node);
559
560 READ_DONE();
561}
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
static Node * newNode(size_t size, NodeTag tag)
Definition: nodes.h:150
void(* nodeRead)(struct ExtensibleNode *node)
Definition: extensible.h:72
const char * extnodename
Definition: extensible.h:37

References elog, ERROR, ExtensibleNode::extnodename, GetExtensibleNodeMethods(), newNode(), ExtensibleNodeMethods::node_size, ExtensibleNodeMethods::nodeRead, nullable_string(), pg_strtok(), READ_DONE, and READ_TEMP_LOCALS.

◆ _readRangeTblEntry()

static RangeTblEntry * _readRangeTblEntry ( void  )
static

Definition at line 353 of file readfuncs.c.

354{
356
357 READ_NODE_FIELD(alias);
358 READ_NODE_FIELD(eref);
359 READ_ENUM_FIELD(rtekind, RTEKind);
360
361 switch (local_node->rtekind)
362 {
363 case RTE_RELATION:
364 READ_OID_FIELD(relid);
365 READ_BOOL_FIELD(inh);
366 READ_CHAR_FIELD(relkind);
367 READ_INT_FIELD(rellockmode);
368 READ_UINT_FIELD(perminfoindex);
369 READ_NODE_FIELD(tablesample);
370 break;
371 case RTE_SUBQUERY:
372 READ_NODE_FIELD(subquery);
373 READ_BOOL_FIELD(security_barrier);
374 /* we re-use these RELATION fields, too: */
375 READ_OID_FIELD(relid);
376 READ_BOOL_FIELD(inh);
377 READ_CHAR_FIELD(relkind);
378 READ_INT_FIELD(rellockmode);
379 READ_UINT_FIELD(perminfoindex);
380 break;
381 case RTE_JOIN:
382 READ_ENUM_FIELD(jointype, JoinType);
383 READ_INT_FIELD(joinmergedcols);
384 READ_NODE_FIELD(joinaliasvars);
385 READ_NODE_FIELD(joinleftcols);
386 READ_NODE_FIELD(joinrightcols);
387 READ_NODE_FIELD(join_using_alias);
388 break;
389 case RTE_FUNCTION:
391 READ_BOOL_FIELD(funcordinality);
392 break;
393 case RTE_TABLEFUNC:
394 READ_NODE_FIELD(tablefunc);
395 /* The RTE must have a copy of the column type info, if any */
396 if (local_node->tablefunc)
397 {
398 TableFunc *tf = local_node->tablefunc;
399
400 local_node->coltypes = tf->coltypes;
401 local_node->coltypmods = tf->coltypmods;
402 local_node->colcollations = tf->colcollations;
403 }
404 break;
405 case RTE_VALUES:
406 READ_NODE_FIELD(values_lists);
407 READ_NODE_FIELD(coltypes);
408 READ_NODE_FIELD(coltypmods);
409 READ_NODE_FIELD(colcollations);
410 break;
411 case RTE_CTE:
412 READ_STRING_FIELD(ctename);
413 READ_UINT_FIELD(ctelevelsup);
414 READ_BOOL_FIELD(self_reference);
415 READ_NODE_FIELD(coltypes);
416 READ_NODE_FIELD(coltypmods);
417 READ_NODE_FIELD(colcollations);
418 break;
420 READ_STRING_FIELD(enrname);
421 READ_FLOAT_FIELD(enrtuples);
422 READ_NODE_FIELD(coltypes);
423 READ_NODE_FIELD(coltypmods);
424 READ_NODE_FIELD(colcollations);
425 /* we re-use these RELATION fields, too: */
426 READ_OID_FIELD(relid);
427 break;
428 case RTE_RESULT:
429 /* no extra fields */
430 break;
431 case RTE_GROUP:
432 READ_NODE_FIELD(groupexprs);
433 break;
434 default:
435 elog(ERROR, "unrecognized RTE kind: %d",
436 (int) local_node->rtekind);
437 break;
438 }
439
440 READ_BOOL_FIELD(lateral);
441 READ_BOOL_FIELD(inFromCl);
442 READ_NODE_FIELD(securityQuals);
443
444 READ_DONE();
445}
JoinType
Definition: nodes.h:298
RTEKind
Definition: parsenodes.h:1041
@ RTE_JOIN
Definition: parsenodes.h:1044
@ RTE_CTE
Definition: parsenodes.h:1048
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:1049
@ RTE_VALUES
Definition: parsenodes.h:1047
@ RTE_SUBQUERY
Definition: parsenodes.h:1043
@ RTE_RESULT
Definition: parsenodes.h:1050
@ RTE_FUNCTION
Definition: parsenodes.h:1045
@ RTE_TABLEFUNC
Definition: parsenodes.h:1046
@ RTE_GROUP
Definition: parsenodes.h:1053
@ RTE_RELATION
Definition: parsenodes.h:1042
#define READ_UINT_FIELD(fldname)
Definition: readfuncs.c:66
#define READ_CHAR_FIELD(fldname)
Definition: readfuncs.c:96
#define READ_STRING_FIELD(fldname)
Definition: readfuncs.c:121
#define READ_FLOAT_FIELD(fldname)
Definition: readfuncs.c:109
#define READ_ENUM_FIELD(fldname, enumtype)
Definition: readfuncs.c:103
static const struct fns functions
Definition: regcomp.c:358

References elog, ERROR, functions, READ_BOOL_FIELD, READ_CHAR_FIELD, READ_DONE, READ_ENUM_FIELD, READ_FLOAT_FIELD, READ_INT_FIELD, READ_LOCALS, READ_NODE_FIELD, READ_OID_FIELD, READ_STRING_FIELD, READ_UINT_FIELD, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, and RTE_VALUES.

◆ nullable_string()

static char * nullable_string ( const char *  token,
int  length 
)
static

Definition at line 188 of file readfuncs.c.

189{
190 /* outToken emits <> for NULL, and pg_strtok makes that an empty string */
191 if (length == 0)
192 return NULL;
193 /* outToken emits "" for empty string */
194 if (length == 2 && token[0] == '"' && token[1] == '"')
195 return pstrdup("");
196 /* otherwise, we must remove protective backslashes added by outToken */
197 return debackslash(token, length);
198}
char * pstrdup(const char *in)
Definition: mcxt.c:1759
char * debackslash(const char *token, int length)
Definition: read.c:214

References debackslash(), and pstrdup().

Referenced by _readExtensibleNode().

◆ parseNodeString()

Node * parseNodeString ( void  )

Definition at line 573 of file readfuncs.c.

574{
576
577 /* Guard against stack overflow due to overly complex expressions */
579
580 token = pg_strtok(&length);
581
582#define MATCH(tokname, namelen) \
583 (length == namelen && memcmp(token, tokname, namelen) == 0)
584
585#include "readfuncs.switch.c"
586
587 elog(ERROR, "badly formatted node string \"%.32s\"...", token);
588 return NULL; /* keep compiler quiet */
589}
void check_stack_depth(void)
Definition: stack_depth.c:95

References check_stack_depth(), elog, ERROR, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

◆ readBitmapset()

Bitmapset * readBitmapset ( void  )

Definition at line 251 of file readfuncs.c.

252{
253 return _readBitmapset();
254}

References _readBitmapset().

◆ readDatum()

Datum readDatum ( bool  typbyval)

Definition at line 600 of file readfuncs.c.

601{
602 Size length,
603 i;
604 int tokenLength;
605 const char *token;
606 Datum res;
607 char *s;
608
609 /*
610 * read the actual length of the value
611 */
612 token = pg_strtok(&tokenLength);
613 length = atoui(token);
614
615 token = pg_strtok(&tokenLength); /* read the '[' */
616 if (token == NULL || token[0] != '[')
617 elog(ERROR, "expected \"[\" to start datum, but got \"%s\"; length = %zu",
618 token ? token : "[NULL]", length);
619
620 if (typbyval)
621 {
622 if (length > (Size) sizeof(Datum))
623 elog(ERROR, "byval datum but length = %zu", length);
624 res = (Datum) 0;
625 s = (char *) (&res);
626 for (i = 0; i < (Size) sizeof(Datum); i++)
627 {
628 token = pg_strtok(&tokenLength);
629 s[i] = (char) atoi(token);
630 }
631 }
632 else if (length <= 0)
633 res = (Datum) 0;
634 else
635 {
636 s = (char *) palloc(length);
637 for (i = 0; i < length; i++)
638 {
639 token = pg_strtok(&tokenLength);
640 s[i] = (char) atoi(token);
641 }
642 res = PointerGetDatum(s);
643 }
644
645 token = pg_strtok(&tokenLength); /* read the ']' */
646 if (token == NULL || token[0] != ']')
647 elog(ERROR, "expected \"]\" to end datum, but got \"%s\"; length = %zu",
648 token ? token : "[NULL]", length);
649
650 return res;
651}
size_t Size
Definition: c.h:611
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332
uint64_t Datum
Definition: postgres.h:70

References atoui, elog, ERROR, i, palloc(), pg_strtok(), PointerGetDatum(), and token.

Referenced by _readConst().