Re: select statement fails
От | Tom Lane |
---|---|
Тема | Re: select statement fails |
Дата | |
Msg-id | 2560.1207843045@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: select statement fails ("Andrus" <kobruleht2@hot.ee>) |
Список | pgsql-general |
"Andrus" <kobruleht2@hot.ee> writes: > 1. SQL assumes that CHARACTER(n) column is always padded with spaces in > right. > So casting to text should preserve spaces. No, it should not. In CHAR(n), trailing spaces are semantically insignificant; 'foo' and 'foo ' are considered equal. In TEXT they are just as significant as any other character, and those strings are definitely not equal. So 'foo ' as CHAR(4) and 'foo ' as TEXT do not actually mean the same thing at all, and similarly ' ' means two different things as CHAR(1) and as TEXT, even though they look the same. The SQL spec's definition of CHAR(n) behavior is really pretty broken in my opinion; you're almost always better off using varchar. In this particular case, where you think that a space has semantic significance, CHAR(n) is simply wrong. regards, tom lane
В списке pgsql-general по дате отправления: