Search Postgresql Archives

Re: String comparison and the SQL standard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tom Lane wrote:

> This probably has more to do with what these systems think the
> data type of an undecorated literal is, than with whether they do
> trailing-space-insensitive comparison all the time.

I suspect so. Keep in mind that PostgreSQL does not comply with the
standard in this regard, but this has been discussed before and it
is a concious decision to deviate.  See section section 5.3
<literal> syntax 17:

| The declared type of a <character string literal> is fixed-length
| character string.

... so according to the standard 'a' is CHAR(1) and 'a   ' is
CHAR(4), and they should compare as equal. To make literals for
user-defined types more convenient to write, PostgreSQL treats
those literals as type UNKOWN until forced to resolve them to a
type, and in the absence of any other clues uses text instead of
char(n). The reason for that is that the community finds the
semantics of char(n) strange and generally encourages use of text
or varchar(n) for character-based types.

I'm not sure that this is as clearly and prominently documented as
it should be.

-Kevin


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux