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 1wT1Xh-000GM1-05 for pgsql-bugs@arkaria.postgresql.org; Fri, 29 May 2026 18:02:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wT1Xf-003tLn-1y for pgsql-bugs@arkaria.postgresql.org; Fri, 29 May 2026 18:02:43 +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.96) (envelope-from ) id 1wT1Xf-003tLe-19 for pgsql-bugs@lists.postgresql.org; Fri, 29 May 2026 18:02:43 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wT1Xd-00000000BNF-2KIg for pgsql-bugs@lists.postgresql.org; Fri, 29 May 2026 18:02:43 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-bd4d7f4fa02so2414022766b.3 for ; Fri, 29 May 2026 11:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780077759; cv=none; d=google.com; s=arc-20240605; b=E1xc/to6TZTstRSch3MxkdrL39IkBEIwXZMDrPkU/Mg2D3Sf5AykK9BTXQC3vTeFnh gRxUENFPkSviz8Crp5uqoXeLF8tk2xgYTQXjUoAfY2q09HQvpt+vUveTcUMLfnqb3b+P St43formLqaKYk4lZUeOf8XJ35oHncToSUUSryUoZfllVRhire1i5CfoFMHDZSDA3Sct pM2A8eNDxqa+/e5MbfIeKc72xCS6sXvl6JhrfdF9CMEeyiLs4hNjk5adigByd8fEXQGs rZKu6E9uXbjW8g3TR/VRAuj1qQoK0AKUJ/oqemv+OPxyzPG5x7+xl0OciFexdny+SQUz DR6w== 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=xHsXmq1D63bHvhBT8KP5Qn8NWsICmMukQ7e28vbtRFA=; fh=N3O2xCnGvJjOjMoj7dArS9YhA6nvxJrAJrRvscMlrHc=; b=Ph6SBY8ASGvt7Sy2EjPiJ3n/JXq3l7m9mEU4iC+GaBkRBE76V/mWt48C4TTqJg6BGo RU6rBKrXxxQpBv8QS9tWHjB7VUNWovvRHVevbEIf2AoDfPORR18c9QHPlyk89fkIXtqH iqCAhB63X3C01FUb3qM358WNz4p5doOJv4v4UdaQd/ZetEQtaTtcQ4JEZasuRW85dtLN dt/FBUlqos2NWKQq5Q5qEqoBOwZP2rcSB3PchBygeLebIz2UpTDZ2Hsv2FNo7ke3X7bw ayrldbUhmnDkJQN/76DSGC+iQTH7WIWeGXJvFWlVT7KuwgJ7a86Gh9i2Rl1NYJjmDDgm xSlQ==; 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=1780077759; x=1780682559; 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=xHsXmq1D63bHvhBT8KP5Qn8NWsICmMukQ7e28vbtRFA=; b=IvYQzUCMF7+nkyLCG6+Zkrdw2PFkpMtztxb3gRKraxGfuLpyFkv+d3BXff3JZQxtPr c957P3j3sPGkyEuWwBNJPKLnEp+sesFqGqcvX1l0D2awqcleFGLpmFXCXGkXSihN/hk9 yFNFU8TfvAG0vWjYQBgAUzO/8+y+SkxjKAsSVjUroYW+nu/Xv7Bqe8DKKm/si93lk7Mm QTPsTDM0ENy+vFqXmhow65czv3DxND4BGhoteYYccgWq8Tn4K+qzRM9mAc6g/0xHKZA+ t/2ztX6Ory4Bvi8QjcX94A5dRrh3f7am3cJ1d3TdirznMR4f5IGJzqo4yYwoohkv6/r7 nPQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780077759; x=1780682559; 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=xHsXmq1D63bHvhBT8KP5Qn8NWsICmMukQ7e28vbtRFA=; b=UYA9q4QW0PAL6GQfCqTbGUbOfoehkSy/1j1JZvarR7blkcPnzHJVTASr50hGJ35k07 B9uR8FjYlrvPkEszN50wNIyMVZvCPXKQ8L4t1OkgSWyRE1jEIxo6rLQUiDziLwKobxE1 X2LrakJ6eEOz+vm74Djw/CH4tCnsyz+3LxtWUZKrFRFkqPyOHcW8axfe2O7v++B3Teao zqN1xGaJ+dCBoj4eoJASvJu/g492S8rUadlQpjywpvCAF03QSvTvQcI7tCuO4ngBRunT lds82TbugOG9iXnCjBawGm+R2H/tP4dxdzqzeWEbDQFxIEUyCAJ7NbivZ201o/mnFnuj qW/A== X-Gm-Message-State: AOJu0YxzsmuRS23Un0+20Y7Nq818Yk299W7Wv+kktSZdwT7B3FmzkuCY EUeJUoTiNBaEn0DzXGS7OEktMgUXVEgY50T2tOghAun7V0CnSusQutbx+B3v7clZvUeGH5Io7EW TKIvR9yzt7WpQzk25Yc/eOk8jScPmRCQ= X-Gm-Gg: Acq92OHGp1V5gQSAFLmR4WUXZG04+03cFi/QeVPZHqab7BbrdEkSxr4jTrJ0wK1NjJf qfzVEDHGPczAW0c7qzDiAERSQkahs98iJCKhs2Mo6nMlt1tpQKL3kMO8ej1vI8usIFCkoJZuzn+ dvyf3W/oPcloomyUkrtEqXu/a1tyyKESifKxN836jpkD9ilbmbCStmi7aUiEjmXaB5hUzcYrbwK pSGSevtkHAEEoa2Ydgrn3QrrPIog2VlICAIuKT57egVyz0vyuDsUYTdHGWHh/lUXjJdETUluVBW ZoYieOYFPawf2rVYJ8qlXWtkGRWZoN4IdtmTpcGUCpd+Dkv57Q== X-Received: by 2002:a17:907:7352:b0:bd4:e5bf:76b6 with SMTP id a640c23a62f3a-beab0dd8e65mr24251866b.5.1780077758900; Fri, 29 May 2026 11:02:38 -0700 (PDT) MIME-Version: 1.0 References: <19493-5878eac7a2525c23@postgresql.org> <2d59d7d6-6afe-4565-8ff7-ae764651589a@gmail.com> <1779843554.737126560@fmail2.qdit> <418106.1779844099@sss.pgh.pa.us> In-Reply-To: From: Robert Haas Date: Fri, 29 May 2026 14:02:25 -0400 X-Gm-Features: AVHnY4IV4YS44TcPN8rBHrdfo-F9p5djnJu_DDbMSKDpApEVRezMriN5C0UBtdM Message-ID: Subject: Re: BUG #19493: Assertion failure in pg_plan_advice with EXISTS subquery and DO_NOT_SCAN advice To: Tender Wang Cc: pgsql-bugs@lists.postgresql.org, Tom Lane , Ayush Tiwari , =?UTF-8?B?0JrQsNC70LjQvdC40L0g0J3QuNC60LjRgtCw?= , Michael Paquier , Pierre Forstmann 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 Thu, May 28, 2026 at 10:04=E2=80=AFPM Tender Wang w= rote: > -- Tags like SEQ_SCAN and NO_GATHER don't allow sublists at all; other ta= gs, > -- except for JOIN_ORDER, allow at most one level of sublist. Hence, thes= e > -- examples should error out. > " > So 'DO_NOT_SCAN((x))' is valid syntax. The original codes in > pgpa_build_trove() may > forget about this case. I added this syntax case to the syntax.sql. > > I also added the query to scan.sql and adjusted the original comments. Thanks for the analysis and the patch, but in fact DO_NOT_SCAN() was intended to be a "simple" tag, not a "generic" one, and I just messed up. This makes sense if you think through how it actually works. For a tag like GATHER, GATHER((x y)) means something different form GATHER(x y): the former means that there should be a Gather node on top of the join between x and y, while the latter means that there should be two separate Gather nodes, one atop x and the other atop y. On the other hand, NO_GATHER(x y) means that no Gather node can appear anywhere above x or y, and there is no such thing as NO_GATHER((x y)) because it couldn't mean anything different. Likewise, SEQ_SCAN(x) means use a sequential scan on x, and SEQ_SCAN((x)) or SEQ_SCAN((x y)) is refused because you can't use a sequential scan on a group of tables. Extending that reasoning to the current case, DO_NOT_SCAN() is like SEQ_SCAN() or NO_GATHER(): it applies to a single relation, not to a list of relations. However, for things to actually work that way, pgpa_scanner.l needs to classify it as TOK_TAG_SIMPLE, and a corresponding adjustment is needed in pgpa_parser.y. I overlooked the need for this in the patch that introduced DO_NOT_SCAN. I have committed a fix. --=20 Robert Haas EDB: http://www.enterprisedb.com