Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions

readfuncs.c File Reference

#include "postgres.h"
#include <math.h>
#include "nodes/parsenodes.h"
#include "nodes/readfuncs.h"
Include dependency graph for readfuncs.c:

Go to the source code of this file.

Defines

#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_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_DONE()   return local_node
#define atoui(x)   ((unsigned int) strtoul((x), NULL, 10))
#define atooid(x)   ((Oid) strtoul((x), NULL, 10))
#define strtobool(x)   ((*(x) == 't') ? true : false)
#define nullable_string(token, length)   ((length) == 0 ? NULL : debackslash(token, length))
#define MATCH(tokname, namelen)   (length == namelen && memcmp(token, tokname, namelen) == 0)

Functions

static Datum readDatum (bool typbyval)
static Bitmapset_readBitmapset (void)
static Query_readQuery (void)
static NotifyStmt_readNotifyStmt (void)
static DeclareCursorStmt_readDeclareCursorStmt (void)
static SortGroupClause_readSortGroupClause (void)
static WindowClause_readWindowClause (void)
static RowMarkClause_readRowMarkClause (void)
static CommonTableExpr_readCommonTableExpr (void)
static SetOperationStmt_readSetOperationStmt (void)
static Alias_readAlias (void)
static RangeVar_readRangeVar (void)
static IntoClause_readIntoClause (void)
static Var_readVar (void)
static Const_readConst (void)
static Param_readParam (void)
static Aggref_readAggref (void)
static WindowFunc_readWindowFunc (void)
static ArrayRef_readArrayRef (void)
static FuncExpr_readFuncExpr (void)
static NamedArgExpr_readNamedArgExpr (void)
static OpExpr_readOpExpr (void)
static DistinctExpr_readDistinctExpr (void)
static NullIfExpr_readNullIfExpr (void)
static ScalarArrayOpExpr_readScalarArrayOpExpr (void)
static BoolExpr_readBoolExpr (void)
static SubLink_readSubLink (void)
static FieldSelect_readFieldSelect (void)
static FieldStore_readFieldStore (void)
static RelabelType_readRelabelType (void)
static CoerceViaIO_readCoerceViaIO (void)
static ArrayCoerceExpr_readArrayCoerceExpr (void)
static ConvertRowtypeExpr_readConvertRowtypeExpr (void)
static CollateExpr_readCollateExpr (void)
static CaseExpr_readCaseExpr (void)
static CaseWhen_readCaseWhen (void)
static CaseTestExpr_readCaseTestExpr (void)
static ArrayExpr_readArrayExpr (void)
static RowExpr_readRowExpr (void)
static RowCompareExpr_readRowCompareExpr (void)
static CoalesceExpr_readCoalesceExpr (void)
static MinMaxExpr_readMinMaxExpr (void)
static XmlExpr_readXmlExpr (void)
static NullTest_readNullTest (void)
static BooleanTest_readBooleanTest (void)
static CoerceToDomain_readCoerceToDomain (void)
static CoerceToDomainValue_readCoerceToDomainValue (void)
static SetToDefault_readSetToDefault (void)
static CurrentOfExpr_readCurrentOfExpr (void)
static TargetEntry_readTargetEntry (void)
static RangeTblRef_readRangeTblRef (void)
static JoinExpr_readJoinExpr (void)
static FromExpr_readFromExpr (void)
static RangeTblEntry_readRangeTblEntry (void)
NodeparseNodeString (void)

Define Documentation

#define atooid (   x  )     ((Oid) strtoul((x), NULL, 10))

Definition at line 136 of file readfuncs.c.

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

Definition at line 134 of file readfuncs.c.

Referenced by readDatum().

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

Referenced by parseNodeString().

#define nullable_string (   token,
  length 
)    ((length) == 0 ? NULL : debackslash(token, length))

Definition at line 140 of file readfuncs.c.

#define READ_BITMAPSET_FIELD (   fldname  ) 
Value:
token = pg_strtok(&length);     /* skip :fldname */ \
    local_node->fldname = _readBitmapset()

Definition at line 119 of file readfuncs.c.

Referenced by _readRangeTblEntry().

#define READ_BOOL_FIELD (   fldname  ) 
#define READ_CHAR_FIELD (   fldname  ) 
Value:
token = pg_strtok(&length);     /* skip :fldname */ \
    token = pg_strtok(&length);     /* get field value */ \
    local_node->fldname = token[0]

