Re: [GENERAL] bpchar, text and indexes

2016-02-22 Thread Tom Lane
Victor Yegorov writes: > Well, for `varchar` type Postgres is able to do `varchar` -> `bpchar` cast > for my constant. I do not understand why for `text` it cannot and casts > column instead. In cross-type comparisons like these, the parser basically has a choice between whether to apply texteq o

Re: [GENERAL] bpchar, text and indexes

2016-02-22 Thread Victor Yegorov
2016-02-22 18:00 GMT+02:00 Thomas Kellerer : > I assume that this has to do with the fact that char(n) is blank padded to > 20 character. > Yes, this was my thought too, but I do not understand what is going on in details. To be able to correctly compare that to a text value, sn_c has to be cas

Re: [GENERAL] bpchar, text and indexes

2016-02-22 Thread Thomas Kellerer
Victor Yegorov schrieb am 22.02.2016 um 16:45: > Test setup: > > PostgreSQL 9.4.6 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 > 20120313 (Red Hat 4.4.7-16), 64-bit > > create table t(t_id int4, sn_c char(20)); > insert into t select id, > chr((random()*26)::int4+65)||chr((random()*