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 1r8pc6-00BwZq-Ly for pgsql-admin@arkaria.postgresql.org; Thu, 30 Nov 2023 22:34:30 +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 1r8pc5-003cM5-Bo for pgsql-admin@arkaria.postgresql.org; Thu, 30 Nov 2023 22:34:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8pc5-003cLG-0c for pgsql-admin@lists.postgresql.org; Thu, 30 Nov 2023 22:34:29 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8pc2-009QRP-MJ for pgsql-admin@lists.postgresql.org; Thu, 30 Nov 2023 22:34:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AUMYPjn526194; Thu, 30 Nov 2023 17:34:25 -0500 From: Tom Lane To: Ron Johnson cc: Pgsql-admin Subject: Re: char column with a single space as the default not working In-reply-to: References: <507459.1701374156@sss.pgh.pa.us> Comments: In-reply-to Ron Johnson message dated "Thu, 30 Nov 2023 17:00:24 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <526192.1701383665.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 30 Nov 2023 17:34:25 -0500 Message-ID: <526193.1701383665@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson writes: > On Thu, Nov 30, 2023 at 2:56 PM Tom Lane wrote: >> Yeah, the space is stored. What is probably surprising the OP >> is that applying the || operator involves a coercion from "char" >> to "text", which strips the defined-to-be-insignificant trailing >> space(s) of the "char" value. > How do you get a trailing space when trailing spaces are significant? Use varchar or text. If you want trailing spaces to be significant, char is simply the wrong data type. regards, tom lane