Definition at line 77 of file readfuncs.c.

Referenced by _readRangeTblEntry(), and _readRangeVar().

#define READ_DONE (  )     return local_node
#define READ_ENUM_FIELD (   fldname,
  enumtype 
)
#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 89 of file readfuncs.c.

#define READ_INT_FIELD (   fldname  ) 
#define READ_LOCALS (   nodeTypeName  ) 
#define READ_LOCALS_NO_FIELDS (   nodeTypeName  )     nodeTypeName *local_node = makeNode(nodeTypeName)

Definition at line 45 of file readfuncs.c.

#define READ_LOCATION_FIELD (   fldname  ) 
#define READ_NODE_FIELD (   fldname  ) 
#define READ_OID_FIELD (   fldname  ) 
#define READ_STRING_FIELD (   fldname  ) 
#define READ_TEMP_LOCALS (  ) 
Value:
char       *token;      \
    int         length

Definition at line 49 of file readfuncs.c.

Referenced by _readBitmapset(), and parseNodeString().

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

Definition at line 65 of file readfuncs.c.

Referenced by _readAggref(), _readCurrentOfExpr(), _readRangeTblEntry(), _readRowMarkClause(), _readSortGroupClause(), _readTargetEntry(), _readVar(), _readWindowClause(), and _readWindowFunc().

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

Definition at line 138 of file readfuncs.c.


Function Documentation

static Aggref* _readAggref ( void   )  [static]

Definition at line 471 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, READ_OID_FIELD, and READ_UINT_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(Aggref);

    READ_OID_FIELD(aggfnoid);
    READ_OID_FIELD(aggtype);
    READ_OID_FIELD(aggcollid);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_NODE_FIELD(aggorder);
    READ_NODE_FIELD(aggdistinct);
    READ_BOOL_FIELD(aggstar);
    READ_UINT_FIELD(agglevelsup);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static Alias* _readAlias ( void   )  [static]

Definition at line 359 of file readfuncs.c.

References READ_DONE, READ_LOCALS, READ_NODE_FIELD, and READ_STRING_FIELD.

Referenced by parseNodeString().

static ArrayCoerceExpr* _readArrayCoerceExpr ( void   )  [static]
static ArrayExpr* _readArrayExpr ( void   )  [static]

Definition at line 907 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(ArrayExpr);

    READ_OID_FIELD(array_typeid);
    READ_OID_FIELD(array_collid);
    READ_OID_FIELD(element_typeid);
    READ_NODE_FIELD(elements);
    READ_BOOL_FIELD(multidims);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static ArrayRef* _readArrayRef ( void   )  [static]

Definition at line 514 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(ArrayRef);

    READ_OID_FIELD(refarraytype);
    READ_OID_FIELD(refelemtype);
    READ_INT_FIELD(reftypmod);
    READ_OID_FIELD(refcollid);
    READ_NODE_FIELD(refupperindexpr);
    READ_NODE_FIELD(reflowerindexpr);
    READ_NODE_FIELD(refexpr);
    READ_NODE_FIELD(refassgnexpr);

    READ_DONE();
}

static Bitmapset* _readBitmapset ( void   )  [static]

Definition at line 150 of file readfuncs.c.

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

{
    Bitmapset  *result = NULL;

    READ_TEMP_LOCALS();

    token = pg_strtok(&length);
    if (token == NULL)
        elog(ERROR, "incomplete Bitmapset structure");
    if (length != 1 || token[0] != '(')
        elog(ERROR, "unrecognized token: \"%.*s\"", length, token);

    token = pg_strtok(&length);
    if (token == NULL)
        elog(ERROR, "incomplete Bitmapset structure");
    if (length != 1 || token[0] != 'b')
        elog(ERROR, "unrecognized token: \"%.*s\"", length, token);

    for (;;)
    {
        int         val;
        char       *endptr;

        token = pg_strtok(&length);
        if (token == NULL)
            elog(ERROR, "unterminated Bitmapset structure");
        if (length == 1 && token[0] == ')')
            break;
        val = (int) strtol(token, &endptr, 10);
        if (endptr != token + length)
            elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
        result = bms_add_member(result, val);
    }

    return result;
}

