Print baserestrictinfo for varchar fields
Hi,
I noticed that debug_print_rel outputs "unknown expr" when the fields
in baserestrictinfo are typed as varchar.
create table tbl_a(id int, info varchar(32));
RELOPTINFO (tbl_a): rows=4 width=86
baserestrictinfo: unknown expr = pattern
My approach is to handle the RelabelType case in print_expr. After
the patch, I get:
RELOPTINFO (tbl_a): rows=4 width=86
baserestrictinfo: tbl_a.info = pattern
I wonder if this is a proper way of fixing it?
Thank you,
Donald Dong
Attachments:
001_print_baserestrictinfo_varchar.patchapplication/octet-stream; name=001_print_baserestrictinfo_varchar.patch; x-unix-mode=0644Download
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index 4b9e141404..5076e85cfe 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -415,6 +415,12 @@ print_expr(const Node *expr, const List *rtable)
}
printf(")");
}
+ else if (IsA(expr, RelabelType))
+ {
+ const RelabelType *r = (const RelabelType*) expr;
+
+ print_expr((Node *) r->arg, rtable);
+ }
else
printf("unknown expr");
}
Donald Dong <xdong@csumb.edu> writes:
I noticed that debug_print_rel outputs "unknown expr" when the fields
in baserestrictinfo are typed as varchar.
...
I wonder if this is a proper way of fixing it?
It's hard to muster much enthusiasm for extending print_expr(),
considering how incomplete and little-used it is. I'd rather
spend effort on ripping it out in favor of using the far more
complete, and better-tested, code in ruleutils.c.
regards, tom lane
On Mon, Jun 03, 2019 at 01:37:22AM -0400, Tom Lane wrote:
It's hard to muster much enthusiasm for extending print_expr(),
considering how incomplete and little-used it is. I'd rather
spend effort on ripping it out in favor of using the far more
complete, and better-tested, code in ruleutils.c.
If it is possible to get the same amount of coverage when debugging
the planner, count me in. Now it seems to me that we'd still require
some work to get the same level of information as for range table
entry kinds..
--
Michael