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 1wDD5u-002jRk-1E for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 03:08:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDD5t-003S3s-1r for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 03:08:41 +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 1wDD5t-003S3j-0v for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 03:08:41 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDD5r-00000001L2W-1H21 for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 03:08:41 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-35d99031e4eso4411522a91.1 for ; Wed, 15 Apr 2026 20:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776308917; cv=none; d=google.com; s=arc-20240605; b=lXMvLl+sZgQRAVyK4XLTWxtd3J89wB1jw1oOwfQBtdlxfqSVreUmpbsFQemSB+bpQa UOW5l4kKmSe9C/vvzV26aTBf78Levc0hTeyMsTbQcFooA0sws1Q6t0nwPSMxNZbfhbrW 1rBRyamC/KJupWv4WXJXKPIQhp6hTp/w+alfXIGwx4zpNeD9sVQwjYQRnGH+zQDencD8 h6NGUiAEtv8dh2mM01qHIq189kZvaWFfRKfQcNpiJpvFCfOYW8ZSM4xVDGc+LnwyZ5X/ hQnE2NL3KQ2mSE1CKOWdKzEoLNJ/SsdIJvS+UPEoKDRj3wtLJyHDb71wfIoviIArO+Vx jG3w== 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=8ZaBQrz0+vFzF+aJFkG67wqxvuDb7Q4CDYXVgCCmJ7k=; fh=4xF09ByfSUGG+OPXZCiX+POMC/Lc9iuyh69NxBq8sKc=; b=I1iElhaPTNHzU/GdsiP3AR/9agYBOHjOj6Bttu5wBqTYP4aXiTW3QZsfdTr9UyDQNm ZrVv61UQ71GbqPP54q3Qi4f0HGXj47ZqeuPk/eI7RAUb0YAJxLDUgkFpiq+YgNGLyh6B kyu7P2uXpeJ4EGQ6gk/EWKF4A1bmKZYFNV+Q2xy7Av+T40oJFXUZ8Zw0ZQ7oSGqwU0On pyQrv0IqDj227CYxfJKhQLuwXsWPCxVPdasUq7Gvj/tQTFjOU4N+N8A0DlDO5DaAxfMM 8MCmIUjKN/2wsjKbmDectGLLmi3IA3vy5ymWFIk9zA+ff6NH8MAbdNFjlv0oUkiU8rbU Qwug==; 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=1776308917; x=1776913717; 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=8ZaBQrz0+vFzF+aJFkG67wqxvuDb7Q4CDYXVgCCmJ7k=; b=I1DLakGZi/zZkNOVL35wUGFyCoF/QCWrBhCP4Ufwc642/ZIpf61kUGNxjlLhpzzHEx /On2OtrkTKDjhpMXXm4lMACWkICf3IG8NMr89X8frdO4kEYngRdMI1/DNsZghDF59CF4 50QqevjFonBYzyt4gyvO9B6c82MGYn9l3m0uqDd2ApCP5pFxQ3oZM+GFvxC14cu9mz2u s/9pqce66S0qTer5sSUvM1atbVnS9cxRPL9cms9SfX2UgC2aDzAwOVW3Px/5EAMmwirZ ce7tpDNCoQ1lgXM5oqHM/XdUT2WA+xE3cApv1K7f7qLCxGqGlYe56XlzHhHaABsCJjhZ NzfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776308917; x=1776913717; 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=8ZaBQrz0+vFzF+aJFkG67wqxvuDb7Q4CDYXVgCCmJ7k=; b=X7tsLcHQgen4fz7lphUV//NnPuGQC2JUIisGDkHYKhgCSwDwS1H6m6OkoF8x1LDui7 c047chPmz08Hd//xLrCMKzeV34Qv2kAIuwG5wNWDzSzdpdnTApPeIPtwEEXcT/yvqCVw qRNIELCQvSJAVkXp9wBYoGGWnU3pziaz4ho4abI8HnjNhAEXXTn/cqaqfc7TL9eQsBeZ 7E2WFAtdJ1ATj15cTWIYP+p5FMq5Uyw8N4aX6XiJhk3ng6Ge/MQchveQMduCKOMyfw9E RD1IsukCWty2rIKvVUiT9ruM/e9ATo++kQEY8by6EXMYE34GpDWZCuKZVW6qNOBQkpj1 96gA== X-Forwarded-Encrypted: i=1; AFNElJ+Q0ek3YhZnA/71IhYSiLe3RtBSMNUiGAhaomK7H1NueWzXC262uvYDjqVzaF5VhyFouqOqFmW4wkwAdMvO@lists.postgresql.org X-Gm-Message-State: AOJu0Yz/pJPkWIdrBT4Y3ID7sh62q28/WgGy/pqpGL+SEp0y4oxIrY/e EG+lM5n5VaTXq0jVzl3tMjlokR95zRM24gxqSBByrTwZru2vgrfy2ZGzmKYwltMX6MviXs223nr Tyz/9uEnW7vK5oI565o8O1J5vluDYrHI= X-Gm-Gg: AeBDiev2bY1LB5X5ZMJedUjKaHePKYfR+Gqp5Qy/NDyTyEnxlCAnvfTFZgF9CmGZTJI GhCgaVXxK9oBZLlTMCeN/TkXT0EWNw+Slj2hFHhq/SRUo1HzVEkUMh8sQTyXAeJf3ZKSYmlbHoi HO/mOuNdWbYLhCQrGuyX31sKp3Jh+NjTd20Gi9wO4vP7/5pbgzPuzolyxkP3ZmFruvRwbX8ixT0 XOk7zwQXYU63qW8RHYF9K5dOXNeotaozNI7R9lXQFx3ViMlq7J3gaclu9m4p1qXPlXEfXVAO+Pa O6lBiHr+pKiz/FSnXzrHgYQGpU1cV4GRa9VB7jAyCXNI/kMPxKyiz1JvziHjekTWBMIFAjC5a78 = X-Received: by 2002:a17:90b:2b46:b0:35f:b423:688b with SMTP id 98e67ed59e1d1-35fb4236a9dmr14898994a91.28.1776308916887; Wed, 15 Apr 2026 20:08:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Langote Date: Thu, 16 Apr 2026 12:08:19 +0900 X-Gm-Features: AQROBzCUYuywz5HusRCt6hQHWU_JT_vPBy3HZs0tRVAIdhwTa6wLDtHVwRn8ngU Message-ID: Subject: Re: pg_overexplain produces invalid JSON with RANGE_TABLE option To: Chao Li Cc: SATYANARAYANA NARLAPURAM , 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 Hi, On Thu, Apr 16, 2026 at 10:22=E2=80=AFAM Chao Li w= rote: > > On Apr 16, 2026, at 08:06, Amit Langote wrote= : > > On Thu, Apr 16, 2026 at 6:36=E2=80=AFAM SATYANARAYANA NARLAPURAM > > wrote: > >> > >> Hi Hackers, > >> > >> It appears that pg_overexplain produces invalid JSON output when > >> EXPLAIN (FORMAT JSON, RANGE_TABLE) is used. The "Unprunable RTIs" and > >> "Result RTIs" properties are emitted as key:value pairs directly insid= e > >> the "Range Table" JSON array, which is structurally invalid. > > > > Thanks for the report and the patch. That makes sense. > > > >> Attempted to fix this by moving ExplainCloseGroup() before the two ove= rexplain_bitmapset() > >> calls, so the properties are emitted as siblings of "Range Table" in t= he parent object rather > >> than inside the array. > >> > >> Attached a patch to address this which also includes a test. > > > > I have added a commit message. Will commit shortly to master and v18. > > Hi Amit, as the commit message mentions YAML format as well, but I don=E2= =80=99t find a test case in pg_overexplain.sql, would it make sense to also= add a test case for YAML. I tried to add one, see the attached diff file. Thanks, but I think the JSON test is sufficient here. The fix is in format-agnostic code (the ordering of ExplainCloseGroup relative to the bitmapset calls), so any regression that affects YAML would show up in the JSON test too. Generally, we should avoid adding test cases that only duplicate existing coverage (though I'm sure I've been guilty of it myself), as this increases the maintenance burden on expected-output files without catching anything new. --=20 Thanks, Amit Langote