static BooleanTest* _readBooleanTest ( void   )  [static]
static BoolExpr* _readBoolExpr ( void   )  [static]

Definition at line 693 of file readfuncs.c.

References elog, ERROR, length(), pg_strtok(), READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, and READ_NODE_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(BoolExpr);

    /* do-it-yourself enum representation */
    token = pg_strtok(&length); /* skip :boolop */
    token = pg_strtok(&length); /* get field value */
    if (strncmp(token, "and", 3) == 0)
        local_node->boolop = AND_EXPR;
    else if (strncmp(token, "or", 2) == 0)
        local_node->boolop = OR_EXPR;
    else if (strncmp(token, "not", 3) == 0)
        local_node->boolop = NOT_EXPR;
    else
        elog(ERROR, "unrecognized boolop \"%.*s\"", length, token);

    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static CaseExpr* _readCaseExpr ( void   )  [static]
static CaseTestExpr* _readCaseTestExpr ( void   )  [static]

Definition at line 892 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, READ_LOCALS, and READ_OID_FIELD.

Referenced by parseNodeString().

static CaseWhen* _readCaseWhen ( void   )  [static]

Definition at line 877 of file readfuncs.c.

References READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, and READ_NODE_FIELD.

Referenced by parseNodeString().

static CoalesceExpr* _readCoalesceExpr ( void   )  [static]

Definition at line 960 of file readfuncs.c.

References READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(CoalesceExpr);

    READ_OID_FIELD(coalescetype);
    READ_OID_FIELD(coalescecollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static CoerceToDomain* _readCoerceToDomain ( void   )  [static]
static CoerceToDomainValue* _readCoerceToDomainValue ( void   )  [static]
static CoerceViaIO* _readCoerceViaIO ( void   )  [static]
static CollateExpr* _readCollateExpr ( void   )  [static]
static CommonTableExpr* _readCommonTableExpr ( void   )  [static]

Definition at line 315 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_STRING_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(CommonTableExpr);

    READ_STRING_FIELD(ctename);
    READ_NODE_FIELD(aliascolnames);
    READ_NODE_FIELD(ctequery);
    READ_LOCATION_FIELD(location);
    READ_BOOL_FIELD(cterecursive);
    READ_INT_FIELD(cterefcount);
    READ_NODE_FIELD(ctecolnames);
    READ_NODE_FIELD(ctecoltypes);
    READ_NODE_FIELD(ctecoltypmods);
    READ_NODE_FIELD(ctecolcollations);

    READ_DONE();
}

static Const* _readConst ( void   )  [static]

Definition at line 428 of file readfuncs.c.

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

Referenced by parseNodeString().

{
    READ_LOCALS(Const);

    READ_OID_FIELD(consttype);
    READ_INT_FIELD(consttypmod);
    READ_OID_FIELD(constcollid);
    READ_INT_FIELD(constlen);
    READ_BOOL_FIELD(constbyval);
    READ_BOOL_FIELD(constisnull);
    READ_LOCATION_FIELD(location);

    token = pg_strtok(&length); /* skip :constvalue */
    if (local_node->constisnull)
        token = pg_strtok(&length);     /* skip "<>" */
    else
        local_node->constvalue = readDatum(local_node->constbyval);

    READ_DONE();
}

static ConvertRowtypeExpr* _readConvertRowtypeExpr ( void   )  [static]
static CurrentOfExpr* _readCurrentOfExpr ( void   )  [static]

Definition at line 1094 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_STRING_FIELD, and READ_UINT_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(CurrentOfExpr);

    READ_UINT_FIELD(cvarno);
    READ_STRING_FIELD(cursor_name);
    READ_INT_FIELD(cursor_param);

    READ_DONE();
}

static DeclareCursorStmt* _readDeclareCursorStmt ( void   )  [static]
static DistinctExpr* _readDistinctExpr ( void   )  [static]

Definition at line 602 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(DistinctExpr);

    READ_OID_FIELD(opno);
    READ_OID_FIELD(opfuncid);

    /*
     * The opfuncid is stored in the textual format primarily for debugging
     * and documentation reasons.  We want to always read it as zero to force
     * it to be re-looked-up in the pg_operator entry.  This ensures that
     * stored rules don't have hidden dependencies on operators' functions.
     * (We don't currently support an ALTER OPERATOR command, but might
     * someday.)
     */
    local_node->opfuncid = InvalidOid;

    READ_OID_FIELD(opresulttype);
    READ_BOOL_FIELD(opretset);
    READ_OID_FIELD(opcollid);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static FieldSelect* _readFieldSelect ( void   )  [static]

