Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pguEr-0005ZD-4i for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Mar 2023 21:18:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pguEp-0008N8-No for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Mar 2023 21:18:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pguEp-0008Mx-BY for pgsql-hackers@lists.postgresql.org; Mon, 27 Mar 2023 21:18:47 +0000 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pguEn-0004Lo-3o for pgsql-hackers@postgresql.org; Mon, 27 Mar 2023 21:18:46 +0000 Received: by mail-il1-x12d.google.com with SMTP id h11so5330750ild.11 for ; Mon, 27 Mar 2023 14:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; t=1679951923; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Dz0eWj0MynHOfaRWX36VHmIC1cnpyFTjHnySvw5llGE=; b=nXBcqTt7ZQwluT3SQD3QbtYPliNehbqekunMq/lRNLQ8C2V7JJhaR1b0H2DRXyP0tY v4qVjZVbTX95vXU05v2sEYcysXWouW6j6ZvBGkl5Db2t6UXl8EFBY9B3IzfwVvEud1qF 2uDsSzQQw7AxJD8Gh1TtbvWpMkSYtGc9z3dwO4vB09tDJ10db7SUuqDl32nDywsg5Wmv S1FDI3LPiusYn0OwuEJX870ILJmr2vaKln8D4POnKQuY73+ZvMrvISSgDZDVeXAO/amH Fb8WEwJkdPovJzPKY0KJUiIisXgsM60cr+aUxsAN10pByfuI6pPG5jhRZYLUXQ7d59dB I/PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679951923; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dz0eWj0MynHOfaRWX36VHmIC1cnpyFTjHnySvw5llGE=; b=2WhQRX16PRvj4ouNSHwaUTMBxkllzbq5+Of3McUc+aakVLKPjYTmpz2NX/K6+tCla0 jk1vnjELOshTIl4J+E1Dd37VIRKG4A1IWbsaNnqpMV3FaSnb/hWHrQHuARFPI8NrDv8y 0WcvDzjYcfQdNT0Mt8hMiXmtfNbBQbksM6LckfYbn/xmF8k7IUXD2r0YNzIiiEs/g2IO sYNmtehpfQw6dvFVxa5fzAMnMqz8B6F2Nhdjt0WmaKq1GK5tWahKSJnsNi+SIJa2RKOb hwugXWHmc4uaSFpJrEN1MduW6wfyVMt7adV8+NxZZGr1T45ffQg6USfTNGYApipbyZ94 Hwzw== X-Gm-Message-State: AAQBX9dRl3W2L+mOanQqhmUqxhhegmi9a96VYkQejjY+vFic9SJb87NS l7S6MMWqDXeeD5MuvqmCJOH0WA== X-Google-Smtp-Source: AKy350Y0B4doO+dzjQw8+dJf7IAigAcIOIHG12wSlJTbvyims+tNRvuB0hSHAJrrXXsq8+2qJJZ68g== X-Received: by 2002:a92:cf07:0:b0:323:2434:7154 with SMTP id c7-20020a92cf07000000b0032324347154mr10963903ilo.26.1679951923349; Mon, 27 Mar 2023 14:18:43 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id j2-20020a056e02124200b00325c0d7a0bcsm4161780ilq.72.2023.03.27.14.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 14:18:42 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 601A4800C08; Mon, 27 Mar 2023 16:18:41 -0500 (CDT) Date: Mon, 27 Mar 2023 16:18:41 -0500 From: Justin Pryzby To: Alvaro Herrera Cc: Andrew Dunstan , Amit Langote , Peter Eisentraut , Andres Freund , vignesh C , pgsql-hackers@postgresql.org, e.indrupskaya@postgrespro.ru Subject: Re: SQL/JSON revisited Message-ID: References: <20230322121846.vcxjogqyguihkicr@alvherre.pgsql> <20230327185456.wbb5gchworsu3hf7@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230327185456.wbb5gchworsu3hf7@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I ran sqlsmith on this patch for a short while, and reduced one of its appalling queries to this: postgres=# SELECT jsonb_object_agg_unique_strict('', null::xid8); ERROR: unexpected jsonb type as object key postgres=# \errverbose ERROR: XX000: unexpected jsonb type as object key UBICACIÓN: JsonbIteratorNext, jsonb_util.c:958 As you know, it's considered bad if elog()s are reachable, user-facing errors. 2023-03-27 15:46:47.351 CDT client backend[13361] psql ERROR: unexpected jsonb type as object key 2023-03-27 15:46:47.351 CDT client backend[13361] psql BACKTRACE: postgres: pryzbyj postgres [local] SELECT(JsonbIteratorNext+0x1e5) [0x5638fa11ba82] postgres: pryzbyj postgres [local] SELECT(+0x4ff951) [0x5638fa114951] postgres: pryzbyj postgres [local] SELECT(JsonbToCString+0x12) [0x5638fa116584] postgres: pryzbyj postgres [local] SELECT(jsonb_out+0x24) [0x5638fa1165ad] postgres: pryzbyj postgres [local] SELECT(FunctionCall1Coll+0x51) [0x5638fa1ef585] postgres: pryzbyj postgres [local] SELECT(OutputFunctionCall+0x15) [0x5638fa1f067d] postgres: pryzbyj postgres [local] SELECT(+0xe7ef7) [0x5638f9cfcef7] postgres: pryzbyj postgres [local] SELECT(+0x2b4271) [0x5638f9ec9271] postgres: pryzbyj postgres [local] SELECT(standard_ExecutorRun+0x146) [0x5638f9ec9402] What might indicate a worse problem is that with debug_discard_caches=1, it does something different: postgres=# \errverbose ERROR: XX000: invalid jsonb scalar type UBICACIÓN: convertJsonbScalar, jsonb_util.c:1865 2023-03-27 15:51:21.788 CDT client backend[15939] psql ERROR: invalid jsonb scalar type 2023-03-27 15:51:21.788 CDT client backend[15939] psql CONTEXT: parallel worker 2023-03-27 15:51:21.788 CDT client backend[15939] psql BACKTRACE: postgres: pryzbyj postgres [local] SELECT(ThrowErrorData+0x2a6) [0x5638fa1ec8f3] postgres: pryzbyj postgres [local] SELECT(+0x194820) [0x5638f9da9820] postgres: pryzbyj postgres [local] SELECT(HandleParallelMessages+0x15d) [0x5638f9daac95] postgres: pryzbyj postgres [local] SELECT(ProcessInterrupts+0x906) [0x5638fa094873] postgres: pryzbyj postgres [local] SELECT(+0x2d202b) [0x5638f9ee702b] postgres: pryzbyj postgres [local] SELECT(+0x2d2206) [0x5638f9ee7206] postgres: pryzbyj postgres [local] SELECT(+0x2d245a) [0x5638f9ee745a] postgres: pryzbyj postgres [local] SELECT(+0x2bbcec) [0x5638f9ed0cec] postgres: pryzbyj postgres [local] SELECT(+0x2b4240) [0x5638f9ec9240] postgres: pryzbyj postgres [local] SELECT(standard_ExecutorRun+0x146) [0x5638f9ec9402] +valgrind indicates this: ==14095== Use of uninitialised value of size 8 ==14095== at 0x60D1C9: convertJsonbScalar (jsonb_util.c:1822) ==14095== by 0x60D44F: convertJsonbObject (jsonb_util.c:1741) ==14095== by 0x60D630: convertJsonbValue (jsonb_util.c:1611) ==14095== by 0x60D903: convertToJsonb (jsonb_util.c:1565) ==14095== by 0x60F272: JsonbValueToJsonb (jsonb_util.c:117) ==14095== by 0x60A504: jsonb_object_agg_finalfn (jsonb.c:2057) ==14095== by 0x3D0806: finalize_aggregate (nodeAgg.c:1119) ==14095== by 0x3D2210: finalize_aggregates (nodeAgg.c:1353) ==14095== by 0x3D2E7F: agg_retrieve_direct (nodeAgg.c:2512) ==14095== by 0x3D32DC: ExecAgg (nodeAgg.c:2172) ==14095== by 0x3C3CEB: ExecProcNodeFirst (execProcnode.c:464) ==14095== by 0x3BC23F: ExecProcNode (executor.h:272) ==14095== by 0x3BC23F: ExecutePlan (execMain.c:1633) And then it shows a different error: 2023-03-27 16:00:10.072 CDT standalone backend[14095] ERROR: unknown type of jsonb container to convert In the docs: + The key can not be null. If the + value is null then the entry is skipped, s/can not/cannot/ The "," is dangling. -- Justin