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 1rQfGp-002olr-7G for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jan 2024 03:10:15 +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 1rQfGo-006e30-8B for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jan 2024 03:10:14 +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 1rQfGn-006e2r-Uf for pgsql-hackers@lists.postgresql.org; Fri, 19 Jan 2024 03:10:13 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQfGj-002ZNA-98 for pgsql-hackers@postgresql.org; Fri, 19 Jan 2024 03:10:13 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5cfa71498feso300415a12.1 for ; Thu, 18 Jan 2024 19:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705633806; x=1706238606; darn=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=2N0SSg19Oy+8oWhw+QSzqCEZBYn/XW/uEbODCKbC7N4=; b=hzyfj8QpYpy5fJBU2tFo4ZVwpA0qikTjrYyqZmRJGb3rQimvZIBJnvNyUhovoBMuX1 8x7jNCaznmGE2wAzoFo4swL4FwKupIFdDexyFfOmSoC8KYla26oJRxxOCE2Hj6JTfSKq j+E3ys+UErBXmbKT79ev8sEEejGMaMYtPoHYovtLtVldVN1HNGAaFYQakKkHsf/5227m Xl3GgEQpgmyMgub6P3x2sl7pxAv0yVNYGbBysdQs5KJ6u1IHCn52V1/hHOOL7bYWVVdU yWR4pKoaxXFtq5A+sBDdq7pOYwbHN58gICKymznndbK2MPFfyqbjC5t7BAelOAY4WfR2 8knw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705633806; x=1706238606; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2N0SSg19Oy+8oWhw+QSzqCEZBYn/XW/uEbODCKbC7N4=; b=bHDBcf8SoOVCIwHxr72gDU5ZQx+YGvh/dwxh7d+guAHo9E0ilIjoz3iEx7t/1Zcr+B 2Bz0PeszrdRVF3XreYorrj2uqIxp1lNz2u2ejWYzQjZUtgGBavnwQKkaREUfP5B2fapk lUmOmJ7jezy4K6aRZZl5CXO3UT4wC0hYl9fSIz+gjv90qWDCwZ14+Jj88gi7G9J9Bmto Qacdjx/uzDLaM8p9aqH8v/Kw2uof4+/pSNfYtTXzZgxs89sp6Sa4iiDGehVnWNEGqZQx HWN2zTp1AN83ywof5drmEDckIxRfUQ+LN5NDrXVf2RkFj0zpMv1EuWsGvlrqdrOzVD6D zt7w== X-Gm-Message-State: AOJu0Yy0DGXM3MfzCB+N69wwaFhH+15F/zbN3dRYb9Fgw4Y+DPoL7R2n 02Y2STQoBPS8BHCa2aH5oE7/TKOL/0mB+fk0MhIDkjt/9KKRlhsry8uLPnb68VfH+kI74v0UJUf cXW//zTNJGf3OZIqZ10I5WwEduiw= X-Google-Smtp-Source: AGHT+IFXujLjP5crbw/d6x+g666dzgw2PI9e87i4O96EB19Ij4wC7HEI/ezJ9bqm8aEPKsP5GUfpRwxxJ2zEEDU4Gmk= X-Received: by 2002:a05:6a20:1590:b0:19a:3451:14dd with SMTP id h16-20020a056a20159000b0019a345114ddmr2213384pzj.60.1705633806627; Thu, 18 Jan 2024 19:10:06 -0800 (PST) MIME-Version: 1.0 References: <202401181146.fuoeskfzriq7@alvherre.pgsql> <202401181711.qxjxpnl3ohnw@alvherre.pgsql> In-Reply-To: <202401181711.qxjxpnl3ohnw@alvherre.pgsql> From: Amit Langote Date: Fri, 19 Jan 2024 12:09:49 +0900 Message-ID: Subject: Re: remaining sql/json patches To: Alvaro Herrera Cc: Andres Freund , Erik Rijkers , jian he , Andrew Dunstan , PostgreSQL-development 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 Fri, Jan 19, 2024 at 2:11=E2=80=AFAM Alvaro Herrera wrote: > On 2024-Jan-18, Alvaro Herrera wrote: > > > commands/explain.c (Hmm, I think this is a preexisting bug actually) > > > > 3893 18 : case T_TableFuncScan: > > 3894 18 : Assert(rte->rtekind =3D=3D RTE_TABLE= FUNC); > > 3895 18 : if (rte->tablefunc) > > 3896 0 : if (rte->tablefunc->functype =3D= =3D TFT_XMLTABLE) > > 3897 0 : objectname =3D "xmltable"; > > 3898 : else /* Must be TFT_J= SON_TABLE */ > > 3899 0 : objectname =3D "json_table"; > > 3900 : else > > 3901 18 : objectname =3D NULL; > > 3902 18 : objecttag =3D "Table Function Name"; > > 3903 18 : break; > > Indeed -- the problem seems to be that add_rte_to_flat_rtable is > creating a new RTE and zaps the ->tablefunc pointer for it. So when > EXPLAIN goes to examine the struct, there's a NULL pointer there and > nothing is printed. Ah yes. > One simple fix is to change add_rte_to_flat_rtable so that it doesn't > zero out the tablefunc pointer, but this is straight against what that > function is trying to do, namely to remove substructure. Yes. > Which means > that we need to preserve the name somewhere else. I added a new member > to RangeTblEntry for this, which perhaps is a little ugly. So here's > the patch for that. > > (I also added an alias to one XMLTABLE invocation > under EXPLAIN, to show what it looks like when an alias is specified. > Otherwise they're always shown as "XMLTABLE" "xmltable" which is a bit > dumb). Thanks for the patch. Seems alright to me. > Another possible way out is to decide that we don't want the > "objectname" to be reported here. I admit it's perhaps redundant. In > this case we'd just remove lines 3896-3899 shown above and let it be > NULL. Showing the function's name spelled out in the query (XMLTABLE / JSON_TABLE) seems fine to me, even though maybe a bit redundant, yes. --=20 Thanks, Amit Langote EDB: http://www.enterprisedb.com