pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: Yessica Brinkmann <yessica.brinkmann@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: The connection to the server was lost. Attempting reset: Failed.
Date: Thu, 10 Oct 2019 18:15:06 +0200
Message-ID: <0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com> (raw)
In-Reply-To: <CABrYqSORdWxb_eV5=CTWAz=LrkF5Fd8xq_EbtpkvbZkfOF-8_Q@mail.gmail.com>
References: <CABrYqSORdWxb_eV5=CTWAz=LrkF5Fd8xq_EbtpkvbZkfOF-8_Q@mail.gmail.com>


> On 10 Oct 2019, at 17:55, Yessica Brinkmann <yessica.brinkmann@gmail.com> wrote:
> 
> I really thought a lot, but I don't understand why but the function fails after the expression is executed:
> appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> varattno [i]);
> The error appears only to me when entering the cycle:
> foreach (cell, candidates) / * foreach cell in candidates * /
> more than once, that is, when you have more than one candidate index. If the cycle is entered only once, the function works correctly.
> The error that appears to me is that the connection to the PostgreSQL server is directly lost. I proved that the error occurs in that statement, printing some values.

There is probably an error in the Postgres log-file providing you more info.

That said, at least the below bit in your code is dangerous:

    foreach( cell, candidates ) /* foreach cell in candidates */
    {

        idxcd = (IndexCandidate*)lfirst( cell );

        if( !idxcd->idxused )
            continue;

        if (idxcd!=NULL)
        {


You should at least check for NULL before referencing an attribute of that structure. Personally, I would invert the test like so (and then move it before the idxused test:

	if (idxcd == NULL) {
            elog( INFO, "idxcd IS NULL" );
	    continue; /* Or is that fatal enough to break instead? */
	)

        if (!idxcd->idxused)
            continue;



Alban Hertroys
--
There is always an exception to always.









view thread (10+ messages)  latest in thread

Message-ID: <0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com>
Permalink:  ../0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com/
Also on:    postgresql.org/message-id/0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com

 · 

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: haramrae@gmail.com, yessica.brinkmann@gmail.com
  Subject: Re: The connection to the server was lost. Attempting reset: Failed.
  In-Reply-To: <0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com>
  References: <CABrYqSORdWxb_eV5=CTWAz=LrkF5Fd8xq_EbtpkvbZkfOF-8_Q@mail.gmail.com> <0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com>

* 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