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 1whrM6-000SY4-0R for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 16:12:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whrM4-00Drph-2E for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 16:12:05 +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 1whrM4-00DrpW-1J for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 16:12:05 +0000 Received: from mail-wr1-f45.google.com ([209.85.221.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whrM3-00000000LNI-0RIt for pgsql-hackers@postgresql.org; Thu, 09 Jul 2026 16:12:04 +0000 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-470174001a0so70206f8f.0 for ; Thu, 09 Jul 2026 09:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783613522; cv=none; d=google.com; s=arc-20260327; b=eH2zFyMu78n3vPWthdQ8ktbfXK44w9yMvglYDayp4/bEAI1FrN00C12Qory4BS0wGK ZUgNwXeRyW8zzO2O4CkoK11D5lctxJPo7kRvj5jVUraBQPiUb0oF/kHpie1/6pwPd0mH dKnpN3UrwAl2adgCpt6ndl9v+zVxYmBEoUOYhqFxonemljeWJgopHutvRHPIlJsAxFLK n97Cf2razj5Z7oIhqOqZXse4HkE0Pa/VQn9fXJqZ9IuZ44lwuHngQdcjyPjSPJjtrawo 92fBXbdt/FBZggDPFoIOwDnfkvGavYEIje0FGMGYczGhBjXpxsa7iyYaKSNQZqRYMBJL SR0A== 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=iJg3GDIqiXhIeGfwszWFhrY3FC2o5fBi9WZQKTeydW0=; fh=mYHYjyryOg0+ANjwy8AAumZQvnW2bAF1pvVEbFIEqK8=; b=nfizrbl4dr91VNiMFBYmwAMJK8gNrS95DTKkd72vHOU/qG7d+HHfRzkncEef+rz1t6 w58ErW7EijWJiTI0uuAnqEDNXcd/rTRE1RGQ5jawQhsjRO0mO6xmOmx9AKqLWac7uHEZ XC/EMixWhCC7/1CGD4nF7aaYRUrQvv6gGTxVkcHy/2Z80M/oGsu3TnEtmd+THeiQN0rJ tcpg84jLOZ/rZ7Ai2XNPmYK8jXcVrD7UqhqkAhag6J9MR+1l8c7vUYCzyG/r0JTl6teT AZi2usrElCv5ZIYXuargKvjUg4V1bgTLAqy92b3ZMNIU7TQXLbI9nRU6poauidfz/Bsy o/nw==; 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=1783613522; x=1784218322; 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=iJg3GDIqiXhIeGfwszWFhrY3FC2o5fBi9WZQKTeydW0=; b=s46x4j/mXmchJ5TuO4Li439g11sJJrZHydXhO5dlKXE/pzzb1VsmXfZ/4KaPjsuZxG H4wafBa/T4ZpA2PSIgbxqelrxf1184kjotKcNAFPRjYIrXbFETVZt3OnUaCBVDYiXM39 KGbTNVkbp5JWV0h9PtZyjUQHJJKiRP3tVCW4roJIySQaE8q73imUdbxSbHxXw6BNRqZP OM25hBqyRe23hgDY8uNgMb8mPx7ST58oVd/wjcfKviQjPO21EWjAOecH8E0UtiOiGV+m xJG2Xn9YZOZ5A0HXmOSr8f94rNwbbdPhveizT81Q+QkyoBJ+Z55HL7D9SWhM0B7whVKk 109w== X-Forwarded-Encrypted: i=1; AHgh+Ro3p0Tyhoy8nrjT+fsEdk0WcLE8eKIn6cIbZrZgfJDCBPjFy/MeNsv1BOZQDd9tqk7OCTLHfcaMmJZgHMVc@postgresql.org X-Gm-Message-State: AOJu0Yy/xYtsyC/JM1qt9zApT79UhGqUGdOKOT98ZsAjjjgrXr5Xeh5c muYiebKKJYzV1gFVndC5mrceQFQkSTSsCR4KAZ7DQK/ziObk0BEQNENVPyXteOO30hkpZPWBA+a Ww5fup2iXuwOhR9Bon2k3Sd1vRQg8DFk= X-Gm-Gg: AfdE7cmxv5id/0YjK4VTPIOxEebHdoPCoOm0orKpCD+I5u4NNTa/dw/7B/DoUq+qgc6 uTk5H7By1ZgjLWGeZx9/HFyOQAfcod/yi3JEgbizZH1qTEUuQ/ZikKK0yrKqZZT1BsmtANheEv0 oaCgFApbcBSvS1ttJhlx9fmO5O+6PFbxQ7xaVLwEJXhrOkqDG1tQhuv/YNVlDOU3kCFwhmgleHR xZ1wTddahWqv/euyiW1nHmjOP1HvuXcJkZFiazbknQPnvJiSTlXigqvsg+vBLR56VbEOf1A X-Received: by 2002:a5d:59c5:0:b0:475:f0f0:9ec8 with SMTP id ffacd0b85a97d-47df0813a82mr9245367f8f.51.1783613521452; Thu, 09 Jul 2026 09:12:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Thom Brown Date: Thu, 9 Jul 2026 17:11:32 +0100 X-Gm-Features: AUfX_mz7GuDIG7552sXP4wURBIMQyekGgbSWOivboiC27F0trLXA6iLZPx64-eY 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 Wed, 8 Jul 2026 at 18:04, Alexander Korotkov wrot= e: > > 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 you= r 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. First, doesn't this need a catversion bump? This adds fields to existing node types. 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) 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. 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 haven't done any performance testing yet Thom