Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIb5t-00028j-Ph for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 16:15:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIb5s-0005Mi-Id for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 16:15:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIb5s-0005MZ-70 for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 16:15:12 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIb5q-0001zg-63 for pgsql-general@postgresql.org; Thu, 10 Oct 2019 16:15:11 +0000 Received: by mail-ed1-x541.google.com with SMTP id p10so6020119edq.1 for ; Thu, 10 Oct 2019 09:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2++OadOAjoe9HscWNRuZoEndTdyyNl8PeZ1DFLwpZio=; b=IRcxkFS2tgsUOiK+kl1kX+NMdo5PIFXoAPTN6i8yzQD3lil/Wj88a8le1Ogiq/c9v1 ec1YiY5YStYm48e6LKTRwtqlN7dCIHmR98PjncDS1iASgS0ZuHHazlioGaDRhDMdrPN9 KbB5yO647v1FfjzZz3yASxRH4nwGHwI+JeivbU7z0gZEe8dA+pdrQ+sZB0N42XjeIwu1 Ju6QrV4ijSQ3h704MLrlYRv/8PzEmCWRHTuPdaruMX0j6JYlhI/+bt9zQorh7Zkro2RW PnbFtqIaul7MCydSc0+QLDloB5vIQfz5i38j17GR3mHBcZYfLZv+Yd1bpziwWRglKS5p KUDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2++OadOAjoe9HscWNRuZoEndTdyyNl8PeZ1DFLwpZio=; b=G0PCwQNika382yctZLnPGIn1Y9I4VY5a5hD0ZizZmSrsRTivIxKb9eUWbADbA80TPB Xe3DRa7lGd2iTK1qkA5ZoN7CU/14EPQHBvTwoua3hi2zQ5RaRDe/SWftMUHNFbLVIHZ1 p0EFSiEX11l0mSNEt6OvvU8ZNoaAaW2X3+0JNkpL7WlS8FyekFka8iEVI2nHWBN32FO4 NHGHHd1ct3bWXElztKPnen8Qf5siU94XqHrnwvBGRL26BxWS4wShPdBjJJ28xWfc+boY ADEIkumEYhAKaU5HVzDVHr0DODMAs8tU1gRGRzzatxqFTCKXkKBqbWFTltsYwgRIToPv JBNA== X-Gm-Message-State: APjAAAXqG5/YsEzWztbtseTrpnLVf9vIIbA9W4l/rtYRag+kPul85aiD yKKtY8tU5v0Kj06zboEoXY4= X-Google-Smtp-Source: APXvYqzo6n8i09gAHfeDvX1LxwDH9gRcgl+8YdKAGlXWzqQncc63S4uecraoTWQ8B36QTG33Z2esKw== X-Received: by 2002:a17:906:314c:: with SMTP id e12mr8772651eje.140.1570724108481; Thu, 10 Oct 2019 09:15:08 -0700 (PDT) Received: from hollewijn.internal (217-19-30-105.dsl.cambrium.nl. [217.19.30.105]) by smtp.gmail.com with ESMTPSA id 60sm1011041edg.10.2019.10.10.09.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Oct 2019 09:15:06 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: The connection to the server was lost. Attempting reset: Failed. From: Alban Hertroys In-Reply-To: Date: Thu, 10 Oct 2019 18:15:06 +0200 Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <0AB1D241-F535-4E95-9D3B-D9AD1090FDAE@gmail.com> References: To: Yessica Brinkmann X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On 10 Oct 2019, at 17:55, Yessica Brinkmann = wrote: >=20 > 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 =3D% 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 =3D (IndexCandidate*)lfirst( cell ); if( !idxcd->idxused ) continue; if (idxcd!=3DNULL) { 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 =3D=3D 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.