Definition at line 740 of file readfuncs.c.

References arg, READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(FieldSelect);

    READ_NODE_FIELD(arg);
    READ_INT_FIELD(fieldnum);
    READ_OID_FIELD(resulttype);
    READ_INT_FIELD(resulttypmod);
    READ_OID_FIELD(resultcollid);

    READ_DONE();
}

static FieldStore* _readFieldStore ( void   )  [static]

Definition at line 757 of file readfuncs.c.

References arg, READ_DONE, READ_LOCALS, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

static FromExpr* _readFromExpr ( void   )  [static]

Definition at line 1161 of file readfuncs.c.

References READ_DONE, READ_LOCALS, and READ_NODE_FIELD.

Referenced by parseNodeString().

static FuncExpr* _readFuncExpr ( void   )  [static]

Definition at line 534 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_ENUM_FIELD, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(FuncExpr);

    READ_OID_FIELD(funcid);
    READ_OID_FIELD(funcresulttype);
    READ_BOOL_FIELD(funcretset);
    READ_BOOL_FIELD(funcvariadic);
    READ_ENUM_FIELD(funcformat, CoercionForm);
    READ_OID_FIELD(funccollid);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static IntoClause* _readIntoClause ( void   )  [static]
static JoinExpr* _readJoinExpr ( void   )  [static]
static MinMaxExpr* _readMinMaxExpr ( void   )  [static]
static NamedArgExpr* _readNamedArgExpr ( void   )  [static]
static NotifyStmt* _readNotifyStmt ( void   )  [static]

Definition at line 232 of file readfuncs.c.

References READ_DONE, READ_LOCALS, and READ_STRING_FIELD.

Referenced by parseNodeString().

static NullIfExpr* _readNullIfExpr ( void   )  [static]

Definition at line 633 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(NullIfExpr);

    READ_OID_FIELD(opno);
    READ_OID_FIELD(opfuncid);

    /*
     * The opfuncid is stored in the textual format primarily for debugging
     * and documentation reasons.  We want to always read it as zero to force
     * it to be re-looked-up in the pg_operator entry.  This ensures that
     * stored rules don't have hidden dependencies on operators' functions.
     * (We don't currently support an ALTER OPERATOR command, but might
     * someday.)
     */
    local_node->opfuncid = InvalidOid;

    READ_OID_FIELD(opresulttype);
    READ_BOOL_FIELD(opretset);
    READ_OID_FIELD(opcollid);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static NullTest* _readNullTest ( void   )  [static]
static OpExpr* _readOpExpr ( void   )  [static]

Definition at line 571 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(OpExpr);

    READ_OID_FIELD(opno);
    READ_OID_FIELD(opfuncid);

    /*
     * The opfuncid is stored in the textual format primarily for debugging
     * and documentation reasons.  We want to always read it as zero to force
     * it to be re-looked-up in the pg_operator entry.  This ensures that
     * stored rules don't have hidden dependencies on operators' functions.
     * (We don't currently support an ALTER OPERATOR command, but might
     * someday.)
     */
    local_node->opfuncid = InvalidOid;

    READ_OID_FIELD(opresulttype);
    READ_BOOL_FIELD(opretset);
    READ_OID_FIELD(opcollid);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static Param* _readParam ( void   )  [static]

Definition at line 453 of file readfuncs.c.

References READ_DONE, READ_ENUM_FIELD, READ_INT_FIELD, READ_LOCALS, READ_LOCATION_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(Param);

    READ_ENUM_FIELD(paramkind, ParamKind);
    READ_INT_FIELD(paramid);
    READ_OID_FIELD(paramtype);
    READ_INT_FIELD(paramtypmod);
    READ_OID_FIELD(paramcollid);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static Query* _readQuery ( void   )  [static]

