X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0CF8FD1DD71 for ; Wed, 18 Feb 2004 00:25:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06436-08 for ; Tue, 17 Feb 2004 20:25:54 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B55CED1DD60 for ; Tue, 17 Feb 2004 20:25:50 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1I0PlVk019237; Tue, 17 Feb 2004 19:25:47 -0500 (EST) To: "scott.marlowe" Cc: elein , "news.postgresql.org" , pgsql-sql@postgresql.org Subject: Re: CHAR(n) always trims trailing spaces in 7.4 In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Tue, 17 Feb 2004 17:07:24 -0700" Date: Tue, 17 Feb 2004 19:25:47 -0500 Message-ID: <19236.1077063947@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/236 X-Sequence-Number: 16926 "scott.marlowe" writes: > But then this: > select 'x'||' '||'x' > should produce xx, but it produces x x. No, because the imputed type of those literals is text. You'd have to cast the middle guy to char(n) explicitly to make its trailing spaces go away when it's reconverted to text. The real issue here is that trailing spaces in char(n) are semantically insignificant according to the SQL spec. The spec is pretty vague about which operations should actually honor that insignificance --- it's clear that comparisons should, less clear about other things. I think the 7.4 behavior is more consistent than what we had before, but I'm willing to be persuaded to change it again if someone can give an alternate definition that's more workable than this one. regards, tom lane