Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc063da1

Browse files
committed
Add parse location fields to NullTest and BooleanTest structs.
We did not need a location tag on NullTest or BooleanTest before, becauseno error messages referred directly to their locations. That's plannedto change though, so add these fields in a separate housekeeping commit.Catversion bump because stored rules may change.
1 parent6a75562 commitc063da1

File tree

14 files changed

+44
-5
lines changed

14 files changed

+44
-5
lines changed

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,7 @@ _copyNullTest(const NullTest *from)
16931693
COPY_NODE_FIELD(arg);
16941694
COPY_SCALAR_FIELD(nulltesttype);
16951695
COPY_SCALAR_FIELD(argisrow);
1696+
COPY_LOCATION_FIELD(location);
16961697

16971698
returnnewnode;
16981699
}
@@ -1707,6 +1708,7 @@ _copyBooleanTest(const BooleanTest *from)
17071708

17081709
COPY_NODE_FIELD(arg);
17091710
COPY_SCALAR_FIELD(booltesttype);
1711+
COPY_LOCATION_FIELD(location);
17101712

17111713
returnnewnode;
17121714
}

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ _equalNullTest(const NullTest *a, const NullTest *b)
622622
COMPARE_NODE_FIELD(arg);
623623
COMPARE_SCALAR_FIELD(nulltesttype);
624624
COMPARE_SCALAR_FIELD(argisrow);
625+
COMPARE_LOCATION_FIELD(location);
625626

626627
return true;
627628
}
@@ -631,6 +632,7 @@ _equalBooleanTest(const BooleanTest *a, const BooleanTest *b)
631632
{
632633
COMPARE_NODE_FIELD(arg);
633634
COMPARE_SCALAR_FIELD(booltesttype);
635+
COMPARE_LOCATION_FIELD(location);
634636

635637
return true;
636638
}

‎src/backend/nodes/nodeFuncs.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,12 +1346,22 @@ exprLocation(const Node *expr)
13461346
}
13471347
break;
13481348
caseT_NullTest:
1349-
/* just use argument's location */
1350-
loc=exprLocation((Node*) ((constNullTest*)expr)->arg);
1349+
{
1350+
constNullTest*nexpr= (constNullTest*)expr;
1351+
1352+
/* Much as above */
1353+
loc=leftmostLoc(nexpr->location,
1354+
exprLocation((Node*)nexpr->arg));
1355+
}
13511356
break;
13521357
caseT_BooleanTest:
1353-
/* just use argument's location */
1354-
loc=exprLocation((Node*) ((constBooleanTest*)expr)->arg);
1358+
{
1359+
constBooleanTest*bexpr= (constBooleanTest*)expr;
1360+
1361+
/* Much as above */
1362+
loc=leftmostLoc(bexpr->location,
1363+
exprLocation((Node*)bexpr->arg));
1364+
}
13551365
break;
13561366
caseT_CoerceToDomain:
13571367
{

‎src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ _outNullTest(StringInfo str, const NullTest *node)
13701370
WRITE_NODE_FIELD(arg);
13711371
WRITE_ENUM_FIELD(nulltesttype,NullTestType);
13721372
WRITE_BOOL_FIELD(argisrow);
1373+
WRITE_LOCATION_FIELD(location);
13731374
}
13741375

13751376
staticvoid
@@ -1379,6 +1380,7 @@ _outBooleanTest(StringInfo str, const BooleanTest *node)
13791380

13801381
WRITE_NODE_FIELD(arg);
13811382
WRITE_ENUM_FIELD(booltesttype,BoolTestType);
1383+
WRITE_LOCATION_FIELD(location);
13821384
}
13831385

13841386
staticvoid

‎src/backend/nodes/readfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ _readNullTest(void)
10441044
READ_NODE_FIELD(arg);
10451045
READ_ENUM_FIELD(nulltesttype,NullTestType);
10461046
READ_BOOL_FIELD(argisrow);
1047+
READ_LOCATION_FIELD(location);
10471048

10481049
READ_DONE();
10491050
}
@@ -1058,6 +1059,7 @@ _readBooleanTest(void)
10581059