Definition at line 192 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_ENUM_FIELD, READ_INT_FIELD, READ_LOCALS, and READ_NODE_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(Query);

    READ_ENUM_FIELD(commandType, CmdType);
    READ_ENUM_FIELD(querySource, QuerySource);
    local_node->queryId = 0;    /* not saved in output format */
    READ_BOOL_FIELD(canSetTag);
    READ_NODE_FIELD(utilityStmt);
    READ_INT_FIELD(resultRelation);
    READ_BOOL_FIELD(hasAggs);
    READ_BOOL_FIELD(hasWindowFuncs);
    READ_BOOL_FIELD(hasSubLinks);
    READ_BOOL_FIELD(hasDistinctOn);
    READ_BOOL_FIELD(hasRecursive);
    READ_BOOL_FIELD(hasModifyingCTE);
    READ_BOOL_FIELD(hasForUpdate);
    READ_NODE_FIELD(cteList);
    READ_NODE_FIELD(rtable);
    READ_NODE_FIELD(jointree);
    READ_NODE_FIELD(targetList);
    READ_NODE_FIELD(returningList);
    READ_NODE_FIELD(groupClause);
    READ_NODE_FIELD(havingQual);
    READ_NODE_FIELD(windowClause);
    READ_NODE_FIELD(distinctClause);
    READ_NODE_FIELD(sortClause);
    READ_NODE_FIELD(limitOffset);
    READ_NODE_FIELD(limitCount);
    READ_NODE_FIELD(rowMarks);
    READ_NODE_FIELD(setOperations);
    READ_NODE_FIELD(constraintDeps);

    READ_DONE();
}

static RangeTblEntry* _readRangeTblEntry ( void   )  [static]

Definition at line 1180 of file readfuncs.c.

References elog, ERROR, READ_BITMAPSET_FIELD, READ_BOOL_FIELD, READ_CHAR_FIELD, READ_DONE, READ_ENUM_FIELD, READ_LOCALS, READ_NODE_FIELD, READ_OID_FIELD, READ_STRING_FIELD, READ_UINT_FIELD, RTE_CTE, RTE_FUNCTION, RTE_JOIN, RTE_RELATION, RTE_SUBQUERY, and RTE_VALUES.

Referenced by parseNodeString().

{
    READ_LOCALS(RangeTblEntry);

    /* put alias + eref first to make dump more legible */
    READ_NODE_FIELD(alias);
    READ_NODE_FIELD(eref);
    READ_ENUM_FIELD(rtekind, RTEKind);

    switch (local_node->rtekind)
    {
        case RTE_RELATION:
            READ_OID_FIELD(relid);
            READ_CHAR_FIELD(relkind);
            break;
        case RTE_SUBQUERY:
            READ_NODE_FIELD(subquery);
            READ_BOOL_FIELD(security_barrier);
            break;
        case RTE_JOIN:
            READ_ENUM_FIELD(jointype, JoinType);
            READ_NODE_FIELD(joinaliasvars);
            break;
        case RTE_FUNCTION:
            READ_NODE_FIELD(funcexpr);
            READ_NODE_FIELD(funccoltypes);
            READ_NODE_FIELD(funccoltypmods);
            READ_NODE_FIELD(funccolcollations);
            break;
        case RTE_VALUES:
            READ_NODE_FIELD(values_lists);
            READ_NODE_FIELD(values_collations);
            break;
        case RTE_CTE:
            READ_STRING_FIELD(ctename);
            READ_UINT_FIELD(ctelevelsup);
            READ_BOOL_FIELD(self_reference);
            READ_NODE_FIELD(ctecoltypes);
            READ_NODE_FIELD(ctecoltypmods);
            READ_NODE_FIELD(ctecolcollations);
            break;
        default:
            elog(ERROR, "unrecognized RTE kind: %d",
                 (int) local_node->rtekind);
            break;
    }

    READ_BOOL_FIELD(lateral);
    READ_BOOL_FIELD(inh);
    READ_BOOL_FIELD(inFromCl);
    READ_UINT_FIELD(requiredPerms);
    READ_OID_FIELD(checkAsUser);
    READ_BITMAPSET_FIELD(selectedCols);
    READ_BITMAPSET_FIELD(modifiedCols);

    READ_DONE();
}

static RangeTblRef* _readRangeTblRef ( void   )  [static]

Definition at line 1128 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, and READ_LOCALS.

Referenced by parseNodeString().

static RangeVar* _readRangeVar ( void   )  [static]

Definition at line 370 of file readfuncs.c.

