From 399edafa2aba562a8013fbe039f3cbf3a41a436e Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Fri, 13 Aug 2021 10:34:04 +0200 Subject: Fix connection handling for DEALLOCATE and DESCRIBE statements After binding a statement to a connection with DECLARE STATEMENT the connection was still not used for DEALLOCATE and DESCRIBE statements. This patch fixes that, adds a missing warning and cleans up the code. Author: Hayato Kuroda Reviewed-by: Kyotaro Horiguchi, Michael Paquier Discussion: https://postgr.es/m/TYAPR01MB5866BA57688DF2770E2F95C6F5069%40TYAPR01MB5866.jpnprd01.prod.outlook.com --- src/interfaces/ecpg/preproc/descriptor.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/interfaces/ecpg/preproc/descriptor.c') diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c index a29f5303273..35d94711d56 100644 --- a/src/interfaces/ecpg/preproc/descriptor.c +++ b/src/interfaces/ecpg/preproc/descriptor.c @@ -121,7 +121,10 @@ drop_descriptor(char *name, char *connection) } } } - mmerror(PARSE_ERROR, ET_WARNING, "descriptor \"%s\" does not exist", name); + if (connection) + mmerror(PARSE_ERROR, ET_WARNING, "descriptor %s bound to connection %s does not exist", name, connection); + else + mmerror(PARSE_ERROR, ET_WARNING, "descriptor %s bound to the default connection does not exist", name); } struct descriptor @@ -141,9 +144,18 @@ lookup_descriptor(char *name, char *connection) || (connection && i->connection && strcmp(connection, i->connection) == 0)) return i; + if (connection && !i->connection) + { + /* overwrite descriptor's connection */ + i->connection = mm_strdup(connection); + return i; + } } } - mmerror(PARSE_ERROR, ET_WARNING, "descriptor \"%s\" does not exist", name); + if (connection) + mmerror(PARSE_ERROR, ET_WARNING, "descriptor %s bound to connection %s does not exist", name, connection); + else + mmerror(PARSE_ERROR, ET_WARNING, "descriptor %s bound to the default connection does not exist", name); return NULL; } -- cgit v1.2.3