alovaros
alovaros

Reputation: 476

SQLITE3 increase Max Columns

I am thinking about using SQLlite3 so I started some performance tests.

Because I've got an table with many Columns I want to increase the MAX Column Limit from SQLite3. As I read on the SQLite website the limit was set to 2000 columns and now I want to increase it.

I wanted to use sqlite3_limit() but, because I use SQLAPI, I cannot use this function.

I've read on some website I need to change something "inside" SQLite and then have to recompile it but I haven't really understood this part and so I wanted to ask:

Is there was another way to increase Max columns?

My programm is running on Win10 in c++

Upvotes: 0

Views: 1022

Answers (1)

Edd
Edd

Reputation: 1370

There is no other way but by setting the number of columns you want at compile time.

Luckily, it is not hard.

  1. Download amalgamation source code here. It is named sqlite-amalgamation-*.zip
  2. Unzip and change directory inside the unzippped folder. You will see sqlite3.c and sqlite3.h among other files.
  3. Issue this statement to create an object file and setting the desired number of columns: gcc -I. -O3 -DSQLITE_MAX_COLUMN=5000 -c sqlite3.c -o sqlite3.o Change 5000 to the number you desire. Note that, according to the comments in sqlite3.c, you shouldn't use a number greater than 32676.
  4. create a static library to link against: ar crsf libsqlite3.a sqlite3.o

Now you can link against the library when compiling your program using -lsqlite3, after having placed the library in a location that your linker is aware of (or use -L/path/to/library).

Alternative to steps 3) and 4).

If you don't want to actually create the static library but you just want to drop the sqlite3.h and sqlite3.c in your source code (something that SQLite itself suggests doing with their amalgamation files), then open sqlite3.c with your favourite editor, look for SQLITE_MAX_COLUMN and modify the value in there.

I used gcc via MinGW to do this. The same steps apply to the tools offered by MSVC, just changing the commands for compilation and library creation as appropriate.

Upvotes: 3

Related Questions