10591060
READ_NODE_FIELD(arg);
10601061
READ_ENUM_FIELD(booltesttype,BoolTestType);
1062+
READ_LOCATION_FIELD(location);
10611063

10621064
READ_DONE();
10631065
}

‎src/backend/optimizer/plan/planagg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ build_minmax_path(PlannerInfo *root, MinMaxAggInfo *mminfo,
449449
ntest->arg=copyObject(mminfo->target);
450450
/* we checked it wasn't a rowtype in find_minmax_aggs_walker */
451451
ntest->argisrow= false;
452+
ntest->location=-1;
452453

453454
/* User might have had that in WHERE already */
454455
if (!list_member((List*)parse->jointree->quals,ntest))

‎src/backend/optimizer/prep/prepqual.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ negate_clause(Node *node)
212212
newexpr->nulltesttype= (expr->nulltesttype==IS_NULL ?
213213
IS_NOT_NULL :IS_NULL);
214214
newexpr->argisrow=expr->argisrow;
215+
newexpr->location=expr->location;
215216
return (Node*)newexpr;
216217
}
217218
}
@@ -247,6 +248,7 @@ negate_clause(Node *node)
247248
(int)expr->booltesttype);
248249
break;
249250
}
251+
newexpr->location=expr->location;
250252
return (Node*)newexpr;
251253
}
252254
break;

‎src/backend/optimizer/util/clauses.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,7 @@ eval_const_expressions_mutator(Node *node,
33053305
newntest->arg= (Expr*)relem;
33063306
newntest->nulltesttype=ntest->nulltesttype;
33073307
newntest->argisrow=type_is_rowtype(exprType(relem));
3308+
newntest->location=ntest->location;
33083309
newargs=lappend(newargs,newntest);
33093310
}
33103311
/* If all the inputs were constants, result is TRUE */
@@ -3343,6 +3344,7 @@ eval_const_expressions_mutator(Node *node,
33433344
newntest->arg= (Expr*)arg;
33443345
newntest->nulltesttype=ntest->nulltesttype;
33453346
newntest->argisrow=ntest->argisrow;
3347+
newntest->location=ntest->location;
33463348
return (Node*)newntest;
33473349
}
33483350
caseT_BooleanTest:
@@ -3395,6 +3397,7 @@ eval_const_expressions_mutator(Node *node,
33953397
newbtest=makeNode(BooleanTest);
33963398
newbtest->arg= (Expr*)arg;
33973399
newbtest->booltesttype=btest->booltesttype;
3400+
newbtest->location=btest->location;
33983401
return (Node*)newbtest;
33993402
}
34003403
caseT_PlaceHolderVar:

‎src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ get_relation_constraints(PlannerInfo *root,
720720
0);
721721
ntest->nulltesttype=IS_NOT_NULL;
722722
ntest->argisrow=type_is_rowtype(att->atttypid);
723+
ntest->location=-1;
723724
result=lappend(result,ntest);
724725
}
725726
}

