From fe8c0a762b30b94868b5d197cd63115b2f1f9faf Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Mon, 8 Jun 2026 17:11:12 +0900 Subject: [PATCH] ecpg: Reject multiple header items in GET/SET DESCRIPTOR Previously, ecpg accepted multiple descriptor header items in GET DESCRIPTOR and SET DESCRIPTOR, but generated broken C code when they were used. Although the grammar allowed this syntax, the implementation did not actually support it. This commit tightens the ecpg grammar so the header form of GET/SET DESCRIPTOR accepts only a single header item, matching the implementation and preventing generation of broken C code. Also update the documentation synopsis accordingly. Backpatch to all supported versions. Author: Masashi Kamura Reviewed-by: Hayato Kuroda Reviewed-by: Lakshmi G Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/OS9PR01MB13174AD7D1829D0644B6BB90E9447A@OS9PR01MB13174.jpnprd01.prod.outlook.com Backpatch-through: 14 --- doc/src/sgml/ecpg.sgml | 6 +++--- src/interfaces/ecpg/preproc/ecpg.trailer | 12 ++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml index d6f1161374c..a7aae6ea4e8 100644 --- a/doc/src/sgml/ecpg.sgml +++ b/doc/src/sgml/ecpg.sgml @@ -7314,7 +7314,7 @@ EXEC SQL EXECUTE IMMEDIATE :command; -GET DESCRIPTOR descriptor_name :cvariable = descriptor_header_item [, ... ] +GET DESCRIPTOR descriptor_name :cvariable = descriptor_header_item GET DESCRIPTOR descriptor_name VALUE column_number :cvariable = descriptor_item [, ... ] @@ -7333,7 +7333,7 @@ GET DESCRIPTOR descriptor_name VALU This command has two forms: The first form retrieves - descriptor header items, which apply to the result + descriptor header item, which applies to the result set in its entirety. One example is the row count. The second form, which requires the column number as additional parameter, retrieves information about a particular column. Examples are @@ -7809,7 +7809,7 @@ EXEC SQL SET CONNECTION = con1; -SET DESCRIPTOR descriptor_name descriptor_header_item = value [, ... ] +SET DESCRIPTOR descriptor_name descriptor_header_item = value SET DESCRIPTOR descriptor_name VALUE number descriptor_item = value [, ...] diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index b2aa44f36dd..ec21cc3b19e 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1282,27 +1282,19 @@ ECPGDeallocateDescr: DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar * manipulate a descriptor header */ -ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems +ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItem { $$ = $3; } ; -ECPGGetDescHeaderItems: ECPGGetDescHeaderItem - | ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem - ; - ECPGGetDescHeaderItem: cvariable '=' desc_header_item { push_assignment($1, $3); } ; -ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems +ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItem { $$ = $3; } ; -ECPGSetDescHeaderItems: ECPGSetDescHeaderItem - | ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem - ; - ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar { push_assignment($3, $1);