koron / nvgd

Filterable (grep, head and tail) HTTP file server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support 1000 columns in TRDSQL filter

koron opened this issue · comments

OK: 500 columns
NG: 501 columns

Threshold is 500 columns.

trdsql error: import: sql: expected 501 arguments, got 0: 

trdsqlでimport時のエラー

trdsqlがSQLiteに対しては500カラムまでの制限をかけている。
どうしてそうするひつようがあるのか?
外すことはできないのか?

https://github.com/noborus/trdsql/blob/4a05ac286a6f161287b6d5b511b88fb9a8b279be/database.go#L81-L83

どうしてそうするひつようがあるのか?

試しに1000に書き換えたら、問題なく動いた。なので必要性はないようだ。

mattn/go-sqlite3@v1.14.16 は SQLite v3.39.4 をバンドルしている。
そのため上記の記述が真ならば、すでにtrdsqlがbulkを指定する必要はない。

https://www.sqlite.org/releaselog/3_32_0.html

Increase the default upper bound on the number of parameters from 999 to 32766.

制限がなくなったわけではなく、999から32766になったらしい。

trdsqlにこの制限がかかったのは 2018-01-20 リリースの v0.4.0
noborus/trdsql@b7a8f69

この時 go.mod はまだないので mattn/go-sqlite3 のバージョンは固定できない。

ただ SQLite 3.23.0 のリリースが 2020-05-22 なので、ほぼ確実に 2018-01-20 時点のパラメーター数の上限は 999

なので既に必要のないモノである可能性が高い。

32766 まで行けることの確認を試みたが、カラム数に上限2000があって阻まれた。

The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.

https://www.sqlite.org/limits.html

  1. とりあえず trdsql を fork して、2000までサポートしてしまう
  2. 本家 trdsql に2000にするPRを送る

this will fix with #82