‎src/backend/parser/gram.y

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11299,27 +11299,31 @@ a_expr:c_expr{ $$ = $1; }
1129911299
NullTest *n = makeNode(NullTest);
1130011300
n->arg = (Expr *)$1;
1130111301
n->nulltesttype = IS_NULL;
11302+
n->location =@2;
1130211303
$$ = (Node *)n;
1130311304
}
1130411305
|a_exprISNULL
1130511306
{
1130611307
NullTest *n = makeNode(NullTest);
1130711308
n->arg = (Expr *)$1;
1130811309
n->nulltesttype = IS_NULL;
11310+
n->location =@2;
1130911311
$$ = (Node *)n;
1131011312
}
1131111313
|a_exprISNOTNULL_P%precIS
1131211314
{
1131311315
NullTest *n = makeNode(NullTest);
1131411316
n->arg = (Expr *)$1;
1131511317
n->nulltesttype = IS_NOT_NULL;
11318+
n->location =@2;
1131611319
$$ = (Node *)n;
1131711320
}
1131811321
|a_exprNOTNULL
1131911322
{
1132011323
NullTest *n = makeNode(NullTest);
1132111324
n->arg = (Expr *)$1;
1132211325
n->nulltesttype = IS_NOT_NULL;
11326+
n->location =@2;
1132311327
$$ = (Node *)n;
1132411328
}
1132511329
|rowOVERLAPSrow
@@ -11343,41 +11347,47 @@ a_expr:c_expr{ $$ = $1; }
1134311347
BooleanTest *b = makeNode(BooleanTest);
1134411348
b->arg = (Expr *)$1;
1134511349
b->booltesttype = IS_TRUE;
11350+
b->location =@2;
1134611351
$$ = (Node *)b;
1134711352
}
1134811353
|a_exprISNOTTRUE_P%precIS
1134911354
{
1135011355
BooleanTest *b = makeNode(BooleanTest);
1135111356
b->arg = (Expr *)$1;
1135211357
b->booltesttype = IS_NOT_TRUE;
11358+
b->location =@2;
1135311359
$$ = (Node *)b;
1135411360
}
1135511361
|a_exprISFALSE_P%precIS
1135611362
{
1135711363
BooleanTest *b = makeNode(BooleanTest);
1135811364
b->arg = (Expr *)$1;
1135911365
b->booltesttype = IS_FALSE;
11366+
b->location =@2;
1136011367
$$ = (Node *)b;
1136111368
}
1136211369
|a_exprISNOTFALSE_P%precIS
1136311370
{
1136411371
BooleanTest *b = makeNode(BooleanTest);
1136511372
b->arg = (Expr *)$1;
1136611373
b->booltesttype = IS_NOT_FALSE;
11374+
b->location =@2;
1136711375
$$ = (Node *)b;
1136811376
}
1136911377
|a_exprISUNKNOWN%precIS
1137011378
{
1137111379
BooleanTest *b = makeNode(BooleanTest);
1137211380
b->arg = (Expr *)$1;
1137311381
b->booltesttype = IS_UNKNOWN;
11382+
b->location =@2;
1137411383
$$ = (Node *)b;
1137511384
}
1137611385
|a_exprISNOTUNKNOWN%precIS
1137711386
{
1137811387
BooleanTest *b = makeNode(BooleanTest);
1137911388
b->arg = (Expr *)$1;
1138011389
b->booltesttype = IS_NOT_UNKNOWN;
11390+
b->location =@2;
1138111391
$$ = (Node *)b;
1138211392
}
1138311393
|a_exprISDISTINCTFROMa_expr%precIS

‎src/backend/parser/parse_expr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ transformAExprOp(ParseState *pstate, A_Expr *a)
789789
NullTest*n=makeNode(NullTest);
790790

791791
n->nulltesttype=IS_NULL;
792+
n->location=a->location;
792793

793794
if (exprIsNullConstant(lexpr))
794795
n->arg= (Expr*)rexpr;

‎src/backend/rewrite/rewriteManip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ AddInvertedQual(Query *parsetree, Node *qual)
10231023
invqual=makeNode(BooleanTest);
10241024
invqual->arg= (Expr*)qual;
10251025
invqual->booltesttype=IS_NOT_TRUE;
1026+
invqual->location=-1;
10261027

10271028
AddQual(parsetree, (Node*)invqual);
10281029
}

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201502191
56+
#defineCATALOG_VERSION_NO201502221
5757

5858
#endif

‎src/include/nodes/primnodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ typedef struct NullTest
10501050
Expr*arg;/* input expression */
10511051
NullTestTypenulltesttype;/* IS NULL, IS NOT NULL */
10521052
boolargisrow;/* T if input is of a composite type */
1053+
intlocation;/* token location, or -1 if unknown */
10531054
}NullTest;
10541055

10551056
/*
@@ -1071,6 +1072,7 @@ typedef struct BooleanTest
10711072
Exprxpr;
10721073
Expr*arg;/* input expression */
10731074
BoolTestTypebooltesttype;/* test type */
1075+
intlocation;/* token location, or -1 if unknown */
10741076
}BooleanTest;
10751077

10761078
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp