pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Ribe <scott_ribe@elevated-dev.com>
To: Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.com>
Cc: mahesh <mahesha_dba@yahoo.com>
Cc: Mohammed Aslam <hmdaslam97@gmail.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: M Sarwar <sarwarmd02@outlook.com>
Subject: Re: The same result for with SPACE and without SPACE
Date: Thu, 15 Jun 2023 09:56:37 -0600
Message-ID: <BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com> (raw)
In-Reply-To: <3f21240f59a54f96898886f2c9189cf3@express-scripts.com>
References: <DM4PR19MB5978EB964FA1C7B55FFCB02DD35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
	<DM4PR19MB59782360E0C452810D70CBE8D35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
	<B600CCAA-59E5-4907-8E6D-C645CA24AB1D@elevated-dev.com>
	<DM4PR19MB59784B518F25D2C2292CA3FBD35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
	<2018059.1686782739@sss.pgh.pa.us>
	<0055148e2cc742cbbc23485ae0c6c04e@express-scripts.com>
	<2CAFD37D-68FC-4A01-BE65-FAF1ADF7A60A@elevated-dev.com>
	<CAJXhg9ByRV9QPVcW5MPi2c20g948Oxt8qU1DrcVb51fFgTEj2A@mail.gmail.com>
	<1726236757.407336.1686838293703@mail.yahoo.com>
	<3f21240f59a54f96898886f2c9189cf3@express-scripts.com>

Nobody's kicking you out of any group. Someone requested themselves to be removed, with a typo that made it ambiguous.

The original question had nothing to do with INT, it was behavior of CHAR and trailing spaces.

> select c1 from matt_test where c1 = '123'
> -- all 3 rows returned.
>  Is it expected behavior that all 3 rows would be returned (because the space isn’t an INT?)


Yes. Or more precisely, it is because when a string is cast to an int, leading and trailing spaces are ignored. The alternative would be to raise an error, as 'an integer plus some spaces' is not an integer...

> select c2 from matt_test2 where c2 = '123'
> -- 1 rows returned.


Yes, for TEXT column, which behaves the same as VARCHAR. Also 1 row for:

select c2 from matt_test2 where c2 = '123 '

But 2 rows returned for CHAR column, as inserting '123' and '123 ' into CHAR(n) results in the same value being inserted. And also 2 rows returned for:

select c2 from matt_test2 where c2 = '123 '

^^^ which was the original question




view thread (22+ messages)  latest in thread

Message-ID: <BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com>
Permalink:  ../BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com/
Also on:    postgresql.org/message-id/BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: scott_ribe@elevated-dev.com, Matthew.Wetmore@express-scripts.com, mahesha_dba@yahoo.com, hmdaslam97@gmail.com, pgsql-admin@lists.postgresql.org, tgl@sss.pgh.pa.us, sarwarmd02@outlook.com
  Subject: Re: The same result for with SPACE and without SPACE
  In-Reply-To: <BA739906-039B-409E-AD72-B7D1821D161D@elevated-dev.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox