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 1jlvVu-0000vy-Ox for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 14:27:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlvVt-0008Hv-Gr for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 14:27:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlvVt-0008Hn-95 for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 14:27:33 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlvVq-00089j-Kg for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 14:27:31 +0000 Received: by mail-ej1-x631.google.com with SMTP id mb16so6651606ejb.4 for ; Thu, 18 Jun 2020 07:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=ckLFXwcpmGdnvzTrgFwZ3jnXmnlmL1k7OA58z0USfgQ=; b=bWbl2qrBGuWZvEGSoDdtt6ezKtZ5lJ2dWeqAeKZIfGVEzb/9k418fpLZqyq5yXLHDB ce5K74zc51Vn1KZcQDm7Wd1rA8JGQ+JyMT3rMEnWGMo18jn90mA1363hq8shGwXIY45+ FD+YHHeZUEnWVi/rE4eklScy42SR1ONF26Ouijr0Bl6Q1/1vHLBcj6qhhSEi+e0cHx+Y IjCfsuVQ8zRy6hT01VV/+usELXJoxKuEjnkzWqhmLwPHWgOIkThy1R3g7IPnctYJmGsp UAqTqXpy3QPlcVKkfFr0n7bQwMj11Oi5ZjP6vmOal1xV/Zb3liroqnYaU049HWUBKf20 ZAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ckLFXwcpmGdnvzTrgFwZ3jnXmnlmL1k7OA58z0USfgQ=; b=VnQl3iF3Jdv4chYaJRHwFhIRKJhzzrpBCg6QeJXo+8UUA7LVVn+vPKQCy8hRox/LzG Pm8oWDLRAELfxwR2uFt1E1D0SBGpbGf58RoZxPS5cQyvpnD6HCJGwtA4Txm4Y53/s++1 ZBy+HaOd3ZlXTHgvLn7FkMcxDizceOP44gXBJq9B1kDvX7BeqEnn+A+X8EF223YF9Zu7 zomLFwDsQoFFQxQtY84Ws6kYFdr0dWbutfCFJ8i/TCrnX8aKgIY1M1A6XXavE/VwUh2G YZgFO2HKOf2nMxc/O4RkaOpxGI4ZX1yyY8XMFcj4NvtEpymlYVhSCg8HiZTYaFVvPDmz mTuA== X-Gm-Message-State: AOAM531tWpSTpmUAgrUJi38fnLIBW9A27gobRWFgu1ls0b+KDHBz2rie bM3m+8V9glsri+0zcVFIaVRPaZ7qzzo= X-Google-Smtp-Source: ABdhPJwKkitipU/bvLmmEBa4iLpUe3t8Wrk7gPn/kvE2DG1D2f3nzo0GEDDM2lGkzdRUreBSqpIFWg== X-Received: by 2002:a17:906:7c56:: with SMTP id g22mr4056033ejp.507.1592490448159; Thu, 18 Jun 2020 07:27:28 -0700 (PDT) Received: from dynamic-em32qc3bam80l1w4o-pd01.res.v6.highway.a1.net (dynamic-em32qc3bam80l1w4o-pd01.res.v6.highway.a1.net. [2001:871:60:3448:8fa:a39f:2073:8de8]) by smtp.gmail.com with ESMTPSA id o13sm2385517ejb.46.2020.06.18.07.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 07:27:27 -0700 (PDT) Message-ID: <2ec31705b9c4a5e8ff8627a9f5a4edb099fd7edd.camel@cybertec.at> Subject: Re: ESQL/C no indicator variables ./. error -213 From: Laurenz Albe To: Matthias Apitz , pgsql-general@lists.postgresql.org Date: Thu, 18 Jun 2020 16:27:26 +0200 In-Reply-To: <20200617170221.GA30377@sh4-5.1blu.de> References: <20200617170221.GA30377@sh4-5.1blu.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2020-06-17 at 19:02 +0200, Matthias Apitz wrote: > 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: > > [29217] [17.06.2020 15:49:16:499]: ecpg_execute on line 69: query: select * from acq_ffleit where bnr = $1 ; with 1 parameter(s) on connection sisis > [29217] [17.06.2020 15:49:16:500]: ecpg_execute on line 69: using PQexecParams > [29217] [17.06.2020 15:49:16:500]: ecpg_free_params on line 69: parameter 1 = 742 > [29217] [17.06.2020 15:49:16:500]: ecpg_process_output on line 69: correctly got 1 tuples with 55 fields > [29217] [17.06.2020 15:49:16:500]: ecpg_get_data on line 69: RESULT: 742 offset: 752; array: no > ... > [29217] [17.06.2020 15:49:16:500]: ecpg_get_data on line 69: RESULT: 49 offset: 752; array: no > [29217] [17.06.2020 15:49:16:500]: ecpg_get_data on line 69: RESULT: offset: 752; array: no > [29217] [17.06.2020 15:49:16:500]: raising sqlcode -213 on line 69: null value without indicator on line 69 > > In the above examples the transfer stopped after 47 RESULTs; the > hostvariables after this have been untouched in our program, i.e. only > part of the row has been read. > > One could say, "so what, you have error -213 and you deserve it". But at > least this behaviour should be documented clearly in the above mentioned page. > > I would expect, that NULL values would not be transfered in such case > but all other hostvariables yes, i.e. for me this is perhaps a bug in the > ESQL/C implementation. I think that is as expected. The documentation says: To be able to pass null values to the database or retrieve null values from the database, you need to append a second host variable specification to each host variable that contains data. This second host variable is called the *indicator* [...] Failure to do that causes an error (which you catch). If a statement causes an error, you cannot rely on the state of any host valiable that gets set by that statement. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com