References READ_CHAR_FIELD, READ_DONE, READ_ENUM_FIELD, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_STRING_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(RangeVar);

    local_node->catalogname = NULL;     /* not currently saved in output
                                         * format */

    READ_STRING_FIELD(schemaname);
    READ_STRING_FIELD(relname);
    READ_ENUM_FIELD(inhOpt, InhOption);
    READ_CHAR_FIELD(relpersistence);
    READ_NODE_FIELD(alias);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static RelabelType* _readRelabelType ( void   )  [static]
static RowCompareExpr* _readRowCompareExpr ( void   )  [static]

Definition at line 942 of file readfuncs.c.

References READ_DONE, READ_ENUM_FIELD, READ_LOCALS, and READ_NODE_FIELD.

Referenced by parseNodeString().

static RowExpr* _readRowExpr ( void   )  [static]
static RowMarkClause* _readRowMarkClause ( void   )  [static]
static ScalarArrayOpExpr* _readScalarArrayOpExpr ( void   )  [static]

Definition at line 664 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_LOCATION_FIELD, READ_NODE_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(ScalarArrayOpExpr);

    READ_OID_FIELD(opno);
    READ_OID_FIELD(opfuncid);

    /*
     * The opfuncid is stored in the textual format primarily for debugging
     * and documentation reasons.  We want to always read it as zero to force
     * it to be re-looked-up in the pg_operator entry.  This ensures that
     * stored rules don't have hidden dependencies on operators' functions.
     * (We don't currently support an ALTER OPERATOR command, but might
     * someday.)
     */
    local_node->opfuncid = InvalidOid;

    READ_BOOL_FIELD(useOr);
    READ_OID_FIELD(inputcollid);
    READ_NODE_FIELD(args);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static SetOperationStmt* _readSetOperationStmt ( void   )  [static]
static SetToDefault* _readSetToDefault ( void   )  [static]

Definition at line 1078 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_LOCATION_FIELD, and READ_OID_FIELD.

Referenced by parseNodeString().

static SortGroupClause* _readSortGroupClause ( void   )  [static]

Definition at line 261 of file readfuncs.c.

References READ_BOOL_FIELD, READ_DONE, READ_LOCALS, READ_OID_FIELD, and READ_UINT_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(SortGroupClause);

    READ_UINT_FIELD(tleSortGroupRef);
    READ_OID_FIELD(eqop);
    READ_OID_FIELD(sortop);
    READ_BOOL_FIELD(nulls_first);
    READ_BOOL_FIELD(hashable);

    READ_DONE();
}

static SubLink* _readSubLink ( void   )  [static]

Definition at line 719 of file readfuncs.c.

References READ_DONE, READ_ENUM_FIELD, READ_LOCALS, READ_LOCATION_FIELD, and READ_NODE_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(SubLink);

    READ_ENUM_FIELD(subLinkType, SubLinkType);
    READ_NODE_FIELD(testexpr);
    READ_NODE_FIELD(operName);
    READ_NODE_FIELD(subselect);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static TargetEntry* _readTargetEntry ( void   )  [static]
static Var* _readVar ( void   )  [static]

Definition at line 407 of file readfuncs.c.

References READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_LOCATION_FIELD, READ_OID_FIELD, and READ_UINT_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(Var);

    READ_UINT_FIELD(varno);
    READ_INT_FIELD(varattno);
    READ_OID_FIELD(vartype);
    READ_INT_FIELD(vartypmod);
    READ_OID_FIELD(varcollid);
    READ_UINT_FIELD(varlevelsup);
    READ_UINT_FIELD(varnoold);
    READ_INT_FIELD(varoattno);
    READ_LOCATION_FIELD(location);

    READ_DONE();
}

static WindowClause* _readWindowClause ( void   )  [static]

Definition at line 278 of file readfuncs.c.

References name, READ_BOOL_FIELD, READ_DONE, READ_INT_FIELD, READ_LOCALS, READ_NODE_FIELD, READ_STRING_FIELD, and READ_UINT_FIELD.

Referenced by parseNodeString().

{
    READ_LOCALS(WindowClause);

    READ_STRING_FIELD(name);
    READ_STRING_FIELD(refname);
    READ_NODE_FIELD(partitionClause);
    READ_NODE_FIELD(orderClause);
    READ_INT_FIELD(frameOptions);
    READ_NODE_FIELD(startOffset);
    READ_NODE_FIELD(endOffset);
    READ_UINT_FIELD(winref);
    READ_BOOL_FIELD(copiedOrder);

    READ_DONE();
}

