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 1qKf8k-001EQW-Te for pgsql-general@arkaria.postgresql.org; Sat, 15 Jul 2023 13:16:50 +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 1qKf8i-00HVrG-AU for pgsql-general@arkaria.postgresql.org; Sat, 15 Jul 2023 13:16:48 +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 1qKf8h-00HVr6-VK for pgsql-general@lists.postgresql.org; Sat, 15 Jul 2023 13:16:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qKf8e-000YeJ-Aq for pgsql-general@postgresql.org; Sat, 15 Jul 2023 13:16:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 36FDGfgC3579169; Sat, 15 Jul 2023 09:16:41 -0400 From: Tom Lane To: jian he cc: Priyank Rajvansh , pgsql-general@postgresql.org Subject: Re: error in the example given for numeric data types In-reply-to: References: <167488510764.649.16865817209461558696@wrigleys.postgresql.org> Comments: In-reply-to jian he message dated "Sat, 15 Jul 2023 15:16:45 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3579167.1689427001.1@sss.pgh.pa.us> Date: Sat, 15 Jul 2023 09:16:41 -0400 Message-ID: <3579168.1689427001@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: >> practice=# create table t1(height numeric(3,5)); >> ERROR: NUMERIC scale 5 must be between 0 and precision 3 > it works in pg15, not in pg14. > see my test: https://dbfiddle.uk/wgfjCx7j Indeed. The quoted documentation text is different between v15 and prior versions. Observe also the v15 release notes: https://www.postgresql.org/docs/15/release-15.html E.4.3.4. Data Types Allow the scale of a numeric value to be negative, or greater than its precision (Dean Rasheed, Tom Lane) This allows rounding of values to the left of the decimal point, e.g., '1234'::numeric(4, -2) returns 1200. regards, tom lane