Re: character varying == text?

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: character varying == text?
Дата
Msg-id 1127159227.30120.107.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на Re: character varying == text?  (Alex Turner <armtuk@gmail.com>)
Список pgsql-general
On Mon, 2005-09-19 at 12:54, Alex Turner wrote:
> I thought a char field was supposed to return a padded string, and
> varchar was supposed to return a non-padded string?
>
> I just checked though:
>
> create table test (
> stuff char(10)
> );
>
> insert into test values ('foo');
>
> select stuff || 'lemon' from test;
>
> This returns 'foolemon', not 'foo        lemon' as I would have
> expected.
>
> Alex Turner
> NetEconomist
>
> On 9/15/05, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>         CSN <cool_screen_name90001@yahoo.com> writes:
>         > Just something I was curious about - is there any
>         > difference at all between "character varying" (in the
>         > SQL spec) without a length specified and "text" (not
>         > in the SQL spec)?
>
>         The SQL standard doesn't allow "character varying" without a
>         length spec.
>
>         But yeah, in Postgres they're essentially the same thing.
>
>                                 regards, tom lane
>
>         ---------------------------(end of
>         broadcast)---------------------------
>         TIP 9: In versions below 8.0, the planner will ignore your
>         desire to
>                choose an index scan if your joining column's datatypes
>         do not
>                match
>

That's because || is a text operator, not a char operator here.  So,
what's really happening is:

select cast(charfield as text)||cast(textfield as text)



В списке pgsql-general по дате отправления:

Предыдущее
От: "Ignacio Colmenero"
Дата:
Сообщение: Problems with vacuumdb
Следующее
От: Tom Lane
Дата:
Сообщение: Re: postgres 8.03 initdb error for Rhel ES-4