RE: ECPG: inconsistent behavior with the document in “GET/SET DESCRIPTOR.”

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: "Masashi Kamura (Fujitsu)" <kamura(dot)masashi(at)fujitsu(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: ECPG: inconsistent behavior with the document in “GET/SET DESCRIPTOR.”
Date: 2026-04-16 05:48:15
Message-ID: OS9PR01MB12149D090EDD1D8D70770DED7F5232@OS9PR01MB12149.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Kamura-san,

> Embedded SQL:
> ```
> EXEC SQL GET DESCRIPTOR d :desc_count1 = count, :desc_count2 = count;
> ```
>
> Precompiled result:
> ```
> { ECPGget_desc_header(__LINE__, "d", &(desc_count2desc_count1));
> ```
>
> Reported error by the compiler:
> ```
> bytea.pgc: In function 'main':
>
> bytea.pgc:123:48: error: 'desc_count2desc_count1' undeclared (first use in this
> function)

Good catch, agreed that current result should be fixed.

> According to my analysis, the parser can accept multiple headers,
> but the output function cannot.
> See ECPGGetDescHeaderItems and output_get_descr_header().
> Therefore, it is thought that the variables were incorrectly concatenated,
> resulting in an error.
>
> I feel even if multiple header items cannot be specified,
> invalid syntax should be detected by the precompiler, not the compiler.
> Attached patch fixes both parser and the documentation.
> After applying the patch, the above example can detect the invalid syntax
> by the precompiler anymore.

IIUC, there is another approach, allowing to specify multiple COUNT clause
in the SET/GET DESCRIPTOR. E.g.,

```
EXEC SQL GET DESCRIPTOR d :desc_count1 = count, :desc_count2 = count;
-> set COUNT value to desc_count1 and desc_count2.
```

Do you have theory which one is better?

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-04-16 05:50:25 Re: Add errdetail() with PID and UID about source of termination signal
Previous Message Masahiko Sawada 2026-04-16 05:47:58 Re: First draft of PG 19 release notes