pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Apitz <guru@unixarea.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: ESQL/C no indicator variables ./. error -213
Date: Thu, 18 Jun 2020 09:13:55 +0200
Message-ID: <20200618071355.GA31656@sh4-5.1blu.de> (raw)
In-Reply-To: <1451504.1592415593@sss.pgh.pa.us>
References: <20200617170221.GA30377@sh4-5.1blu.de>
	<1451504.1592415593@sss.pgh.pa.us>

El día Mittwoch, Juni 17, 2020 a las 01:39:53 -0400, Tom Lane escribió:

> Matthias Apitz <guru@unixarea.de> 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, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!

Attachments:

embedded.pgc (text/plain, 1.1K) download #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; }

view thread (6+ messages)  latest in thread

Message-ID: <20200618071355.GA31656@sh4-5.1blu.de>
Permalink:  ../20200618071355.GA31656@sh4-5.1blu.de/
Also on:    postgresql.org/message-id/20200618071355.GA31656@sh4-5.1blu.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guru@unixarea.de, tgl@sss.pgh.pa.us
  Subject: Re: ESQL/C no indicator variables ./. error -213
  In-Reply-To: <20200618071355.GA31656@sh4-5.1blu.de>
  References: <20200617170221.GA30377@sh4-5.1blu.de> <1451504.1592415593@sss.pgh.pa.us> <20200618071355.GA31656@sh4-5.1blu.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox