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 1vV26k-00CFx1-2q for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 06:30:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vV26j-00FuA8-2m for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 06:30:58 +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 1vV26j-00Fu9z-1s for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 06:30:58 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vV26i-000oS5-0G for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 06:30:58 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-34aa62f9e74so3770710a91.1 for ; Sun, 14 Dec 2025 22:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765780254; x=1766385054; 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=NZfZYqg/tx44Av2fmO+U4r/5wfEMDfpfGYOGjLgnmMY=; b=mILRNnC28kcCYQvjFCO3SRZi/lR2Dz6+N+8Smz9TcsdKg82b1vsom1ZtEzGXeeqsfD PrMBdQUe1v9YG1eHp2N99GQn9lTlyeGFnsUr3zOBHOaew7q0LtIQcv7LRySBVQWGGTlI RITh2wQVovsV8VnYb6EQpgZKkCQP2TraKPihfwtUd8VMmiBLeN2rFSDmdYwCeVueGSOL 2zPT5rPpY6/JvokeL/KD5Ag41Sdb9DNuEKXPlby7QC3mC2pvl2TciSEpj8Tz7m4R54p7 FA369GO0aAZ3EJbJyjJfhWzXudyi5QOSG4G7fF42VFtBtdQIf1smSR/m0s21HixhkiI7 sy8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765780254; x=1766385054; 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=NZfZYqg/tx44Av2fmO+U4r/5wfEMDfpfGYOGjLgnmMY=; b=gJYuz8TGK+GaL54Vzg5ioy+jwaI1/WV+qwZ6VNgzaNEwm+L0xtDYrgqbCjJJme7ELO x5TeRXwhPI7fj3KgA3or6qORpN5ehyw0Dhrr6w2dwbbFG4AAQGpuvwC8xRrPsF6XywGl Z75gJCscpYbOTl3h3xUDzmKd/m74NIPPhmqV06SwBPqMmdJh/NXOcEPKtFEftJ/jtJIP QdU8GZbkNCHftuPWPnvVISnppH0Ln8Mr1PAZ5HcIlr15dLrVi+6GCpn0fVe2EM8LDgyi zCUQeyN6Z0oCz0W2hovzEwTM3DIL/dEe9tR3Jfi34Tx+3AvM+ZurDp+XKkZNoRrY0aK6 6HCQ== X-Forwarded-Encrypted: i=1; AJvYcCV9sYqdaUiNhmeQj8LV5PZLPM0kBkJdFe9ZaRjE04BTJhBwec2ndGNJeCwZLc3OECMK85CbUhfYt8124RB4@lists.postgresql.org X-Gm-Message-State: AOJu0YxKJdtEYXqkT71/poXUlkNmJqH+oyOWhf4JNGzmMlp62d4KYY5R ee4KYzVXYf2BOLluf2J714vkgkNDk/DUh7FjTKZ8kDqKtCzeGt5s0QPNWy3R6UBOz+m6TUvedR2 Tlh24+rThiZaTZtgt8vHlSApjGwUoOgM= X-Gm-Gg: AY/fxX4zZDvw4cq2hkpL48r9dLHeDpLljHfgX/FIcn19scqbjbQqHy5cDf35J/Uafdk gGbadQqnQSt2obGonnP11FDr7wdQk8FlVQlUAEs75AonQdfH4DGoYWAuUvzABxDZOIbAx7AyyzC Y/9CWmVvkNvlWUAXDn3zqK7U7Gyl8pSxt5tw5wocAIRJfPEOKMU0lO9i75zBGvoiYLpRCQaeDOI mfMDd1cVkcG0oKNOeaHm+C40wDUI6l3xD6lwQgf7AGd5Mwl1bcHDvUVOBR/JZYL6SHqApRH08nT 4aNmf0vV X-Google-Smtp-Source: AGHT+IG7wjcs47BlNvdiu0JVGxlcTKyidUW1APjocFmvJzFl3NuNoraST24rie/Phjh+QWjUUTc8cxbgN+0fzBMseVc= X-Received: by 2002:a17:90b:5348:b0:341:88c1:6a7d with SMTP id 98e67ed59e1d1-34abd78fb40mr9305480a91.18.1765780254181; Sun, 14 Dec 2025 22:30:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ajay Pal Date: Mon, 15 Dec 2025 12:00:43 +0530 X-Gm-Features: AQt7F2pFEa6kc8PK9Ts9DuOO_-Xd9Aeiwf7sit7w_CdmZ1wdL28LMis6y2r1rSY Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Dian Fay , Matheus Alcantara , Jakub Wartak , PostgreSQL Hackers , Jacob Champion 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 During further testing of the plan_advice patch's latest version, I observed that the following query is generating a no_gather plan. This specific plan structure is not being accepted by the query planner. postgres=3D*# set local pg_plan_advice.advice=3D'NO_GATHER("*RESULT*")'; SET postgres=3D*# explain ( plan_advice) SELECT CAST('99999999999999999999999999999999999999999999999999' AS NUMERIC); QUERY PLAN ------------------------------------------- Result (cost=3D0.00..0.01 rows=3D1 width=3D32) Supplied Plan Advice: NO_GATHER("*RESULT*") /* not matched */ Generated Plan Advice: NO_GATHER("*RESULT*") (5 rows) Thanks Ajay On Fri, Dec 12, 2025 at 11:40=E2=80=AFPM Jacob Champion wrote: > > On Fri, Dec 12, 2025 at 9:36=E2=80=AFAM Robert Haas wrote: > > At least for me, setting pg_plan_advice.advice to any of these strings > > does not provoke a crash. What I discovered after a bit of > > experimentation is that you get the crash if you (a) set the string to > > something like this and then (b) run an EXPLAIN. > > Makes sense (this fuzzer was exercising pgpa_format_advice_target()). > > > > With USE_ASSERT_CHECKING, that should help, but I'm not sure if it > > > does without. (I could have sworn there was a conversation about that > > > at some point but I can't remember any of the keywords.) Could also > > > just make a dummy assignment. Or tag pg_plan_advice_dsa_area() with > > > __attribute__((returns_nonnull)), but that's more portability work. > > > > As in initialize ca_pointer to InvalidDsaPointer? > > Yeah. > > Next bit of fuzzer feedback: I need the following diff in > pgpa_trove_add_to_hash() to avoid a crash when the hashtable starts to > fill up: > > > element =3D pgpa_trove_entry_insert(hash, key, &found); > > + if (!found) > > + element->indexes =3D NULL; > > element->indexes =3D bms_add_member(element->indexes, index); > > The advice string that triggered this is horrific, but I can send it > to you offline if you're morbidly curious. (I can spend time to > minimize it or I can get more fuzzer coverage, and I'd rather do the > latter right now :D) > > --Jacob > >