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.96) (envelope-from ) id 1wKbl2-001B8U-0r for pgsql-bugs@arkaria.postgresql.org; Wed, 06 May 2026 12:53:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wKbl0-00Gzf8-0n for pgsql-bugs@arkaria.postgresql.org; Wed, 06 May 2026 12:53:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wKbkz-00Gzf0-37 for pgsql-bugs@lists.postgresql.org; Wed, 06 May 2026 12:53:42 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wKbkx-00000000p7Y-1OuR for pgsql-bugs@lists.postgresql.org; Wed, 06 May 2026 12:53:41 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-48a3e9862f0so6534795e9.1 for ; Wed, 06 May 2026 05:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1778072017; x=1778676817; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=8rd9MetpyqeNutEh/0oJd2MzE99nKVJv/BfeE3SiWk4=; b=O1TvckadFJsf/MYy/zCtADqa5Vc0DqE8IlzCaV9zrlpMSCBv7H6b3SWchNteSlCRLf S3VGmq+KjozyUPdjZcdZkgQufMiSqmE0KEYoUJaYAW+iMPN+z2JjZuo6FhOR/HKuTuj0 oRS6Ez70Pht3Mo9FNZ9S/B1BX+gEq30faKeUvz+1eRtRS+Ltz942Fymya1UybEn0wdRs ImVHxW8/BHxN4zjb32oWHFIMtO5vojq1ZdFaGfINQtYyu+n5YCqO3iNouGnjmQlOSS6E G+pqpWbFkzufeABfTf3mxBplTWvcDNDk3WaN/jZrBdbN4ajx74NkBg9ORoPhKgHcybOi aGqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778072017; x=1778676817; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8rd9MetpyqeNutEh/0oJd2MzE99nKVJv/BfeE3SiWk4=; b=GHsVszrxLaSmf09quREn6XzSitAWN9AsFi73wf7NAjSKDBY6mSUcie10XeK6sUXYAy zWUr2IXsOZOrCuhnUXgZ8ywTlz530qffIBKg1qoDy1c0+RzEVxOwru6UlNN3viHGwFhp vSxmJcEcF7/q9j2DDc37fLZ/pa97VV6+uPqsTKiI2/cffQHrJ50EbC/eWXOnrNZ/ewmr xMW6gCAibAWt+r3qgb1IWt1qbRDoq08e/fZJKxkh9AzOeEs9L2wkGBGNnQJv+AbARFvE 2vS12SPCxiz+ROQCFv1NbKmxILvI8dscNaWkDLCY6BhGZOmdbuDMxL3Ff0SNhuv5U6Uc l5gg== X-Forwarded-Encrypted: i=1; AFNElJ/DkhHA/fIRvayIjANqAUbw1VKjXFRm81K09O697kGBZFl5oLUYa1J4feNR2epT1gplPu6EMII0Zz3e@lists.postgresql.org X-Gm-Message-State: AOJu0YwVPR9PB4LpmzIZGPp/LE6+G4eKCg2VwvgZoYW/lWKmi6TNjWoe 2b598TMR81XHvkf6U4nhcC22gVKG0mWW0sdWYXOpTATOlc0cGA5JH/rRbkOwKSsUQHGE9q+qSK8 J+mkr X-Gm-Gg: AeBDietzt/BYwVU4hiHW2NCJCxM7qGSwl9ZCNpNmzth4S0QQSH5HgVT0jfkGF1ghRng yzazHbQxMq9dxTxRyhy8R0a7Za/YKY/the5+PtLeod1hYJByfaqEEK1CKkLn8Su9Ew48B7nSpk+ 7M2XeaZKNQS6n1yvUXjB4g7sK3VCAVquiLoAKMs3M9r3HqnpKS00ycBWsTDNUrvdU2IOZ0f2Bd2 fb1EsC9fcfpCAs1stLgr2NJ0ebHHNLXfS/2iNlI+LdZzwNAU8O5Ei0AFab3jb8FUQ/lXUHEO/Nm G/QGE3mxudss2EvJBtyWy/YUHIx+xhgEqf/AIMObLRJzD5UKCD4gsYFdrVK+LNej8m5kaPCPm2d +MTGR52Oc9XrbnkSQrTb5ph/fy7BLf5CBCoOXC5h3OM0HBdTD+5pT2rp62iBJ78IYThrmyMUIPt Sf6QtNkSgnktX3qk+TT9B6RlCLQGYeMpm5MQ== X-Received: by 2002:a05:600c:821a:b0:48a:79d8:a8d6 with SMTP id 5b1f17b1804b1-48e52286b5dmr45743225e9.7.1778072016723; Wed, 06 May 2026 05:53:36 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([213.208.157.88]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e53895f0asm50258495e9.2.2026.05.06.05.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 05:53:36 -0700 (PDT) Message-ID: Subject: Re: BUG #19472: CAST(-32768::SMALLINT AS REAL) fails with "SMALLINT out of range" but -32768 is valid SMALLINT value From: Laurenz Albe To: vectorplanck@gmail.com, pgsql-bugs@lists.postgresql.org Date: Wed, 06 May 2026 14:53:34 +0200 In-Reply-To: <19472-6b130bcff370911d@postgresql.org> References: <19472-6b130bcff370911d@postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2026-05-06 at 09:09 +0000, PG Bug reporting form wrote: > When casting -32768 to SMALLINT and then to REAL using the :: operator, > PostgreSQL throws an error "smallint out of range", even though -32768 is= a > valid value within the SMALLINT range (-32768 to +32767). >=20 > Expected Behavior: > -32768 should be recognized as a valid SMALLINT value (the minimum value = for > smallint is -32768), and the cast to REAL should succeed. This is not a bug, but working as expected. The documentation at https://www.postgresql.org/docs/current/sql-syntax-lex= ical.html#SQL-PRECEDENCE clearly states that the typecast operator :: has higher precedence than an unary minus. Yours, Laurenz Albe