static WindowFunc* _readWindowFunc ( void   )  [static]
static XmlExpr* _readXmlExpr ( void   )  [static]
Node* parseNodeString ( void   ) 

Definition at line 1248 of file readfuncs.c.

References _readAggref(), _readAlias(), _readArrayCoerceExpr(), _readArrayExpr(), _readArrayRef(), _readBooleanTest(), _readBoolExpr(), _readCaseExpr(), _readCaseTestExpr(), _readCaseWhen(), _readCoalesceExpr(), _readCoerceToDomain(), _readCoerceToDomainValue(), _readCoerceViaIO(), _readCollateExpr(), _readCommonTableExpr(), _readConst(), _readConvertRowtypeExpr(), _readCurrentOfExpr(), _readDeclareCursorStmt(), _readDistinctExpr(), _readFieldSelect(), _readFieldStore(), _readFromExpr(), _readFuncExpr(), _readIntoClause(), _readJoinExpr(), _readMinMaxExpr(), _readNamedArgExpr(), _readNotifyStmt(), _readNullIfExpr(), _readNullTest(), _readOpExpr(), _readParam(), _readQuery(), _readRangeTblEntry(), _readRangeTblRef(), _readRangeVar(), _readRelabelType(), _readRowCompareExpr(), _readRowExpr(), _readRowMarkClause(), _readScalarArrayOpExpr(), _readSetOperationStmt(), _readSetToDefault(), _readSortGroupClause(), _readSubLink(), _readTargetEntry(), _readVar(), _readWindowClause(), _readWindowFunc(), _readXmlExpr(), elog, ERROR, length(), MATCH, pg_strtok(), and READ_TEMP_LOCALS.

Referenced by nodeRead().

