knizhnik / imcs

In-Memory Columnar Store extension for PostgreSQL
Apache License 2.0
203 stars 33 forks source link

cs_filter with cs_and/or condition always return false #4

Closed amutu closed 10 years ago

amutu commented 10 years ago

postgres=# select distinct k1,k2,k3,k4,k5 from test2; k1 | k2 | k3 | k4 | k5
------------------+------------------+------------------+------------------+------------------ abc | def | ghk | xxx | ab
xxx | fdsxxfd | dseee | xxxxxx | xfffxff
xffxx | fxxdsxxfd | deseee | xfxxxxx | xffffxff
xffffffxx | fxxdfsxffxfd | deffsfeee | xfffxfxxxx | xfffffffxff
xeffffffxx | fxxedfsxffxfd | deeffsfeee | xffefxfxxxx | xffffefffxff
xffffxx | fxxdsxffxfd | deffseee | xfffxxxxx | xffffffxff
xxx | fdsfd | dse | xxx | xxff
(7 rows)

postgres=# select cs_count(cs_filter(k1=cs_const('xxx',16),k1)) from test2_get();

cs_count

11000000 (1 row)

Time: 307.997 ms postgres=# select cs_count(cs_filter(k3=cs_const('dse',16),k1)) from test2_get();

cs_count

1000000 (1 row)

Time: 244.292 ms postgres=# select cs_count(cs_filter(cs_or(k1=cs_const('xxx',16),k3=cs_const('dse',16)),k1)) from test2_get();

cs_count

    0

(1 row) !!!!!!expect 11000000,but return 0;

Time: 438.360 ms postgres=# select cs_count(cs_filter(cs_and(k1=cs_const('xxx',16),k3=cs_const('dse',16)),k1)) from test2_get();

cs_count

    0

(1 row) !!!!!! expect 1000000,but get 0

knizhnik commented 10 years ago

The problem is caused by construction of character literals (when string size is less than specified element size). The rest of element was not initialized and contains garbage. Now it is fixed.