v1-0001-Don-t-allow-to-execute-an-empty-query.patch

text/x-patch

Filename: v1-0001-Don-t-allow-to-execute-an-empty-query.patch
Type: text/x-patch
Part: 0
Message: Re: BUG #18984: Empty prepared statement from psql \parse triggers assert in PortalRunMulti

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v1-0001
Subject: Don't allow to execute an empty query
File+
src/backend/commands/prepare.c 3 0
From 6c5e08a3d4698d5966044543b438438376b5b6c1 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 15 Jul 2025 00:09:07 +0300
Subject: [PATCH v1] Don't allow to execute an empty query

---
 src/backend/commands/prepare.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 34b6410d6a2..244967920f3 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -169,6 +169,9 @@ ExecuteQuery(ParseState *pstate,
 	if (!entry->plansource->fixed_result)
 		elog(ERROR, "EXECUTE does not support variable-result cached plans");
 
+	if (strcmp(entry->plansource->query_string, "") == 0)
+		elog(ERROR, "EXECUTE can't execute an empty query");
+
 	/* Evaluate parameters, if any */
 	if (entry->plansource->num_params > 0)
 	{
-- 
2.43.0