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 1r8n8n-00BhQU-GA for pgsql-admin@arkaria.postgresql.org; Thu, 30 Nov 2023 19:56:05 +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 1r8n8j-002TkE-Vr for pgsql-admin@arkaria.postgresql.org; Thu, 30 Nov 2023 19:56:01 +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 1r8n8j-002Tjf-Kw for pgsql-admin@lists.postgresql.org; Thu, 30 Nov 2023 19:56:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8n8g-0089fe-Bv for pgsql-admin@lists.postgresql.org; Thu, 30 Nov 2023 19:56:00 +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 3AUJtuFd507460; Thu, 30 Nov 2023 14:55:56 -0500 From: Tom Lane To: Peter Gram cc: Sbob , Pgsql-admin Subject: Re: char column with a single space as the default not working In-reply-to: References: Comments: In-reply-to Peter Gram message dated "Thu, 30 Nov 2023 18:44:34 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <507458.1701374156.1@sss.pgh.pa.us> Date: Thu, 30 Nov 2023 14:55:56 -0500 Message-ID: <507459.1701374156@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Gram writes: > I think it behaves as expected. Look at my select "select > encode(charcol::bytea, 'hex') , intcol from z;" it returns 20 which is a > space in hex 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. As David said, you're best off not using the char type. The semantics around trailing spaces are too squishy for my taste, and there's no real advantage compared to varchar or text. regards, tom lane