pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: Joshua D. Drake <jd@commandprompt.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
Cc: Michael Meskes <meskes@postgresql.org>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Thread-unsafe coding in ecpg
Date: Wed, 23 Jan 2019 22:53:24 -0500
Message-ID: <18693.1548302004@sss.pgh.pa.us> (raw)
In-Reply-To: <9460.1548299404@sss.pgh.pa.us>
References: <24002.1547944649@sss.pgh.pa.us>
	<d441f5913b147e5b3e0eed4647f9839d926d90fc.camel@postgresql.org>
	<29905.1548005448@sss.pgh.pa.us>
	<29984.1548014676@sss.pgh.pa.us>
	<0A3221C70F24FB45833433255569204D1FB6C47E@G01JPEXMBYT05>
	<21439.1548037255@sss.pgh.pa.us>
	<0A3221C70F24FB45833433255569204D1FB6C4FA@G01JPEXMBYT05>
	<32316.1548040561@sss.pgh.pa.us>
	<0A3221C70F24FB45833433255569204D1FB6C6C0@G01JPEXMBYT05>
	<13850.1548090570@sss.pgh.pa.us>
	<20190121193512.tdmcnic2yjxlufaw@alap3.anarazel.de>
	<20352.1548101123@sss.pgh.pa.us>
	<0f02fb0d-0a80-0dad-a01e-e6879d24e48f@commandprompt.com>
	<27185.1548102332@sss.pgh.pa.us>
	<cf1f04ba-1cd8-2adf-10dc-d2d04de3331b@2ndQuadrant.com>
	<38244c62-e1cc-40f5-d567-777540815c16@2ndQuadrant.com>
	<d06a16bc-52d6-9f0d-2379-21242d7dbe81@2ndQuadrant.com>
	<25026.1548284495@sss.pgh.pa.us>
	<62a84a11-5d3e-1238-afd5-ec11ba91bb09@2ndQuadrant.com>
	<9460.1548299404@sss.pgh.pa.us>

I wrote:
> This suggests that, rather than throwing up our hands if the initial
> _configthreadlocale call returns -1, we should act as though the function
> doesn't exist, and just soldier on the same as before.  The code in there
> assumes that -1 is a can't-happen case and doesn't try to recover,
> but apparently that's over-optimistic.

I pushed a patch to fix that.

It looks to me like the reason that the ecpg tests went into an infinite
loop is that compat_informix/test_informix.pgc has not considered the
possibility of repeated statement failures:

    while (1)
    {
        $fetch forward c into :i, :j, :c;
        if (sqlca.sqlcode == 100) break;
        else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);

        if (risnull(CDECIMALTYPE, (char *)&j))
            printf("%d NULL\n", i);
        else
        {
            int a;

            dectoint(&j, &a);
            printf("%d %d \"%s\"\n", i, a, c);
        }
    }


I know zip about ecpg coding practices, but wouldn't it be a better idea
to break out of the loop on seeing an error?

			regards, tom lane




view thread (37+ messages)  latest in thread

Message-ID: <18693.1548302004@sss.pgh.pa.us>
Permalink:  ../18693.1548302004@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18693.1548302004@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew.dunstan@2ndquadrant.com, jd@commandprompt.com, andres@anarazel.de, tsunakawa.takay@jp.fujitsu.com, meskes@postgresql.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: Thread-unsafe coding in ecpg
  In-Reply-To: <18693.1548302004@sss.pgh.pa.us>

* 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