[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-admin
Subject:    Re: char column with a single space as the default not working
From:       M Sarwar <sarwarmd02 () outlook ! com>
Date:       2023-11-30 22:43:17
Message-ID: DM4PR19MB597873E9E96C6B64C4ADEE4CD382A () DM4PR19MB5978 ! namprd19 ! prod ! outlook ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

I had the similar issue few months ago when I was using CHAR. The issue is resolved \
when I started using VARYING CHARACTERS data types. Thanks,
Sarwar

________________________________
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Thursday, November 30, 2023 5:34 PM
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: char column with a single space as the default not working

Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Thu, Nov 30, 2023 at 2:56 PM Tom Lane <tgl@sss.pgh.pa.us> 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


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof"> I had the similar issue few months&nbsp;ago \
when I was using CHAR. The issue is resolved when I started using VARYING CHARACTERS \
data types.</div> <div style="font-family: Calibri, Helvetica, sans-serif; font-size: \
12pt; color: rgb(0, 0, 0);" class="elementToProof"> Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof"> Sarwar</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);" class="elementToProof"> <br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" \
style="font-size:11pt" color="#000000"><b>From:</b> Tom Lane \
&lt;tgl@sss.pgh.pa.us&gt;<br> <b>Sent:</b> Thursday, November 30, 2023 5:34 PM<br>
<b>To:</b> Ron Johnson &lt;ronljohnsonjr@gmail.com&gt;<br>
<b>Cc:</b> Pgsql-admin &lt;pgsql-admin@lists.postgresql.org&gt;<br>
<b>Subject:</b> Re: char column with a single space as the default not working</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Ron Johnson &lt;ronljohnsonjr@gmail.com&gt; writes:<br>
&gt; On Thu, Nov 30, 2023 at 2:56 PM Tom Lane &lt;tgl@sss.pgh.pa.us&gt; wrote:<br>
&gt;&gt; Yeah, the space is stored.&nbsp; What is probably surprising the OP<br>
&gt;&gt; is that applying the || operator involves a coercion from \
&quot;char&quot;<br> &gt;&gt; to &quot;text&quot;, which strips the \
defined-to-be-insignificant trailing<br> &gt;&gt; space(s) of the &quot;char&quot; \
value.<br> <br>
&gt; How do you get a trailing space when trailing spaces are significant?<br>
<br>
Use varchar or text.&nbsp; If you want trailing spaces to be significant,<br>
char is simply the wrong data type.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
regards, tom lane<br> <br>
<br>
</div>
</span></font></div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic