Hi! I started reviewing it and noticed that your code repeated this cycle maybe it would be better to put it in a separate function, for example in the form of a name like "analyze_stmts"?

or is it possible to create a macro for them?

@@ -2016,6 +2017,17 @@ exec_bind_message(StringInfo input_message)
      */
     cplan = GetCachedPlan(psrc, params, NULL, NULL);

+    foreach(lc, cplan->stmt_list)
+    {
+        PlannedStmt *plan = lfirst_node(PlannedStmt, lc);
+
+        if (plan->planId != UINT64CONST(0))
+        {
+            pgstat_report_plan_id(plan->planId, false);
+            break;
+        }
+    }
+
     /*
      * Now we can define the portal.
      *
@@ -2170,6 +2182,17 @@ exec_execute_message(const char *portal_name, long max_rows)
         }
     }

+    foreach(lc, portal->stmts)
+    {
+        PlannedStmt *stmt = lfirst_node(PlannedStmt, lc);
+
+        if (stmt->planId != UINT64CONST(0))
+        {
+            pgstat_report_plan_id(stmt->planId, false);
+            break;
+        }
+    }
+
     cmdtagname = GetCommandTagNameAndLen(portal->commandTag, &cmdtaglen);

--
Regards,
Alena Rybakina
Postgres Professional



Reply via email to