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 1rlZjN-0039lV-1K for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 19:30:09 +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 1rlZjL-00HLyK-1u for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 19:30:07 +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 1rlYGP-00GyPv-10 for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 17:56:09 +0000 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rlYGI-004qos-TN for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 17:56:06 +0000 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5a46ec4050eso1406872eaf.2 for ; Sat, 16 Mar 2024 10:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710611762; x=1711216562; darn=lists.postgresql.org; h=to:message-id:subject:date:mime-version:from :content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=Vl7thh0nygno2XmKvwl4NiacNlZDnnyxRmwrLuvBSUc=; b=bqOh1g7SnHJkkqk4JtZv/iKomwbyjByxZaEmrRSXjPoHAOsSnlqW1Y6O6NwEic/tw1 QZiTvwnZZ2Qhc62u5b4iMhl2bgy1DSQeEF3Iv5JMnWWdAogi9jrXA0q/HoDIlzBFzw8v JxSljcuNC8m6v4XUyuF9G0r3X9W7zQ0os1Zo856FR/dKKkF1SjqbFQJfLNa1QMYsD5Qv TLoBJ7JIaoJQ8vdoO8a0RHaqj1iL531bbHJb6S46SrUDvvaPs5aQxwsxwKBD9Uj2JAYy fIcBziAMgRfMR+1557Dq+eRHfnz5o7rGi/ZPP+lVpLwaSoibBY9Nx5daqsbPkNfvEiXN dBpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710611762; x=1711216562; h=to:message-id:subject:date:mime-version:from :content-transfer-encoding:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Vl7thh0nygno2XmKvwl4NiacNlZDnnyxRmwrLuvBSUc=; b=cQfPLQOEtBSi91CxfxWZGpDesnKNNr0zbGWoFcIZ+mTHg9EtWuSsQcdbHUZSMX9YGS 67C2TO4+K0jnSHJLHGDuKO3PZohnu9XRBKBQjlI7z0eeHsD0hmOLy+13CNp9cdJcmdZg cQH2pNCDwcX371VdtsWzjX0F710Ue31e95M+y0tLBY6VHgXsNWIMp4rreAZ8FPIF2fPN ZLUmZ0EsghnAPzAL0E+sazRxz/gJh6WxaFfCtUdxm0LMq7KVHU+7IptFGaoN1KVFoF6I dIy8Ds5x84RTnde1IW3jyJmPxE8oykTYBQoSLNZku2xlUPxxwLdwULtEHWgHa4Ta7JCI tpAw== X-Gm-Message-State: AOJu0YyfKg/eLcYbwHLDYVVpw0/Rh/IndishFMokIjn7O7KM2vsXc92v loJnQcgvw1kqWbdpO/tu/5Q4quv4fDlU1jwQ64rcXZmSWeeN/l4n7f6nfP8i5BE= X-Google-Smtp-Source: AGHT+IFIsoyLdxFh/bKB0SpfO1K79EPmUFBN00IRRcmiNoQdgZrqxkA/jlza43Wr9ug4bSo/wFth0w== X-Received: by 2002:a05:6359:5f90:b0:17b:5c4b:90a with SMTP id lh16-20020a0563595f9000b0017b5c4b090amr6691495rwc.5.1710611762145; Sat, 16 Mar 2024 10:56:02 -0700 (PDT) Received: from smtpclient.apple ([2405:201:6823:687b:30e5:5dc6:7181:acfc]) by smtp.gmail.com with ESMTPSA id i36-20020a635864000000b005dc507e8d13sm4259214pgm.91.2024.03.16.10.56.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Mar 2024 10:56:01 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-413FEBC0-75BB-4F01-8311-AD58978B9825 Content-Transfer-Encoding: 7bit From: Rahul Uniyal Mime-Version: 1.0 (1.0) Date: Sat, 16 Mar 2024 23:25:49 +0530 Subject: Postgres jdbc driver inconsistent behaviour with double precession Message-Id: To: pgsql-bugs@lists.postgresql.org X-Mailer: iPhone Mail (21D61) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-413FEBC0-75BB-4F01-8311-AD58978B9825 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Hello Team, Hope everyone is doing well here. I am writing this email to understand an issue I'm facing when fetching data= in our Java application. We are using PostgreSQL JDBC Driver version 42.6.0= . Issue: We are encountering an issue where the double precision data type in Postgre= SQL is giving some intermittent results when fetching data. For example, in t= he database the value is 40, but sometimes this value is fetched as 40.0. Si= milarly, for a value of 0.0005, it is being fetched as 0.00050, resulting in= extra trailing zeros. While debugging, it seems like this issue is caused by the different data fo= rmats, such as Text and Binary. There is some logic in the PgResultSet class= that converts values based on this data format. Example: Below is an example where we are getting different data formats for the same= table: Text Format: [Field(id,FLOAT8,8,T), Field(client_id,FLOAT8,8,T), Field(creat= e_ts,TIMESTAMP,8,T), ...] Binary Format: [Field(id,FLOAT8,8,B), Field(client_id,FLOAT8,8,B), ...] (not= ice some format changes) We are not sure why different formats are coming for the same table. Schema: Below is the schema for the table used: SQL =20 CREATE TABLE IF NOT EXISTS SUBMISSION_QUEUE( ID DOUBLE PRECISION, CLIENT_ID DOUBLE PRECISION, OCODE VARCHAR(20) NOT NULL, PAYLOAD_TYPE VARCHAR(20), REPOSITORY VARCHAR(16), SUB_REPOSITORY VARCHAR(20), FORCE_GENERATION_FLAG BOOLEAN, IS_JMX_CALL BOOLEAN, INSTANCE_ID DOUBLE PRECISION, CREATE_TS TIMESTAMP(6) NOT NULL, ); Request: Team, would it be possible to give some insight on this issue? Any help woul= d be greatly appreciated. Thanks,= --Apple-Mail-413FEBC0-75BB-4F01-8311-AD58978B9825 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

