Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qhCAr-001c05-C6 for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Sep 2023 17:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qhCAp-0025gW-V5 for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Sep 2023 17:00:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qhCAp-0025gC-Kj for pgsql-bugs@lists.postgresql.org; Fri, 15 Sep 2023 17:00:07 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qhCAm-005Hei-Ry for pgsql-bugs@lists.postgresql.org; Fri, 15 Sep 2023 17:00:07 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-501bd164fbfso3841465e87.0 for ; Fri, 15 Sep 2023 10:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694797203; x=1695402003; darn=lists.postgresql.org; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=bRCcAuINFWuUXOG/uRFYIzO+N6/qdhf5pSipiHy0yMw=; b=RmG7PNMaciL0dLhHPnh9qxgKFvhJLN7ArpvzqCR+IkFTvPOKeIyhsaTdpvZQVlMZiU QiP1482yiXBR8RCztPGMaPu+zpLY0ThjEhrPkmpdbNh5KCZVTEo+cpRXFvJRVQwY5im8 ykxC1WGJcxdxASIUZiVYpq4MbBft45A86GC6oOXHeSIML59Ug5/GuWvm7POtVJaM12ZR tGPJQk2UwW1fTAax8vuR+tZ1lZrI7QA0MRE4uPYuuCNuA2eqvKLOM/T6tL3ABVyJ3O4C 6kL5Nq8yseZ3g6JtWFI70Q4Tms6ORvB3xqwg+qehTgOpO5VQyAP088/d31vWd3cKusXX ADzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694797203; x=1695402003; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=bRCcAuINFWuUXOG/uRFYIzO+N6/qdhf5pSipiHy0yMw=; b=jsGEY7m+DXh+5Jzz40ZS/Cj/zgWJ339/MOVrdhfMQENjY+N+8GhtzIPoDPUI8oC3jq vxIzB2q69Jiwvm96ZjUES8zGwjMB8wo9DtXusQj+9ISwwkd8l7/yGMv0Bnhmgef5EEUE ynDP+3WJG7NOJ/PrpFtoZpw/S6cYiJGP73GLFyeLxuzHKptYvFhCfMG/ONpSomV+X+81 8nE4H1PYsUk1cH/RkAKO4dzB7GOjzwjOqaSjvH2Dr8sRuHD796nzi5AH3bmplnERgO0Y Cwu7zItseoOEdyDO4rJ0VFGZTuuXYjtQQbE+ZH4EfZUh3aJfxfQlO3wD2dJrF7XbPXZJ SGuw== X-Gm-Message-State: AOJu0YzSmet3rLM6roSQZOk/G+Qnz2wX3C0U586L4mkxCxmTKX7LTPmy VvI0k/iP0DivAt2+5K8etri7gMSZJfJeIQ== X-Google-Smtp-Source: AGHT+IGqyQVIJnyHGHY4oXjtK6As6kO2VZiHIzSffPOLfVtZAh2WqAMvzNqPGQh9V7IqPv98eLLnTw== X-Received: by 2002:a05:6512:eaa:b0:500:99e8:573e with SMTP id bi42-20020a0565120eaa00b0050099e8573emr2272490lfb.7.1694797203095; Fri, 15 Sep 2023 10:00:03 -0700 (PDT) Received: from [1.0.0.7] ([178.155.20.111]) by smtp.gmail.com with ESMTPSA id d12-20020ac244cc000000b00502d7fc7007sm701441lfm.34.2023.09.15.10.00.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 10:00:01 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------c2WkN9NRhe6YOZcpvZQeJdSf" Message-ID: <9fa9c154-d084-07de-8224-aab7fc8a119e@gmail.com> Date: Fri, 15 Sep 2023 20:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #18070: Assertion failed when processing error from plpy's iterator Content-Language: en-US To: pgsql-bugs@lists.postgresql.org References: <18070-ab9c171cbf4ebb0f@postgresql.org> From: Alexander Lakhin In-Reply-To: <18070-ab9c171cbf4ebb0f@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------c2WkN9NRhe6YOZcpvZQeJdSf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 25.08.2023 17:00, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 18070 > ... > It looks like the following coding in PLy_elog_impl(): > /* Since we have a format string, we cannot have a SPI detail. */ > Assert(detail == NULL); > > /* If there's an exception message, it goes in the detail. */ > if (xmsg) > detail = xmsg; > > doesn't expect to process a call PLy_elog(LEVEL, "message") when some (SPI) > error occurred before the call. > Please look at the patch attached, which removes the Assert and changes the detail message e.g. , for the query: CREATE EXTENSION plpython3u; CREATE TYPE tst AS (t text); CREATE FUNCTION pyfunc() RETURNS SETOF text AS $$   plan = plpy.prepare("SELECT * FROM tst", ["text"])   for row in plpy.cursor(plan, ["w"]):     yield row[0] $$ LANGUAGE plpython3u; SELECT pyfunc(); From: ERROR:  error fetching next item from iterator LINE 1: SELECT * FROM tst                       ^ DETAIL:  spiexceptions.WrongObjectType: cannot open relation "tst" QUERY:  SELECT * FROM tst CONTEXT:  Traceback (most recent call last): PL/Python function "pyfunc" To: ERROR:  error fetching next item from iterator LINE 1: SELECT * FROM tst                       ^ DETAIL:  This operation is not supported for composite types. QUERY:  SELECT * FROM tst CONTEXT:  Traceback (most recent call last): PL/Python function "pyfunc" Best regards, Alexander --------------c2WkN9NRhe6YOZcpvZQeJdSf Content-Type: text/x-patch; charset=UTF-8; name="fix-plpy_elog.patch" Content-Disposition: attachment; filename="fix-plpy_elog.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9wbC9wbHB5dGhvbi9wbHB5X2Vsb2cuYyBiL3NyYy9wbC9wbHB5 dGhvbi9wbHB5X2Vsb2cuYwppbmRleCA3YzYyN2VhY2ZiLi42OTM1OTkwOGY4IDEwMDY0NAot LS0gYS9zcmMvcGwvcGxweXRob24vcGxweV9lbG9nLmMKKysrIGIvc3JjL3BsL3BscHl0aG9u L3BscHlfZWxvZy5jCkBAIC0xMDMsMTEgKzEwMywxMSBAQCBQTHlfZWxvZ19pbXBsKGludCBl bGV2ZWwsIGNvbnN0IGNoYXIgKmZtdCwuLi4pCiAJCX0KIAkJcHJpbWFyeSA9IGVtc2cuZGF0 YTsKIAotCQkvKiBTaW5jZSB3ZSBoYXZlIGEgZm9ybWF0IHN0cmluZywgd2UgY2Fubm90IGhh dmUgYSBTUEkgZGV0YWlsLiAqLwotCQlBc3NlcnQoZGV0YWlsID09IE5VTEwpOwotCi0JCS8q IElmIHRoZXJlJ3MgYW4gZXhjZXB0aW9uIG1lc3NhZ2UsIGl0IGdvZXMgaW4gdGhlIGRldGFp bC4gKi8KLQkJaWYgKHhtc2cpCisJCS8qCisJCSAqIFdoZW4gd2UgaGF2ZSBubyBkZXRhaWwg ZnJvbSB0aGUgZXJyb3IgZGF0YSwgYW4gZXhjZXB0aW9uIG1lc3NhZ2UsCisJCSAqIGlmIG5v dCBlbXB0eSwgZ29lcyBpbiB0aGUgZGV0YWlsLgorCQkgKi8KKwkJaWYgKGRldGFpbCA9PSBO VUxMICYmIHhtc2cgIT0gTlVMTCkKIAkJCWRldGFpbCA9IHhtc2c7CiAJfQogCWVsc2UK --------------c2WkN9NRhe6YOZcpvZQeJdSf--