pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Nicolas Gouteux <nicolas.gouteux@sonarsource.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
Date: Wed, 09 Aug 2023 11:26:12 -0400
Message-ID: <101253.1691594772@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvppj5iWgsbnqQdVEG=HqOGhfkoEWELXxJ=S74qnmPL--A@mail.gmail.com>
References: <18051-3d2890ce9127a33a@postgresql.org>
	<CAKFQuwaGDMzxhifyQjAStjP-_e+cRJj=2hZ0Bbynrn9DjHTjSw@mail.gmail.com>
	<CANyQZ-6jub8k4cuuiE=1V+aWSdWWXYug_dK+ytR6RoUjm=zxew@mail.gmail.com>
	<CAApHDvq5TaQ54LFSmzWVJe2oMERskXkFTi8fC5FknAMSKTq6eQ@mail.gmail.com>
	<CANyQZ-60Y0wYMNTzSN6O=XkEVgrfvMmKAR7nDv=jgaF1apEa2w@mail.gmail.com>
	<CAApHDvppj5iWgsbnqQdVEG=HqOGhfkoEWELXxJ=S74qnmPL--A@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
> Anyway, 2004 was a long time ago. I can't imagine we could possibly
> make such a change today to put it back.

Yeah.  IMV, char(N) is a legacy type with legacy behaviors, and
we shouldn't change those behaviors for fear of breaking legacy
applications that might expect them.  If you don't like the way it
works, don't use char(N).

BTW, as far as the question of better optimization of fixed-width
fields goes, we couldn't do that anyway with char(N) except in the
ever-more-minority case of single-byte database encoding.  That's
because N is counted in characters not bytes (as is quite clear
from the SQL standard, even if their opinion about trailing spaces
is less clear).  I think that's a primary reason why nobody has
bothered to pursue such an optimization, and in turn that's why
char(N) is now such a backwater.

			regards, tom lane





view thread (11+ messages)

Message-ID: <101253.1691594772@sss.pgh.pa.us>
Permalink:  ../101253.1691594772@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/101253.1691594772@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, nicolas.gouteux@sonarsource.com, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
  In-Reply-To: <101253.1691594772@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox