Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlokQ-0002eM-JI for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 07:14:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlokP-0000yJ-Gd for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 07:14:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlokP-0000yB-8p for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 07:14:05 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlokK-0003H8-Cw for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 07:14:04 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1jlokF-00054d-NV; Thu, 18 Jun 2020 09:13:56 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.90_1) (envelope-from ) id 1jlokF-0000dy-LF; Thu, 18 Jun 2020 09:13:55 +0200 Date: Thu, 18 Jun 2020 09:13:55 +0200 From: Matthias Apitz To: Tom Lane Cc: pgsql-general@lists.postgresql.org Subject: Re: ESQL/C no indicator variables ./. error -213 Message-ID: <20200618071355.GA31656@sh4-5.1blu.de> Reply-To: Matthias Apitz References: <20200617170221.GA30377@sh4-5.1blu.de> <1451504.1592415593@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1451504.1592415593@sss.pgh.pa.us> X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit El día Mittwoch, Juni 17, 2020 a las 01:39:53 -0400, Tom Lane escribió: > Matthias Apitz 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! --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="embedded.pgc" #include #include 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; } --Nq2Wo0NMKNjxTN9z--