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.96) (envelope-from ) id 1w9q0U-001nwX-2P for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 19:53:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9q0T-00BjUU-07 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 19:53:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9q0S-00BjUL-2R for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 19:53:09 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9q0R-00000000uMG-1BrE for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 19:53:08 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b936331786dso458168866b.3 for ; Mon, 06 Apr 2026 12:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775505186; cv=none; d=google.com; s=arc-20240605; b=kdxwSGxW/5/jaF9KdWYmzOqcfoyr3irO5d/EoW8qmq6m4zwVPCW6OWroXZkWDPtvwh zN6wAetPK2XxnnSFM1v4d8k0i1qArGNMWmlmtatpyboskttIWHy+ELq9ZW4+3Jew5Rfd Wr3BxSA2aRguRQJsS5FCDPDvUkeBGJWAb6yOyXSYwWUmPvbRr98ZnYtzZ145BL3llJqU oDfEHOEIEMMK1B2earUD55gAQl3u8DniWDIf/G0R6+I/tk3PjgAkxmCjjFGUQCnJfw3a 5ja89a164IKI13UxN4xaPH9hSdIWuJxdr7L9L3ig/zFCHMUwYzKtfND4kDyxWITsnpRH Xq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kdqcw/+7csoVUws/d11QHC0OpbgHYN4Efi06lwAIhdg=; fh=gDXoL2D2Y4heJe/fvUoQJRymO/vfXxQfyOPOzS/OxtE=; b=VtI5YaYgQfZuXR7eEES9fzDxSEj58be9m3e6fqQyOcMuu4s8YyLjA4RTj+Js46rdWG mR6kRDwU30vSuNchLsXHN9hyD1VeKVBU1zevj/lkFYd+QXRWjQf6eCJ6yzvkU89+14PZ abirrYykOEE/xlrlMGCea4y+YEKbM4cGFBTxEqvgQKpTEpurIThaYMEmQ9JF4YQUdfOP jLxXb/SL0pPThokTmaEeadJRtrkj3rGkOKQvMIjqKNDKdsPxP+8HQos7HEpO4dBIam+l PXWS7UDIX3jL1JA1GM8oIp3PkHUD4GVn/4DLfgFt+YZfPcBGt17y8hCRzqqaLzqWs11q J8FA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775505186; x=1776109986; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kdqcw/+7csoVUws/d11QHC0OpbgHYN4Efi06lwAIhdg=; b=D5Vg9Qn9P8I9xg4W2rCsm3911QNap8idivXdfuh4XOeUr+Pjg0tYkuiJETA/kv3AUI oplnaaG0kgAKY+iWUNJa7A/N9A/snOV9lCjRiY4LIkuRx9MCTYHSJT+m3rldLzwz6gZQ sOdjEZkVna5WiEZ2IPw4A3olChGy+kf+0TRWfmQ/lzNBk6ITqwsFy1JesFCIWkzdI8xK fXkBg7S85m4GYrGU8fNLaI8KjchLL0/Nq2nmiQ7uvE/mncdBg2EV7+6J5fyOvMImwZmy TszaIIWV+q061psw3Pp88caH0BniHQyhk53FsfvCrPWer2Bwk+nMnESAA76M8MtOGSUM ipBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775505186; x=1776109986; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kdqcw/+7csoVUws/d11QHC0OpbgHYN4Efi06lwAIhdg=; b=ZgJsGbF92bSGWud5k3uNPBzERJV5Bq5/Yg014zOQess60kFUKw0lYQKFSG73ZittNk 5jzEFYtRwX3lyaVl4txrnlThepawC/HdGRzhu2oCJCNY0casibmuOJZGdyQijPJmVuW7 a9t4fAMulLFE9LlEKhmsjH9UEo5q2gzzSMVNqSomCRSsTHASsWH3aHrOE5ituDEXxrnZ vlHuJe6jolF7V/TbvZj6BJV2H56qxWJj18tEA4XpL5Pv1ddNNX5HiwKnnfmcXO0F1bqL CA8KPT/nkfwlyawWuKFhWSSO6aGqtf8EcawHratYdWAdUgm3br21z3kq22J0TEVzJLw1 pvog== X-Forwarded-Encrypted: i=1; AJvYcCUIpCzqvNXXknKDJ5OmEuXQ6ApZZRSKQ997pO1m++VhyU6XpS/7oUpAC+usvshJ+n9jDycytOuYlijO4GAE@lists.postgresql.org X-Gm-Message-State: AOJu0YxDGyIhrXHyddvaYDtsr+0ybvbpxx++8D35r3AYatpXiLiJXrbb 1vQ5cvbmR9r4CFN7QoX+29xtiOXLEsHytIx9IpJ7HBb8H+EHfYIbsojlHpdw9QEnnXEoxiIdMVQ bAEGUbPyARRfeqsrRwlguxLf0YHU7S/A= X-Gm-Gg: AeBDiesjzko3ihdTbhvaRDk19Dj+O1ITsbNInQasNf1DjVGMCD3CWYku7agp15jhIjC +appGjHeUsPhlnT3HBGhsLZX0ELMgCj7kjklYCUpLhhXsiyHWTT3BAjEGX/YmWNEzSw2/M6nBrL N//Z463so7UBDThhQUre0Q7fN1GWiGHxxrRmuRbtirmikVfniAVYA/8T30N26nRfgl+YJp2EWI+ hrlESmRvbO5J82ZvyShSZJljscRyxwLnzhFU3QE1ZcR0QKb0yWWjwZuytXZ/hzcEOXjkSR1zHKt Tc9X4XZFp+3tFMf9vYyMupdywmbgwVsvA3kPf8WQy0VWr2iSIQ== X-Received: by 2002:a17:907:c8c4:b0:b9c:648f:7d3c with SMTP id a640c23a62f3a-b9c679adca8mr722352766b.40.1775505185984; Mon, 06 Apr 2026 12:53:05 -0700 (PDT) MIME-Version: 1.0 References: <3683430.1775173413@sss.pgh.pa.us> <3817825.1775240432@sss.pgh.pa.us> <3877210.1775272486@sss.pgh.pa.us> <386d8c06-0f96-40bb-b1b1-107db209c676@gmail.com> <2e7bdb5d-68ba-4c65-9931-a865ab6fc3d2@gmail.com> In-Reply-To: From: Robert Haas Date: Mon, 6 Apr 2026 15:52:51 -0400 X-Gm-Features: AQROBzAmDGmmxoOVg33RmatMHqe82tjIyax_nAnU5jU26icyucEYAcOwgY0lTVs Message-ID: Subject: Re: pg_plan_advice To: Alexander Lakhin Cc: Tom Lane , Lukas Fittl , Andrei Lepikhov , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Apr 5, 2026 at 4:00=E2=80=AFAM Alexander Lakhin wrote: > I and SQLsmith have discovered one more anomaly (reproduced starting from > e0e4c132e): > load 'test_plan_advice'; > select object_type from > (select object_type from information_schema.element_types limit 1), > lateral > (select sum(1) over (partition by a) from generate_series(1, 2) g(a) wh= ere false); > > triggers an internal error: > ERROR: XX000: no rtoffset for plan unnamed_subquery > LOCATION: pgpa_plan_walker, pgpa_walker.c:110 > > Could you please have a look? Thanks for the report. What seems to be happening here is that the whole query is replaced by a single Result node, since the join must be empty. But that means that unnamed_subquery doesn't make it into the final plan tree, and then pgpa_plan_walker() is sad about not finding it. Normally it wouldn't care, but apparently this query involves at least one semijoin someplace that the planner considered converting into a regular join with one side made unique, so pgpa_plan_walker() has an entry in sj_unique_rels and then wants to adjust that entry for the final, flattened range table, and it can't. I'm inclined to think that the fix is just: - elog(ERROR, "no rtoffset for plan %s", proot->plan_name); + continue; ...plus a comment update, but I want to spend some time mulling over whether that might break anything else before I go do it. --=20 Robert Haas EDB: http://www.enterprisedb.com