Hello Team,

Hope everyone is doing well here.

I am writing this email to understand an issue I'm facing when fetching data in our Java application. We are using PostgreSQL JDBC Driver version 42.6.0.

Issue:

We are encountering an issue where the double precision data type in PostgreSQL is giving some intermittent results when fetching data. For example, in the database the value is 40, but sometimes this value is fetched as 40.0. Similarly, for a value of 0.0005, it is being fetched as 0.00050, resulting in extra trailing zeros.

While debugging, it seems like this issue is caused by the different data formats, such as Text and Binary. There is some logic in the PgResultSet class that converts values based on this data format.

Example:

Below is an example where we are getting different data formats for the same table:

Text Format: [Field(id,FLOAT8,8,T), Field(client_id,FLOAT8,8,T), Field(create_ts,TIMESTAMP,8,T), ...]

Binary Format: [Field(id,FLOAT8,8,B), Field(client_id,FLOAT8,8,B), ...] (notice some format changes)

We are not sure why different formats are coming for the same table.

Schema:

Below is the schema for the table used:

SQL

 

 CREATE TABLE IF NOT EXISTS SUBMISSION_QUEUE(
  ID               DOUBLE PRECISION,
  CLIENT_ID           DOUBLE PRECISION,
  OCODE VARCHAR(20) NOT NULL,
  PAYLOAD_TYPE        VARCHAR(20),
  REPOSITORY VARCHAR(16),
  SUB_REPOSITORY          VARCHAR(20),
  FORCE_GENERATION_FLAG   BOOLEAN,
IS_JMX_CALL BOOLEAN,
INSTANCE_ID           DOUBLE PRECISION,
CREATE_TS         TIMESTAMP(6) NOT NULL,
);


Request:

Team, would it be possible to give some insight on this issue? Any help would be greatly appreciated.

Thanks,

--Apple-Mail-413FEBC0-75BB-4F01-8311-AD58978B9825--