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 AF369D1B49E for ; Thu, 19 Feb 2004 04:58:45 +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 20751-04 for ; Thu, 19 Feb 2004 00:58:46 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 8E0DAD1B456 for ; Thu, 19 Feb 2004 00:58:40 -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 i1J4wc9O028867; Wed, 18 Feb 2004 23:58:38 -0500 (EST) To: elein Cc: "scott.marlowe" , "news.postgresql.org" , pgsql-sql@postgresql.org Subject: Re: CHAR(n) always trims trailing spaces in 7.4 In-reply-to: <20040218120547.J25537@cookie.varlena.com> References: <18872.1077061249@sss.pgh.pa.us> <20040217162713.H25537@cookie.varlena.com> <20170.1077076397@sss.pgh.pa.us> <20040218120547.J25537@cookie.varlena.com> Comments: In-reply-to elein message dated "Wed, 18 Feb 2004 12:05:47 -0800" Date: Wed, 18 Feb 2004 23:58:37 -0500 Message-ID: <28866.1077166717@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/271 X-Sequence-Number: 16961 elein writes: > So exactly what is the order of casts that produces > different results with: > 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' > Are operators being invoked both (text,text)? The only relevant operator is "text || text" (there are also some || operators for arrays, bytea, and BIT, but these will all be discarded as not the most plausible match). Therefore, in your first example the unspecified literals will all be presumed to be text, so the space does not get trimmed. One of the things we could think about as a way to tweak the behavior is creating "||" variants that are declared to accept char(n) on one or both sides. These could actually use the same C implementation function (textcat) of course. But declaring them that way would suppress the invocation of rtrim() as char-to-text conversion. However, if we did that then "||" would behave differently from other operators on character strings, so it doesn't seem like a very attractive option to me. regards, tom lane