Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFQET-0007Fe-2u for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Oct 2018 20:58:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gFQER-0005gm-NF for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Oct 2018 20:58:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFQER-0005ge-60 for pgsql-bugs@lists.postgresql.org; Wed, 24 Oct 2018 20:58:23 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gFQEJ-0007j2-TY for pgsql-bugs@lists.postgresql.org; Wed, 24 Oct 2018 20:58:21 +0000 Received: by mail-io1-xd34.google.com with SMTP id d80-v6so4059633iof.1 for ; Wed, 24 Oct 2018 13:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y0gwx8wR3TqxN1G5t55Yw0Y6VxYkJeVvSso99iQMHSg=; b=ZnFcoc1a1vN1ZsgJOOjnJGOIwrzU9ucIBkRN7kRaJjFxtvmMMuaOusZ3WQMpniw2jK blNrc8YjPqmnAI5HjTaqo+9Hx4xQprgACf4uwBX/KJruaNb0BhRsc9X/yKJAQIjywY04 jHJaaCeNjqAmEKk2gTCseaW+6ynBxI+b5dwbMDmp7prf4dZb9Ysg1SIexjFExP+sqDSu 9LF5bQNMZg3tDCNNm0uXVLyff528GTJ04mDIB1WaC1JgMDzZZoO5C50nu3DQAQLPAJeA kIzIq43mC/e88Ycpjg1x4ftB9T8iNInXl85zPXLwNkBWkU3pD6U3BfcYlRFhXuTEJljK MUsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y0gwx8wR3TqxN1G5t55Yw0Y6VxYkJeVvSso99iQMHSg=; b=hPDdKQuytpvyGS8a5X3bnUGRG06PRFheuKXJNrjQ+Sr1dkj3s5ReqG8lILkvXroAuH kj50JOHINrXZqLU0nhgQIp0ks1EbLmqXI96rUA+QJhp6+5SkglwYNSYnY29Iv+Tf6KhL 9xAGzHnXIQYNDPrg7Mtb9xN13OuOflhppqwrSseeJXiajwzROnG+vwdB+yFz3Nhkukq6 cJE950ZWgHRLD6c36RNAdCrlx22zdfXZnw7XevxhitEr1vNUaI6j34Vte2D5N9auYuEK DHuZmvKi1K3C7A9tU/Xc1isXc4o8Nuz+FjAiStyPGJ+OeAE6NCCYVnN58p8OjlNK9ewm 0qqg== X-Gm-Message-State: AGRZ1gLf+dLo8MpVFFbVBOs1H6ak4SbArFzH5/kMY9HhKAGCCgVNLoSA NVK032kR8Yod9yjxsoeCjUulkOvk X-Google-Smtp-Source: AJdET5eC51lbk8utV8nd51cT0MTnv+wYSqoDVbt1I0eS0fpiZ9+cTFOIBrr3lfQslUGJF194L4wD0w== X-Received: by 2002:a6b:6c03:: with SMTP id a3-v6mr14315783ioh.230.1540414694925; Wed, 24 Oct 2018 13:58:14 -0700 (PDT) Received: from hammer.magicstack.net (toroon12-3096784575.sdsl.bell.ca. [184.149.46.191]) by smtp.gmail.com with ESMTPSA id 127-v6sm4288240itj.36.2018.10.24.13.58.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 13:58:14 -0700 (PDT) From: Elvis Pranskevichus To: Andres Freund Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15458: pg_typeof inconsistency on negative integer constant limits Date: Wed, 24 Oct 2018 16:58:13 -0400 Message-ID: <7428706.JDTFIi69Ek@hammer.magicstack.net> In-Reply-To: <20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de> References: <15458-632e422e26e19786@postgresql.org> <20181024205432.yh2jswtvbhl3x536@alap3.anarazel.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wednesday, October 24, 2018 4:54:32 PM EDT Andres Freund wrote: > Hi, > > On 2018-10-24 20:47:21 +0000, PG Bug reporting form wrote: > > The following bug has been logged on the website: > > > > Bug reference: 15458 > > Logged by: Elvis Pranskevichus > > Email address: elprans@gmail.com > > PostgreSQL version: 11.0 > > Operating system: x86_64-pc-linux-gnu > > Description: > > > > There seems to be an inconsistency in how the parser and the integer > > input functions interpret the integers at the negative limit (-2 ^ > > 31 and -2 ^ 63): > > > > > > SELECT pg_typeof(-2147483648); > > > > pg_typeof > > > > ----------- > > > > integer > > > > (1 row) > > > > But: > > > > SELECT -2147483648::integer; > > ERROR: integer out of range > > > > > > The same issue applies to int8 as well. > > > > PG_INT32_MIN is explicitly defined as -(2 ^ 31 - 1), and it seems > > inconsistent that the parser does not respect that when determining > > the type of numeric constants. > > It's just a precedence issue. :: binds with higher precedence, so the > above is actually -(2147483648::integer), rather than > (-2147483648)::integer. Therefore you get an overflow. Ah, you're right. Sorry for the noise. Elvis