Re: The connection to the server was lost. Attempting reset: Failed.

From: Yessica Brinkmann <yessica(dot)brinkmann(at)gmail(dot)com>
To: Alban Hertroys <haramrae(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: The connection to the server was lost. Attempting reset: Failed.
Date: 2019-10-10 19:56:10
Message-ID: CABrYqSM=Y57HH0uB9gsJDJFASoVw-ADNA8PW+5sm39dY4yt55w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That is,
It worked by changing the code to:

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

if (!idxcd->idxused)
continue;

Very thanks,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 16:43, Yessica Brinkmann (<
yessica(dot)brinkmann(at)gmail(dot)com>) escribió:

> Thank you very much for your answer.
> It helped me.
> Really now the get_columnnames function is already working and ends
> cleanly.
> I have an error in the following function to be executed that generates
> the same error: The connection to the server was lost. Attempting reset:
> Failed. I will try to solve it alone and if I cannot write another new mail
> thread.
> Because this problem of get_columnnames is already solved.
> Many thanks,
> Best regards,
> Yessica Brinkmann
>
> El jue., 10 oct. 2019 a las 13:15, Alban Hertroys (<haramrae(at)gmail(dot)com>)
> escribió:
>
>>
>> > On 10 Oct 2019, at 17:55, Yessica Brinkmann <
>> yessica(dot)brinkmann(at)gmail(dot)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.
>>
>>
>>
>>
>>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lev Kokotov 2019-10-10 20:08:38 Re: DDL support for logical replication
Previous Message Miles Elam 2019-10-10 19:49:29 Re: DDL support for logical replication