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

Commit13d53aa

Browse files
committed
Doc/improve confusing, inefficient tests to locate CTID variable.
The IsCTIDVar() tests in nodeTidscan.c and nodeTidrangescan.clook buggy at first sight: they aren't checking that the varnomatches the table to be scanned. Actually they're safe becauseany Var in a scan-level qual must be for the correct table ...but if we're depending on that, it's pretty pointless to verifyvarlevelsup. (Besides which, varlevelsup is *always* zero atexecution, since we've flattened the rangetable long since.)Remove the useless varlevelsup check, and instead add somecommentary explaining why we don't need to check varno.Noted while fooling with a planner change that causes the orderof "t1.ctid = t2.ctid" to change in some tidscan.sql tests;I was briefly fooled into thinking there was a live bug here.
1 parent0e972f5 commit13d53aa

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

‎src/backend/executor/nodeTidrangescan.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@
2525
#include"utils/rel.h"
2626

2727

28+
/*
29+
* It's sufficient to check varattno to identify the CTID variable, as any
30+
* Var in the relation scan qual must be for our table. (Even if it's a
31+
* parameterized scan referencing some other table's CTID, the other table's
32+
* Var would have become a Param by the time it gets here.)
33+
*/
2834
#defineIsCTIDVar(node) \
2935
((node) != NULL && \
3036
IsA((node), Var) && \
31-
((Var *) (node))->varattno == SelfItemPointerAttributeNumber && \
32-
((Var *) (node))->varlevelsup == 0)
37+
((Var *) (node))->varattno == SelfItemPointerAttributeNumber)
3338

3439
typedefenum
3540
{

‎src/backend/executor/nodeTidscan.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@
3535
#include"utils/rel.h"
3636

3737

38+
/*
39+
* It's sufficient to check varattno to identify the CTID variable, as any
40+
* Var in the relation scan qual must be for our table. (Even if it's a
41+
* parameterized scan referencing some other table's CTID, the other table's
42+
* Var would have become a Param by the time it gets here.)
43+
*/
3844
#defineIsCTIDVar(node) \
3945
((node) != NULL && \
4046
IsA((node), Var) && \
41-
((Var *) (node))->varattno == SelfItemPointerAttributeNumber && \
42-
((Var *) (node))->varlevelsup == 0)
47+
((Var *) (node))->varattno == SelfItemPointerAttributeNumber)
4348

4449
/* one element in tss_tidexprs */
4550
typedefstructTidExpr

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp