]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
ecpg: Reject multiple header items in GET/SET DESCRIPTOR
authorFujii Masao <fujii@postgresql.org>
Mon, 8 Jun 2026 08:07:48 +0000 (17:07 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 8 Jun 2026 08:09:46 +0000 (17:09 +0900)
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 <kamura.masashi@fujitsu.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Lakshmi G <lakshmigcdac@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OS9PR01MB13174AD7D1829D0644B6BB90E9447A@OS9PR01MB13174.jpnprd01.prod.outlook.com
Backpatch-through: 14

doc/src/sgml/ecpg.sgml
src/interfaces/ecpg/preproc/ecpg.trailer

index 6203b2518cf0cf75f18e49c012ef9d352da3b52c..4651382b6351a6a06b2f78ed990eee6bf19f00d5 100644 (file)
@@ -7312,7 +7312,7 @@ EXEC SQL EXECUTE IMMEDIATE :command;
 
    <refsynopsisdiv>
 <synopsis>
-GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> <replaceable class="parameter">:cvariable</replaceable> = <replaceable class="parameter">descriptor_header_item</replaceable> [, ... ]
+GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> <replaceable class="parameter">:cvariable</replaceable> = <replaceable class="parameter">descriptor_header_item</replaceable>
 GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALUE <replaceable class="parameter">column_number</replaceable> <replaceable class="parameter">:cvariable</replaceable> = <replaceable class="parameter">descriptor_item</replaceable> [, ... ]
 </synopsis>
    </refsynopsisdiv>
@@ -7331,7 +7331,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
 
     <para>
      This command has two forms: The first form retrieves
-     descriptor <quote>header</quote> items, which apply to the result
+     descriptor <quote>header</quote> 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;
 
    <refsynopsisdiv>
 <synopsis>
-SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> <replaceable class="parameter">descriptor_header_item</replaceable> = <replaceable>value</replaceable> [, ... ]
+SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> <replaceable class="parameter">descriptor_header_item</replaceable> = <replaceable>value</replaceable>
 SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALUE <replaceable class="parameter">number</replaceable> <replaceable class="parameter">descriptor_item</replaceable> = <replaceable>value</replaceable> [, ...]
 </synopsis>
    </refsynopsisdiv>
index e4c13fdd2b607f941fb345c5e03e89f50ab76ff5..ed6fa1d36571d7655072f178c57327805ff792c5 100644 (file)
@@ -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);