From: Fujii Masao Date: Mon, 8 Jun 2026 08:07:48 +0000 (+0900) Subject: ecpg: Reject multiple header items in GET/SET DESCRIPTOR X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4484165b0712f09ca369ed497fc6f504b718abac;p=thirdparty%2Fpostgresql.git 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 --- diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml index 6203b2518cf..4651382b635 100644 --- a/doc/src/sgml/ecpg.sgml +++ b/doc/src/sgml/ecpg.sgml @@ -7312,7 +7312,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 [, ... ] @@ -7331,7 +7331,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 @@ -7807,7 +7807,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 e4c13fdd2b6..ed6fa1d3657 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1421,32 +1421,24 @@ 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);