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 1kJmCa-0006NV-Bn for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Sep 2020 23:23:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJmCZ-0002um-7c for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Sep 2020 23:23:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJmCY-0002uD-F3 for pgsql-hackers@lists.postgresql.org; Sat, 19 Sep 2020 23:23:31 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJmCT-0006C8-S9 for pgsql-hackers@lists.postgresql.org; Sat, 19 Sep 2020 23:23:29 +0000 Received: from [192.168.0.105] (unknown [188.235.32.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 4429521C0585; Sun, 20 Sep 2020 02:23:22 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1600557802; bh=3SxZw2R6eLuPhbmWoNJzjRcVCgrpM6EoGxMpwXNLIWQ=; h=To:From:Subject:Date; b=nGiHz3ai29Mq4LSlzew69lMN983K6QCr2hsoW4Kf1BSPTshsCElpcaS1s4ZUl0/Su QU6DXnIX5zj0tSHlRztOB3UC5TJWynKQgkdMgWvsVNK0rwZ50CJHTsF1BLJMvd2q6g rOsltALd4avFfUxFGz7nGLxk4SFEJ/p9fMwgfqoY= To: PostgreSQL Hackers , Alexander Korotkov From: Nikita Glukhov Organization: Postgres Professional Subject: Fix inconsistency in jsonpath .datetime() Message-ID: <94321be0-cc96-1a81-b6df-796f437f7c66@postgrespro.ru> Date: Sun, 20 Sep 2020 02:23:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------6606F6FF0EAC9D6AC4266614" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------6606F6FF0EAC9D6AC4266614 Content-Type: multipart/alternative; boundary="------------C13E8494E9EDEDB4978B9EA1" --------------C13E8494E9EDEDB4978B9EA1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi! The beta-tester of PG13 reported a inconsistency in our current jsonpath datetime() method implementation. By the standard format strings in datetime() allows only characters "-./,':; " to be used as separators in format strings. But our to_json[b]() serializes timestamps into XSD format with "T" separator between date and time, so the serialized data cannot be parsed back by jsonpath and it looks inconsistent: =# SELECT to_jsonb('2020-09-19 23:45:06'::timestamp); to_jsonb ----------------------- "2020-09-19T23:45:06" (1 row) =# SELECT jsonb_path_query(to_jsonb('2020-09-19 23:45:06'::timestamp), '$.datetime()'); ERROR: datetime format is not recognized: "2020-09-19T23:45:06" HINT: Use a datetime template argument to specify the input data format. =# SELECT jsonb_path_query(to_jsonb('2020-09-19 23:45:06'::timestamp), '$.datetime("yyyy-mm-dd HH:MI:SS")'); ERROR: unmatched format separator " " =# SELECT jsonb_path_query(to_jsonb('2020-09-19 23:45:06'::timestamp), '$.datetime("yyyy-mm-dd\"T\"HH:MI:SS")'); ERROR: invalid datetime format separator: """ Excerpt from SQL-2916 standard (5.3 , page 197): ::= ::=