Hi hackers

Let me propose to amend ExplainStmt structure with an new attribute explainable_loc of ParseLoc type

with the purpose of separating an EXPLAIN command ( together with it's options ) from the statement to be explained.

This, for example, will allow to execute EXPLAIN remotely with a different set of options.

Please, find code changes in the patch.


Best regards,

Anton Ratundalov,

Postgres Professional
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 0f4e8638c3d..c431fce7ac9 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -12758,6 +12758,7 @@ ExplainStmt:
 
 					n->query = $2;
 					n->options = NIL;
+					n->explainable_loc = @2;
 					$$ = (Node *) n;
 				}
 		| EXPLAIN analyze_keyword opt_verbose ExplainableStmt
@@ -12769,6 +12770,7 @@ ExplainStmt:
 					if ($3)
 						n->options = lappend(n->options,
 											 makeDefElem("verbose", NULL, @3));
+					n->explainable_loc = @4;
 					$$ = (Node *) n;
 				}
 		| EXPLAIN VERBOSE ExplainableStmt
@@ -12777,6 +12779,7 @@ ExplainStmt:
 
 					n->query = $3;
 					n->options = list_make1(makeDefElem("verbose", NULL, @2));
+					n->explainable_loc = @3;
 					$$ = (Node *) n;
 				}
 		| EXPLAIN '(' utility_option_list ')' ExplainableStmt
@@ -12785,6 +12788,7 @@ ExplainStmt:
 
 					n->query = $5;
 					n->options = $3;
+					n->explainable_loc = @5;
 					$$ = (Node *) n;
 				}
 		;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index a92dbda0770..bad933d4f0e 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -4152,4 +4152,5 @@ typedef struct ExplainStmt
 	NodeTag		type;
 	Node	   *query;			/* the query (see comments above) */
 	List	   *options;		/* list of DefElem nodes */
+	ParseLoc   explainable_loc;
 } ExplainStmt;

Reply via email to