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.94.2) (envelope-from ) id 1rhtIB-00Dtfc-7u for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 15:34:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rhtI8-00B8W1-No for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 15:34:49 +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.94.2) (envelope-from ) id 1rhtI8-00B8Vt-DV for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 15:34:48 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhtI4-0039xy-8A for pgsql-hackers@postgresql.org; Wed, 06 Mar 2024 15:34:47 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-412e68b8594so8540415e9.1 for ; Wed, 06 Mar 2024 07:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1709739282; x=1710344082; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=UJLFwS/pu3AhHuipDArj5y1hi634lhodsWLSU+8h4Cc=; b=H+Rd/6qJ1nWSuj3ii6mjCvJw+ecnsoTmsb3NVee8S139wXLECYEYXWL30C/9VqxHFb EuYoRZtxCi7NAvD0fJ6HEzPTrOjtMX/iJ9KpwMW0QcSUzEx8o6JQo3UFnznrRZe3l7jS wGZ+Uq+cyMRFdPupWCnQYuMnVTgrMktyUlgbXR0K1lIILj/c5SjicvvKTJwuapctqRnA +eUhSvJ8VI+3DN05+Obg2v1CNiXqmZhGqtU/SDCdYwivVFota0yU56kiicgTQ23fajXs tvsxwDRuc9HBb9c1/QX895vEuN48CCsMo9b1D+8gQZ8c97xsstn1q7mdv6pqoEbpe8hl cnEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709739282; x=1710344082; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UJLFwS/pu3AhHuipDArj5y1hi634lhodsWLSU+8h4Cc=; b=UpiSdyortDyMo/R8S5H4CVBgMATe+UOxyxaQF48acpeJrFCnjXt6ppIiBAAuBgCNnS qpEoqVNNqdO0ZHtd8eulvAXID3ICUwCvgq/3LTAemmkK08UDHgu8a2OrGSdgxNkZWhID vEjFgRmKD5v6qz8aouIAkMSVClVda+8C7mEvWlvJap5D5K3Xq3OLzl6b8c10/FfK6H2g CtmkHDW+vyGNWDqCjrNQFCpVCGgPsI5Nqjs/TNrqJSLe+3ICUCvx8yVSFU87bl4TRj0C xRAAnvy7NrPTGMp9lsNj/8MN7G3l7/Mihj7d+vZ0xhBCfR47faXFClvA8yNhCIE318Ka oLSA== X-Forwarded-Encrypted: i=1; AJvYcCV8Ie4ZpoAEnSooewL2pO49Rd+NLcO3c4QFn8jNqAn11kMITU0Q9Nj5vGnYkYufhLqj55fEnUZeLWmSAdH+TvYajbTHDr2j3IBYTa8F X-Gm-Message-State: AOJu0Ywp7oXIGU6fNZAOd/1qi4V4HJNG4hj0s/C3CjCdgoWr+1UpDyNv oTSF6weUgSVXYe7lfwKGER9nftg18zSnJwXE9PPri/e7XGN1yXoSoTdr3Ft++Q== X-Google-Smtp-Source: AGHT+IHlR1hTPHzFQnpvqB1JSiZe82u84vCYen8n1svd/NWkEMzzFDkixJo34OyQyyWWYoh+4eczzg== X-Received: by 2002:a05:600c:1c84:b0:412:e555:818c with SMTP id k4-20020a05600c1c8400b00412e555818cmr6109586wms.26.1709739282563; Wed, 06 Mar 2024 07:34:42 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id fc11-20020a05600c524b00b00412d4c8b743sm14476498wmb.30.2024.03.06.07.34.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Mar 2024 07:34:42 -0800 (PST) Message-ID: <562e5ad9-1357-4752-ad28-7e56740f74f8@enterprisedb.com> Date: Wed, 6 Mar 2024 16:34:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: remaining sql/json patches Content-Language: en-US To: Himanshu Upadhyaya , Amit Langote Cc: Alvaro Herrera , Erik Rijkers , jian he , Andres Freund , Andrew Dunstan , PostgreSQL-development References: <1cee81f3-312f-30e3-0282-c4df7ee72f93@xs4all.nl> <202403041503.5momp6knupgo@alvherre.pgsql> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/6/24 12:58, Himanshu Upadhyaya wrote: > On Tue, Mar 5, 2024 at 6:52 AM Amit Langote wrote: > > Hi, > > I am doing some random testing with the latest patch and found one scenario > that I wanted to share. > consider a below case. > > ‘postgres[102531]=#’SELECT * FROM JSON_TABLE(jsonb '{ > "id" : 12345678901, > "FULL_NAME" : "JOHN DOE"}', > '$' > COLUMNS( > name varchar(20) PATH 'lax $.FULL_NAME', > id int PATH 'lax $.id' > ) > ) > ; > ERROR: 22003: integer out of range > LOCATION: numeric_int4_opt_error, numeric.c:4385 > ‘postgres[102531]=#’SELECT * FROM JSON_TABLE(jsonb '{ > "id" : "12345678901", > "FULL_NAME" : "JOHN DOE"}', > '$' > COLUMNS( > name varchar(20) PATH 'lax $.FULL_NAME', > id int PATH 'lax $.id' > ) > ) > ; > name | id > ----------+---- > JOHN DOE | > (1 row) > > The first query throws an error that the integer is "out of range" and is > quite expected but in the second case(when the value is enclosed with ") it > is able to process the JSON object but does not return any relevant > error(in fact processes the JSON but returns it with empty data for "id" > field). I think second query should fail with a similar error. > I'm pretty sure this is the correct & expected behavior. The second query treats the value as string (because that's what should happen for values in double quotes). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company