Brad DeJong <bpd0018@gmail.com> writes:
> Given that PostgreSQL is silently converting NCHAR, NCHAR VARYING, ... to
> CHAR, CHAR VARYING, ... it seems to me like national character literals
> should also silently convert to character literals - with exactly the same
> behavior in regards to trimming of trailing spaces during casts to ::text.
But ' ' without any decoration IS NOT a character literal. It's a literal
of unknown type, which in cases like this will ultimately default to text,
but in other cases will be deemed to have other types. N/NCHAR, on the
other hand, defines what the data type is, just as much as if you'd
written an explicit cast.
regression=# select 'a' || char ' ' || 'b';?column?
----------ab
(1 row)
regression=# select 'a' || nchar ' ' || 'b';?column?
----------ab
(1 row)
regression=# select 'a' || char varying ' ' || 'b';?column?
----------a b
(1 row)
regression=# select 'a' || nchar varying ' ' || 'b';?column?
----------a b
(1 row)
I don't see anything wrong there. You can certainly quibble with our
basic choice to strip trailing blanks when converting from char to
varchar/text, but NCHAR isn't doing anything different from CHAR.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs