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 1whvMt-000UWk-0j for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 20:29:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whvMp-00EaZ7-2Y for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 20:29:08 +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 1whvMp-00EaYx-0k for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 20:29:08 +0000 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whvMn-00000000N6P-32w3 for pgsql-hackers@postgresql.org; Thu, 09 Jul 2026 20:29:07 +0000 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493e8d4f4dcso1894195e9.0 for ; Thu, 09 Jul 2026 13:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783628944; cv=none; d=google.com; s=arc-20260327; b=RqhSBXuU7PsRqlqKV9j3h3dW085fXgeLRUMXbCMF329TfnHlVGpeYrRSBzzsVCd7WZ vc/GPXYzf141W0i5qfeDedwUTkwkTsa849VOAYUwYkOOzLfDD57vIj5C8V966eG6Qh7n 3UZoauccfcANpjJ6PmTuzgJkGxR2TXDKPa+D/wQTbdguIuoAC+tqpbfZjt+bgNwvfGiw NRSw4e/w48R1skV70WUlohO4WqRSY3oSscdSmUXuZEqERVxvnKYDWqmcW2t0fPefcm90 6vCTkihGPNKvL24kDRFkBmEX3+kMJbQob2TE4pAiuYo0olDEd8Zsd67aagIeARsOZ8NZ zNiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=IO8NzSZEuOINDXRzvpWoPiCHmwmhCenR33drkQBT62g=; fh=zQJiRfzv7b69hziYNZIeqNfOhFoBXSAahxmYY7docAs=; b=MuOeFfedSDYfl0gTGFkFhH+UBltwHFSievlikeyPjMk7V1lz7iOUmrjNx/7deVxk5t 9D4M0k4heb2e39h0nodXiz7Y65t1Ck+vwiP9fAk8cVPDgMjKlVlh3K55HFtjo0FGBr+j UYqI+6KO6KacuhlCm9YjR0pFQFva75wbzICzzmQcLoa3/b7C8rn/O6J9/+DzG32UzVrr 2F+WGLAS8vbIu9hF5kj6K3IuiS0bgTh2AHjz9pI5FSvs1XhrJCGU8hsboOqCDJ1a9bCK 9pD+oiYnU3w+SLpXCNdOopqfJjdJtqPzTtMwwwy8khS3ZyUaSey+FsOdsLtkMbEgv/k3 KqDQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783628944; x=1784233744; h=content-transfer-encoding:content-type: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 :content-type; bh=IO8NzSZEuOINDXRzvpWoPiCHmwmhCenR33drkQBT62g=; b=QOOrmOYFaSp4NvElmeq+0K6s1TpAG+1onLlXbY3rw/n60XKwd0pMrWjqTpvqkwk0fj G4v8AUTiGQ1Pah68vMtLT7NvfPH7S1vEqpESeZHUz0tL1Etgg9hXpRginpN6DKUf9LNU thdY8XEVITJNRDQ0LGlUwssd8PN9+4jQ8/Zm8q8LYsnCZtCNC/NAQQMW6/pHnwYJPT3e LOneToEz51B6LwtERDB4ZEXPN8WeqUIE9OuOlJHztYnTbG85FBhRINPouEBdxx36VtyK uIK0m72jQ3xhZHz559+nTEGP0jJfrqjre/ultDYi7umm933ZPIp/MrcvtIgPR+mEqCSj UtEg== X-Forwarded-Encrypted: i=1; AHgh+RpIHLcCYhoYLQrjdWVkhoTOkL4W6i7Ure/p3BITvInOujJFjWOVPEoDVF7OerF+Cs4XetpduTpEF+0DJEMA@postgresql.org X-Gm-Message-State: AOJu0YyvublQuyAcBd7x9s+O12mBS5POZXPBc7p9yZP5EXCAcfdG9LEQ 3eFGgvU1gn16hJadxEmmzJPvqrUT43MLyGplOU1MH+9Iew6c9C9KnwIbCpoM6K6QHVdeSR9hn+H h4wCqSxGX+VHQt/2Ydq4pPu4If1B2sGE= X-Gm-Gg: AfdE7ckJ0D5xwbbRPfyzWOweTxUKEjyEOQWAqGssLhiwNK7VzySpMCbJx79APCxYcg0 +jspc0p5RofcyeAiV4dKJAJB8HW7Fg6ah7MRiD0vmhvCyfIvF6pI29VDpMF+NOsXUCgW2vGgEVm 7MYce+Ecsh26v3hpueMvD7yU1SqhCRoK7rmCCDn85kAUzHo8FYOBb7fxl6Q4ggcl0GuzO2oCzTK pJNMCrHGsGG26pzmtWoa2cof15dUceN+FKAjuQG7K9VZDC77G8+VGzar9/XwR2tyVH66dn9 X-Received: by 2002:a05:600c:3b0d:b0:493:bc4a:fb56 with SMTP id 5b1f17b1804b1-493e68a4e54mr82845085e9.39.1783628943940; Thu, 09 Jul 2026 13:29:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Thom Brown Date: Thu, 9 Jul 2026 21:28:37 +0100 X-Gm-Features: AUfX_mwiCdpE293wgWc4VJgFKLejR-4x-L-YaYYV00M5ooO9BCLvFT9ejcR0KqU Message-ID: Subject: Re: SQL/JSON json_table plan clause To: Alexander Korotkov Cc: Nikita Malakhov , Amit Langote , pgsql-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 On Thu, 9 Jul 2026 at 20:52, Alexander Korotkov wrot= e: > > Hi, Thom! > > On Thu, Jul 9, 2026 at 7:12=E2=80=AFPM Thom Brown wrote: > > On Wed, 8 Jul 2026 at 18:04, Alexander Korotkov = wrote: > > > > > > On Wed, Jul 8, 2026 at 6:35=E2=80=AFPM Nikita Malakhov wrote: > > > > Alexander, thank you for your participation. I am very sorry, I've = seen your previous > > > > email but was busy with other tasks and didn't have time to work on= your notes. > > > > Thank you very much! > > > > > > OK, no problem. Are you good with the current shape of the patch? > > > > I've been giving this a test drive. I saw that this has been > > committed, and re-tested against that, and the issues I identified > > (unless I've misunderstood some functionality) seem to have survived. > > I tried my best to check if all the critics is addressed. SQL/JSON patch= es > go through so many threads. Sorry that I missed your valuable insights. You didn't miss anything from me, so nothing to be sorry about. I just meant I retested the issues I had found against the commit to see if they had been fixed prior to submitting them. I hadn't raised them prior to today. > > First, doesn't this need a catversion bump? This adds fields to > > existing node types. > > Thank you for noticing, catversion is bumped. > > > I only get the first column from the following. The second one > > disappears without error: > > > > SELECT * FROM JSON_TABLE( > > jsonb '[{"x":[1],"y":[2]}]', '$[*]' AS p0 > > COLUMNS ( > > NESTED PATH '$.x[*]' AS json_table_path_0 COLUMNS (x int PATH '$'), > > NESTED PATH '$.y[*]' COLUMNS (y int PATH '$') > > ) > > PLAN (p0 OUTER json_table_path_0) > > ) jt; > > x > > --- > > 1 > > (1 row) > > Yes, there is a bug in assignment of generated names. Fixed in 0003. > > > I have the following view: > > CREATE VIEW v_chain AS > > SELECT * FROM JSON_TABLE( > > jsonb '[{"x": [{"y": [1,2]}]}]', '$[*]' AS p0 > > COLUMNS ( NESTED PATH '$.x[*]' AS p1 COLUMNS ( > > NESTED PATH '$.y[*]' AS p11 COLUMNS ( y int PATH '$' ) ) ) > > PLAN (p0 OUTER (p1 INNER p11)) > > ) jt; > > > > When I dump it, I get: > > > > CREATE VIEW public.v_chain AS > > SELECT y > > FROM JSON_TABLE( > > '[{"x": [{"y": [1, 2]}]}]'::jsonb, '$[*]' AS p0 > > COLUMNS ( > > NESTED PATH '$."x"[*]' AS p1 > > COLUMNS ( > > NESTED PATH '$."y"[*]' AS p11 > > COLUMNS ( > > y integer PATH '$' > > ) > > ) > > ) > > PLAN (p0 OUTER p1 INNER p11) > > ) jt; > > > > The parentheses around "p1 INNER p11" aren't preserved. > > Yes, there is a bug in the deparsing. 0002 fixes that. > > > Another dump issue with the following: > > > > CREATE VIEW v_onempty AS SELECT * FROM JSON_TABLE( > > jsonb '{}', '$' AS p0 > > COLUMNS ( a int PATH '$.nosuch' ERROR ON EMPTY ) > > ERROR ON ERROR > > ) jt; > > > > This dumps as: > > > > CREATE VIEW public.v_onempty AS > > SELECT a > > FROM JSON_TABLE( > > '{}'::jsonb, '$' AS p0 > > COLUMNS ( > > a integer PATH '$."nosuch"' > > ) ERROR ON ERROR > > ) jt; > > > > It's lost "ERROR ON EMPTY". > > > > > > Another example: > > > > SELECT * FROM JSON_TABLE(jsonb '"mystring"', '$' > > COLUMNS (a int PATH '$') > > ERROR ON ERROR > > ) jt; > > > > This gives me: > > > > ERROR: invalid input syntax for type integer: "mystring" > > > > But the documentation says that the table-level clause "does not > > affect the errors that occur when evaluating columns". Am I missing > > something here? > > I've rechecked with SQL 2023 standard. AFAICS, ON ERROR clause should > be propagated from table to column. We don't propagate it, so that must = be > a bug since PG 17. But this patch shouldn't try to change it, it's out o= f scope. > 0001 reverts attempt to change ON ERROR handling (this also fixes the cas= e > about of invalid dumpinged). I think we need to consider this subject se= parately. Yeah, I haven't exercised JSON_TABLE enough since release, so I'm clearly late in hitting this. Thanks for the fixes. I'll try to get round to testing them tomorrow unless someone beats me to it. Thom