The same result for with SPACE and without SPACE

From: "Wetmore, Matthew (CTR)" <Matthew(dot)Wetmore(at)express-scripts(dot)com>
To: mahesh <mahesha_dba(at)yahoo(dot)com>, Scott Ribe <scott_ribe(at)elevated-dev(dot)com>, Mohammed Aslam <hmdaslam97(at)gmail(dot)com>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, M Sarwar <sarwarmd02(at)outlook(dot)com>
Subject: The same result for with SPACE and without SPACE
Date: 2023-06-15 15:21:56
Message-ID: 3f21240f59a54f96898886f2c9189cf3@express-scripts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-advocacy

Before you kick me out of the group, can you please explain.

I thought the orig issue was that purposefully spaces/whitespace are being ignored (or not ignored.) in the select. Maybe there was an email in the middle that I missed.

create table matt_test (c1 int)

insert into matt_test values ('123')

insert into matt_test values (' 123')

insert into matt_test values ('123 ')

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?)

Works as I would expect with TEXT

create table matt_test2 (c2 text)

insert into matt_test2 values ('123')

insert into matt_test2 values (' 123')

insert into matt_test2 values ('123 ')

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

From: mahesh <mahesha_dba(at)yahoo(dot)com>
Sent: Thursday, June 15, 2023 7:12 AM
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>; Mohammed Aslam <hmdaslam97(at)gmail(dot)com>; pgsql-admin(at)lists(dot)postgresql(dot)org
Cc: Wetmore, Matthew (CTR) <Matthew(dot)Wetmore(at)express-scripts(dot)com>; Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>; M Sarwar <sarwarmd02(at)outlook(dot)com>
Subject: [EXTERNAL] Re: The same result for with SPACE and without SPACE

Kindly remove from from the group..

On Thursday, June 15, 2023 at 08:44:58 AM CDT, Mohammed Aslam <hmdaslam97(at)gmail(dot)com<mailto:hmdaslam97(at)gmail(dot)com>> wrote:

Kindly remove from here

On Thu, 15 Jun, 2023, 7:09 pm Scott Ribe, <scott_ribe(at)elevated-dev(dot)com<mailto:scott_ribe(at)elevated-dev(dot)com>> wrote:
> On Jun 15, 2023, at 7:08 AM, Wetmore, Matthew (CTR) <Matthew(dot)Wetmore(at)express-scripts(dot)com<mailto:Matthew(dot)Wetmore(at)express-scripts(dot)com>> wrote:
>
> I can reproduce this with a INT

?

When casting string to integer, trailing spaces do not cause an exception. When casting integer to char(n), the string will be blank padded.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Paul Smith* 2023-06-15 15:48:18 Re: The same result for with SPACE and without SPACE
Previous Message OracleDba OracleDba 2023-06-15 14:11:48 is there pgadmin interface with Hashicorp Vault or command line interface to use master password and update password repository

Browse pgsql-advocacy by date

  From Date Subject
Next Message Paul Smith* 2023-06-15 15:48:18 Re: The same result for with SPACE and without SPACE
Previous Message mahesh 2023-06-15 14:11:33 Re: The same result for with SPACE and without SPACE