Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9ZH9-0002Sj-TZ for pgsql-admin@arkaria.postgresql.org; Wed, 14 Jun 2023 22:47:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9ZH8-00024g-QY for pgsql-admin@arkaria.postgresql.org; Wed, 14 Jun 2023 22:47:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9ZH8-00024X-G9 for pgsql-admin@lists.postgresql.org; Wed, 14 Jun 2023 22:47:38 +0000 Received: from mailout.easymail.ca ([64.68.200.34]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9ZH5-002Pqp-KJ for pgsql-admin@lists.postgresql.org; Wed, 14 Jun 2023 22:47:37 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id BA7A56156E; Wed, 14 Jun 2023 22:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=elevated-dev.com; s=easymail; t=1686782852; bh=znHhT5Mv07Dv07rY55ISOVoTN0dclsp4nc80VxrJ8+I=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ui0j4tlzlq0kKlCWywCCGr4pFseR7rFj4pFBrSSsolrEy4dY91dyDLs8r32dzYQW3 XWz0EJe7WgrsRG4FHo+6Z0UgPS6dqYuRY9cseTXIIeWPRnD6k5NBLKtA02uZB9QZ4D aiF2TKP8VaPRzyH99Sg0LHIVu2bGmKPUACA7nVfbdn30DITeReloNdxDnYDiTL2ZI3 0NNq2/T5zhmNm00VjI1gnXwxoX+V7TSdjq81wWtIgjyk9K72mN1RceG3flalgi+RQw NLw7UgoIdTse0ytNxvWXiM+sYgjEGr/87Ez8du0ubjoQe7m5A3Z05IG5b5n5DtznKN PfaSVX/VcowyQ== X-Virus-Scanned: Debian amavisd-new at emo07-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo07-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cG09WHsl_IRP; Wed, 14 Jun 2023 22:47:32 +0000 (UTC) Received: from smtpclient.apple (unknown [165.140.184.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 3FDEE61570; Wed, 14 Jun 2023 22:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=elevated-dev.com; s=easymail; t=1686782852; bh=znHhT5Mv07Dv07rY55ISOVoTN0dclsp4nc80VxrJ8+I=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ui0j4tlzlq0kKlCWywCCGr4pFseR7rFj4pFBrSSsolrEy4dY91dyDLs8r32dzYQW3 XWz0EJe7WgrsRG4FHo+6Z0UgPS6dqYuRY9cseTXIIeWPRnD6k5NBLKtA02uZB9QZ4D aiF2TKP8VaPRzyH99Sg0LHIVu2bGmKPUACA7nVfbdn30DITeReloNdxDnYDiTL2ZI3 0NNq2/T5zhmNm00VjI1gnXwxoX+V7TSdjq81wWtIgjyk9K72mN1RceG3flalgi+RQw NLw7UgoIdTse0ytNxvWXiM+sYgjEGr/87Ez8du0ubjoQe7m5A3Z05IG5b5n5DtznKN PfaSVX/VcowyQ== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: The same result for with SPACE and without SPACE From: Scott Ribe In-Reply-To: Date: Wed, 14 Jun 2023 16:47:21 -0600 Cc: "pgsql-admin@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <9358F9A5-2926-4046-AD48-0C83C790A523@elevated-dev.com> References: To: M Sarwar X-Mailer: Apple Mail (2.3731.600.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jun 14, 2023, at 4:31 PM, M Sarwar wrote: >=20 > I expect this to behave the same way whether it comes from CHAR or = VARCHAR. Why would you expect that??? CHAR explicitly means that: 1) shorter strings will be space-padded to the given length 2) if a string is presented with spaces making it longer, it will be = truncated Putting it all together, it implies: 3) trailing spaces are semantically meaningless Anyway, the closest I could to finding a reference on comparison = behavior for this case states: "The ANSI standard requires padding for = the character strings used in comparisons so that their lengths match = before comparing them." And there you go, you used CHAR(10), so all values in the table are = space-padded to length 10, so for comparison *any* value will be = space-padded to 10.