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.98.2) (envelope-from ) id 1xSRKG-00000001pxn-3SNV for pgsql-bugs@arkaria.postgresql.org; Sun, 15 Nov 2026 03:54:44 +0000 Received: from localhost ([127.0.0.1]:35822 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSRKF-0000000Ee3w-38Nv for pgsql-bugs@arkaria.postgresql.org; Sun, 15 Nov 2026 03:54:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:33418) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSRKF-0000000Ee3n-1zb2 for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 03:54:43 +0000 Received: from mail-vs1-xe2c.google.com ([2607:f8b0:4864:20::e2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xSRKD-000000016q7-0s82 for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 03:54:42 +0000 Received: by mail-vs1-xe2c.google.com with SMTP id ada2fe7eead31-7a6e560f580so2958562137.1 for ; Sat, 14 Nov 2026 19:54:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794714879; x=1795319679; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8fgwr+wiNTviMNYMDZOpHux8h0ByQVIin0BTiexH+gY=; b=YWI0m9cJ2E/66bfxYTb+IcXBxHmm966/Tkzjx4gXOjh30JT7Wo6TF5MqNQabqDm9Vg PvJ5GfIQbYGiFcHhoLo+at8lNwlbEFEHfnMdQR7JzVRCo/Zr3w+7BzwUwBtKwMLWjVqh tpYBEfE4kONLUO5xfLuzUyOxz2rRwpNYPDHTg9qZ52JdDXbokgc7udNr987kQzGLwzSs XJThlYc4jlLEjils/hQpLAoC1ZDIegA3iTfOcQ6ghQ4u3+2J9ybrbrLJBKWnZTAhmUYx YLj+befG+vRZwOLYJ9wV2TSn0l6VzpYP9h6tMk556KHgQkueFjCdOOQQpBcba39I99ZV Kw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794714879; x=1795319679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8fgwr+wiNTviMNYMDZOpHux8h0ByQVIin0BTiexH+gY=; b=flV/+qNQfHMc2ND+XeNK6q17zlC1BCczq3FweSA7fvf7J7Zj8oatQOWNrHiNyHhSel sQJ+aDviAFHlvrcvZoP1sYJb8QELmZfm95nrvi089WemBEqvycZLf2YxSQgXBsh1sMLu 3A6FXOLOIhZ2LuFAngTDaEOfEfOZ1SHK9blv8oku5ju+SyPUXPDfG0XUaV5c4tMBAqYa D9OX364IBy+Zq1mH07eyYFGv8ij8Sfrf6QrrCmjAUklMG+M0a1IKdCCmCs6KPkulB9b1 wmSEj251AobI2lNgHJWrbpDHXIvhFVYkZ7gooADR03ODdpYu94JfP1vAm3kuIIukzC3S XRxw== X-Forwarded-Encrypted: i=1; AL+hErFEA7Uobm0oc1qRvrXVJYRNNWEYupFGFNUBa15ODiPsgD1zwehtv6vi2Nwe7hVyKEnlF6oglgl44Agy@lists.postgresql.org X-Gm-Message-State: APuU4Z+K76U0j9U4ce4UeTgwC9IAqnpUnZE2pRN8hCHw1IS8k3uo3Let O7uRRO4+mgFK7gq+Gf5WJnp7SCu0UkuQ+EuFVfJZFZVA/AWQGqeMl93QrsUSpvUkaypwCg== X-Gm-Gg: AYBFou1hfMeYa485piKbuQ97S9/0xk+YzMLp3KivSpHyXk42CSLf4MkVdQ24Akw6QZl MkMElQRWHUpfEGsrbj9B+x2gxo+iVdCh0lj8g7xAWtDFqBtn2y0+0uCqrst2VqqZdsIShbPXVsy UEkfFdHCq2bjRYvnICu4DhiuGVALKZXHRbapqGhXz6cURpNcH5bGETi7eUm+As+8B3+NH/wAARo ph7iDij5npbn1LOsSD6FGeRoMo6LxDnZPPNolPzx5xl+ae05aqZEqU2dtIK+ZpY7cri+JzuVasH fO7bg90S7q1/ctv25/1buGj5XULqOcSycPG8T4gbPSRwkvikH/PqD9dXmDDBE11TbP5t5UX5SMR emOev+us6dnITYU/SzxXUPQmRaV2Z4xBcdmlm7CqCasKHgvstSJPcxARGpvBzUOYKvmmAnLgnp2 9Dn8M+nOU6P3dnFxPpIggYXblU5TEoL1Ozy3lVu/YWiwjGWCTb/a57i9TqaW5lm54jVwxORarLY 6oR+PI14MQGRhG1mUqdCjhdOiKlA00J7R5FX7e8qzimPLdYxxFP6FUg4En3Kz6nyvr6sWGYCLFI 3Uqoy27+wcc7LPLo1tn5z2C1dtR1Tf9AlL60CZdj/uoGwgNu0klQUDuIo1dL7MA0WeV2OHonXaU 5DrUdmLyD6A9nddD6CjMuqCWZv5gQR1Lm7IPfq4oURIrp6TScYLA6CcPImDxd X-Received: by 2002:a05:6102:4410:b0:7c3:c0b9:9028 with SMTP id ada2fe7eead31-7d64d77b869mr2478101137.24.1794714879559; Sat, 14 Nov 2026 19:54:39 -0800 (PST) Received: from NOTEBOOK-LAILA ([2804:14d:5c27:1387:a053:f15d:8c82:ed64]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-99dfe8fd40dsm2439601241.6.2026.11.14.19.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Nov 2026 19:54:38 -0800 (PST) From: Joao Rito To: Amit Langote Cc: Man Zeng , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19625: SQL/JSON boolean DEFAULT expression silently replaced with 'false' Date: Sun, 15 Nov 2026 00:54:32 -0300 Message-ID: <20261115035432.23742-1-joaovictor.rito@gmail.com> X-Mailer: git-send-email 2.53.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Amit, Man, I tested v2 on current master (81b2179b492, built with cassert and tap tests) and it applies cleanly. On master, a boolean DEFAULT ON ERROR or ON EMPTY returned 'false' in every case I ran where the result was not already boolean: DEFAULT true, NULL::bool (the result was not NULL), (1 = 1) and (random() < 2, ON ERROR only), in JSON_VALUE, JSON_QUERY and JSON_TABLE. I used RETURNING text, char(5), varchar(10), json and jsonb. RETURNING bool was already correct on master. With v2 all of them return the expected value, and a view shows DEFAULT to_jsonb(true) and gives the same result. DEFAULT 'abc', 42, a numeric, a date and a jsonb object, and JSON_EXISTS with TRUE/FALSE/UNKNOWN ON ERROR, give the same results as on master. The new test in sqljson_queryfuncs fails on master without the C change (it shows false | false | f where true | false | t is expected), and the regress suite passes with the patch (243 tests). I could also reproduce what Man reported after v2. On master, CREATE INDEX on JSON_VALUE(j, '$.x' DEFAULT true ON EMPTY) and a STORED generated column with the same expression both work. With v2 they fail with "functions in index expression must be marked IMMUTABLE" and "generation expression is not immutable", because to_jsonb(anyelement) is STABLE. With a non-boolean DEFAULT, the index (text, and RETURNING int) and the generated column (text) still work with v2. What I did not test: the isolation and tap suites, pgindent, the docs, the back branches (v17 onward), other platforms (I ran one Linux build), and a fix for the immutability issue. Small suggestion: since the index and generated column cases work today, maybe the fix could avoid a STABLE function for a constant boolean DEFAULT (for example by building the jsonb Const at parse time, as the TRUE and FALSE behaviors do), and the test could cover an index or generated column. I do not have a tested patch for that. I have no objection to the rest of the approach. Regards, Joao Rito