mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 00:03:23 -04:00
Add parse location fields to NullTest and BooleanTest structs.
We did not need a location tag on NullTest or BooleanTest before, because no error messages referred directly to their locations. That's planned to change though, so add these fields in a separate housekeeping commit. Catversion bump because stored rules may change.
This commit is contained in:
parent
6a75562ed1
commit
c063da1769
@ -1693,6 +1693,7 @@ _copyNullTest(const NullTest *from)
|
||||
COPY_NODE_FIELD(arg);
|
||||
COPY_SCALAR_FIELD(nulltesttype);
|
||||
COPY_SCALAR_FIELD(argisrow);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -1707,6 +1708,7 @@ _copyBooleanTest(const BooleanTest *from)
|
||||
|
||||
COPY_NODE_FIELD(arg);
|
||||
COPY_SCALAR_FIELD(booltesttype);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
@ -622,6 +622,7 @@ _equalNullTest(const NullTest *a, const NullTest *b)
|
||||
COMPARE_NODE_FIELD(arg);
|
||||
COMPARE_SCALAR_FIELD(nulltesttype);
|
||||
COMPARE_SCALAR_FIELD(argisrow);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -631,6 +632,7 @@ _equalBooleanTest(const BooleanTest *a, const BooleanTest *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(arg);
|
||||
COMPARE_SCALAR_FIELD(booltesttype);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1346,12 +1346,22 @@ exprLocation(const Node *expr)
|
||||
}
|
||||
break;
|
||||
case T_NullTest:
|
||||
/* just use argument's location */
|
||||
loc = exprLocation((Node *) ((const NullTest *) expr)->arg);
|
||||
{
|
||||
const NullTest *nexpr = (const NullTest *) expr;
|
||||
|
||||
/* Much as above */
|
||||
loc = leftmostLoc(nexpr->location,
|
||||
exprLocation((Node *) nexpr->arg));
|
||||
}
|
||||
break;
|
||||
case T_BooleanTest:
|
||||
/* just use argument's location */
|
||||
loc = exprLocation((Node *) ((const BooleanTest *) expr)->arg);
|
||||
{
|
||||
const BooleanTest *bexpr = (const BooleanTest *) expr;
|
||||
|
||||
/* Much as above */
|
||||
loc = leftmostLoc(bexpr->location,
|
||||
exprLocation((Node *) bexpr->arg));
|
||||
}
|
||||
break;
|
||||
case T_CoerceToDomain:
|
||||
{
|
||||
|
@ -1370,6 +1370,7 @@ _outNullTest(StringInfo str, const NullTest *node)
|
||||
WRITE_NODE_FIELD(arg);
|
||||
WRITE_ENUM_FIELD(nulltesttype, NullTestType);
|
||||
WRITE_BOOL_FIELD(argisrow);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1379,6 +1380,7 @@ _outBooleanTest(StringInfo str, const BooleanTest *node)
|
||||
|
||||
WRITE_NODE_FIELD(arg);
|
||||
WRITE_ENUM_FIELD(booltesttype, BoolTestType);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1044,6 +1044,7 @@ _readNullTest(void)
|
||||
READ_NODE_FIELD(arg);
|
||||
READ_ENUM_FIELD(nulltesttype, NullTestType);
|
||||
READ_BOOL_FIELD(argisrow);
|
||||
READ_LOCATION_FIELD(location);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
@ -1058,6 +1059,7 @@ _readBooleanTest(void)
|
||||
|
||||
READ_NODE_FIELD(arg);
|
||||
READ_ENUM_FIELD(booltesttype, BoolTestType);
|
||||
READ_LOCATION_FIELD(location);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
@ -449,6 +449,7 @@ build_minmax_path(PlannerInfo *root, MinMaxAggInfo *mminfo,
|
||||
ntest->arg = copyObject(mminfo->target);
|
||||
/* we checked it wasn't a rowtype in find_minmax_aggs_walker */
|
||||
ntest->argisrow = false;
|
||||
ntest->location = -1;
|
||||
|
||||
/* User might have had that in WHERE already */
|
||||
if (!list_member((List *) parse->jointree->quals, ntest))
|
||||
|
@ -212,6 +212,7 @@ negate_clause(Node *node)
|
||||
newexpr->nulltesttype = (expr->nulltesttype == IS_NULL ?
|
||||
IS_NOT_NULL : IS_NULL);
|
||||
newexpr->argisrow = expr->argisrow;
|
||||
newexpr->location = expr->location;
|
||||
return (Node *) newexpr;
|
||||
}
|
||||
}
|
||||
@ -247,6 +248,7 @@ negate_clause(Node *node)
|
||||
(int) expr->booltesttype);
|
||||
break;
|
||||
}
|
||||
newexpr->location = expr->location;
|
||||
return (Node *) newexpr;
|
||||
}
|
||||
break;
|
||||
|
@ -3305,6 +3305,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
newntest->arg = (Expr *) relem;
|
||||
newntest->nulltesttype = ntest->nulltesttype;
|
||||
newntest->argisrow = type_is_rowtype(exprType(relem));
|
||||
newntest->location = ntest->location;
|
||||
newargs = lappend(newargs, newntest);
|
||||
}
|
||||
/* If all the inputs were constants, result is TRUE */
|
||||
@ -3343,6 +3344,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
newntest->arg = (Expr *) arg;
|
||||
newntest->nulltesttype = ntest->nulltesttype;
|
||||
newntest->argisrow = ntest->argisrow;
|
||||
newntest->location = ntest->location;
|
||||
return (Node *) newntest;
|
||||
}
|
||||
case T_BooleanTest:
|
||||
@ -3395,6 +3397,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
newbtest = makeNode(BooleanTest);
|
||||
newbtest->arg = (Expr *) arg;
|
||||
newbtest->booltesttype = btest->booltesttype;
|
||||
newbtest->location = btest->location;
|
||||
return (Node *) newbtest;
|
||||
}
|
||||
case T_PlaceHolderVar:
|
||||
|
@ -720,6 +720,7 @@ get_relation_constraints(PlannerInfo *root,
|
||||
0);
|
||||
ntest->nulltesttype = IS_NOT_NULL;
|
||||
ntest->argisrow = type_is_rowtype(att->atttypid);
|
||||
ntest->location = -1;
|
||||
result = lappend(result, ntest);
|
||||
}
|
||||
}
|
||||
|
@ -11299,6 +11299,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
NullTest *n = makeNode(NullTest);
|
||||
n->arg = (Expr *) $1;
|
||||
n->nulltesttype = IS_NULL;
|
||||
n->location = @2;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| a_expr ISNULL
|
||||
@ -11306,6 +11307,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
NullTest *n = makeNode(NullTest);
|
||||
n->arg = (Expr *) $1;
|
||||
n->nulltesttype = IS_NULL;
|
||||
n->location = @2;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| a_expr IS NOT NULL_P %prec IS
|
||||
@ -11313,6 +11315,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
NullTest *n = makeNode(NullTest);
|
||||
n->arg = (Expr *) $1;
|
||||
n->nulltesttype = IS_NOT_NULL;
|
||||
n->location = @2;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| a_expr NOTNULL
|
||||
@ -11320,6 +11323,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
NullTest *n = makeNode(NullTest);
|
||||
n->arg = (Expr *) $1;
|
||||
n->nulltesttype = IS_NOT_NULL;
|
||||
n->location = @2;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| row OVERLAPS row
|
||||
@ -11343,6 +11347,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_TRUE;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS NOT TRUE_P %prec IS
|
||||
@ -11350,6 +11355,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_NOT_TRUE;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS FALSE_P %prec IS
|
||||
@ -11357,6 +11363,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_FALSE;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS NOT FALSE_P %prec IS
|
||||
@ -11364,6 +11371,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_NOT_FALSE;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS UNKNOWN %prec IS
|
||||
@ -11371,6 +11379,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_UNKNOWN;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS NOT UNKNOWN %prec IS
|
||||
@ -11378,6 +11387,7 @@ a_expr: c_expr { $$ = $1; }
|
||||
BooleanTest *b = makeNode(BooleanTest);
|
||||
b->arg = (Expr *) $1;
|
||||
b->booltesttype = IS_NOT_UNKNOWN;
|
||||
b->location = @2;
|
||||
$$ = (Node *)b;
|
||||
}
|
||||
| a_expr IS DISTINCT FROM a_expr %prec IS
|
||||
|
@ -789,6 +789,7 @@ transformAExprOp(ParseState *pstate, A_Expr *a)
|
||||
NullTest *n = makeNode(NullTest);
|
||||
|
||||
n->nulltesttype = IS_NULL;
|
||||
n->location = a->location;
|
||||
|
||||
if (exprIsNullConstant(lexpr))
|
||||
n->arg = (Expr *) rexpr;
|
||||
|
@ -1023,6 +1023,7 @@ AddInvertedQual(Query *parsetree, Node *qual)
|
||||
invqual = makeNode(BooleanTest);
|
||||
invqual->arg = (Expr *) qual;
|
||||
invqual->booltesttype = IS_NOT_TRUE;
|
||||
invqual->location = -1;
|
||||
|
||||
AddQual(parsetree, (Node *) invqual);
|
||||
}
|
||||
|
@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201502191
|
||||
#define CATALOG_VERSION_NO 201502221
|
||||
|
||||
#endif
|
||||
|
@ -1050,6 +1050,7 @@ typedef struct NullTest
|
||||
Expr *arg; /* input expression */
|
||||
NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
|
||||
bool argisrow; /* T if input is of a composite type */
|
||||
int location; /* token location, or -1 if unknown */
|
||||
} NullTest;
|
||||
|
||||
/*
|
||||
@ -1071,6 +1072,7 @@ typedef struct BooleanTest
|
||||
Expr xpr;
|
||||
Expr *arg; /* input expression */
|
||||
BoolTestType booltesttype; /* test type */
|
||||
int location; /* token location, or -1 if unknown */
|
||||
} BooleanTest;
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user