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 1s7XOq-0067HE-Rl for pgsql-bugs@arkaria.postgresql.org; Thu, 16 May 2024 09:27:46 +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 1s7XOq-004Igc-Lx for pgsql-bugs@arkaria.postgresql.org; Thu, 16 May 2024 09:27:44 +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 1s7XOq-004IgU-1X for pgsql-bugs@lists.postgresql.org; Thu, 16 May 2024 09:27:44 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s7XOl-000TWE-86 for pgsql-bugs@lists.postgresql.org; Thu, 16 May 2024 09:27:42 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4202dd90dcfso167625e9.0 for ; Thu, 16 May 2024 02:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=probit-io.20230601.gappssmtp.com; s=20230601; t=1715851657; x=1716456457; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=MoqLIQiGEhkQD2xnTtYxLgx3suxHQwmqbbRh5IkgVOc=; b=OyFmiIw1ZN19qtUtg78S/iF7bkg05toEuB/Fsa1fOD0IQN98onlu88BWeBcKxSEXlJ NTjTmAc0eGhXq4yPxiITwLGTOnmrhSCoeuP7X+5gBuhAGtWAraT3H+ynjfQdkGOQMfO0 GVVdXsLT8KkRF4OqX0Wx/x7TDLQ7L8LGQddBx1bHYGhtllohYrVFb2ZlyWj/yENTnlVg uVIooCDJMY97nxtMzxB5ILercW7d+STWUAsBaBaPvRaSF+VAmlBAd+aPXLO/D8m4Bxsx MPl14JaIuvxiBj4HuoaON0tpgviDHWDM8BilCnzAeWY9KW8/K3d3f33obbVOVyuXYXyB QNGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715851657; x=1716456457; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MoqLIQiGEhkQD2xnTtYxLgx3suxHQwmqbbRh5IkgVOc=; b=cWSTVeKHsdP+t0Coy6KS+LWSkoN/6eSIMIcu8sADbuKK+12iOBMJs9PA2z6cV6+2kJ 03s+mXfI0ieFPv+T/g7iHzdd3lY2FD8jXhJjIkfKWcG/Gw4chdYLMDOJXiZ7fF9F3ZaG OttngUcM7ZNFaqmEKOpktd+YvxvqkqmidMIjXB0wyWazs/Y6VA+ci6/adfQ2mU1FDHw/ 6GlcW/0gw9yyxQPueDFkzceHFassTlnU9tTHo3aSrgfb8dGC9gykjGPxveC8io05FWTF Puq9I5by2JV96Ph6KodW0de8AjOvKrl2/Up2LVi/wW7Wm0fcRwA/kgwWDpp3aEZ6i+x+ o7Bw== X-Gm-Message-State: AOJu0YwVrZ3MIpC+3bloGIBZFdgjogt1U43ntiex5Z1JPIeV7N5QawJW xXvdbfpcYmTZgxz+kI2m4WtA6iff/U1OaFpnZX5ZeaQB9Fw71SZKZkEhKhHdNGPo/JVZ5/x+px0 s X-Google-Smtp-Source: AGHT+IHHp+H6zQWqiC4nXY6vA5wnysfu8iBoNafoUBSe1ALmo5X+sAxMXhXBIgNdlEw9v3+LvftuiQ== X-Received: by 2002:a05:600c:4754:b0:41f:fca0:8c04 with SMTP id 5b1f17b1804b1-41ffca08dcemr125175795e9.11.1715851656940; Thu, 16 May 2024 02:27:36 -0700 (PDT) Received: from smtpclient.apple ([2a02:8012:8a4:2:254::7c9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee962esm261246905e9.31.2024.05.16.02.27.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2024 02:27:36 -0700 (PDT) From: David Hunnisett Content-Type: multipart/alternative; boundary="Apple-Mail=_FA83A508-5201-4967-8F9D-44D12F02B06A" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: differences between <> and != when using signed values on the right hand side Message-Id: Date: Thu, 16 May 2024 10:27:25 +0100 To: pgsql-bugs@lists.postgresql.org X-Mailer: Apple Mail (2.3774.500.171.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_FA83A508-5201-4967-8F9D-44D12F02B06A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii When using a signed comparison !=3D does not behave like <> if the right = hand side comparator is signed and there is no space between the = comparator and the sign <>+1 <>-1=20 Both bahave as the inverse to =3D+1 =3D-1 But=20 !=3D-1 !=3D+1 Throw errors. Tested with 16.3,13.15 and 9.6.24 postgres=3D# select version(); version = =20 = --------------------------------------------------------------------------= ------------------------------------------------- PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on aarch64-unknown-linux-gnu, = compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit (1 row) postgres=3D# select 1<>-1.0; ?column?=20 ---------- t (1 row) postgres=3D# select 1<>-1; ?column?=20 ---------- t (1 row) postgres=3D# select 1!=3D-1.0; ERROR: operator does not exist: integer !=3D- numeric LINE 1: select 1!=3D-1.0; ^ HINT: No operator matches the given name and argument types. You might = need to add explicit type casts. postgres=3D# select 1!=3D-1; ERROR: operator does not exist: integer !=3D- integer LINE 1: select 1!=3D-1; ^ HINT: No operator matches the given name and argument types. You might = need to add explicit type casts. Adding a space does produce the expected answer select 1!=3D -1.0; ?column?=20 ---------- t (1 row) --Apple-Mail=_FA83A508-5201-4967-8F9D-44D12F02B06A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii When using a = signed comparison !=3D does not behave like <> if the right hand = side comparator is signed and there is no space between the comparator = and the = sign

<>+1
<>-1 
Bo= th bahave as the inverse = to
=3D+1
=3D-1
But 
!=3D-1
!=3D+1
Throw = errors.


Tested with 16.3,13.15 and = 9.6.24


postgres=3D# select version();

    =                     =                     =               version     =                     =                     =              

-----------------------------------------------------= ----------------------------------------------------------------------

 PostgreSQL = 16.3 (Debian 16.3-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by = gcc (Debian 12.2.0-14) 12.2.0, 64-bit

(1 row)


postgres=3D# = select 1<>-1.0;

 ?column? 

----------

 t

(1 row)


postgres=3D# = select 1<>-1;

 ?column? 

----------

 t

(1 row)


postgres=3D# = select 1!=3D-1.0;

ERROR:  = operator does not exist: integer !=3D- numeric

LINE 1: select = 1!=3D-1.0;

    =             ^

HINT:  No = operator matches the given name and argument types. You might need to = add explicit type casts.

postgres=3D# = select 1!=3D-1;

ERROR:  = operator does not exist: integer !=3D- integer

LINE 1: select = 1!=3D-1;

    =             ^

HINT:  No = operator matches the given name and argument types. You might need to = add explicit type casts.


Adding a space does produce = the expected answer


select 1!=3D -1.0;

 ?column? 

----------

 t

(1 = row)



= --Apple-Mail=_FA83A508-5201-4967-8F9D-44D12F02B06A--