I have noticed that when I set max_page_count programatically to 16384 and read it back with the shell I get 1073741823. If I set max_page_count with the shell to 16384 and read it back programmatically, the program gets back 1073741823. Both the program and the shell can round-trip their own set/get cycle OK.
This is on a 64 bit Mac with clang, but gcc seemed to exhibit the same behavior (if Apple didn't alias gcc to clang behind my back). Following are 2 examples. The first: 1. Shows my configuration 2. Builds a shell 3. Uses the shell to make a test db, set the max_page_count and read it back correctly 4. Builds a test program (source shown) to open the DB and read back the max_page count incorrectly. [/tmp/sqlite-amalgamation-3130000] -> clang --version Apple LLVM version 7.3.0 (clang-703.0.29) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin [/tmp/sqlite-amalgamation-3130000] -> cat /Users/wardw/.sqliterc .mode column .width 19 .headers on .prompt 'sql>' '...' .nullvalue NULL [/tmp/sqlite-amalgamation-3130000] -> ls -l total 14880 -rw-r--r-- 1 wardw wheel 810 Jul 5 12:54 page_test.c -rw-r--r-- 1 wardw wheel 175474 May 18 04:07 shell.c -rw-r--r-- 1 wardw wheel 6915433 May 18 04:07 sqlite3.c -rw-r--r-- 1 wardw wheel 486805 May 18 04:07 sqlite3.h -rw-r--r-- 1 wardw wheel 29370 May 18 04:07 sqlite3ext.h [/tmp/sqlite-amalgamation-3130000] -> clang -D SQLITE_DEBUG -D HAVE_READLINE -l readline -o sqlite3 sqlite3.c shell.c [/tmp/sqlite-amalgamation-3130000] -> ls -l total 17648 -rw-r--r-- 1 wardw wheel 810 Jul 5 12:54 page_test.c -rw-r--r-- 1 wardw wheel 175474 May 18 04:07 shell.c -rwxr-xr-x 1 wardw wheel 1414652 Jul 5 12:55 sqlite3 -rw-r--r-- 1 wardw wheel 6915433 May 18 04:07 sqlite3.c -rw-r--r-- 1 wardw wheel 486805 May 18 04:07 sqlite3.h -rw-r--r-- 1 wardw wheel 29370 May 18 04:07 sqlite3ext.h [/tmp/sqlite-amalgamation-3130000] -> ./sqlite3 page_test.db -- Loading resources from /Users/wardw/.sqliterc SQLite version 3.13.0 2016-05-18 10:57:30 Enter ".help" for usage hints. sql>pragma max_page_count=16384; max_page_count ------------------- 16384 sql>pragma max_page_count; max_page_count ------------------- 16384 sql>.quit [/tmp/sqlite-amalgamation-3130000] -> ls -l total 17648 -rw-r--r-- 1 wardw wheel 810 Jul 5 12:54 page_test.c -rw-r--r-- 1 wardw wheel 0 Jul 5 12:56 page_test.db -rw-r--r-- 1 wardw wheel 175474 May 18 04:07 shell.c -rwxr-xr-x 1 wardw wheel 1414652 Jul 5 12:55 sqlite3 -rw-r--r-- 1 wardw wheel 6915433 May 18 04:07 sqlite3.c -rw-r--r-- 1 wardw wheel 486805 May 18 04:07 sqlite3.h -rw-r--r-- 1 wardw wheel 29370 May 18 04:07 sqlite3ext.h [/tmp/sqlite-amalgamation-3130000] -> cat page_test.c /* clang -D SQLITE_DEBUG -o page_test page_test.c sqlite3.c */ #include <stdio.h> #include "sqlite3.h" int main() { sqlite3* hDb = NULL; if ( sqlite3_open_v2( "page_test.db", &hDb, SQLITE_OPEN_READWRITE, NULL ) != 0 ) return -1; /* if ( sqlite3_exec( hDb, "pragma max_page_count=16384", NULL, NULL, NULL ) != 0 ) return -2; */ sqlite3_stmt* hStmt = NULL; if ( sqlite3_prepare_v2( hDb, "pragma max_page_count", -1, &hStmt, NULL ) != 0 ) return -3; if ( sqlite3_step( hStmt ) != SQLITE_ROW ) return -4; printf( "Max page size set to %d\n", sqlite3_column_int( hStmt, 0 ) ); if ( sqlite3_finalize( hStmt ) != 0 ) return -5; hStmt = NULL; if ( sqlite3_close_v2( hDb ) != 0 ) return -5; hDb = NULL; return 0; } [/tmp/sqlite-amalgamation-3130000] -> clang -D SQLITE_DEBUG -o page_test page_test.c sqlite3.c [/tmp/sqlite-amalgamation-3130000] -> ls -l total 20240 -rwxr-xr-x 1 wardw wheel 1323224 Jul 5 12:57 page_test -rw-r--r-- 1 wardw wheel 810 Jul 5 12:54 page_test.c -rw-r--r-- 1 wardw wheel 0 Jul 5 12:56 page_test.db -rw-r--r-- 1 wardw wheel 175474 May 18 04:07 shell.c -rwxr-xr-x 1 wardw wheel 1414652 Jul 5 12:55 sqlite3 -rw-r--r-- 1 wardw wheel 6915433 May 18 04:07 sqlite3.c -rw-r--r-- 1 wardw wheel 486805 May 18 04:07 sqlite3.h -rw-r--r-- 1 wardw wheel 29370 May 18 04:07 sqlite3ext.h [/tmp/sqlite-amalgamation-3130000] -> ./page_test Max page size set to 1073741823 [/tmp/sqlite-amalgamation-3130000] -> echo $? 0 ======================================================= EXAMPLE TWO ======================================================= This second example does the reverse: 1. Change the test program to WRITE and read back max_page_count to 16384 (correctly) 2. Read the max_page_count with the shell and get incorrect 1073741823 back. [/tmp/sqlite-amalgamation-3130000] -> ls -l total 14880 -rw-r--r-- 1 wardw wheel 832 Jul 5 13:30 page_test.c -rw-r--r-- 1 wardw wheel 175474 May 18 04:07 shell.c -rw-r--r-- 1 wardw wheel 6915433 May 18 04:07 sqlite3.c -rw-r--r-- 1 wardw wheel 486805 May 18 04:07 sqlite3.h -rw-r--r-- 1 wardw wheel 29370 May 18 04:07 sqlite3ext.h [/tmp/sqlite-amalgamation-3130000] -> cat page_test.c /* clang -D SQLITE_DEBUG -o page_test page_test.c sqlite3.c */ #include <stdio.h> #include "sqlite3.h" int main() { sqlite3* hDb = NULL; if ( sqlite3_open_v2( "page_test.db", &hDb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL ) != 0 ) return -1; if ( sqlite3_exec( hDb, "pragma max_page_count=16384", NULL, NULL, NULL ) != 0 ) return -2; sqlite3_stmt* hStmt = NULL; if ( sqlite3_prepare_v2( hDb, "pragma max_page_count", -1, &hStmt, NULL ) != 0 ) return -3; if ( sqlite3_step( hStmt ) != SQLITE_ROW ) return -4; printf( "Max page size set to %d\n", sqlite3_column_int( hStmt, 0 ) ); if ( sqlite3_finalize( hStmt ) != 0 ) return -5; hStmt = NULL; if ( sqlite3_close_v2( hDb ) != 0 ) return -5; hDb = NULL; return 0; } [/tmp/sqlite-amalgamation-3130000] -> clang -D SQLITE_DEBUG -o page_test page_test.c sqlite3.c [/tmp/sqlite-amalgamation-3130000] -> ./page_test Max page size set to 16384 [/tmp/sqlite-amalgamation-3130000] -> echo $? 0 [/tmp/sqlite-amalgamation-3130000] -> clang -D SQLITE_DEBUG -D HAVE_READLINE -l readline -o sqlite3 sqlite3.c shell.c [/tmp/sqlite-amalgamation-3130000] -> ./sqlite3 page_test.db -- Loading resources from /Users/wardw/.sqliterc SQLite version 3.13.0 2016-05-18 10:57:30 Enter ".help" for usage hints. sql>pragma max_page_count; max_page_count ------------------- 1073741823 sql>.quit _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users