El día Mittwoch, Juni 17, 2020 a las 01:39:53 -0400, Tom Lane escribió:
> Matthias Apitz <[email protected]> writes:
> > We encountered that if our ESQL/C written servers see on SELECT or FETCH
> > in a row a NULL value, it will raise correctly the error -213 as written
> > and explained in
> > https://www.postgresql.org/docs/11/ecpg-variables.html#ECPG-INDICATORS
> > We catch this error -213 and deal with in.
>
> > What we did not knew and discovered today is something very fatal: In
> > such a situation on a FETCH of a row of some 55 columns, the transfer of
> > the column elements into their hostvariables stops on first NULL value,
> > as here to be seen in the log:
>
> Could you provide a self-contained test case for this? It's hard to
> guess at what the problem might be.
Hello,
attached is a simple ESQL/C code; if it is not passing the mailing-list,
the code is also here: http://www.unixarea.de/embedded.pgc and this is
its output together with the ESQL/C error log file and SQL examples:
psql -Usisis -dsisis
psql (11.4)
Geben Sie »help« für Hilfe ein.
sisis=# \d dbctest
Tabelle »public.dbctest«
Spalte | Typ | Sortierfolge | NULL erlaubt? | Vorgabewert
-----------+---------------+--------------+---------------+-------------
tstchar25 | character(25) | | |
tstint | integer | | |
Indexe:
"i_tstint" UNIQUE, btree (tstint)
sisis=# select * from dbctest where tstint = 1;
tstchar25 | tstint
-----------+--------
| 1
(1 Zeile)
./embedded
hostvariable 'tstint' before SELECT tstchar25, tstint INTO :tstchar25, :tstint
FROM dbctest: 99
hostvariable 'tstint' after SELECT tstchar25, tstint INTO :tstchar25, :tstint
FROM dbctest with -213: 99
cat esqlc.6485
[6485] [18.06.2020 08:26:38:433]: ECPGdebug: set to 1
[6485] [18.06.2020 08:26:38:433]: ECPGdebug: proc argv0 is embedded
[6485] [18.06.2020 08:26:38:433]: ECPGconnect: opening database sisis on
localhost port 5432 with options application_name=SunRise DBCALL V7.1
(pid=6485) for user sisis
[6485] [18.06.2020 08:26:38:436]: ecpg_execute on line 36: query: select
tstchar25 , tstint from dbctest where tstint = 1; with 0 parameter(s) on
connection sisis
[6485] [18.06.2020 08:26:38:437]: ecpg_execute on line 36: using PQexec
[6485] [18.06.2020 08:26:38:437]: ecpg_process_output on line 36: correctly got
1 tuples with 2 fields
[6485] [18.06.2020 08:26:38:437]: ecpg_get_data on line 36: RESULT: offset:
80; array: no
[6485] [18.06.2020 08:26:38:437]: raising sqlcode -213 on line 36: null value
without indicator on line 36
[6485] [18.06.2020 08:26:38:438]: ecpg_finish: connection sisis closed
Thanks
matthias
--
Matthias Apitz, ✉ [email protected], http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!
#include <stdio.h>
#include <stdlib.h>
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR sqlprint;
void posSqlError() { return; }
main()
{
FILE *fp;
char file[80];
sprintf(file, "esqlc.%d", getpid());
fp = fopen(file, "w");
ECPGdebug(1, fp);
EXEC SQL BEGIN DECLARE SECTION;
char connection[1024];
char user[80];
char pass[80];
char tstchar25[80];
int tstint = 99;
EXEC SQL END DECLARE SECTION;
sprintf(connection,
"tcp:postgresql://localhost:5432/sisis?application_name=SunRise DBCALL V7.1
(pid=%d)", getpid());
strcpy(user, "sisis");
strcpy(pass, "sisis123");
EXEC SQL WHENEVER SQLERROR call posSqlError();
EXEC SQL CONNECT TO :connection USER :user USING :pass ;
printf("hostvariable 'tstint' before SELECT tstchar25, tstint INTO
:tstchar25, :tstint FROM dbctest: %d\n", tstint);
EXEC SQL SELECT tstchar25, tstint INTO :tstchar25, :tstint FROM dbctest
WHERE tstint = 1;
printf("hostvariable 'tstint' after SELECT tstchar25, tstint INTO
:tstchar25, :tstint FROM dbctest with -213: %d\n", tstint);
EXEC SQL DISCONNECT;
return 0;
}