From: Michael Meskes <meskes@postgresql.org>
To: Matthias Apitz <guru@unixarea.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16200: returned data from ESQL/C FETCH is trampling outside assigned memory for CHAR column
Date: Fri, 10 Jan 2020 20:46:42 +0100
Message-ID: <f4ed822c8819851534ced9e4a6efb621e23775d1.camel@postgresql.org> (raw)
In-Reply-To: <20200110150114.GA3186@c720-r342378>
References: <16200-358624daecff6820@postgresql.org>
<c3b5c8c3375e5e4da53aae70b5152930dc3460e0.camel@postgresql.org>
<20200110150114.GA3186@c720-r342378>
> I mean with ESQL/C the general term "Embedded SQL in C". Of course I
> do
> know that for PostgreSQL the precompiler is named "ecpg".
No worries, I was just making sure we do not talk about different
things as I have never seen anyone use this abbreviation before.
> Neither do I know if there is some written standard, but char strings
There is.
> IMHO
> should be NULL terminated. Our application expects in this example no
> more than 16 bytes and that's why we provide a host variable as the
> struct member of 17 bytes so the NULL fits into.
>
> I digged into the sources of the ecpglib and this small fix solved
> our problem:
> ...
Sure, this fixes your use case, but as I said, I'm not sure it's the
right thing to do for general use.
> > Could you please verify if the indicator is set accordingly?
>
> If I read the docs here
> https://www.postgresql.org/docs/11/ecpg-variables.html#ECPG-INDICATORS
> indicator vars are meant to show null values in the table and not the
> string truncation. Am I wrong? We do not use indicators at all, but
> catch the error condition -213.
Sorry, you're right of course. What I meant was the sqlca structure
which includes:
...
char sqlwarn[8];
/* Element 0: set to 'W' if at least one other is 'W' */
/* 1: if 'W' at least one character string */
/* value was truncated when it was */
/* stored into a host variable. */
...
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
Attachments:
signature.asc (application/pgp-signature, 832B) download
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-bugs@postgresql.org
Cc: meskes@postgresql.org, guru@unixarea.de
Subject: Re: BUG #16200: returned data from ESQL/C FETCH is trampling outside assigned memory for CHAR column
In-Reply-To: <f4ed822c8819851534ced9e4a6efb621e23775d1.camel@postgresql.org>
References: <16200-358624daecff6820@postgresql.org> <c3b5c8c3375e5e4da53aae70b5152930dc3460e0.camel@postgresql.org> <20200110150114.GA3186@c720-r342378> <f4ed822c8819851534ced9e4a6efb621e23775d1.camel@postgresql.org>
* 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