{
    void       *return_value;

    READ_TEMP_LOCALS();

    token = pg_strtok(&length);

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

    if (MATCH("QUERY", 5))
        return_value = _readQuery();
    else if (MATCH("SORTGROUPCLAUSE", 15))
        return_value = _readSortGroupClause();
    else if (MATCH("WINDOWCLAUSE", 12))
        return_value = _readWindowClause();
    else if (MATCH("ROWMARKCLAUSE", 13))
        return_value = _readRowMarkClause();
    else if (MATCH("COMMONTABLEEXPR", 15))
        return_value = _readCommonTableExpr();
    else if (MATCH("SETOPERATIONSTMT", 16))
        return_value = _readSetOperationStmt();
    else if (MATCH("ALIAS", 5))
        return_value = _readAlias();
    else if (MATCH("RANGEVAR", 8))
        return_value = _readRangeVar();
    else if (MATCH("INTOCLAUSE", 10))
        return_value = _readIntoClause();
    else if (MATCH("VAR", 3))
        return_value = _readVar();
    else if (MATCH("CONST", 5))
        return_value = _readConst();
    else if (MATCH("PARAM", 5))
        return_value = _readParam();
    else if (MATCH("AGGREF", 6))
        return_value = _readAggref();
    else if (MATCH("WINDOWFUNC", 10))
        return_value = _readWindowFunc();
    else if (MATCH("ARRAYREF", 8))
        return_value = _readArrayRef();
    else if (MATCH("FUNCEXPR", 8))
        return_value = _readFuncExpr();
    else if (MATCH("NAMEDARGEXPR", 12))
        return_value = _readNamedArgExpr();
    else if (MATCH("OPEXPR", 6))
        return_value = _readOpExpr();
    else if (MATCH("DISTINCTEXPR", 12))
        return_value = _readDistinctExpr();
    else if (MATCH("NULLIFEXPR", 10))
        return_value = _readNullIfExpr();
    else if (MATCH("SCALARARRAYOPEXPR", 17))
        return_value = _readScalarArrayOpExpr();
    else if (MATCH("BOOLEXPR", 8))
        return_value = _readBoolExpr();
    else if (MATCH("SUBLINK", 7))
        return_value = _readSubLink();
    else if (MATCH("FIELDSELECT", 11))
        return_value = _readFieldSelect();
    else if (MATCH("FIELDSTORE", 10))
        return_value = _readFieldStore();
    else if (MATCH("RELABELTYPE", 11))
        return_value = _readRelabelType();
    else if (MATCH("COERCEVIAIO", 11))
        return_value = _readCoerceViaIO();
    else if (MATCH("ARRAYCOERCEEXPR", 15))
        return_value = _readArrayCoerceExpr();
    else if (MATCH("CONVERTROWTYPEEXPR", 18))
        return_value = _readConvertRowtypeExpr();
    else if (MATCH("COLLATE", 7))
        return_value = _readCollateExpr();
    else if (MATCH("CASE", 4))
        return_value = _readCaseExpr();
    else if (MATCH("WHEN", 4))
        return_value = _readCaseWhen();
    else if (MATCH("CASETESTEXPR", 12))
        return_value = _readCaseTestExpr();
    else if (MATCH("ARRAY", 5))
        return_value = _readArrayExpr();
    else if (MATCH("ROW", 3))
        return_value = _readRowExpr();
    else if (MATCH("ROWCOMPARE", 10))
        return_value = _readRowCompareExpr();
    else if (MATCH("COALESCE", 8))
        return_value = _readCoalesceExpr();
    else if (MATCH("MINMAX", 6))
        return_value = _readMinMaxExpr();
    else if (MATCH("XMLEXPR", 7))
        return_value = _readXmlExpr();
    else if (MATCH("NULLTEST", 8))
        return_value = _readNullTest();
    else if (MATCH("BOOLEANTEST", 11))
        return_value = _readBooleanTest();
    else if (MATCH("COERCETODOMAIN", 14))
        return_value = _readCoerceToDomain();
    else if (MATCH("COERCETODOMAINVALUE", 19))
        return_value = _readCoerceToDomainValue();
    else if (MATCH("SETTODEFAULT", 12))
        return_value = _readSetToDefault();
    else if (MATCH("CURRENTOFEXPR", 13))
        return_value = _readCurrentOfExpr();
    else if (MATCH("TARGETENTRY", 11))
        return_value = _readTargetEntry();
    else if (MATCH("RANGETBLREF", 11))
        return_value = _readRangeTblRef();
    else if (MATCH("JOINEXPR", 8))
        return_value = _readJoinExpr();
    else if (MATCH("FROMEXPR", 8))
        return_value = _readFromExpr();
    else if (MATCH("RTE", 3))
        return_value = _readRangeTblEntry();
    else if (MATCH("NOTIFY", 6))
        return_value = _readNotifyStmt();
    else if (MATCH("DECLARECURSOR", 13))
        return_value = _readDeclareCursorStmt();
    else
    {
        elog(ERROR, "badly formatted node string \"%.32s\"...", token);
        return_value = NULL;    /* keep compiler quiet */
    }

    return (Node *) return_value;
}

static Datum readDatum ( bool  typbyval  )  [static]

Definition at line 1381 of file readfuncs.c.

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

Referenced by _readConst().

{
    Size        length,
                i;
    int         tokenLength;
    char       *token;
    Datum       res;
    char       *s;

    /*
     * read the actual length of the value
     */
    token = pg_strtok(&tokenLength);
    length = atoui(token);

    token = pg_strtok(&tokenLength);    /* read the '[' */
    if (token == NULL || token[0] != '[')
        elog(ERROR, "expected \"[\" to start datum, but got \"%s\"; length = %lu",
             token ? (const char *) token : "[NULL]",
             (unsigned long) length);

    if (typbyval)
    {
        if (length > (Size) sizeof(Datum))
            elog(ERROR, "byval datum but length = %lu",
                 (unsigned long) length);
        res = (Datum) 0;
        s = (char *) (&res);
        for (i = 0; i < (Size) sizeof(Datum); i++)
        {
            token = pg_strtok(&tokenLength);
            s[i] = (char) atoi(token);
        }
    }
    else if (length <= 0)
        res = (Datum) NULL;
    else
    {
        s = (char *) palloc(length);
        for (i = 0; i < length; i++)
        {
            token = pg_strtok(&tokenLength);
            s[i] = (char) atoi(token);
        }
        res = PointerGetDatum(s);
    }

    token = pg_strtok(&tokenLength);    /* read the ']' */
    if (token == NULL || token[0] != ']')
        elog(ERROR, "expected \"]\" to end datum, but got \"%s\"; length = %lu",
             token ? (const char *) token : "[NULL]",
             (unsigned long) length);

    return res;
}