Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(JP) text型のカラムのソート結果が正しくない #24

Closed
taiki-k opened this issue May 28, 2014 · 4 comments
Closed

(JP) text型のカラムのソート結果が正しくない #24

taiki-k opened this issue May 28, 2014 · 4 comments
Labels
bug developer confirmed the steps to reproduce the problem, and does not work as expected

Comments

@taiki-k
Copy link
Contributor

taiki-k commented May 28, 2014

text型カラムのソートを試したところ、ソート結果が正しくありませんでした。
さらに、ソート結果がランダムに変わっているような感じがします。

  • 使用したクエリー
SELECT * FROM text_test_null WHERE str < '!9' ORDER BY str;
  • 使用したテーブル
 Table "public.text_test_null"
 Column |   Type   | Modifiers
--------+----------+-----------
 id     | integer  |
 len    | smallint |
 str    | text     |
  • 結果(1回目)
   id    | len |         str
---------+-----+----------------------
 4714751 |   1 | !
 3239043 |   3 | !%C
 2752075 |   2 | !#
 4006855 |   2 | !4
 1451770 |   7 | !2bza8)
 4359686 |   1 | !
 1025680 |   6 | !#lJQr
 1892999 |   2 | !0
  656532 |   1 | !
 4707357 |   1 | !
 3596320 |   1 | !
 3725305 |   1 | !
  904560 |   1 | !
 4115748 |   1 | !
  671368 |   1 | !
  391973 |   1 | !
 4189961 |   1 | !
 2744618 |   1 | !
(snip)
  • 結果(2回目)
   id    | len |         str
---------+-----+----------------------
 4935705 |   3 | !%X
  508460 |  11 | !7kqID_-7C3
 2913026 |   1 | !
  209857 |   1 | !
 2496844 |   1 | !
  770890 |   1 | !
 3305833 |   1 | !
 3333653 |   1 | !
 2571933 |   1 | !
 1956452 |   1 | !
  721247 |   1 | !
 3104838 |   1 | !
 4149266 |   1 | !
 1458619 |   1 | !
 3850674 |   1 | !
 1824199 |   1 | !
 3520604 |   1 | !
 1132854 |   1 | !
(snip)
  • 結果(3回目)
   id    | len |         str
---------+-----+----------------------
 2498205 |   2 | !"
 4928480 |   2 | !&
  428458 |   1 | !
 2609068 |   1 | !
 1171356 |   1 | !
 2688475 |   1 | !
 1978959 |   1 | !
 3742408 |   1 | !
 3245354 |   1 | !
 3503182 |   1 | !
  897478 |   1 | !
 1119357 |   1 | !
 1166894 |   1 | !
 2592404 |   1 | !
 3972008 |   1 | !
 3937692 |   1 | !
 2481119 |   1 | !
 4894788 |   1 | !
@kaigai
Copy link
Contributor

kaigai commented May 28, 2014

別の問題と共通の根っこのように思えます。

OpenCL Kernel側でNULL値をbitmapに変換して処理しているのですが、
ビットマップの終端での処理にバグがあり、0~31個のレコードが問答無用に
NULL値として扱われる→NULL値同士の比較は同値であると判断されるため
並び順を変えないというものです。

今朝、修正を加えましたので、再現確認と、200個程度までデータを増やした場合
での検査をお願いします。
(Intelではworkgroup-sizeが128になるので、それを越える辺りという事で)

@taiki-k
Copy link
Contributor Author

taiki-k commented May 29, 2014

最新版で再現確認を行いました。
残念ながら、再現しています。

@kaigai
Copy link
Contributor

kaigai commented May 29, 2014

OpenCL Kernel内で不定長データのコピーを行う kern_varlena_to_toast() で
オフセット値の計算を間違っていました。
一定の長さの文字列であれば顕在化しませんが、長さの異なる可変長データが
混在している場合、N+1レコード目のデータがNレコード目のデータを上書きして
しまう可能性があります。

可変長バッファに必要な長さの計算を行う arithmetic_stairlike_add を修正し、
呼び出しスレッドが自分の使ってよい位置を取得できるように修正しました。

@taiki-k
Copy link
Contributor Author

taiki-k commented May 29, 2014

最新版で再現確認を行ったところ、再現しなくなりました。
修正されたものと判断します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug developer confirmed the steps to reproduce the problem, and does not work as expected
Projects
None yet
Development

No branches or pull requests

2 participants