@@ -801,7 +801,7 @@ pg_rewrite_query(Query *query)
801801 new_list = copyObject (querytree_list );
802802 /* This checks both copyObject() and the equal() routines... */
803803 if (!equal (new_list , querytree_list ))
804- elog (WARNING , "copyObject() failed to produce equal parse tree" );
804+ elog (WARNING , "copyObject() failed to produce an equal rewritten parse tree" );
805805 else
806806 querytree_list = new_list ;
807807 }
@@ -813,35 +813,25 @@ pg_rewrite_query(Query *query)
813813 List * new_list = NIL ;
814814 ListCell * lc ;
815815
816- /*
817- * We currently lack outfuncs/readfuncs support for most utility
818- * statement types, so only attempt to write/read non-utility queries.
819- */
820816 foreach (lc , querytree_list )
821817 {
822818 Query * query = lfirst_node (Query , lc );
819+ char * str = nodeToString (query );
820+ Query * new_query = stringToNodeWithLocations (str );
823821
824- if (query -> commandType != CMD_UTILITY )
825- {
826- char * str = nodeToString (query );
827- Query * new_query = stringToNodeWithLocations (str );
828-
829- /*
830- * queryId is not saved in stored rules, but we must preserve
831- * it here to avoid breaking pg_stat_statements.
832- */
833- new_query -> queryId = query -> queryId ;
822+ /*
823+ * queryId is not saved in stored rules, but we must preserve it
824+ * here to avoid breaking pg_stat_statements.
825+ */
826+ new_query -> queryId = query -> queryId ;
834827
835- new_list = lappend (new_list , new_query );
836- pfree (str );
837- }
838- else
839- new_list = lappend (new_list , query );
828+ new_list = lappend (new_list , new_query );
829+ pfree (str );
840830 }
841831
842832 /* This checks both outfuncs/readfuncs and the equal() routines... */
843833 if (!equal (new_list , querytree_list ))
844- elog (WARNING , "outfuncs/readfuncs failed to produce equal parse tree" );
834+ elog (WARNING , "outfuncs/readfuncs failed to produce an equal rewritten parse tree" );
845835 else
846836 querytree_list = new_list ;
847837 }
0 commit comments