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 1wlfsy-000KDR-2Y for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jul 2026 04:45:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wlfsy-001zgr-0l for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jul 2026 04:45:47 +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 1wlfsx-001zgi-34 for pgsql-hackers@lists.postgresql.org; Mon, 20 Jul 2026 04:45:47 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wlfsu-000000013oJ-29Fr for pgsql-hackers@lists.postgresql.org; Mon, 20 Jul 2026 04:45:46 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-848595b338cso11046173b3a.0 for ; Sun, 19 Jul 2026 21:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784522743; x=1785127543; darn=lists.postgresql.org; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:content-type:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XqDsInbM/IFN5W2AB4+D9pdDeqvqpgJYeMzkimaaRoM=; b=SrZoeZNx4w4Zo+/vt/baVctXDaAuBX+ELzHOxhIVJ5AYFEUnDZeU+7+51O7hT3TALm 8gHhKLvitpuLpQgFVU4VWxuCxG7vYi2fBBaRrieT6vSlxdSGIjeCh9uWUlofTgC5Hfx2 qz2+n6NR+pf4TAUhrubTLcJKHHuR8nOSNTxrTp2hkdqOiNYa7nd7JoszeYITdMjbOjzj FEcuIGKEJmyIC12onSJjJVboFdx9mof3n4Q3vGzABVckWaAdQKwr3JHj9ty1PXMwwGRt TKHJ72f7735JIaoqpmonlK03ZkbYqqzFfbSVXzJp/Tp5dyunH7VpmHWVC9v+nf7ESDlC RJcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784522743; x=1785127543; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:content-type:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XqDsInbM/IFN5W2AB4+D9pdDeqvqpgJYeMzkimaaRoM=; b=mdtkaylFoot7ZCO00CiBXvJeYxHzrFYbS8ACVnXFuC+Eqakb0gGBzs9BAYkCwZkZsv kkZ0vieWBmAPoK8UFBwbXBRDt5DCHvzh6mOYKd2RkhZ/rsZZ+dD671UbmpVOUVJi6qU8 VSkdDttzjAOo57rUmKFnOYQ5cHsUoPU3ZDrF4HLCCQUH4uU9fS7NNAGUEG/BkhY/07hm PItA6np6iljhO+rFJo9ZmGtdlUyuzRKbj2Bi1zcfweN/NmZR8kY5iUkmp2+kcVG0ilkT lQdpaxTN+J4007xhNVW3zM4FQeUy/CqNoelssUJvVSkA6zMJ+4HagEPM2H8bnA/gdNvc paVQ== X-Gm-Message-State: AOJu0YxgeVJlbZ1R84fXZWVZ1oMcgZZGIJDI235f+hHnS1V8lZr9XSkN RGp0WlARp32TtC/tevofkXJYvALqT3KSnBTD9eWx8rAk/UIBLBL8DNqJw2LTX98iI88= X-Gm-Gg: AfdE7ck4ElG0pt0ZlbJd/8TJfg4fYYfgZVReYVEyGMLUJQTceBp8SBaxlpLgsL993gs yCZ+XpbCZqYXZ4aoYimuoXw2c19AEu6pFNmLG9+gsQzNa108QAaOF1BcT5bUal5DPpSE05++dXy K6xy0mih7xkYl0FKaRYQOFMgFXxVnRtS08R9Qz8QLktIMblkc5hvxqQ0O/EPgub5nPg3Ox7b7Ck p8n2Ah+qDrWCq6ug2c9T8Bkjyhi1QL47sDRxx2tmEkSrP3/7F+FlsUX0fxvhXxqZOlXRapaH4H5 kP0dgYblamqUPKjkGBbrIWbMavme9U/kJPwAhOUwincplJHjHFF/sNYlQgraYDWxhl6aYfAMUXD tWu0esBLaRLOWN8Syib9tgEWriVFL/aErIty2m5a8eKbmKrVAA22Vlt8OMuO6WzisL0dQunus9o qG/FPfocP/kco= X-Received: by 2002:a05:6a00:4c8e:b0:848:761b:4cd3 with SMTP id d2e1a72fcca58-84c294ca205mr12321402b3a.44.1784522742675; Sun, 19 Jul 2026 21:45:42 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517aada63sm3908724a12.3.2026.07.19.21.45.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jul 2026 21:45:41 -0700 (PDT) From: Chao Li Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: pg_plan_advice: fix empty FOREIGN_JOIN sublist validation Message-Id: Date: Mon, 20 Jul 2026 12:45:06 +0800 Cc: Robert Haas To: PostgreSQL-development X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, While playing with pg_plan_advice, I noticed another small issue. Each FOREIGN_JOIN target sublist must contain at least two relation = identifiers, as the error message states: ``` evantest=3D# SET pg_plan_advice.advice =3D 'FOREIGN_JOIN((x))'; ERROR: invalid value for parameter "pg_plan_advice.advice": = "FOREIGN_JOIN((x))" DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more = than one relation identifier at or near ")" ``` However, it silently accepts an empty sublist: ``` evantest=3D# SET pg_plan_advice.advice =3D 'FOREIGN_JOIN(())'; SET ``` The problem is that, the parser currently checks whether the sublist = length is =3D=3D 1, rather than < 2: ``` if ($$->tag =3D=3D PGPA_TAG_FOREIGN_JOIN) { foreach_ptr(pgpa_advice_target, target, = $3) { if (target->ttype =3D=3D = PGPA_TARGET_IDENTIFIER || = list_length(target->children) =3D=3D 1) = pgpa_yyerror(result, parse_error_msg_p, yyscanner, = "FOREIGN_JOIN targets must contain more than one relation identifier"); } } ``` So the fix is simply to change =3D=3D 1 to < 2. With the fix, = FOREIGN_JOIN(()) is rejected: ``` evantest=3D# SET pg_plan_advice.advice =3D 'FOREIGN_JOIN(())'; ERROR: invalid value for parameter "pg_plan_advice.advice": = "FOREIGN_JOIN(())" DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more = than one relation identifier at or near ")" ``` FOREIGN_JOIN() is still accepted. As documented in the opening comments = of syntax.sql, empty target lists are allowed for most advice tags, = except JOIN_ORDER: ``` -- An empty string is allowed. Empty target lists are allowed for most = advice -- tags, but not for JOIN_ORDER. "Supplied Plan Advice" should be = omitted in -- text format when there is no actual advice, but not in non-text = format. ``` Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/