OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 15 | 2 ** 2001 September 15 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** Code for testing all sorts of SQLite interfaces. This code | 12 ** Code for testing all sorts of SQLite interfaces. This code |
13 ** is not included in the SQLite library. It is used for automated | 13 ** is not included in the SQLite library. It is used for automated |
14 ** testing of the SQLite library. | 14 ** testing of the SQLite library. |
15 */ | 15 */ |
16 #include "sqliteInt.h" | 16 #include "sqliteInt.h" |
| 17 #if SQLITE_OS_WIN |
| 18 # include "os_win.h" |
| 19 #endif |
| 20 |
| 21 #include "vdbeInt.h" |
17 #include "tcl.h" | 22 #include "tcl.h" |
18 #include <stdlib.h> | 23 #include <stdlib.h> |
19 #include <string.h> | 24 #include <string.h> |
20 | 25 |
21 /* | 26 /* |
22 ** This is a copy of the first part of the SqliteDb structure in | 27 ** This is a copy of the first part of the SqliteDb structure in |
23 ** tclsqlite.c. We need it here so that the get_sqlite_pointer routine | 28 ** tclsqlite.c. We need it here so that the get_sqlite_pointer routine |
24 ** can extract the sqlite3* pointer from an existing Tcl SQLite | 29 ** can extract the sqlite3* pointer from an existing Tcl SQLite |
25 ** connection. | 30 ** connection. |
26 */ | 31 */ |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 Tcl_CmdInfo cmdInfo; | 110 Tcl_CmdInfo cmdInfo; |
106 if( Tcl_GetCommandInfo(interp, zA, &cmdInfo) ){ | 111 if( Tcl_GetCommandInfo(interp, zA, &cmdInfo) ){ |
107 p = (struct SqliteDb*)cmdInfo.objClientData; | 112 p = (struct SqliteDb*)cmdInfo.objClientData; |
108 *ppDb = p->db; | 113 *ppDb = p->db; |
109 }else{ | 114 }else{ |
110 *ppDb = (sqlite3*)sqlite3TestTextToPtr(zA); | 115 *ppDb = (sqlite3*)sqlite3TestTextToPtr(zA); |
111 } | 116 } |
112 return TCL_OK; | 117 return TCL_OK; |
113 } | 118 } |
114 | 119 |
| 120 #if SQLITE_OS_WIN |
| 121 /* |
| 122 ** Decode a Win32 HANDLE object. |
| 123 */ |
| 124 int getWin32Handle(Tcl_Interp *interp, const char *zA, LPHANDLE phFile){ |
| 125 *phFile = (HANDLE)sqlite3TestTextToPtr(zA); |
| 126 return TCL_OK; |
| 127 } |
| 128 #endif |
115 | 129 |
116 const char *sqlite3TestErrorName(int rc){ | 130 extern const char *sqlite3ErrName(int); |
117 const char *zName = 0; | 131 #define t1ErrorName sqlite3ErrName |
118 switch( rc ){ | |
119 case SQLITE_OK: zName = "SQLITE_OK"; break; | |
120 case SQLITE_ERROR: zName = "SQLITE_ERROR"; break; | |
121 case SQLITE_INTERNAL: zName = "SQLITE_INTERNAL"; break; | |
122 case SQLITE_PERM: zName = "SQLITE_PERM"; break; | |
123 case SQLITE_ABORT: zName = "SQLITE_ABORT"; break; | |
124 case SQLITE_BUSY: zName = "SQLITE_BUSY"; break; | |
125 case SQLITE_LOCKED: zName = "SQLITE_LOCKED"; break; | |
126 case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break; | |
127 case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break; | |
128 case SQLITE_READONLY: zName = "SQLITE_READONLY"; break; | |
129 case SQLITE_INTERRUPT: zName = "SQLITE_INTERRUPT"; break; | |
130 case SQLITE_IOERR: zName = "SQLITE_IOERR"; break; | |
131 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break; | |
132 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break; | |
133 case SQLITE_FULL: zName = "SQLITE_FULL"; break; | |
134 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break; | |
135 case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break; | |
136 case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break; | |
137 case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break; | |
138 case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break; | |
139 case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break; | |
140 case SQLITE_MISMATCH: zName = "SQLITE_MISMATCH"; break; | |
141 case SQLITE_MISUSE: zName = "SQLITE_MISUSE"; break; | |
142 case SQLITE_NOLFS: zName = "SQLITE_NOLFS"; break; | |
143 case SQLITE_AUTH: zName = "SQLITE_AUTH"; break; | |
144 case SQLITE_FORMAT: zName = "SQLITE_FORMAT"; break; | |
145 case SQLITE_RANGE: zName = "SQLITE_RANGE"; break; | |
146 case SQLITE_NOTADB: zName = "SQLITE_NOTADB"; break; | |
147 case SQLITE_ROW: zName = "SQLITE_ROW"; break; | |
148 case SQLITE_DONE: zName = "SQLITE_DONE"; break; | |
149 case SQLITE_IOERR_READ: zName = "SQLITE_IOERR_READ"; break; | |
150 case SQLITE_IOERR_SHORT_READ: zName = "SQLITE_IOERR_SHORT_READ"; break; | |
151 case SQLITE_IOERR_WRITE: zName = "SQLITE_IOERR_WRITE"; break; | |
152 case SQLITE_IOERR_FSYNC: zName = "SQLITE_IOERR_FSYNC"; break; | |
153 case SQLITE_IOERR_DIR_FSYNC: zName = "SQLITE_IOERR_DIR_FSYNC"; break; | |
154 case SQLITE_IOERR_TRUNCATE: zName = "SQLITE_IOERR_TRUNCATE"; break; | |
155 case SQLITE_IOERR_FSTAT: zName = "SQLITE_IOERR_FSTAT"; break; | |
156 case SQLITE_IOERR_UNLOCK: zName = "SQLITE_IOERR_UNLOCK"; break; | |
157 case SQLITE_IOERR_RDLOCK: zName = "SQLITE_IOERR_RDLOCK"; break; | |
158 case SQLITE_IOERR_DELETE: zName = "SQLITE_IOERR_DELETE"; break; | |
159 case SQLITE_IOERR_BLOCKED: zName = "SQLITE_IOERR_BLOCKED"; break; | |
160 case SQLITE_IOERR_NOMEM: zName = "SQLITE_IOERR_NOMEM"; break; | |
161 case SQLITE_IOERR_ACCESS: zName = "SQLITE_IOERR_ACCESS"; break; | |
162 case SQLITE_IOERR_CHECKRESERVEDLOCK: | |
163 zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break; | |
164 case SQLITE_IOERR_LOCK: zName = "SQLITE_IOERR_LOCK"; break; | |
165 default: zName = "SQLITE_Unknown"; break; | |
166 } | |
167 return zName; | |
168 } | |
169 #define t1ErrorName sqlite3TestErrorName | |
170 | 132 |
171 /* | 133 /* |
172 ** Convert an sqlite3_stmt* into an sqlite3*. This depends on the | 134 ** Convert an sqlite3_stmt* into an sqlite3*. This depends on the |
173 ** fact that the sqlite3* is the first field in the Vdbe structure. | 135 ** fact that the sqlite3* is the first field in the Vdbe structure. |
174 */ | 136 */ |
175 #define StmtToDb(X) sqlite3_db_handle(X) | 137 #define StmtToDb(X) sqlite3_db_handle(X) |
176 | 138 |
177 /* | 139 /* |
178 ** Check a return value to make sure it agrees with the results | 140 ** Check a return value to make sure it agrees with the results |
179 ** from sqlite3_errcode. | 141 ** from sqlite3_errcode. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 iotrace_file = stderr; | 249 iotrace_file = stderr; |
288 }else{ | 250 }else{ |
289 iotrace_file = fopen(argv[1], "w"); | 251 iotrace_file = fopen(argv[1], "w"); |
290 } | 252 } |
291 sqlite3IoTrace = io_trace_callback; | 253 sqlite3IoTrace = io_trace_callback; |
292 } | 254 } |
293 #endif | 255 #endif |
294 return TCL_OK; | 256 return TCL_OK; |
295 } | 257 } |
296 | 258 |
297 | 259 /* |
| 260 ** Usage: clang_sanitize_address |
| 261 ** |
| 262 ** Returns true if the program was compiled using clang with the |
| 263 ** -fsanitize=address switch on the command line. False otherwise. |
| 264 */ |
| 265 static int clang_sanitize_address( |
| 266 void *NotUsed, |
| 267 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 268 int argc, /* Number of arguments */ |
| 269 char **argv /* Text of each argument */ |
| 270 ){ |
| 271 int res = 0; |
| 272 #if defined(__has_feature) |
| 273 # if __has_feature(address_sanitizer) |
| 274 res = 1; |
| 275 # endif |
| 276 #endif |
| 277 Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); |
| 278 return TCL_OK; |
| 279 } |
| 280 |
298 /* | 281 /* |
299 ** Usage: sqlite3_exec_printf DB FORMAT STRING | 282 ** Usage: sqlite3_exec_printf DB FORMAT STRING |
300 ** | 283 ** |
301 ** Invoke the sqlite3_exec_printf() interface using the open database | 284 ** Invoke the sqlite3_exec_printf() interface using the open database |
302 ** DB. The SQL is the string FORMAT. The format string should contain | 285 ** DB. The SQL is the string FORMAT. The format string should contain |
303 ** one %s or %q. STRING is the value inserted into %s or %q. | 286 ** one %s or %q. STRING is the value inserted into %s or %q. |
304 */ | 287 */ |
305 static int test_exec_printf( | 288 static int test_exec_printf( |
306 void *NotUsed, | 289 void *NotUsed, |
307 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 290 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 ** Usage: sqlite3_key DB KEY | 640 ** Usage: sqlite3_key DB KEY |
658 ** | 641 ** |
659 ** Set the codec key. | 642 ** Set the codec key. |
660 */ | 643 */ |
661 static int test_key( | 644 static int test_key( |
662 void *NotUsed, | 645 void *NotUsed, |
663 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 646 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
664 int argc, /* Number of arguments */ | 647 int argc, /* Number of arguments */ |
665 char **argv /* Text of each argument */ | 648 char **argv /* Text of each argument */ |
666 ){ | 649 ){ |
| 650 #ifdef SQLITE_HAS_CODEC |
667 sqlite3 *db; | 651 sqlite3 *db; |
668 const char *zKey; | 652 const char *zKey; |
669 int nKey; | 653 int nKey; |
670 if( argc!=3 ){ | 654 if( argc!=3 ){ |
671 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 655 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
672 " FILENAME\"", 0); | 656 " FILENAME\"", 0); |
673 return TCL_ERROR; | 657 return TCL_ERROR; |
674 } | 658 } |
675 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 659 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
676 zKey = argv[2]; | 660 zKey = argv[2]; |
677 nKey = strlen(zKey); | 661 nKey = strlen(zKey); |
678 #ifdef SQLITE_HAS_CODEC | |
679 sqlite3_key(db, zKey, nKey); | 662 sqlite3_key(db, zKey, nKey); |
680 #endif | 663 #endif |
681 return TCL_OK; | 664 return TCL_OK; |
682 } | 665 } |
683 | 666 |
684 /* | 667 /* |
685 ** Usage: sqlite3_rekey DB KEY | 668 ** Usage: sqlite3_rekey DB KEY |
686 ** | 669 ** |
687 ** Change the codec key. | 670 ** Change the codec key. |
688 */ | 671 */ |
689 static int test_rekey( | 672 static int test_rekey( |
690 void *NotUsed, | 673 void *NotUsed, |
691 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 674 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
692 int argc, /* Number of arguments */ | 675 int argc, /* Number of arguments */ |
693 char **argv /* Text of each argument */ | 676 char **argv /* Text of each argument */ |
694 ){ | 677 ){ |
| 678 #ifdef SQLITE_HAS_CODEC |
695 sqlite3 *db; | 679 sqlite3 *db; |
696 const char *zKey; | 680 const char *zKey; |
697 int nKey; | 681 int nKey; |
698 if( argc!=3 ){ | 682 if( argc!=3 ){ |
699 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 683 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
700 " FILENAME\"", 0); | 684 " FILENAME\"", 0); |
701 return TCL_ERROR; | 685 return TCL_ERROR; |
702 } | 686 } |
703 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 687 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
704 zKey = argv[2]; | 688 zKey = argv[2]; |
705 nKey = strlen(zKey); | 689 nKey = strlen(zKey); |
706 #ifdef SQLITE_HAS_CODEC | |
707 sqlite3_rekey(db, zKey, nKey); | 690 sqlite3_rekey(db, zKey, nKey); |
708 #endif | 691 #endif |
709 return TCL_OK; | 692 return TCL_OK; |
710 } | 693 } |
711 | 694 |
712 /* | 695 /* |
713 ** Usage: sqlite3_close DB | 696 ** Usage: sqlite3_close DB |
714 ** | 697 ** |
715 ** Closes the database opened by sqlite3_open. | 698 ** Closes the database opened by sqlite3_open. |
716 */ | 699 */ |
(...skipping 10 matching lines...) Expand all Loading... |
727 " FILENAME\"", 0); | 710 " FILENAME\"", 0); |
728 return TCL_ERROR; | 711 return TCL_ERROR; |
729 } | 712 } |
730 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 713 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
731 rc = sqlite3_close(db); | 714 rc = sqlite3_close(db); |
732 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 715 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
733 return TCL_OK; | 716 return TCL_OK; |
734 } | 717 } |
735 | 718 |
736 /* | 719 /* |
| 720 ** Usage: sqlite3_close_v2 DB |
| 721 ** |
| 722 ** Closes the database opened by sqlite3_open. |
| 723 */ |
| 724 static int sqlite_test_close_v2( |
| 725 void *NotUsed, |
| 726 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 727 int argc, /* Number of arguments */ |
| 728 char **argv /* Text of each argument */ |
| 729 ){ |
| 730 sqlite3 *db; |
| 731 int rc; |
| 732 if( argc!=2 ){ |
| 733 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 734 " FILENAME\"", 0); |
| 735 return TCL_ERROR; |
| 736 } |
| 737 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 738 rc = sqlite3_close_v2(db); |
| 739 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 740 return TCL_OK; |
| 741 } |
| 742 |
| 743 /* |
737 ** Implementation of the x_coalesce() function. | 744 ** Implementation of the x_coalesce() function. |
738 ** Return the first argument non-NULL argument. | 745 ** Return the first argument non-NULL argument. |
739 */ | 746 */ |
740 static void t1_ifnullFunc( | 747 static void t1_ifnullFunc( |
741 sqlite3_context *context, | 748 sqlite3_context *context, |
742 int argc, | 749 int argc, |
743 sqlite3_value **argv | 750 sqlite3_value **argv |
744 ){ | 751 ){ |
745 int i; | 752 int i; |
746 for(i=0; i<argc; i++){ | 753 for(i=0; i<argc; i++){ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 struct dstr { | 796 struct dstr { |
790 int nAlloc; /* Space allocated */ | 797 int nAlloc; /* Space allocated */ |
791 int nUsed; /* Space used */ | 798 int nUsed; /* Space used */ |
792 char *z; /* The space */ | 799 char *z; /* The space */ |
793 }; | 800 }; |
794 | 801 |
795 /* | 802 /* |
796 ** Append text to a dstr | 803 ** Append text to a dstr |
797 */ | 804 */ |
798 static void dstrAppend(struct dstr *p, const char *z, int divider){ | 805 static void dstrAppend(struct dstr *p, const char *z, int divider){ |
799 int n = strlen(z); | 806 int n = (int)strlen(z); |
800 if( p->nUsed + n + 2 > p->nAlloc ){ | 807 if( p->nUsed + n + 2 > p->nAlloc ){ |
801 char *zNew; | 808 char *zNew; |
802 p->nAlloc = p->nAlloc*2 + n + 200; | 809 p->nAlloc = p->nAlloc*2 + n + 200; |
803 zNew = sqlite3_realloc(p->z, p->nAlloc); | 810 zNew = sqlite3_realloc(p->z, p->nAlloc); |
804 if( zNew==0 ){ | 811 if( zNew==0 ){ |
805 sqlite3_free(p->z); | 812 sqlite3_free(p->z); |
806 memset(p, 0, sizeof(*p)); | 813 memset(p, 0, sizeof(*p)); |
807 return; | 814 return; |
808 } | 815 } |
809 p->z = zNew; | 816 p->z = zNew; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 p2 = (const void*)sqlite3_value_text16(argv[0]); | 970 p2 = (const void*)sqlite3_value_text16(argv[0]); |
964 #endif | 971 #endif |
965 }else if( strcmp(zCmd, "blob")==0 ){ | 972 }else if( strcmp(zCmd, "blob")==0 ){ |
966 p2 = (const void*)sqlite3_value_blob(argv[0]); | 973 p2 = (const void*)sqlite3_value_blob(argv[0]); |
967 }else{ | 974 }else{ |
968 return; | 975 return; |
969 } | 976 } |
970 sqlite3_result_int(context, p1!=p2); | 977 sqlite3_result_int(context, p1!=p2); |
971 } | 978 } |
972 | 979 |
| 980 /* |
| 981 ** This SQL function returns a different answer each time it is called, even if |
| 982 ** the arguments are the same. |
| 983 */ |
| 984 static void nondeterministicFunction( |
| 985 sqlite3_context *context, |
| 986 int argc, |
| 987 sqlite3_value **argv |
| 988 ){ |
| 989 static int cnt = 0; |
| 990 sqlite3_result_int(context, cnt++); |
| 991 } |
973 | 992 |
974 /* | 993 /* |
975 ** Usage: sqlite_test_create_function DB | 994 ** Usage: sqlite3_create_function DB |
976 ** | 995 ** |
977 ** Call the sqlite3_create_function API on the given database in order | 996 ** Call the sqlite3_create_function API on the given database in order |
978 ** to create a function named "x_coalesce". This function does the same thing | 997 ** to create a function named "x_coalesce". This function does the same thing |
979 ** as the "coalesce" function. This function also registers an SQL function | 998 ** as the "coalesce" function. This function also registers an SQL function |
980 ** named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() | 999 ** named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() |
981 ** in this way is illegal recursion and should raise an SQLITE_MISUSE error. | 1000 ** in this way is illegal recursion and should raise an SQLITE_MISUSE error. |
982 ** The effect is similar to trying to use the same database connection from | 1001 ** The effect is similar to trying to use the same database connection from |
983 ** two threads at the same time. | 1002 ** two threads at the same time. |
984 ** | 1003 ** |
985 ** The original motivation for this routine was to be able to call the | 1004 ** The original motivation for this routine was to be able to call the |
986 ** sqlite3_create_function function while a query is in progress in order | 1005 ** sqlite3_create_function function while a query is in progress in order |
987 ** to test the SQLITE_MISUSE detection logic. | 1006 ** to test the SQLITE_MISUSE detection logic. |
988 */ | 1007 */ |
989 static int test_create_function( | 1008 static int test_create_function( |
990 void *NotUsed, | 1009 void *NotUsed, |
991 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1010 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
992 int argc, /* Number of arguments */ | 1011 int argc, /* Number of arguments */ |
993 char **argv /* Text of each argument */ | 1012 char **argv /* Text of each argument */ |
994 ){ | 1013 ){ |
995 int rc; | 1014 int rc; |
996 sqlite3 *db; | 1015 sqlite3 *db; |
997 | 1016 |
998 if( argc!=2 ){ | 1017 if( argc!=2 ){ |
999 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1018 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
1000 " DB\"", 0); | 1019 " DB\"", 0); |
1001 return TCL_ERROR; | 1020 return TCL_ERROR; |
1002 } | 1021 } |
1003 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 1022 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
1004 rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, | 1023 rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_UTF8, 0, |
1005 t1_ifnullFunc, 0, 0); | 1024 t1_ifnullFunc, 0, 0); |
1006 if( rc==SQLITE_OK ){ | 1025 if( rc==SQLITE_OK ){ |
1007 rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0, | 1026 rc = sqlite3_create_function(db, "hex8", 1, SQLITE_UTF8 | SQLITE_DETERMINIST
IC, |
1008 hex8Func, 0, 0); | 1027 0, hex8Func, 0, 0); |
1009 } | 1028 } |
1010 #ifndef SQLITE_OMIT_UTF16 | 1029 #ifndef SQLITE_OMIT_UTF16 |
1011 if( rc==SQLITE_OK ){ | 1030 if( rc==SQLITE_OK ){ |
1012 rc = sqlite3_create_function(db, "hex16", 1, SQLITE_ANY, 0, | 1031 rc = sqlite3_create_function(db, "hex16", 1, SQLITE_UTF16 | SQLITE_DETERMINI
STIC, |
1013 hex16Func, 0, 0); | 1032 0, hex16Func, 0, 0); |
1014 } | 1033 } |
1015 #endif | 1034 #endif |
1016 if( rc==SQLITE_OK ){ | 1035 if( rc==SQLITE_OK ){ |
1017 rc = sqlite3_create_function(db, "tkt2213func", 1, SQLITE_ANY, 0, | 1036 rc = sqlite3_create_function(db, "tkt2213func", 1, SQLITE_ANY, 0, |
1018 tkt2213Function, 0, 0); | 1037 tkt2213Function, 0, 0); |
1019 } | 1038 } |
1020 if( rc==SQLITE_OK ){ | 1039 if( rc==SQLITE_OK ){ |
1021 rc = sqlite3_create_function(db, "pointer_change", 4, SQLITE_ANY, 0, | 1040 rc = sqlite3_create_function(db, "pointer_change", 4, SQLITE_ANY, 0, |
1022 ptrChngFunction, 0, 0); | 1041 ptrChngFunction, 0, 0); |
1023 } | 1042 } |
1024 | 1043 |
| 1044 /* Functions counter1() and counter2() have the same implementation - they |
| 1045 ** both return an ascending integer with each call. But counter1() is marked |
| 1046 ** as non-deterministic and counter2() is marked as deterministic. |
| 1047 */ |
| 1048 if( rc==SQLITE_OK ){ |
| 1049 rc = sqlite3_create_function(db, "counter1", -1, SQLITE_UTF8, |
| 1050 0, nondeterministicFunction, 0, 0); |
| 1051 } |
| 1052 if( rc==SQLITE_OK ){ |
| 1053 rc = sqlite3_create_function(db, "counter2", -1, SQLITE_UTF8|SQLITE_DETERMIN
ISTIC, |
| 1054 0, nondeterministicFunction, 0, 0); |
| 1055 } |
| 1056 |
1025 #ifndef SQLITE_OMIT_UTF16 | 1057 #ifndef SQLITE_OMIT_UTF16 |
1026 /* Use the sqlite3_create_function16() API here. Mainly for fun, but also | 1058 /* Use the sqlite3_create_function16() API here. Mainly for fun, but also |
1027 ** because it is not tested anywhere else. */ | 1059 ** because it is not tested anywhere else. */ |
1028 if( rc==SQLITE_OK ){ | 1060 if( rc==SQLITE_OK ){ |
1029 const void *zUtf16; | 1061 const void *zUtf16; |
1030 sqlite3_value *pVal; | 1062 sqlite3_value *pVal; |
1031 sqlite3_mutex_enter(db->mutex); | 1063 sqlite3_mutex_enter(db->mutex); |
1032 pVal = sqlite3ValueNew(db); | 1064 pVal = sqlite3ValueNew(db); |
1033 sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC); | 1065 sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC); |
1034 zUtf16 = sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); | 1066 zUtf16 = sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 return TCL_ERROR; | 1736 return TCL_ERROR; |
1705 } | 1737 } |
1706 | 1738 |
1707 if( nByte>0 ){ | 1739 if( nByte>0 ){ |
1708 zBuf = (unsigned char *)Tcl_Alloc(nByte); | 1740 zBuf = (unsigned char *)Tcl_Alloc(nByte); |
1709 } | 1741 } |
1710 rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset); | 1742 rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset); |
1711 if( rc==SQLITE_OK ){ | 1743 if( rc==SQLITE_OK ){ |
1712 Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zBuf, nByte)); | 1744 Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zBuf, nByte)); |
1713 }else{ | 1745 }else{ |
1714 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 1746 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1715 } | 1747 } |
1716 Tcl_Free((char *)zBuf); | 1748 Tcl_Free((char *)zBuf); |
1717 | 1749 |
1718 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); | 1750 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); |
1719 } | 1751 } |
1720 | 1752 |
1721 /* | 1753 /* |
1722 ** sqlite3_blob_write CHANNEL OFFSET DATA ?NDATA? | 1754 ** sqlite3_blob_write CHANNEL OFFSET DATA ?NDATA? |
1723 ** | 1755 ** |
1724 ** This command is used to test the sqlite3_blob_write() in ways that | 1756 ** This command is used to test the sqlite3_blob_write() in ways that |
(...skipping 29 matching lines...) Expand all Loading... |
1754 if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){ | 1786 if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){ |
1755 return TCL_ERROR; | 1787 return TCL_ERROR; |
1756 } | 1788 } |
1757 | 1789 |
1758 zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf); | 1790 zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf); |
1759 if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){ | 1791 if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){ |
1760 return TCL_ERROR; | 1792 return TCL_ERROR; |
1761 } | 1793 } |
1762 rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset); | 1794 rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset); |
1763 if( rc!=SQLITE_OK ){ | 1795 if( rc!=SQLITE_OK ){ |
1764 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 1796 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1765 } | 1797 } |
1766 | 1798 |
1767 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); | 1799 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); |
1768 } | 1800 } |
1769 | 1801 |
1770 static int test_blob_reopen( | 1802 static int test_blob_reopen( |
1771 ClientData clientData, /* Not used */ | 1803 ClientData clientData, /* Not used */ |
1772 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1804 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
1773 int objc, /* Number of arguments */ | 1805 int objc, /* Number of arguments */ |
1774 Tcl_Obj *CONST objv[] /* Command arguments */ | 1806 Tcl_Obj *CONST objv[] /* Command arguments */ |
1775 ){ | 1807 ){ |
1776 Tcl_WideInt iRowid; | 1808 Tcl_WideInt iRowid; |
1777 sqlite3_blob *pBlob; | 1809 sqlite3_blob *pBlob; |
1778 int rc; | 1810 int rc; |
1779 | 1811 |
1780 if( objc!=3 ){ | 1812 if( objc!=3 ){ |
1781 Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL ROWID"); | 1813 Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL ROWID"); |
1782 return TCL_ERROR; | 1814 return TCL_ERROR; |
1783 } | 1815 } |
1784 | 1816 |
1785 if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR; | 1817 if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR; |
1786 if( Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ) return TCL_ERROR; | 1818 if( Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ) return TCL_ERROR; |
1787 | 1819 |
1788 rc = sqlite3_blob_reopen(pBlob, iRowid); | 1820 rc = sqlite3_blob_reopen(pBlob, iRowid); |
1789 if( rc!=SQLITE_OK ){ | 1821 if( rc!=SQLITE_OK ){ |
1790 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 1822 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1791 } | 1823 } |
1792 | 1824 |
1793 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); | 1825 return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); |
1794 } | 1826 } |
1795 | 1827 |
1796 #endif | 1828 #endif |
1797 | 1829 |
1798 /* | 1830 /* |
1799 ** Usage: sqlite3_create_collation_v2 DB-HANDLE NAME CMP-PROC DEL-PROC | 1831 ** Usage: sqlite3_create_collation_v2 DB-HANDLE NAME CMP-PROC DEL-PROC |
1800 ** | 1832 ** |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 if( p->pDestroy ) Tcl_IncrRefCount(p->pDestroy); | 2022 if( p->pDestroy ) Tcl_IncrRefCount(p->pDestroy); |
1991 | 2023 |
1992 rc = sqlite3_create_function_v2(db, zFunc, nArg, enc, (void *)p, | 2024 rc = sqlite3_create_function_v2(db, zFunc, nArg, enc, (void *)p, |
1993 (p->pFunc ? cf2Func : 0), | 2025 (p->pFunc ? cf2Func : 0), |
1994 (p->pStep ? cf2Step : 0), | 2026 (p->pStep ? cf2Step : 0), |
1995 (p->pFinal ? cf2Final : 0), | 2027 (p->pFinal ? cf2Final : 0), |
1996 cf2Destroy | 2028 cf2Destroy |
1997 ); | 2029 ); |
1998 if( rc!=SQLITE_OK ){ | 2030 if( rc!=SQLITE_OK ){ |
1999 Tcl_ResetResult(interp); | 2031 Tcl_ResetResult(interp); |
2000 Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); | 2032 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
2001 return TCL_ERROR; | 2033 return TCL_ERROR; |
2002 } | 2034 } |
2003 return TCL_OK; | 2035 return TCL_OK; |
2004 } | 2036 } |
2005 | 2037 |
2006 /* | 2038 /* |
2007 ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? | 2039 ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? |
2008 */ | 2040 */ |
2009 static int test_load_extension( | 2041 static int test_load_extension( |
2010 ClientData clientData, /* Not used */ | 2042 ClientData clientData, /* Not used */ |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 const char *zOpName; | 2271 const char *zOpName; |
2240 sqlite3_stmt *pStmt; | 2272 sqlite3_stmt *pStmt; |
2241 | 2273 |
2242 static const struct { | 2274 static const struct { |
2243 const char *zName; | 2275 const char *zName; |
2244 int op; | 2276 int op; |
2245 } aOp[] = { | 2277 } aOp[] = { |
2246 { "SQLITE_STMTSTATUS_FULLSCAN_STEP", SQLITE_STMTSTATUS_FULLSCAN_STEP }, | 2278 { "SQLITE_STMTSTATUS_FULLSCAN_STEP", SQLITE_STMTSTATUS_FULLSCAN_STEP }, |
2247 { "SQLITE_STMTSTATUS_SORT", SQLITE_STMTSTATUS_SORT }, | 2279 { "SQLITE_STMTSTATUS_SORT", SQLITE_STMTSTATUS_SORT }, |
2248 { "SQLITE_STMTSTATUS_AUTOINDEX", SQLITE_STMTSTATUS_AUTOINDEX }, | 2280 { "SQLITE_STMTSTATUS_AUTOINDEX", SQLITE_STMTSTATUS_AUTOINDEX }, |
| 2281 { "SQLITE_STMTSTATUS_VM_STEP", SQLITE_STMTSTATUS_VM_STEP }, |
2249 }; | 2282 }; |
2250 if( objc!=4 ){ | 2283 if( objc!=4 ){ |
2251 Tcl_WrongNumArgs(interp, 1, objv, "STMT PARAMETER RESETFLAG"); | 2284 Tcl_WrongNumArgs(interp, 1, objv, "STMT PARAMETER RESETFLAG"); |
2252 return TCL_ERROR; | 2285 return TCL_ERROR; |
2253 } | 2286 } |
2254 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2287 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
2255 zOpName = Tcl_GetString(objv[2]); | 2288 zOpName = Tcl_GetString(objv[2]); |
2256 for(i=0; i<ArraySize(aOp); i++){ | 2289 for(i=0; i<ArraySize(aOp); i++){ |
2257 if( strcmp(aOp[i].zName, zOpName)==0 ){ | 2290 if( strcmp(aOp[i].zName, zOpName)==0 ){ |
2258 op = aOp[i].op; | 2291 op = aOp[i].op; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); | 2352 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
2320 return TCL_ERROR; | 2353 return TCL_ERROR; |
2321 } | 2354 } |
2322 | 2355 |
2323 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2356 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
2324 rc = sqlite3_stmt_readonly(pStmt); | 2357 rc = sqlite3_stmt_readonly(pStmt); |
2325 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); | 2358 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); |
2326 return TCL_OK; | 2359 return TCL_OK; |
2327 } | 2360 } |
2328 | 2361 |
| 2362 /* |
| 2363 ** Usage: sqlite3_stmt_busy STMT |
| 2364 ** |
| 2365 ** Return true if STMT is a non-NULL pointer to a statement |
| 2366 ** that has been stepped but not to completion. |
| 2367 */ |
| 2368 static int test_stmt_busy( |
| 2369 void * clientData, |
| 2370 Tcl_Interp *interp, |
| 2371 int objc, |
| 2372 Tcl_Obj *CONST objv[] |
| 2373 ){ |
| 2374 sqlite3_stmt *pStmt; |
| 2375 int rc; |
| 2376 |
| 2377 if( objc!=2 ){ |
| 2378 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2379 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
| 2380 return TCL_ERROR; |
| 2381 } |
| 2382 |
| 2383 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2384 rc = sqlite3_stmt_busy(pStmt); |
| 2385 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); |
| 2386 return TCL_OK; |
| 2387 } |
| 2388 |
| 2389 /* |
| 2390 ** Usage: uses_stmt_journal STMT |
| 2391 ** |
| 2392 ** Return true if STMT uses a statement journal. |
| 2393 */ |
| 2394 static int uses_stmt_journal( |
| 2395 void * clientData, |
| 2396 Tcl_Interp *interp, |
| 2397 int objc, |
| 2398 Tcl_Obj *CONST objv[] |
| 2399 ){ |
| 2400 sqlite3_stmt *pStmt; |
| 2401 |
| 2402 if( objc!=2 ){ |
| 2403 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2404 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
| 2405 return TCL_ERROR; |
| 2406 } |
| 2407 |
| 2408 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2409 sqlite3_stmt_readonly(pStmt); |
| 2410 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->usesStmtJournal)); |
| 2411 return TCL_OK; |
| 2412 } |
| 2413 |
2329 | 2414 |
2330 /* | 2415 /* |
2331 ** Usage: sqlite3_reset STMT | 2416 ** Usage: sqlite3_reset STMT |
2332 ** | 2417 ** |
2333 ** Reset a statement handle. | 2418 ** Reset a statement handle. |
2334 */ | 2419 */ |
2335 static int test_reset( | 2420 static int test_reset( |
2336 void * clientData, | 2421 void * clientData, |
2337 Tcl_Interp *interp, | 2422 Tcl_Interp *interp, |
2338 int objc, | 2423 int objc, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 /* | 2523 /* |
2439 ** This is the "static_bind_value" that variables are bound to when | 2524 ** This is the "static_bind_value" that variables are bound to when |
2440 ** the FLAG option of sqlite3_bind is "static" | 2525 ** the FLAG option of sqlite3_bind is "static" |
2441 */ | 2526 */ |
2442 static char *sqlite_static_bind_value = 0; | 2527 static char *sqlite_static_bind_value = 0; |
2443 static int sqlite_static_bind_nbyte = 0; | 2528 static int sqlite_static_bind_nbyte = 0; |
2444 | 2529 |
2445 /* | 2530 /* |
2446 ** Usage: sqlite3_bind VM IDX VALUE FLAGS | 2531 ** Usage: sqlite3_bind VM IDX VALUE FLAGS |
2447 ** | 2532 ** |
2448 ** Sets the value of the IDX-th occurance of "?" in the original SQL | 2533 ** Sets the value of the IDX-th occurrence of "?" in the original SQL |
2449 ** string. VALUE is the new value. If FLAGS=="null" then VALUE is | 2534 ** string. VALUE is the new value. If FLAGS=="null" then VALUE is |
2450 ** ignored and the value is set to NULL. If FLAGS=="static" then | 2535 ** ignored and the value is set to NULL. If FLAGS=="static" then |
2451 ** the value is set to the value of a static variable named | 2536 ** the value is set to the value of a static variable named |
2452 ** "sqlite_static_bind_value". If FLAGS=="normal" then a copy | 2537 ** "sqlite_static_bind_value". If FLAGS=="normal" then a copy |
2453 ** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored | 2538 ** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored |
2454 ** an a 10-byte blob "abc\000xyz\000pq" is inserted. | 2539 ** an a 10-byte blob "abc\000xyz\000pq" is inserted. |
2455 */ | 2540 */ |
2456 static int test_bind( | 2541 static int test_bind( |
2457 void *NotUsed, | 2542 void *NotUsed, |
2458 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 2543 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 ** The collation sequence test_collate is implemented by calling the | 2598 ** The collation sequence test_collate is implemented by calling the |
2514 ** following TCL script: | 2599 ** following TCL script: |
2515 ** | 2600 ** |
2516 ** "test_collate <enc> <lhs> <rhs>" | 2601 ** "test_collate <enc> <lhs> <rhs>" |
2517 ** | 2602 ** |
2518 ** The <lhs> and <rhs> are the two values being compared, encoded in UTF-8. | 2603 ** The <lhs> and <rhs> are the two values being compared, encoded in UTF-8. |
2519 ** The <enc> parameter is the encoding of the collation function that | 2604 ** The <enc> parameter is the encoding of the collation function that |
2520 ** SQLite selected to call. The TCL test script implements the | 2605 ** SQLite selected to call. The TCL test script implements the |
2521 ** "test_collate" proc. | 2606 ** "test_collate" proc. |
2522 ** | 2607 ** |
2523 ** Note that this will only work with one intepreter at a time, as the | 2608 ** Note that this will only work with one interpreter at a time, as the |
2524 ** interp pointer to use when evaluating the TCL script is stored in | 2609 ** interp pointer to use when evaluating the TCL script is stored in |
2525 ** pTestCollateInterp. | 2610 ** pTestCollateInterp. |
2526 */ | 2611 */ |
2527 static Tcl_Interp* pTestCollateInterp; | 2612 static Tcl_Interp* pTestCollateInterp; |
2528 static int test_collate_func( | 2613 static int test_collate_func( |
2529 void *pCtx, | 2614 void *pCtx, |
2530 int nA, const void *zA, | 2615 int nA, const void *zA, |
2531 int nB, const void *zB | 2616 int nB, const void *zB |
2532 ){ | 2617 ){ |
2533 Tcl_Interp *i = pTestCollateInterp; | 2618 Tcl_Interp *i = pTestCollateInterp; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 }else{ | 2699 }else{ |
2615 rc = sqlite3_create_collation16(db, zUtf16, SQLITE_UTF16BE, | 2700 rc = sqlite3_create_collation16(db, zUtf16, SQLITE_UTF16BE, |
2616 (void *)SQLITE_UTF16BE, val?test_collate_func:0); | 2701 (void *)SQLITE_UTF16BE, val?test_collate_func:0); |
2617 } | 2702 } |
2618 sqlite3ValueFree(pVal); | 2703 sqlite3ValueFree(pVal); |
2619 sqlite3_mutex_leave(db->mutex); | 2704 sqlite3_mutex_leave(db->mutex); |
2620 } | 2705 } |
2621 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 2706 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
2622 | 2707 |
2623 if( rc!=SQLITE_OK ){ | 2708 if( rc!=SQLITE_OK ){ |
2624 Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); | 2709 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
2625 return TCL_ERROR; | 2710 return TCL_ERROR; |
2626 } | 2711 } |
2627 return TCL_OK; | 2712 return TCL_OK; |
2628 | 2713 |
2629 bad_args: | 2714 bad_args: |
2630 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2715 Tcl_AppendResult(interp, "wrong # args: should be \"", |
2631 Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0); | 2716 Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0); |
2632 return TCL_ERROR; | 2717 return TCL_ERROR; |
2633 } | 2718 } |
2634 | 2719 |
2635 /* | 2720 /* |
| 2721 ** Usage: add_test_utf16bin_collate <db ptr> |
| 2722 ** |
| 2723 ** Add a utf-16 collation sequence named "utf16bin" to the database |
| 2724 ** handle. This collation sequence compares arguments in the same way as the |
| 2725 ** built-in collation "binary". |
| 2726 */ |
| 2727 static int test_utf16bin_collate_func( |
| 2728 void *pCtx, |
| 2729 int nA, const void *zA, |
| 2730 int nB, const void *zB |
| 2731 ){ |
| 2732 int nCmp = (nA>nB ? nB : nA); |
| 2733 int res = memcmp(zA, zB, nCmp); |
| 2734 if( res==0 ) res = nA - nB; |
| 2735 return res; |
| 2736 } |
| 2737 static int test_utf16bin_collate( |
| 2738 void * clientData, |
| 2739 Tcl_Interp *interp, |
| 2740 int objc, |
| 2741 Tcl_Obj *CONST objv[] |
| 2742 ){ |
| 2743 sqlite3 *db; |
| 2744 int rc; |
| 2745 |
| 2746 if( objc!=2 ) goto bad_args; |
| 2747 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 2748 |
| 2749 rc = sqlite3_create_collation(db, "utf16bin", SQLITE_UTF16, 0, |
| 2750 test_utf16bin_collate_func |
| 2751 ); |
| 2752 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 2753 return TCL_OK; |
| 2754 |
| 2755 bad_args: |
| 2756 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 2757 return TCL_ERROR; |
| 2758 } |
| 2759 |
| 2760 /* |
2636 ** When the collation needed callback is invoked, record the name of | 2761 ** When the collation needed callback is invoked, record the name of |
2637 ** the requested collating function here. The recorded name is linked | 2762 ** the requested collating function here. The recorded name is linked |
2638 ** to a TCL variable and used to make sure that the requested collation | 2763 ** to a TCL variable and used to make sure that the requested collation |
2639 ** name is correct. | 2764 ** name is correct. |
2640 */ | 2765 */ |
2641 static char zNeededCollation[200]; | 2766 static char zNeededCollation[200]; |
2642 static char *pzNeededCollation = zNeededCollation; | 2767 static char *pzNeededCollation = zNeededCollation; |
2643 | 2768 |
2644 | 2769 |
2645 /* | 2770 /* |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3004 ** binds a 64-bit integer VALUE to that wildcard. | 3129 ** binds a 64-bit integer VALUE to that wildcard. |
3005 */ | 3130 */ |
3006 static int test_bind_int64( | 3131 static int test_bind_int64( |
3007 void * clientData, | 3132 void * clientData, |
3008 Tcl_Interp *interp, | 3133 Tcl_Interp *interp, |
3009 int objc, | 3134 int objc, |
3010 Tcl_Obj *CONST objv[] | 3135 Tcl_Obj *CONST objv[] |
3011 ){ | 3136 ){ |
3012 sqlite3_stmt *pStmt; | 3137 sqlite3_stmt *pStmt; |
3013 int idx; | 3138 int idx; |
3014 i64 value; | 3139 Tcl_WideInt value; |
3015 int rc; | 3140 int rc; |
3016 | 3141 |
3017 if( objc!=4 ){ | 3142 if( objc!=4 ){ |
3018 Tcl_AppendResult(interp, "wrong # args: should be \"", | 3143 Tcl_AppendResult(interp, "wrong # args: should be \"", |
3019 Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE", 0); | 3144 Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE", 0); |
3020 return TCL_ERROR; | 3145 return TCL_ERROR; |
3021 } | 3146 } |
3022 | 3147 |
3023 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3148 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
3024 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; | 3149 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3172 } | 3297 } |
3173 | 3298 |
3174 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3299 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
3175 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; | 3300 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; |
3176 value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes); | 3301 value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes); |
3177 if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; | 3302 if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; |
3178 | 3303 |
3179 rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT); | 3304 rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT); |
3180 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; | 3305 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; |
3181 if( rc!=SQLITE_OK ){ | 3306 if( rc!=SQLITE_OK ){ |
3182 Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); | 3307 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
3183 return TCL_ERROR; | 3308 return TCL_ERROR; |
3184 } | 3309 } |
3185 | 3310 |
3186 return TCL_OK; | 3311 return TCL_OK; |
3187 } | 3312 } |
3188 | 3313 |
3189 /* | 3314 /* |
3190 ** Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES | 3315 ** Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES |
3191 ** | 3316 ** |
3192 ** Test the sqlite3_bind_text16 interface. STMT is a prepared statement. | 3317 ** Test the sqlite3_bind_text16 interface. STMT is a prepared statement. |
3193 ** N is the index of a wildcard in the prepared statement. This command | 3318 ** N is the index of a wildcard in the prepared statement. This command |
3194 ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes | 3319 ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes |
3195 ** long. | 3320 ** long. |
3196 */ | 3321 */ |
3197 static int test_bind_text16( | 3322 static int test_bind_text16( |
3198 void * clientData, | 3323 void * clientData, |
3199 Tcl_Interp *interp, | 3324 Tcl_Interp *interp, |
3200 int objc, | 3325 int objc, |
3201 Tcl_Obj *CONST objv[] | 3326 Tcl_Obj *CONST objv[] |
3202 ){ | 3327 ){ |
3203 #ifndef SQLITE_OMIT_UTF16 | 3328 #ifndef SQLITE_OMIT_UTF16 |
3204 sqlite3_stmt *pStmt; | 3329 sqlite3_stmt *pStmt; |
3205 int idx; | 3330 int idx; |
3206 int bytes; | 3331 int bytes; |
3207 char *value; | 3332 char *value; |
3208 int rc; | 3333 int rc; |
3209 | 3334 |
3210 void (*xDel)() = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT); | 3335 void (*xDel)(void*) = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT); |
3211 Tcl_Obj *oStmt = objv[objc-4]; | 3336 Tcl_Obj *oStmt = objv[objc-4]; |
3212 Tcl_Obj *oN = objv[objc-3]; | 3337 Tcl_Obj *oN = objv[objc-3]; |
3213 Tcl_Obj *oString = objv[objc-2]; | 3338 Tcl_Obj *oString = objv[objc-2]; |
3214 Tcl_Obj *oBytes = objv[objc-1]; | 3339 Tcl_Obj *oBytes = objv[objc-1]; |
3215 | 3340 |
3216 if( objc!=5 && objc!=6){ | 3341 if( objc!=5 && objc!=6){ |
3217 Tcl_AppendResult(interp, "wrong # args: should be \"", | 3342 Tcl_AppendResult(interp, "wrong # args: should be \"", |
3218 Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE BYTES", 0); | 3343 Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE BYTES", 0); |
3219 return TCL_ERROR; | 3344 return TCL_ERROR; |
3220 } | 3345 } |
3221 | 3346 |
3222 if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR; | 3347 if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR; |
3223 if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR; | 3348 if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR; |
3224 value = (char*)Tcl_GetByteArrayFromObj(oString, 0); | 3349 value = (char*)Tcl_GetByteArrayFromObj(oString, 0); |
3225 if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR; | 3350 if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR; |
3226 | 3351 |
3227 rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel); | 3352 rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel); |
3228 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; | 3353 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; |
3229 if( rc!=SQLITE_OK ){ | 3354 if( rc!=SQLITE_OK ){ |
3230 Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); | 3355 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
3231 return TCL_ERROR; | 3356 return TCL_ERROR; |
3232 } | 3357 } |
3233 | 3358 |
3234 #endif /* SQLITE_OMIT_UTF16 */ | 3359 #endif /* SQLITE_OMIT_UTF16 */ |
3235 return TCL_OK; | 3360 return TCL_OK; |
3236 } | 3361 } |
3237 | 3362 |
3238 /* | 3363 /* |
3239 ** Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES | 3364 ** Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES |
3240 ** | 3365 ** |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3546 } | 3671 } |
3547 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 3672 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
3548 zSql = Tcl_GetString(objv[2]); | 3673 zSql = Tcl_GetString(objv[2]); |
3549 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; | 3674 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; |
3550 | 3675 |
3551 rc = sqlite3_prepare(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); | 3676 rc = sqlite3_prepare(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); |
3552 Tcl_ResetResult(interp); | 3677 Tcl_ResetResult(interp); |
3553 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 3678 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
3554 if( zTail && objc>=5 ){ | 3679 if( zTail && objc>=5 ){ |
3555 if( bytes>=0 ){ | 3680 if( bytes>=0 ){ |
3556 bytes = bytes - (zTail-zSql); | 3681 bytes = bytes - (int)(zTail-zSql); |
3557 } | 3682 } |
3558 if( strlen(zTail)<bytes ){ | 3683 if( (int)strlen(zTail)<bytes ){ |
3559 bytes = strlen(zTail); | 3684 bytes = (int)strlen(zTail); |
3560 } | 3685 } |
3561 Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); | 3686 Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); |
3562 } | 3687 } |
3563 if( rc!=SQLITE_OK ){ | 3688 if( rc!=SQLITE_OK ){ |
3564 assert( pStmt==0 ); | 3689 assert( pStmt==0 ); |
3565 sprintf(zBuf, "(%d) ", rc); | 3690 sprintf(zBuf, "(%d) ", rc); |
3566 Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); | 3691 Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); |
3567 return TCL_ERROR; | 3692 return TCL_ERROR; |
3568 } | 3693 } |
3569 | 3694 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3604 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 3729 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
3605 zSql = Tcl_GetString(objv[2]); | 3730 zSql = Tcl_GetString(objv[2]); |
3606 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; | 3731 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; |
3607 | 3732 |
3608 rc = sqlite3_prepare_v2(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); | 3733 rc = sqlite3_prepare_v2(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); |
3609 assert(rc==SQLITE_OK || pStmt==0); | 3734 assert(rc==SQLITE_OK || pStmt==0); |
3610 Tcl_ResetResult(interp); | 3735 Tcl_ResetResult(interp); |
3611 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 3736 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
3612 if( zTail && objc>=5 ){ | 3737 if( zTail && objc>=5 ){ |
3613 if( bytes>=0 ){ | 3738 if( bytes>=0 ){ |
3614 bytes = bytes - (zTail-zSql); | 3739 bytes = bytes - (int)(zTail-zSql); |
3615 } | 3740 } |
3616 Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); | 3741 Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); |
3617 } | 3742 } |
3618 if( rc!=SQLITE_OK ){ | 3743 if( rc!=SQLITE_OK ){ |
3619 assert( pStmt==0 ); | 3744 assert( pStmt==0 ); |
3620 sprintf(zBuf, "(%d) ", rc); | 3745 sprintf(zBuf, "(%d) ", rc); |
3621 Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); | 3746 Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); |
3622 return TCL_ERROR; | 3747 return TCL_ERROR; |
3623 } | 3748 } |
3624 | 3749 |
3625 if( pStmt ){ | 3750 if( pStmt ){ |
3626 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; | 3751 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; |
3627 Tcl_AppendResult(interp, zBuf, 0); | 3752 Tcl_AppendResult(interp, zBuf, 0); |
3628 } | 3753 } |
3629 return TCL_OK; | 3754 return TCL_OK; |
3630 } | 3755 } |
3631 | 3756 |
3632 /* | 3757 /* |
3633 ** Usage: sqlite3_prepare_tkt3134 DB | 3758 ** Usage: sqlite3_prepare_tkt3134 DB |
3634 ** | 3759 ** |
3635 ** Generate a prepared statement for a zero-byte string as a test | 3760 ** Generate a prepared statement for a zero-byte string as a test |
3636 ** for ticket #3134. The string should be preceeded by a zero byte. | 3761 ** for ticket #3134. The string should be preceded by a zero byte. |
3637 */ | 3762 */ |
3638 static int test_prepare_tkt3134( | 3763 static int test_prepare_tkt3134( |
3639 void * clientData, | 3764 void * clientData, |
3640 Tcl_Interp *interp, | 3765 Tcl_Interp *interp, |
3641 int objc, | 3766 int objc, |
3642 Tcl_Obj *CONST objv[] | 3767 Tcl_Obj *CONST objv[] |
3643 ){ | 3768 ){ |
3644 sqlite3 *db; | 3769 sqlite3 *db; |
3645 static const char zSql[] = "\000SELECT 1"; | 3770 static const char zSql[] = "\000SELECT 1"; |
3646 sqlite3_stmt *pStmt = 0; | 3771 sqlite3_stmt *pStmt = 0; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3705 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; | 3830 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; |
3706 | 3831 |
3707 rc = sqlite3_prepare16(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); | 3832 rc = sqlite3_prepare16(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); |
3708 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 3833 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
3709 if( rc ){ | 3834 if( rc ){ |
3710 return TCL_ERROR; | 3835 return TCL_ERROR; |
3711 } | 3836 } |
3712 | 3837 |
3713 if( objc>=5 ){ | 3838 if( objc>=5 ){ |
3714 if( zTail ){ | 3839 if( zTail ){ |
3715 objlen = objlen - ((u8 *)zTail-(u8 *)zSql); | 3840 objlen = objlen - (int)((u8 *)zTail-(u8 *)zSql); |
3716 }else{ | 3841 }else{ |
3717 objlen = 0; | 3842 objlen = 0; |
3718 } | 3843 } |
3719 pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen); | 3844 pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen); |
3720 Tcl_IncrRefCount(pTail); | 3845 Tcl_IncrRefCount(pTail); |
3721 Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); | 3846 Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); |
3722 Tcl_DecrRefCount(pTail); | 3847 Tcl_DecrRefCount(pTail); |
3723 } | 3848 } |
3724 | 3849 |
3725 if( pStmt ){ | 3850 if( pStmt ){ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3765 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; | 3890 if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; |
3766 | 3891 |
3767 rc = sqlite3_prepare16_v2(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); | 3892 rc = sqlite3_prepare16_v2(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0); |
3768 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 3893 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
3769 if( rc ){ | 3894 if( rc ){ |
3770 return TCL_ERROR; | 3895 return TCL_ERROR; |
3771 } | 3896 } |
3772 | 3897 |
3773 if( objc>=5 ){ | 3898 if( objc>=5 ){ |
3774 if( zTail ){ | 3899 if( zTail ){ |
3775 objlen = objlen - ((u8 *)zTail-(u8 *)zSql); | 3900 objlen = objlen - (int)((u8 *)zTail-(u8 *)zSql); |
3776 }else{ | 3901 }else{ |
3777 objlen = 0; | 3902 objlen = 0; |
3778 } | 3903 } |
3779 pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen); | 3904 pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen); |
3780 Tcl_IncrRefCount(pTail); | 3905 Tcl_IncrRefCount(pTail); |
3781 Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); | 3906 Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); |
3782 Tcl_DecrRefCount(pTail); | 3907 Tcl_DecrRefCount(pTail); |
3783 } | 3908 } |
3784 | 3909 |
3785 if( pStmt ){ | 3910 if( pStmt ){ |
3786 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; | 3911 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; |
3787 } | 3912 } |
3788 Tcl_AppendResult(interp, zBuf, 0); | 3913 Tcl_AppendResult(interp, zBuf, 0); |
3789 #endif /* SQLITE_OMIT_UTF16 */ | 3914 #endif /* SQLITE_OMIT_UTF16 */ |
3790 return TCL_OK; | 3915 return TCL_OK; |
3791 } | 3916 } |
3792 | 3917 |
3793 /* | 3918 /* |
3794 ** Usage: sqlite3_open filename ?options-list? | 3919 ** Usage: sqlite3_open filename ?options-list? |
3795 */ | 3920 */ |
3796 static int test_open( | 3921 static int test_open( |
3797 void * clientData, | 3922 void * clientData, |
3798 Tcl_Interp *interp, | 3923 Tcl_Interp *interp, |
3799 int objc, | 3924 int objc, |
3800 Tcl_Obj *CONST objv[] | 3925 Tcl_Obj *CONST objv[] |
3801 ){ | 3926 ){ |
3802 const char *zFilename; | 3927 const char *zFilename; |
3803 sqlite3 *db; | 3928 sqlite3 *db; |
3804 int rc; | |
3805 char zBuf[100]; | 3929 char zBuf[100]; |
3806 | 3930 |
3807 if( objc!=3 && objc!=2 && objc!=1 ){ | 3931 if( objc!=3 && objc!=2 && objc!=1 ){ |
3808 Tcl_AppendResult(interp, "wrong # args: should be \"", | 3932 Tcl_AppendResult(interp, "wrong # args: should be \"", |
3809 Tcl_GetString(objv[0]), " filename options-list", 0); | 3933 Tcl_GetString(objv[0]), " filename options-list", 0); |
3810 return TCL_ERROR; | 3934 return TCL_ERROR; |
3811 } | 3935 } |
3812 | 3936 |
3813 zFilename = objc>1 ? Tcl_GetString(objv[1]) : 0; | 3937 zFilename = objc>1 ? Tcl_GetString(objv[1]) : 0; |
3814 rc = sqlite3_open(zFilename, &db); | 3938 sqlite3_open(zFilename, &db); |
3815 | 3939 |
3816 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; | 3940 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |
3817 Tcl_AppendResult(interp, zBuf, 0); | 3941 Tcl_AppendResult(interp, zBuf, 0); |
3818 return TCL_OK; | 3942 return TCL_OK; |
3819 } | 3943 } |
3820 | 3944 |
3821 /* | 3945 /* |
| 3946 ** Usage: sqlite3_open_v2 FILENAME FLAGS VFS |
| 3947 */ |
| 3948 static int test_open_v2( |
| 3949 void * clientData, |
| 3950 Tcl_Interp *interp, |
| 3951 int objc, |
| 3952 Tcl_Obj *CONST objv[] |
| 3953 ){ |
| 3954 const char *zFilename; |
| 3955 const char *zVfs; |
| 3956 int flags = 0; |
| 3957 sqlite3 *db; |
| 3958 int rc; |
| 3959 char zBuf[100]; |
| 3960 |
| 3961 int nFlag; |
| 3962 Tcl_Obj **apFlag; |
| 3963 int i; |
| 3964 |
| 3965 if( objc!=4 ){ |
| 3966 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME FLAGS VFS"); |
| 3967 return TCL_ERROR; |
| 3968 } |
| 3969 zFilename = Tcl_GetString(objv[1]); |
| 3970 zVfs = Tcl_GetString(objv[3]); |
| 3971 if( zVfs[0]==0x00 ) zVfs = 0; |
| 3972 |
| 3973 rc = Tcl_ListObjGetElements(interp, objv[2], &nFlag, &apFlag); |
| 3974 if( rc!=TCL_OK ) return rc; |
| 3975 for(i=0; i<nFlag; i++){ |
| 3976 int iFlag; |
| 3977 struct OpenFlag { |
| 3978 const char *zFlag; |
| 3979 int flag; |
| 3980 } aFlag[] = { |
| 3981 { "SQLITE_OPEN_READONLY", SQLITE_OPEN_READONLY }, |
| 3982 { "SQLITE_OPEN_READWRITE", SQLITE_OPEN_READWRITE }, |
| 3983 { "SQLITE_OPEN_CREATE", SQLITE_OPEN_CREATE }, |
| 3984 { "SQLITE_OPEN_DELETEONCLOSE", SQLITE_OPEN_DELETEONCLOSE }, |
| 3985 { "SQLITE_OPEN_EXCLUSIVE", SQLITE_OPEN_EXCLUSIVE }, |
| 3986 { "SQLITE_OPEN_AUTOPROXY", SQLITE_OPEN_AUTOPROXY }, |
| 3987 { "SQLITE_OPEN_MAIN_DB", SQLITE_OPEN_MAIN_DB }, |
| 3988 { "SQLITE_OPEN_TEMP_DB", SQLITE_OPEN_TEMP_DB }, |
| 3989 { "SQLITE_OPEN_TRANSIENT_DB", SQLITE_OPEN_TRANSIENT_DB }, |
| 3990 { "SQLITE_OPEN_MAIN_JOURNAL", SQLITE_OPEN_MAIN_JOURNAL }, |
| 3991 { "SQLITE_OPEN_TEMP_JOURNAL", SQLITE_OPEN_TEMP_JOURNAL }, |
| 3992 { "SQLITE_OPEN_SUBJOURNAL", SQLITE_OPEN_SUBJOURNAL }, |
| 3993 { "SQLITE_OPEN_MASTER_JOURNAL", SQLITE_OPEN_MASTER_JOURNAL }, |
| 3994 { "SQLITE_OPEN_NOMUTEX", SQLITE_OPEN_NOMUTEX }, |
| 3995 { "SQLITE_OPEN_FULLMUTEX", SQLITE_OPEN_FULLMUTEX }, |
| 3996 { "SQLITE_OPEN_SHAREDCACHE", SQLITE_OPEN_SHAREDCACHE }, |
| 3997 { "SQLITE_OPEN_PRIVATECACHE", SQLITE_OPEN_PRIVATECACHE }, |
| 3998 { "SQLITE_OPEN_WAL", SQLITE_OPEN_WAL }, |
| 3999 { "SQLITE_OPEN_URI", SQLITE_OPEN_URI }, |
| 4000 { 0, 0 } |
| 4001 }; |
| 4002 rc = Tcl_GetIndexFromObjStruct(interp, apFlag[i], aFlag, sizeof(aFlag[0]), |
| 4003 "flag", 0, &iFlag |
| 4004 ); |
| 4005 if( rc!=TCL_OK ) return rc; |
| 4006 flags |= aFlag[iFlag].flag; |
| 4007 } |
| 4008 |
| 4009 rc = sqlite3_open_v2(zFilename, &db, flags, zVfs); |
| 4010 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |
| 4011 Tcl_AppendResult(interp, zBuf, 0); |
| 4012 return TCL_OK; |
| 4013 } |
| 4014 |
| 4015 /* |
3822 ** Usage: sqlite3_open16 filename options | 4016 ** Usage: sqlite3_open16 filename options |
3823 */ | 4017 */ |
3824 static int test_open16( | 4018 static int test_open16( |
3825 void * clientData, | 4019 void * clientData, |
3826 Tcl_Interp *interp, | 4020 Tcl_Interp *interp, |
3827 int objc, | 4021 int objc, |
3828 Tcl_Obj *CONST objv[] | 4022 Tcl_Obj *CONST objv[] |
3829 ){ | 4023 ){ |
3830 #ifndef SQLITE_OMIT_UTF16 | 4024 #ifndef SQLITE_OMIT_UTF16 |
3831 const void *zFilename; | 4025 const void *zFilename; |
3832 sqlite3 *db; | 4026 sqlite3 *db; |
3833 int rc; | |
3834 char zBuf[100]; | 4027 char zBuf[100]; |
3835 | 4028 |
3836 if( objc!=3 ){ | 4029 if( objc!=3 ){ |
3837 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4030 Tcl_AppendResult(interp, "wrong # args: should be \"", |
3838 Tcl_GetString(objv[0]), " filename options-list", 0); | 4031 Tcl_GetString(objv[0]), " filename options-list", 0); |
3839 return TCL_ERROR; | 4032 return TCL_ERROR; |
3840 } | 4033 } |
3841 | 4034 |
3842 zFilename = Tcl_GetByteArrayFromObj(objv[1], 0); | 4035 zFilename = Tcl_GetByteArrayFromObj(objv[1], 0); |
3843 rc = sqlite3_open16(zFilename, &db); | 4036 sqlite3_open16(zFilename, &db); |
3844 | 4037 |
3845 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; | 4038 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |
3846 Tcl_AppendResult(interp, zBuf, 0); | 4039 Tcl_AppendResult(interp, zBuf, 0); |
3847 #endif /* SQLITE_OMIT_UTF16 */ | 4040 #endif /* SQLITE_OMIT_UTF16 */ |
3848 return TCL_OK; | 4041 return TCL_OK; |
3849 } | 4042 } |
3850 | 4043 |
3851 /* | 4044 /* |
3852 ** Usage: sqlite3_complete16 <UTF-16 string> | 4045 ** Usage: sqlite3_complete16 <UTF-16 string> |
3853 ** | 4046 ** |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4288 } | 4481 } |
4289 | 4482 |
4290 static u8 *sqlite3_stack_baseline = 0; | 4483 static u8 *sqlite3_stack_baseline = 0; |
4291 | 4484 |
4292 /* | 4485 /* |
4293 ** Fill the stack with a known bitpattern. | 4486 ** Fill the stack with a known bitpattern. |
4294 */ | 4487 */ |
4295 static void prepStack(void){ | 4488 static void prepStack(void){ |
4296 int i; | 4489 int i; |
4297 u32 bigBuf[65536]; | 4490 u32 bigBuf[65536]; |
4298 for(i=0; i<sizeof(bigBuf); i++) bigBuf[i] = 0xdeadbeef; | 4491 for(i=0; i<sizeof(bigBuf)/sizeof(bigBuf[0]); i++) bigBuf[i] = 0xdeadbeef; |
4299 sqlite3_stack_baseline = (u8*)&bigBuf[65536]; | 4492 sqlite3_stack_baseline = (u8*)&bigBuf[65536]; |
4300 } | 4493 } |
4301 | 4494 |
4302 /* | 4495 /* |
4303 ** Get the current stack depth. Used for debugging only. | 4496 ** Get the current stack depth. Used for debugging only. |
4304 */ | 4497 */ |
4305 u64 sqlite3StackDepth(void){ | 4498 u64 sqlite3StackDepth(void){ |
4306 u8 x; | 4499 u8 x; |
4307 return (u64)(sqlite3_stack_baseline - &x); | 4500 return (u64)(sqlite3_stack_baseline - &x); |
4308 } | 4501 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4426 int rc, ms; | 4619 int rc, ms; |
4427 sqlite3 *db; | 4620 sqlite3 *db; |
4428 if( argc!=3 ){ | 4621 if( argc!=3 ){ |
4429 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 4622 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
4430 " DB", 0); | 4623 " DB", 0); |
4431 return TCL_ERROR; | 4624 return TCL_ERROR; |
4432 } | 4625 } |
4433 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 4626 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
4434 if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR; | 4627 if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR; |
4435 rc = sqlite3_busy_timeout(db, ms); | 4628 rc = sqlite3_busy_timeout(db, ms); |
4436 Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); | 4629 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
4437 return TCL_OK; | 4630 return TCL_OK; |
4438 } | 4631 } |
4439 | 4632 |
4440 /* | 4633 /* |
4441 ** Usage: tcl_variable_type VARIABLENAME | 4634 ** Usage: tcl_variable_type VARIABLENAME |
4442 ** | 4635 ** |
4443 ** Return the name of the internal representation for the | 4636 ** Return the name of the internal representation for the |
4444 ** value of the given variable. | 4637 ** value of the given variable. |
4445 */ | 4638 */ |
4446 static int tcl_variable_type( | 4639 static int tcl_variable_type( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4486 if( Tcl_GetIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; | 4679 if( Tcl_GetIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; |
4487 }else{ | 4680 }else{ |
4488 N = -1; | 4681 N = -1; |
4489 } | 4682 } |
4490 amt = sqlite3_release_memory(N); | 4683 amt = sqlite3_release_memory(N); |
4491 Tcl_SetObjResult(interp, Tcl_NewIntObj(amt)); | 4684 Tcl_SetObjResult(interp, Tcl_NewIntObj(amt)); |
4492 #endif | 4685 #endif |
4493 return TCL_OK; | 4686 return TCL_OK; |
4494 } | 4687 } |
4495 | 4688 |
| 4689 |
| 4690 /* |
| 4691 ** Usage: sqlite3_db_release_memory DB |
| 4692 ** |
| 4693 ** Attempt to release memory currently held by database DB. Return the |
| 4694 ** result code (which in the current implementation is always zero). |
| 4695 */ |
| 4696 static int test_db_release_memory( |
| 4697 void * clientData, |
| 4698 Tcl_Interp *interp, |
| 4699 int objc, |
| 4700 Tcl_Obj *CONST objv[] |
| 4701 ){ |
| 4702 sqlite3 *db; |
| 4703 int rc; |
| 4704 if( objc!=2 ){ |
| 4705 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 4706 return TCL_ERROR; |
| 4707 } |
| 4708 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4709 rc = sqlite3_db_release_memory(db); |
| 4710 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
| 4711 return TCL_OK; |
| 4712 } |
| 4713 |
| 4714 /* |
| 4715 ** Usage: sqlite3_db_filename DB DBNAME |
| 4716 ** |
| 4717 ** Return the name of a file associated with a database. |
| 4718 */ |
| 4719 static int test_db_filename( |
| 4720 void * clientData, |
| 4721 Tcl_Interp *interp, |
| 4722 int objc, |
| 4723 Tcl_Obj *CONST objv[] |
| 4724 ){ |
| 4725 sqlite3 *db; |
| 4726 const char *zDbName; |
| 4727 if( objc!=3 ){ |
| 4728 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 4729 return TCL_ERROR; |
| 4730 } |
| 4731 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4732 zDbName = Tcl_GetString(objv[2]); |
| 4733 Tcl_AppendResult(interp, sqlite3_db_filename(db, zDbName), (void*)0); |
| 4734 return TCL_OK; |
| 4735 } |
| 4736 |
| 4737 /* |
| 4738 ** Usage: sqlite3_db_readonly DB DBNAME |
| 4739 ** |
| 4740 ** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does |
| 4741 ** not exist. |
| 4742 */ |
| 4743 static int test_db_readonly( |
| 4744 void * clientData, |
| 4745 Tcl_Interp *interp, |
| 4746 int objc, |
| 4747 Tcl_Obj *CONST objv[] |
| 4748 ){ |
| 4749 sqlite3 *db; |
| 4750 const char *zDbName; |
| 4751 if( objc!=3 ){ |
| 4752 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 4753 return TCL_ERROR; |
| 4754 } |
| 4755 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4756 zDbName = Tcl_GetString(objv[2]); |
| 4757 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName))); |
| 4758 return TCL_OK; |
| 4759 } |
| 4760 |
4496 /* | 4761 /* |
4497 ** Usage: sqlite3_soft_heap_limit ?N? | 4762 ** Usage: sqlite3_soft_heap_limit ?N? |
4498 ** | 4763 ** |
4499 ** Query or set the soft heap limit for the current thread. The | 4764 ** Query or set the soft heap limit for the current thread. The |
4500 ** limit is only changed if the N is present. The previous limit | 4765 ** limit is only changed if the N is present. The previous limit |
4501 ** is returned. | 4766 ** is returned. |
4502 */ | 4767 */ |
4503 static int test_soft_heap_limit( | 4768 static int test_soft_heap_limit( |
4504 void * clientData, | 4769 void * clientData, |
4505 Tcl_Interp *interp, | 4770 Tcl_Interp *interp, |
4506 int objc, | 4771 int objc, |
4507 Tcl_Obj *CONST objv[] | 4772 Tcl_Obj *CONST objv[] |
4508 ){ | 4773 ){ |
4509 sqlite3_int64 amt; | 4774 sqlite3_int64 amt; |
4510 sqlite3_int64 N = -1; | 4775 Tcl_WideInt N = -1; |
4511 if( objc!=1 && objc!=2 ){ | 4776 if( objc!=1 && objc!=2 ){ |
4512 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); | 4777 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); |
4513 return TCL_ERROR; | 4778 return TCL_ERROR; |
4514 } | 4779 } |
4515 if( objc==2 ){ | 4780 if( objc==2 ){ |
4516 if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; | 4781 if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; |
4517 } | 4782 } |
4518 amt = sqlite3_soft_heap_limit64(N); | 4783 amt = sqlite3_soft_heap_limit64(N); |
4519 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); | 4784 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); |
4520 return TCL_OK; | 4785 return TCL_OK; |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4875 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) | 5140 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) |
4876 || Tcl_GetIntFromObj(interp, objv[3], &nSize) | 5141 || Tcl_GetIntFromObj(interp, objv[3], &nSize) |
4877 ){ | 5142 ){ |
4878 return TCL_ERROR; | 5143 return TCL_ERROR; |
4879 } | 5144 } |
4880 zDb = Tcl_GetString(objv[2]); | 5145 zDb = Tcl_GetString(objv[2]); |
4881 if( zDb[0]=='\0' ) zDb = NULL; | 5146 if( zDb[0]=='\0' ) zDb = NULL; |
4882 | 5147 |
4883 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_CHUNK_SIZE, (void *)&nSize); | 5148 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_CHUNK_SIZE, (void *)&nSize); |
4884 if( rc ){ | 5149 if( rc ){ |
4885 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 5150 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
4886 return TCL_ERROR; | 5151 return TCL_ERROR; |
4887 } | 5152 } |
4888 return TCL_OK; | 5153 return TCL_OK; |
4889 } | 5154 } |
4890 | 5155 |
4891 /* | 5156 /* |
4892 ** tclcmd: file_control_sizehint_test DB DBNAME SIZE | 5157 ** tclcmd: file_control_sizehint_test DB DBNAME SIZE |
4893 ** | 5158 ** |
4894 ** This TCL command runs the sqlite3_file_control interface and | 5159 ** This TCL command runs the sqlite3_file_control interface |
4895 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and | 5160 ** with SQLITE_FCNTL_SIZE_HINT |
4896 ** SQLITE_SET_LOCKPROXYFILE verbs. | |
4897 */ | 5161 */ |
4898 static int file_control_sizehint_test( | 5162 static int file_control_sizehint_test( |
4899 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5163 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
4900 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5164 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
4901 int objc, /* Number of arguments */ | 5165 int objc, /* Number of arguments */ |
4902 Tcl_Obj *CONST objv[] /* Command arguments */ | 5166 Tcl_Obj *CONST objv[] /* Command arguments */ |
4903 ){ | 5167 ){ |
4904 sqlite3_int64 nSize; /* Hinted size */ | 5168 Tcl_WideInt nSize; /* Hinted size */ |
4905 char *zDb; /* Db name ("main", "temp" etc.) */ | 5169 char *zDb; /* Db name ("main", "temp" etc.) */ |
4906 sqlite3 *db; /* Database handle */ | 5170 sqlite3 *db; /* Database handle */ |
4907 int rc; /* file_control() return code */ | 5171 int rc; /* file_control() return code */ |
4908 | 5172 |
4909 if( objc!=4 ){ | 5173 if( objc!=4 ){ |
4910 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SIZE"); | 5174 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SIZE"); |
4911 return TCL_ERROR; | 5175 return TCL_ERROR; |
4912 } | 5176 } |
4913 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) | 5177 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) |
4914 || Tcl_GetWideIntFromObj(interp, objv[3], &nSize) | 5178 || Tcl_GetWideIntFromObj(interp, objv[3], &nSize) |
4915 ){ | 5179 ){ |
4916 return TCL_ERROR; | 5180 return TCL_ERROR; |
4917 } | 5181 } |
4918 zDb = Tcl_GetString(objv[2]); | 5182 zDb = Tcl_GetString(objv[2]); |
4919 if( zDb[0]=='\0' ) zDb = NULL; | 5183 if( zDb[0]=='\0' ) zDb = NULL; |
4920 | 5184 |
4921 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_SIZE_HINT, (void *)&nSize); | 5185 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_SIZE_HINT, (void *)&nSize); |
4922 if( rc ){ | 5186 if( rc ){ |
4923 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 5187 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
4924 return TCL_ERROR; | 5188 return TCL_ERROR; |
4925 } | 5189 } |
4926 return TCL_OK; | 5190 return TCL_OK; |
4927 } | 5191 } |
4928 | 5192 |
4929 /* | 5193 /* |
4930 ** tclcmd: file_control_lockproxy_test DB PWD | 5194 ** tclcmd: file_control_lockproxy_test DB PWD |
4931 ** | 5195 ** |
4932 ** This TCL command runs the sqlite3_file_control interface and | 5196 ** This TCL command runs the sqlite3_file_control interface and |
4933 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and | 5197 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and |
4934 ** SQLITE_SET_LOCKPROXYFILE verbs. | 5198 ** SQLITE_SET_LOCKPROXYFILE verbs. |
4935 */ | 5199 */ |
4936 static int file_control_lockproxy_test( | 5200 static int file_control_lockproxy_test( |
4937 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5201 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
4938 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5202 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
4939 int objc, /* Number of arguments */ | 5203 int objc, /* Number of arguments */ |
4940 Tcl_Obj *CONST objv[] /* Command arguments */ | 5204 Tcl_Obj *CONST objv[] /* Command arguments */ |
4941 ){ | 5205 ){ |
4942 sqlite3 *db; | 5206 sqlite3 *db; |
4943 const char *zPwd; | |
4944 int nPwd; | |
4945 | 5207 |
4946 if( objc!=3 ){ | 5208 if( objc!=3 ){ |
4947 Tcl_AppendResult(interp, "wrong # args: should be \"", | 5209 Tcl_AppendResult(interp, "wrong # args: should be \"", |
4948 Tcl_GetStringFromObj(objv[0], 0), " DB PWD", 0); | 5210 Tcl_GetStringFromObj(objv[0], 0), " DB PWD", 0); |
4949 return TCL_ERROR; | 5211 return TCL_ERROR; |
4950 } | 5212 } |
4951 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ | 5213 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
4952 return TCL_ERROR; | 5214 return TCL_ERROR; |
4953 } | 5215 } |
4954 zPwd = Tcl_GetStringFromObj(objv[2], &nPwd); | |
4955 | 5216 |
4956 #if !defined(SQLITE_ENABLE_LOCKING_STYLE) | 5217 #if !defined(SQLITE_ENABLE_LOCKING_STYLE) |
4957 # if defined(__APPLE__) | 5218 # if defined(__APPLE__) |
4958 # define SQLITE_ENABLE_LOCKING_STYLE 1 | 5219 # define SQLITE_ENABLE_LOCKING_STYLE 1 |
4959 # else | 5220 # else |
4960 # define SQLITE_ENABLE_LOCKING_STYLE 0 | 5221 # define SQLITE_ENABLE_LOCKING_STYLE 0 |
4961 # endif | 5222 # endif |
4962 #endif | 5223 #endif |
4963 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) | 5224 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) |
4964 { | 5225 { |
4965 char *testPath; | 5226 char *testPath; |
4966 int rc; | 5227 int rc; |
| 5228 int nPwd; |
| 5229 const char *zPwd; |
4967 char proxyPath[400]; | 5230 char proxyPath[400]; |
4968 | 5231 |
| 5232 zPwd = Tcl_GetStringFromObj(objv[2], &nPwd); |
4969 if( sizeof(proxyPath)<nPwd+20 ){ | 5233 if( sizeof(proxyPath)<nPwd+20 ){ |
4970 Tcl_AppendResult(interp, "PWD too big", (void*)0); | 5234 Tcl_AppendResult(interp, "PWD too big", (void*)0); |
4971 return TCL_ERROR; | 5235 return TCL_ERROR; |
4972 } | 5236 } |
4973 sprintf(proxyPath, "%s/test.proxy", zPwd); | 5237 sprintf(proxyPath, "%s/test.proxy", zPwd); |
4974 rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath); | 5238 rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath); |
4975 if( rc ){ | 5239 if( rc ){ |
4976 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 5240 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
4977 return TCL_ERROR; | 5241 return TCL_ERROR; |
4978 } | 5242 } |
(...skipping 10 matching lines...) Expand all Loading... |
4989 rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath); | 5253 rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath); |
4990 if( rc ){ | 5254 if( rc ){ |
4991 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 5255 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
4992 return TCL_ERROR; | 5256 return TCL_ERROR; |
4993 } | 5257 } |
4994 } | 5258 } |
4995 #endif | 5259 #endif |
4996 return TCL_OK; | 5260 return TCL_OK; |
4997 } | 5261 } |
4998 | 5262 |
4999 | 5263 #if SQLITE_OS_WIN |
5000 /* | 5264 /* |
5001 ** tclcmd: sqlite3_vfs_list | 5265 ** tclcmd: file_control_win32_av_retry DB NRETRY DELAY |
5002 ** | 5266 ** |
5003 ** Return a tcl list containing the names of all registered vfs's. | 5267 ** This TCL command runs the sqlite3_file_control interface with |
| 5268 ** the SQLITE_FCNTL_WIN32_AV_RETRY opcode. |
5004 */ | 5269 */ |
5005 static int vfs_list( | 5270 static int file_control_win32_av_retry( |
5006 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5271 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
5007 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5272 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5008 int objc, /* Number of arguments */ | 5273 int objc, /* Number of arguments */ |
5009 Tcl_Obj *CONST objv[] /* Command arguments */ | 5274 Tcl_Obj *CONST objv[] /* Command arguments */ |
5010 ){ | 5275 ){ |
5011 sqlite3_vfs *pVfs; | 5276 sqlite3 *db; |
5012 Tcl_Obj *pRet = Tcl_NewObj(); | 5277 int rc; |
5013 if( objc!=1 ){ | 5278 int a[2]; |
5014 Tcl_WrongNumArgs(interp, 1, objv, ""); | 5279 char z[100]; |
| 5280 |
| 5281 if( objc!=4 ){ |
| 5282 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5283 Tcl_GetStringFromObj(objv[0], 0), " DB NRETRY DELAY", 0); |
5015 return TCL_ERROR; | 5284 return TCL_ERROR; |
5016 } | 5285 } |
5017 for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){ | 5286 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
5018 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(pVfs->zName, -1)); | 5287 return TCL_ERROR; |
5019 } | 5288 } |
5020 Tcl_SetObjResult(interp, pRet); | 5289 if( Tcl_GetIntFromObj(interp, objv[2], &a[0]) ) return TCL_ERROR; |
| 5290 if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR; |
| 5291 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a); |
| 5292 sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]); |
| 5293 Tcl_AppendResult(interp, z, (char*)0); |
5021 return TCL_OK; | 5294 return TCL_OK; |
5022 } | 5295 } |
5023 | 5296 |
5024 /* | 5297 /* |
5025 ** tclcmd: sqlite3_limit DB ID VALUE | 5298 ** tclcmd: file_control_win32_set_handle DB HANDLE |
5026 ** | 5299 ** |
5027 ** This TCL command runs the sqlite3_limit interface and | 5300 ** This TCL command runs the sqlite3_file_control interface with |
5028 ** verifies correct operation of the same. | 5301 ** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode. |
5029 */ | 5302 */ |
5030 static int test_limit( | 5303 static int file_control_win32_set_handle( |
5031 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5304 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
5032 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5305 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5033 int objc, /* Number of arguments */ | 5306 int objc, /* Number of arguments */ |
5034 Tcl_Obj *CONST objv[] /* Command arguments */ | 5307 Tcl_Obj *CONST objv[] /* Command arguments */ |
5035 ){ | 5308 ){ |
5036 sqlite3 *db; | 5309 sqlite3 *db; |
5037 int rc; | 5310 int rc; |
| 5311 HANDLE hFile = NULL; |
| 5312 char z[100]; |
| 5313 |
| 5314 if( objc!=3 ){ |
| 5315 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5316 Tcl_GetStringFromObj(objv[0], 0), " DB HANDLE", 0); |
| 5317 return TCL_ERROR; |
| 5318 } |
| 5319 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5320 return TCL_ERROR; |
| 5321 } |
| 5322 if( getWin32Handle(interp, Tcl_GetString(objv[2]), &hFile) ){ |
| 5323 return TCL_ERROR; |
| 5324 } |
| 5325 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_SET_HANDLE, |
| 5326 (void*)&hFile); |
| 5327 sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile); |
| 5328 Tcl_AppendResult(interp, z, (char*)0); |
| 5329 return TCL_OK; |
| 5330 } |
| 5331 #endif |
| 5332 |
| 5333 /* |
| 5334 ** tclcmd: file_control_persist_wal DB PERSIST-FLAG |
| 5335 ** |
| 5336 ** This TCL command runs the sqlite3_file_control interface with |
| 5337 ** the SQLITE_FCNTL_PERSIST_WAL opcode. |
| 5338 */ |
| 5339 static int file_control_persist_wal( |
| 5340 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5341 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5342 int objc, /* Number of arguments */ |
| 5343 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5344 ){ |
| 5345 sqlite3 *db; |
| 5346 int rc; |
| 5347 int bPersist; |
| 5348 char z[100]; |
| 5349 |
| 5350 if( objc!=3 ){ |
| 5351 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5352 Tcl_GetStringFromObj(objv[0], 0), " DB FLAG", 0); |
| 5353 return TCL_ERROR; |
| 5354 } |
| 5355 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5356 return TCL_ERROR; |
| 5357 } |
| 5358 if( Tcl_GetIntFromObj(interp, objv[2], &bPersist) ) return TCL_ERROR; |
| 5359 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, (void*)&bPersist
); |
| 5360 sqlite3_snprintf(sizeof(z), z, "%d %d", rc, bPersist); |
| 5361 Tcl_AppendResult(interp, z, (char*)0); |
| 5362 return TCL_OK; |
| 5363 } |
| 5364 |
| 5365 /* |
| 5366 ** tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG |
| 5367 ** |
| 5368 ** This TCL command runs the sqlite3_file_control interface with |
| 5369 ** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode. |
| 5370 */ |
| 5371 static int file_control_powersafe_overwrite( |
| 5372 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5373 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5374 int objc, /* Number of arguments */ |
| 5375 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5376 ){ |
| 5377 sqlite3 *db; |
| 5378 int rc; |
| 5379 int b; |
| 5380 char z[100]; |
| 5381 |
| 5382 if( objc!=3 ){ |
| 5383 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5384 Tcl_GetStringFromObj(objv[0], 0), " DB FLAG", 0); |
| 5385 return TCL_ERROR; |
| 5386 } |
| 5387 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5388 return TCL_ERROR; |
| 5389 } |
| 5390 if( Tcl_GetIntFromObj(interp, objv[2], &b) ) return TCL_ERROR; |
| 5391 rc = sqlite3_file_control(db,NULL,SQLITE_FCNTL_POWERSAFE_OVERWRITE,(void*)&b); |
| 5392 sqlite3_snprintf(sizeof(z), z, "%d %d", rc, b); |
| 5393 Tcl_AppendResult(interp, z, (char*)0); |
| 5394 return TCL_OK; |
| 5395 } |
| 5396 |
| 5397 |
| 5398 /* |
| 5399 ** tclcmd: file_control_vfsname DB ?AUXDB? |
| 5400 ** |
| 5401 ** Return a string that describes the stack of VFSes. |
| 5402 */ |
| 5403 static int file_control_vfsname( |
| 5404 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5405 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5406 int objc, /* Number of arguments */ |
| 5407 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5408 ){ |
| 5409 sqlite3 *db; |
| 5410 const char *zDbName = "main"; |
| 5411 char *zVfsName = 0; |
| 5412 |
| 5413 if( objc!=2 && objc!=3 ){ |
| 5414 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5415 Tcl_GetStringFromObj(objv[0], 0), " DB ?AUXDB?", 0); |
| 5416 return TCL_ERROR; |
| 5417 } |
| 5418 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5419 return TCL_ERROR; |
| 5420 } |
| 5421 if( objc==3 ){ |
| 5422 zDbName = Tcl_GetString(objv[2]); |
| 5423 } |
| 5424 sqlite3_file_control(db, zDbName, SQLITE_FCNTL_VFSNAME,(void*)&zVfsName); |
| 5425 Tcl_AppendResult(interp, zVfsName, (char*)0); |
| 5426 sqlite3_free(zVfsName); |
| 5427 return TCL_OK; |
| 5428 } |
| 5429 |
| 5430 /* |
| 5431 ** tclcmd: file_control_tempfilename DB ?AUXDB? |
| 5432 ** |
| 5433 ** Return a string that is a temporary filename |
| 5434 */ |
| 5435 static int file_control_tempfilename( |
| 5436 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5437 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5438 int objc, /* Number of arguments */ |
| 5439 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5440 ){ |
| 5441 sqlite3 *db; |
| 5442 const char *zDbName = "main"; |
| 5443 char *zTName = 0; |
| 5444 |
| 5445 if( objc!=2 && objc!=3 ){ |
| 5446 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5447 Tcl_GetStringFromObj(objv[0], 0), " DB ?AUXDB?", 0); |
| 5448 return TCL_ERROR; |
| 5449 } |
| 5450 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5451 return TCL_ERROR; |
| 5452 } |
| 5453 if( objc==3 ){ |
| 5454 zDbName = Tcl_GetString(objv[2]); |
| 5455 } |
| 5456 sqlite3_file_control(db, zDbName, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTName); |
| 5457 Tcl_AppendResult(interp, zTName, (char*)0); |
| 5458 sqlite3_free(zTName); |
| 5459 return TCL_OK; |
| 5460 } |
| 5461 |
| 5462 |
| 5463 /* |
| 5464 ** tclcmd: sqlite3_vfs_list |
| 5465 ** |
| 5466 ** Return a tcl list containing the names of all registered vfs's. |
| 5467 */ |
| 5468 static int vfs_list( |
| 5469 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5470 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5471 int objc, /* Number of arguments */ |
| 5472 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5473 ){ |
| 5474 sqlite3_vfs *pVfs; |
| 5475 Tcl_Obj *pRet = Tcl_NewObj(); |
| 5476 if( objc!=1 ){ |
| 5477 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 5478 return TCL_ERROR; |
| 5479 } |
| 5480 for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){ |
| 5481 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(pVfs->zName, -1)); |
| 5482 } |
| 5483 Tcl_SetObjResult(interp, pRet); |
| 5484 return TCL_OK; |
| 5485 } |
| 5486 |
| 5487 /* |
| 5488 ** tclcmd: sqlite3_limit DB ID VALUE |
| 5489 ** |
| 5490 ** This TCL command runs the sqlite3_limit interface and |
| 5491 ** verifies correct operation of the same. |
| 5492 */ |
| 5493 static int test_limit( |
| 5494 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5495 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5496 int objc, /* Number of arguments */ |
| 5497 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5498 ){ |
| 5499 sqlite3 *db; |
| 5500 int rc; |
5038 static const struct { | 5501 static const struct { |
5039 char *zName; | 5502 char *zName; |
5040 int id; | 5503 int id; |
5041 } aId[] = { | 5504 } aId[] = { |
5042 { "SQLITE_LIMIT_LENGTH", SQLITE_LIMIT_LENGTH }, | 5505 { "SQLITE_LIMIT_LENGTH", SQLITE_LIMIT_LENGTH }, |
5043 { "SQLITE_LIMIT_SQL_LENGTH", SQLITE_LIMIT_SQL_LENGTH }, | 5506 { "SQLITE_LIMIT_SQL_LENGTH", SQLITE_LIMIT_SQL_LENGTH }, |
5044 { "SQLITE_LIMIT_COLUMN", SQLITE_LIMIT_COLUMN }, | 5507 { "SQLITE_LIMIT_COLUMN", SQLITE_LIMIT_COLUMN }, |
5045 { "SQLITE_LIMIT_EXPR_DEPTH", SQLITE_LIMIT_EXPR_DEPTH }, | 5508 { "SQLITE_LIMIT_EXPR_DEPTH", SQLITE_LIMIT_EXPR_DEPTH }, |
5046 { "SQLITE_LIMIT_COMPOUND_SELECT", SQLITE_LIMIT_COMPOUND_SELECT }, | 5509 { "SQLITE_LIMIT_COMPOUND_SELECT", SQLITE_LIMIT_COMPOUND_SELECT }, |
5047 { "SQLITE_LIMIT_VDBE_OP", SQLITE_LIMIT_VDBE_OP }, | 5510 { "SQLITE_LIMIT_VDBE_OP", SQLITE_LIMIT_VDBE_OP }, |
5048 { "SQLITE_LIMIT_FUNCTION_ARG", SQLITE_LIMIT_FUNCTION_ARG }, | 5511 { "SQLITE_LIMIT_FUNCTION_ARG", SQLITE_LIMIT_FUNCTION_ARG }, |
5049 { "SQLITE_LIMIT_ATTACHED", SQLITE_LIMIT_ATTACHED }, | 5512 { "SQLITE_LIMIT_ATTACHED", SQLITE_LIMIT_ATTACHED }, |
5050 { "SQLITE_LIMIT_LIKE_PATTERN_LENGTH", SQLITE_LIMIT_LIKE_PATTERN_LENGTH }, | 5513 { "SQLITE_LIMIT_LIKE_PATTERN_LENGTH", SQLITE_LIMIT_LIKE_PATTERN_LENGTH }, |
5051 { "SQLITE_LIMIT_VARIABLE_NUMBER", SQLITE_LIMIT_VARIABLE_NUMBER }, | 5514 { "SQLITE_LIMIT_VARIABLE_NUMBER", SQLITE_LIMIT_VARIABLE_NUMBER }, |
5052 { "SQLITE_LIMIT_TRIGGER_DEPTH", SQLITE_LIMIT_TRIGGER_DEPTH }, | 5515 { "SQLITE_LIMIT_TRIGGER_DEPTH", SQLITE_LIMIT_TRIGGER_DEPTH }, |
| 5516 { "SQLITE_LIMIT_WORKER_THREADS", SQLITE_LIMIT_WORKER_THREADS }, |
5053 | 5517 |
5054 /* Out of range test cases */ | 5518 /* Out of range test cases */ |
5055 { "SQLITE_LIMIT_TOOSMALL", -1, }, | 5519 { "SQLITE_LIMIT_TOOSMALL", -1, }, |
5056 { "SQLITE_LIMIT_TOOBIG", SQLITE_LIMIT_TRIGGER_DEPTH+1 }, | 5520 { "SQLITE_LIMIT_TOOBIG", SQLITE_LIMIT_WORKER_THREADS+1 }, |
5057 }; | 5521 }; |
5058 int i, id; | 5522 int i, id; |
5059 int val; | 5523 int val; |
5060 const char *zId; | 5524 const char *zId; |
5061 | 5525 |
5062 if( objc!=4 ){ | 5526 if( objc!=4 ){ |
5063 Tcl_AppendResult(interp, "wrong # args: should be \"", | 5527 Tcl_AppendResult(interp, "wrong # args: should be \"", |
5064 Tcl_GetStringFromObj(objv[0], 0), " DB ID VALUE", 0); | 5528 Tcl_GetStringFromObj(objv[0], 0), " DB ID VALUE", 0); |
5065 return TCL_ERROR; | 5529 return TCL_ERROR; |
5066 } | 5530 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5121 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5585 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
5122 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5586 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5123 int objc, /* Number of arguments */ | 5587 int objc, /* Number of arguments */ |
5124 Tcl_Obj *CONST objv[] /* Command arguments */ | 5588 Tcl_Obj *CONST objv[] /* Command arguments */ |
5125 ){ | 5589 ){ |
5126 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET); | 5590 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET); |
5127 return TCL_OK; | 5591 return TCL_OK; |
5128 } | 5592 } |
5129 | 5593 |
5130 /* | 5594 /* |
| 5595 ** tclcmd: database_may_be_corrupt |
| 5596 ** |
| 5597 ** Indicate that database files might be corrupt. In other words, set the norma
l |
| 5598 ** state of operation. |
| 5599 */ |
| 5600 static int database_may_be_corrupt( |
| 5601 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5602 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5603 int objc, /* Number of arguments */ |
| 5604 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5605 ){ |
| 5606 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0); |
| 5607 return TCL_OK; |
| 5608 } |
| 5609 /* |
| 5610 ** tclcmd: database_never_corrupt |
| 5611 ** |
| 5612 ** Indicate that database files are always well-formed. This enables extra asse
rt() |
| 5613 ** statements that test conditions that are always true for well-formed database
s. |
| 5614 */ |
| 5615 static int database_never_corrupt( |
| 5616 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5617 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5618 int objc, /* Number of arguments */ |
| 5619 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5620 ){ |
| 5621 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 1); |
| 5622 return TCL_OK; |
| 5623 } |
| 5624 |
| 5625 /* |
5131 ** tclcmd: pcache_stats | 5626 ** tclcmd: pcache_stats |
5132 */ | 5627 */ |
5133 static int test_pcache_stats( | 5628 static int test_pcache_stats( |
5134 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5629 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
5135 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5630 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5136 int objc, /* Number of arguments */ | 5631 int objc, /* Number of arguments */ |
5137 Tcl_Obj *CONST objv[] /* Command arguments */ | 5632 Tcl_Obj *CONST objv[] /* Command arguments */ |
5138 ){ | 5633 ){ |
5139 int nMin; | 5634 int nMin; |
5140 int nMax; | 5635 int nMax; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5231 ** mode argument (passive, full or restart). If present, the database name | 5726 ** mode argument (passive, full or restart). If present, the database name |
5232 ** NAME is passed as the second argument to wal_checkpoint_v2(). If it the | 5727 ** NAME is passed as the second argument to wal_checkpoint_v2(). If it the |
5233 ** NAME argument is not present, a NULL pointer is passed instead. | 5728 ** NAME argument is not present, a NULL pointer is passed instead. |
5234 ** | 5729 ** |
5235 ** If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or | 5730 ** If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or |
5236 ** SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set | 5731 ** SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set |
5237 ** to the error message obtained from sqlite3_errmsg(). | 5732 ** to the error message obtained from sqlite3_errmsg(). |
5238 ** | 5733 ** |
5239 ** Otherwise, this command returns a list of three integers. The first integer | 5734 ** Otherwise, this command returns a list of three integers. The first integer |
5240 ** is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers | 5735 ** is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers |
5241 ** are the values returned via the output paramaters by wal_checkpoint_v2() - | 5736 ** are the values returned via the output parameters by wal_checkpoint_v2() - |
5242 ** the number of frames in the log and the number of frames in the log | 5737 ** the number of frames in the log and the number of frames in the log |
5243 ** that have been checkpointed. | 5738 ** that have been checkpointed. |
5244 */ | 5739 */ |
5245 static int test_wal_checkpoint_v2( | 5740 static int test_wal_checkpoint_v2( |
5246 ClientData clientData, /* Unused */ | 5741 ClientData clientData, /* Unused */ |
5247 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5742 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5248 int objc, /* Number of arguments */ | 5743 int objc, /* Number of arguments */ |
5249 Tcl_Obj *CONST objv[] /* Command arguments */ | 5744 Tcl_Obj *CONST objv[] /* Command arguments */ |
5250 ){ | 5745 ){ |
5251 char *zDb = 0; | 5746 char *zDb = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5295 ** tclcmd: test_sqlite3_log ?SCRIPT? | 5790 ** tclcmd: test_sqlite3_log ?SCRIPT? |
5296 */ | 5791 */ |
5297 static struct LogCallback { | 5792 static struct LogCallback { |
5298 Tcl_Interp *pInterp; | 5793 Tcl_Interp *pInterp; |
5299 Tcl_Obj *pObj; | 5794 Tcl_Obj *pObj; |
5300 } logcallback = {0, 0}; | 5795 } logcallback = {0, 0}; |
5301 static void xLogcallback(void *unused, int err, char *zMsg){ | 5796 static void xLogcallback(void *unused, int err, char *zMsg){ |
5302 Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj); | 5797 Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj); |
5303 Tcl_IncrRefCount(pNew); | 5798 Tcl_IncrRefCount(pNew); |
5304 Tcl_ListObjAppendElement( | 5799 Tcl_ListObjAppendElement( |
5305 0, pNew, Tcl_NewStringObj(sqlite3TestErrorName(err), -1) | 5800 0, pNew, Tcl_NewStringObj(sqlite3ErrName(err), -1) |
5306 ); | 5801 ); |
5307 Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1)); | 5802 Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1)); |
5308 Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); | 5803 Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); |
5309 Tcl_DecrRefCount(pNew); | 5804 Tcl_DecrRefCount(pNew); |
5310 } | 5805 } |
5311 static int test_sqlite3_log( | 5806 static int test_sqlite3_log( |
5312 ClientData clientData, | 5807 ClientData clientData, |
5313 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5808 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
5314 int objc, /* Number of arguments */ | 5809 int objc, /* Number of arguments */ |
5315 Tcl_Obj *CONST objv[] /* Command arguments */ | 5810 Tcl_Obj *CONST objv[] /* Command arguments */ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5410 ){ | 5905 ){ |
5411 int rc; | 5906 int rc; |
5412 sqlite3_stmt *pStmt; | 5907 sqlite3_stmt *pStmt; |
5413 | 5908 |
5414 if( objc!=2 ){ | 5909 if( objc!=2 ){ |
5415 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 5910 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
5416 return TCL_ERROR; | 5911 return TCL_ERROR; |
5417 } | 5912 } |
5418 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 5913 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
5419 rc = printExplainQueryPlan(pStmt); | 5914 rc = printExplainQueryPlan(pStmt); |
| 5915 /* This is needed on Windows so that a test case using this |
| 5916 ** function can open a read pipe and get the output of |
| 5917 ** printExplainQueryPlan() immediately. |
| 5918 */ |
| 5919 fflush(stdout); |
5420 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); | 5920 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); |
5421 return TCL_OK; | 5921 return TCL_OK; |
5422 } | 5922 } |
5423 #endif /* SQLITE_OMIT_EXPLAIN */ | 5923 #endif /* SQLITE_OMIT_EXPLAIN */ |
5424 | 5924 |
5425 /* | 5925 /* |
| 5926 ** sqlite3_test_control VERB ARGS... |
| 5927 */ |
| 5928 static int test_test_control( |
| 5929 void * clientData, |
| 5930 Tcl_Interp *interp, |
| 5931 int objc, |
| 5932 Tcl_Obj *CONST objv[] |
| 5933 ){ |
| 5934 struct Verb { |
| 5935 const char *zName; |
| 5936 int i; |
| 5937 } aVerb[] = { |
| 5938 { "SQLITE_TESTCTRL_LOCALTIME_FAULT", SQLITE_TESTCTRL_LOCALTIME_FAULT }, |
| 5939 { "SQLITE_TESTCTRL_SORTER_MMAP", SQLITE_TESTCTRL_SORTER_MMAP }, |
| 5940 }; |
| 5941 int iVerb; |
| 5942 int iFlag; |
| 5943 int rc; |
| 5944 |
| 5945 if( objc<2 ){ |
| 5946 Tcl_WrongNumArgs(interp, 1, objv, "VERB ARGS..."); |
| 5947 return TCL_ERROR; |
| 5948 } |
| 5949 |
| 5950 rc = Tcl_GetIndexFromObjStruct( |
| 5951 interp, objv[1], aVerb, sizeof(aVerb[0]), "VERB", 0, &iVerb |
| 5952 ); |
| 5953 if( rc!=TCL_OK ) return rc; |
| 5954 |
| 5955 iFlag = aVerb[iVerb].i; |
| 5956 switch( iFlag ){ |
| 5957 case SQLITE_TESTCTRL_LOCALTIME_FAULT: { |
| 5958 int val; |
| 5959 if( objc!=3 ){ |
| 5960 Tcl_WrongNumArgs(interp, 2, objv, "ONOFF"); |
| 5961 return TCL_ERROR; |
| 5962 } |
| 5963 if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR; |
| 5964 sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, val); |
| 5965 break; |
| 5966 } |
| 5967 |
| 5968 case SQLITE_TESTCTRL_SORTER_MMAP: { |
| 5969 int val; |
| 5970 sqlite3 *db; |
| 5971 if( objc!=4 ){ |
| 5972 Tcl_WrongNumArgs(interp, 2, objv, "DB LIMIT"); |
| 5973 return TCL_ERROR; |
| 5974 } |
| 5975 if( getDbPointer(interp, Tcl_GetString(objv[2]), &db) ) return TCL_ERROR; |
| 5976 if( Tcl_GetIntFromObj(interp, objv[3], &val) ) return TCL_ERROR; |
| 5977 sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, val); |
| 5978 break; |
| 5979 } |
| 5980 } |
| 5981 |
| 5982 Tcl_ResetResult(interp); |
| 5983 return TCL_OK; |
| 5984 } |
| 5985 |
| 5986 #if SQLITE_OS_UNIX |
| 5987 #include <sys/time.h> |
| 5988 #include <sys/resource.h> |
| 5989 |
| 5990 static int test_getrusage( |
| 5991 void * clientData, |
| 5992 Tcl_Interp *interp, |
| 5993 int objc, |
| 5994 Tcl_Obj *CONST objv[] |
| 5995 ){ |
| 5996 char buf[1024]; |
| 5997 struct rusage r; |
| 5998 memset(&r, 0, sizeof(r)); |
| 5999 getrusage(RUSAGE_SELF, &r); |
| 6000 |
| 6001 sprintf(buf, "ru_utime=%d.%06d ru_stime=%d.%06d ru_minflt=%d ru_majflt=%d", |
| 6002 (int)r.ru_utime.tv_sec, (int)r.ru_utime.tv_usec, |
| 6003 (int)r.ru_stime.tv_sec, (int)r.ru_stime.tv_usec, |
| 6004 (int)r.ru_minflt, (int)r.ru_majflt |
| 6005 ); |
| 6006 Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); |
| 6007 return TCL_OK; |
| 6008 } |
| 6009 #endif |
| 6010 |
| 6011 #if SQLITE_OS_WIN |
| 6012 /* |
| 6013 ** Information passed from the main thread into the windows file locker |
| 6014 ** background thread. |
| 6015 */ |
| 6016 struct win32FileLocker { |
| 6017 char *evName; /* Name of event to signal thread startup */ |
| 6018 HANDLE h; /* Handle of the file to be locked */ |
| 6019 int delay1; /* Delay before locking */ |
| 6020 int delay2; /* Delay before unlocking */ |
| 6021 int ok; /* Finished ok */ |
| 6022 int err; /* True if an error occurs */ |
| 6023 }; |
| 6024 #endif |
| 6025 |
| 6026 |
| 6027 #if SQLITE_OS_WIN |
| 6028 #include <process.h> |
| 6029 /* |
| 6030 ** The background thread that does file locking. |
| 6031 */ |
| 6032 static void win32_file_locker(void *pAppData){ |
| 6033 struct win32FileLocker *p = (struct win32FileLocker*)pAppData; |
| 6034 if( p->evName ){ |
| 6035 HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName); |
| 6036 if ( ev ){ |
| 6037 SetEvent(ev); |
| 6038 CloseHandle(ev); |
| 6039 } |
| 6040 } |
| 6041 if( p->delay1 ) Sleep(p->delay1); |
| 6042 if( LockFile(p->h, 0, 0, 100000000, 0) ){ |
| 6043 Sleep(p->delay2); |
| 6044 UnlockFile(p->h, 0, 0, 100000000, 0); |
| 6045 p->ok = 1; |
| 6046 }else{ |
| 6047 p->err = 1; |
| 6048 } |
| 6049 CloseHandle(p->h); |
| 6050 p->h = 0; |
| 6051 p->delay1 = 0; |
| 6052 p->delay2 = 0; |
| 6053 } |
| 6054 #endif |
| 6055 |
| 6056 #if SQLITE_OS_WIN |
| 6057 /* |
| 6058 ** lock_win32_file FILENAME DELAY1 DELAY2 |
| 6059 ** |
| 6060 ** Get an exclusive manditory lock on file for DELAY2 milliseconds. |
| 6061 ** Wait DELAY1 milliseconds before acquiring the lock. |
| 6062 */ |
| 6063 static int win32_file_lock( |
| 6064 void * clientData, |
| 6065 Tcl_Interp *interp, |
| 6066 int objc, |
| 6067 Tcl_Obj *CONST objv[] |
| 6068 ){ |
| 6069 static struct win32FileLocker x = { "win32_file_lock", 0, 0, 0, 0, 0 }; |
| 6070 const char *zFilename; |
| 6071 char zBuf[200]; |
| 6072 int retry = 0; |
| 6073 HANDLE ev; |
| 6074 DWORD wResult; |
| 6075 |
| 6076 if( objc!=4 && objc!=1 ){ |
| 6077 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME DELAY1 DELAY2"); |
| 6078 return TCL_ERROR; |
| 6079 } |
| 6080 if( objc==1 ){ |
| 6081 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d %d %d %d %d", |
| 6082 x.ok, x.err, x.delay1, x.delay2, x.h); |
| 6083 Tcl_AppendResult(interp, zBuf, (char*)0); |
| 6084 return TCL_OK; |
| 6085 } |
| 6086 while( x.h && retry<30 ){ |
| 6087 retry++; |
| 6088 Sleep(100); |
| 6089 } |
| 6090 if( x.h ){ |
| 6091 Tcl_AppendResult(interp, "busy", (char*)0); |
| 6092 return TCL_ERROR; |
| 6093 } |
| 6094 if( Tcl_GetIntFromObj(interp, objv[2], &x.delay1) ) return TCL_ERROR; |
| 6095 if( Tcl_GetIntFromObj(interp, objv[3], &x.delay2) ) return TCL_ERROR; |
| 6096 zFilename = Tcl_GetString(objv[1]); |
| 6097 x.h = CreateFile(zFilename, GENERIC_READ|GENERIC_WRITE, |
| 6098 FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS, |
| 6099 FILE_ATTRIBUTE_NORMAL, 0); |
| 6100 if( !x.h ){ |
| 6101 Tcl_AppendResult(interp, "cannot open file: ", zFilename, (char*)0); |
| 6102 return TCL_ERROR; |
| 6103 } |
| 6104 ev = CreateEvent(NULL, TRUE, FALSE, x.evName); |
| 6105 if ( !ev ){ |
| 6106 Tcl_AppendResult(interp, "cannot create event: ", x.evName, (char*)0); |
| 6107 return TCL_ERROR; |
| 6108 } |
| 6109 _beginthread(win32_file_locker, 0, (void*)&x); |
| 6110 Sleep(0); |
| 6111 if ( (wResult = WaitForSingleObject(ev, 10000))!=WAIT_OBJECT_0 ){ |
| 6112 sqlite3_snprintf(sizeof(zBuf), zBuf, "0x%x", wResult); |
| 6113 Tcl_AppendResult(interp, "wait failed: ", zBuf, (char*)0); |
| 6114 CloseHandle(ev); |
| 6115 return TCL_ERROR; |
| 6116 } |
| 6117 CloseHandle(ev); |
| 6118 return TCL_OK; |
| 6119 } |
| 6120 |
| 6121 /* |
| 6122 ** exists_win32_path PATH |
| 6123 ** |
| 6124 ** Returns non-zero if the specified path exists, whose fully qualified name |
| 6125 ** may exceed 260 characters if it is prefixed with "\\?\". |
| 6126 */ |
| 6127 static int win32_exists_path( |
| 6128 void *clientData, |
| 6129 Tcl_Interp *interp, |
| 6130 int objc, |
| 6131 Tcl_Obj *CONST objv[] |
| 6132 ){ |
| 6133 if( objc!=2 ){ |
| 6134 Tcl_WrongNumArgs(interp, 1, objv, "PATH"); |
| 6135 return TCL_ERROR; |
| 6136 } |
| 6137 Tcl_SetObjResult(interp, Tcl_NewBooleanObj( |
| 6138 GetFileAttributesW( Tcl_GetUnicode(objv[1]))!=INVALID_FILE_ATTRIBUTES )); |
| 6139 return TCL_OK; |
| 6140 } |
| 6141 |
| 6142 /* |
| 6143 ** find_win32_file PATTERN |
| 6144 ** |
| 6145 ** Returns a list of entries in a directory that match the specified pattern, |
| 6146 ** whose fully qualified name may exceed 248 characters if it is prefixed with |
| 6147 ** "\\?\". |
| 6148 */ |
| 6149 static int win32_find_file( |
| 6150 void *clientData, |
| 6151 Tcl_Interp *interp, |
| 6152 int objc, |
| 6153 Tcl_Obj *CONST objv[] |
| 6154 ){ |
| 6155 HANDLE hFindFile = INVALID_HANDLE_VALUE; |
| 6156 WIN32_FIND_DATAW findData; |
| 6157 Tcl_Obj *listObj; |
| 6158 DWORD lastErrno; |
| 6159 if( objc!=2 ){ |
| 6160 Tcl_WrongNumArgs(interp, 1, objv, "PATTERN"); |
| 6161 return TCL_ERROR; |
| 6162 } |
| 6163 hFindFile = FindFirstFileW(Tcl_GetUnicode(objv[1]), &findData); |
| 6164 if( hFindFile==INVALID_HANDLE_VALUE ){ |
| 6165 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6166 return TCL_ERROR; |
| 6167 } |
| 6168 listObj = Tcl_NewObj(); |
| 6169 Tcl_IncrRefCount(listObj); |
| 6170 do { |
| 6171 Tcl_ListObjAppendElement(interp, listObj, Tcl_NewUnicodeObj( |
| 6172 findData.cFileName, -1)); |
| 6173 Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj( |
| 6174 findData.dwFileAttributes)); |
| 6175 } while( FindNextFileW(hFindFile, &findData) ); |
| 6176 lastErrno = GetLastError(); |
| 6177 if( lastErrno!=NO_ERROR && lastErrno!=ERROR_NO_MORE_FILES ){ |
| 6178 FindClose(hFindFile); |
| 6179 Tcl_DecrRefCount(listObj); |
| 6180 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6181 return TCL_ERROR; |
| 6182 } |
| 6183 FindClose(hFindFile); |
| 6184 Tcl_SetObjResult(interp, listObj); |
| 6185 return TCL_OK; |
| 6186 } |
| 6187 |
| 6188 /* |
| 6189 ** delete_win32_file FILENAME |
| 6190 ** |
| 6191 ** Deletes the specified file, whose fully qualified name may exceed 260 |
| 6192 ** characters if it is prefixed with "\\?\". |
| 6193 */ |
| 6194 static int win32_delete_file( |
| 6195 void *clientData, |
| 6196 Tcl_Interp *interp, |
| 6197 int objc, |
| 6198 Tcl_Obj *CONST objv[] |
| 6199 ){ |
| 6200 if( objc!=2 ){ |
| 6201 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); |
| 6202 return TCL_ERROR; |
| 6203 } |
| 6204 if( !DeleteFileW(Tcl_GetUnicode(objv[1])) ){ |
| 6205 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6206 return TCL_ERROR; |
| 6207 } |
| 6208 Tcl_ResetResult(interp); |
| 6209 return TCL_OK; |
| 6210 } |
| 6211 |
| 6212 /* |
| 6213 ** make_win32_dir DIRECTORY |
| 6214 ** |
| 6215 ** Creates the specified directory, whose fully qualified name may exceed 248 |
| 6216 ** characters if it is prefixed with "\\?\". |
| 6217 */ |
| 6218 static int win32_mkdir( |
| 6219 void *clientData, |
| 6220 Tcl_Interp *interp, |
| 6221 int objc, |
| 6222 Tcl_Obj *CONST objv[] |
| 6223 ){ |
| 6224 if( objc!=2 ){ |
| 6225 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); |
| 6226 return TCL_ERROR; |
| 6227 } |
| 6228 if( !CreateDirectoryW(Tcl_GetUnicode(objv[1]), NULL) ){ |
| 6229 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6230 return TCL_ERROR; |
| 6231 } |
| 6232 Tcl_ResetResult(interp); |
| 6233 return TCL_OK; |
| 6234 } |
| 6235 |
| 6236 /* |
| 6237 ** remove_win32_dir DIRECTORY |
| 6238 ** |
| 6239 ** Removes the specified directory, whose fully qualified name may exceed 248 |
| 6240 ** characters if it is prefixed with "\\?\". |
| 6241 */ |
| 6242 static int win32_rmdir( |
| 6243 void *clientData, |
| 6244 Tcl_Interp *interp, |
| 6245 int objc, |
| 6246 Tcl_Obj *CONST objv[] |
| 6247 ){ |
| 6248 if( objc!=2 ){ |
| 6249 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); |
| 6250 return TCL_ERROR; |
| 6251 } |
| 6252 if( !RemoveDirectoryW(Tcl_GetUnicode(objv[1])) ){ |
| 6253 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6254 return TCL_ERROR; |
| 6255 } |
| 6256 Tcl_ResetResult(interp); |
| 6257 return TCL_OK; |
| 6258 } |
| 6259 #endif |
| 6260 |
| 6261 |
| 6262 /* |
5426 ** optimization_control DB OPT BOOLEAN | 6263 ** optimization_control DB OPT BOOLEAN |
5427 ** | 6264 ** |
5428 ** Enable or disable query optimizations using the sqlite3_test_control() | 6265 ** Enable or disable query optimizations using the sqlite3_test_control() |
5429 ** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. | 6266 ** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. |
5430 ** OPT is the name of the optimization to be disabled. | 6267 ** OPT is the name of the optimization to be disabled. |
5431 */ | 6268 */ |
5432 static int optimization_control( | 6269 static int optimization_control( |
5433 void * clientData, | 6270 void * clientData, |
5434 Tcl_Interp *interp, | 6271 Tcl_Interp *interp, |
5435 int objc, | 6272 int objc, |
5436 Tcl_Obj *CONST objv[] | 6273 Tcl_Obj *CONST objv[] |
5437 ){ | 6274 ){ |
5438 int i; | 6275 int i; |
5439 sqlite3 *db; | 6276 sqlite3 *db; |
5440 const char *zOpt; | 6277 const char *zOpt; |
5441 int onoff; | 6278 int onoff; |
5442 int mask; | 6279 int mask = 0; |
5443 static const struct { | 6280 static const struct { |
5444 const char *zOptName; | 6281 const char *zOptName; |
5445 int mask; | 6282 int mask; |
5446 } aOpt[] = { | 6283 } aOpt[] = { |
5447 { "all", SQLITE_OptMask }, | 6284 { "all", SQLITE_AllOpts }, |
5448 { "query-flattener", SQLITE_QueryFlattener }, | 6285 { "none", 0 }, |
5449 { "column-cache", SQLITE_ColumnCache }, | 6286 { "query-flattener", SQLITE_QueryFlattener }, |
5450 { "index-sort", SQLITE_IndexSort }, | 6287 { "column-cache", SQLITE_ColumnCache }, |
5451 { "index-search", SQLITE_IndexSearch }, | 6288 { "groupby-order", SQLITE_GroupByOrder }, |
5452 { "index-cover", SQLITE_IndexCover }, | 6289 { "factor-constants", SQLITE_FactorOutConst }, |
5453 { "groupby-order", SQLITE_GroupByOrder }, | 6290 { "distinct-opt", SQLITE_DistinctOpt }, |
5454 { "factor-constants", SQLITE_FactorOutConst }, | 6291 { "cover-idx-scan", SQLITE_CoverIdxScan }, |
| 6292 { "order-by-idx-join", SQLITE_OrderByIdxJoin }, |
| 6293 { "transitive", SQLITE_Transitive }, |
| 6294 { "subquery-coroutine", SQLITE_SubqCoroutine }, |
| 6295 { "omit-noop-join", SQLITE_OmitNoopJoin }, |
| 6296 { "stat3", SQLITE_Stat3 }, |
5455 }; | 6297 }; |
5456 | 6298 |
5457 if( objc!=4 ){ | 6299 if( objc!=4 ){ |
5458 Tcl_WrongNumArgs(interp, 1, objv, "DB OPT BOOLEAN"); | 6300 Tcl_WrongNumArgs(interp, 1, objv, "DB OPT BOOLEAN"); |
5459 return TCL_ERROR; | 6301 return TCL_ERROR; |
5460 } | 6302 } |
5461 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 6303 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
5462 if( Tcl_GetBooleanFromObj(interp, objv[3], &onoff) ) return TCL_ERROR; | 6304 if( Tcl_GetBooleanFromObj(interp, objv[3], &onoff) ) return TCL_ERROR; |
5463 zOpt = Tcl_GetString(objv[2]); | 6305 zOpt = Tcl_GetString(objv[2]); |
5464 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ | 6306 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ |
5465 if( strcmp(zOpt, aOpt[i].zOptName)==0 ){ | 6307 if( strcmp(zOpt, aOpt[i].zOptName)==0 ){ |
5466 mask = aOpt[i].mask; | 6308 mask = aOpt[i].mask; |
5467 break; | 6309 break; |
5468 } | 6310 } |
5469 } | 6311 } |
5470 if( onoff ) mask = ~mask; | 6312 if( onoff ) mask = ~mask; |
5471 if( i>=sizeof(aOpt)/sizeof(aOpt[0]) ){ | 6313 if( i>=sizeof(aOpt)/sizeof(aOpt[0]) ){ |
5472 Tcl_AppendResult(interp, "unknown optimization - should be one of:", | 6314 Tcl_AppendResult(interp, "unknown optimization - should be one of:", |
5473 (char*)0); | 6315 (char*)0); |
5474 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ | 6316 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ |
5475 Tcl_AppendResult(interp, " ", aOpt[i].zOptName); | 6317 Tcl_AppendResult(interp, " ", aOpt[i].zOptName, (char*)0); |
5476 } | 6318 } |
5477 return TCL_ERROR; | 6319 return TCL_ERROR; |
5478 } | 6320 } |
5479 sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask); | 6321 sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask); |
5480 return TCL_OK; | 6322 return TCL_OK; |
5481 } | 6323 } |
5482 | 6324 |
| 6325 typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 6326 /* |
| 6327 ** load_static_extension DB NAME ... |
| 6328 ** |
| 6329 ** Load one or more statically linked extensions. |
| 6330 */ |
| 6331 static int tclLoadStaticExtensionCmd( |
| 6332 void * clientData, |
| 6333 Tcl_Interp *interp, |
| 6334 int objc, |
| 6335 Tcl_Obj *CONST objv[] |
| 6336 ){ |
| 6337 extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6338 extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6339 extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6340 extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6341 extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6342 extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6343 extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*
); |
| 6344 extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6345 extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6346 extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6347 extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines
*); |
| 6348 static const struct { |
| 6349 const char *zExtName; |
| 6350 int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); |
| 6351 } aExtension[] = { |
| 6352 { "amatch", sqlite3_amatch_init }, |
| 6353 { "closure", sqlite3_closure_init }, |
| 6354 { "fileio", sqlite3_fileio_init }, |
| 6355 { "fuzzer", sqlite3_fuzzer_init }, |
| 6356 { "ieee754", sqlite3_ieee_init }, |
| 6357 { "nextchar", sqlite3_nextchar_init }, |
| 6358 { "percentile", sqlite3_percentile_init }, |
| 6359 { "regexp", sqlite3_regexp_init }, |
| 6360 { "spellfix", sqlite3_spellfix_init }, |
| 6361 { "totype", sqlite3_totype_init }, |
| 6362 { "wholenumber", sqlite3_wholenumber_init }, |
| 6363 }; |
| 6364 sqlite3 *db; |
| 6365 const char *zName; |
| 6366 int i, j, rc; |
| 6367 char *zErrMsg = 0; |
| 6368 if( objc<3 ){ |
| 6369 Tcl_WrongNumArgs(interp, 1, objv, "DB NAME ..."); |
| 6370 return TCL_ERROR; |
| 6371 } |
| 6372 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 6373 for(j=2; j<objc; j++){ |
| 6374 zName = Tcl_GetString(objv[j]); |
| 6375 for(i=0; i<ArraySize(aExtension); i++){ |
| 6376 if( strcmp(zName, aExtension[i].zExtName)==0 ) break; |
| 6377 } |
| 6378 if( i>=ArraySize(aExtension) ){ |
| 6379 Tcl_AppendResult(interp, "no such extension: ", zName, (char*)0); |
| 6380 return TCL_ERROR; |
| 6381 } |
| 6382 rc = aExtension[i].pInit(db, &zErrMsg, 0); |
| 6383 if( rc!=SQLITE_OK || zErrMsg ){ |
| 6384 Tcl_AppendResult(interp, "initialization of ", zName, " failed: ", zErrMsg
, |
| 6385 (char*)0); |
| 6386 sqlite3_free(zErrMsg); |
| 6387 return TCL_ERROR; |
| 6388 } |
| 6389 } |
| 6390 return TCL_OK; |
| 6391 } |
| 6392 |
| 6393 /* |
| 6394 ** sorter_test_fakeheap BOOL |
| 6395 ** |
| 6396 */ |
| 6397 static int sorter_test_fakeheap( |
| 6398 void * clientData, |
| 6399 Tcl_Interp *interp, |
| 6400 int objc, |
| 6401 Tcl_Obj *CONST objv[] |
| 6402 ){ |
| 6403 int bArg; |
| 6404 if( objc!=2 ){ |
| 6405 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
| 6406 return TCL_ERROR; |
| 6407 } |
| 6408 |
| 6409 if( Tcl_GetBooleanFromObj(interp, objv[1], &bArg) ){ |
| 6410 return TCL_ERROR; |
| 6411 } |
| 6412 |
| 6413 if( bArg ){ |
| 6414 if( sqlite3GlobalConfig.pHeap==0 ){ |
| 6415 sqlite3GlobalConfig.pHeap = SQLITE_INT_TO_PTR(-1); |
| 6416 } |
| 6417 }else{ |
| 6418 if( sqlite3GlobalConfig.pHeap==SQLITE_INT_TO_PTR(-1) ){ |
| 6419 sqlite3GlobalConfig.pHeap = 0; |
| 6420 } |
| 6421 } |
| 6422 |
| 6423 Tcl_ResetResult(interp); |
| 6424 return TCL_OK; |
| 6425 } |
| 6426 |
| 6427 /* |
| 6428 ** sorter_test_sort4_helper DB SQL1 NSTEP SQL2 |
| 6429 ** |
| 6430 ** Compile SQL statement $SQL1 and step it $NSTEP times. For each row, |
| 6431 ** check that the leftmost and rightmost columns returned are both integers, |
| 6432 ** and that both contain the same value. |
| 6433 ** |
| 6434 ** Then execute statement $SQL2. Check that the statement returns the same |
| 6435 ** set of integers in the same order as in the previous step (using $SQL1). |
| 6436 */ |
| 6437 static int sorter_test_sort4_helper( |
| 6438 void * clientData, |
| 6439 Tcl_Interp *interp, |
| 6440 int objc, |
| 6441 Tcl_Obj *CONST objv[] |
| 6442 ){ |
| 6443 const char *zSql1; |
| 6444 const char *zSql2; |
| 6445 int nStep; |
| 6446 int iStep; |
| 6447 int iCksum1 = 0; |
| 6448 int iCksum2 = 0; |
| 6449 int rc; |
| 6450 int iB; |
| 6451 sqlite3 *db; |
| 6452 sqlite3_stmt *pStmt; |
| 6453 |
| 6454 if( objc!=5 ){ |
| 6455 Tcl_WrongNumArgs(interp, 1, objv, "DB SQL1 NSTEP SQL2"); |
| 6456 return TCL_ERROR; |
| 6457 } |
| 6458 |
| 6459 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 6460 zSql1 = Tcl_GetString(objv[2]); |
| 6461 if( Tcl_GetIntFromObj(interp, objv[3], &nStep) ) return TCL_ERROR; |
| 6462 zSql2 = Tcl_GetString(objv[4]); |
| 6463 |
| 6464 rc = sqlite3_prepare_v2(db, zSql1, -1, &pStmt, 0); |
| 6465 if( rc!=SQLITE_OK ) goto sql_error; |
| 6466 |
| 6467 iB = sqlite3_column_count(pStmt)-1; |
| 6468 for(iStep=0; iStep<nStep && SQLITE_ROW==sqlite3_step(pStmt); iStep++){ |
| 6469 int a = sqlite3_column_int(pStmt, 0); |
| 6470 if( a!=sqlite3_column_int(pStmt, iB) ){ |
| 6471 Tcl_AppendResult(interp, "data error: (a!=b)", 0); |
| 6472 return TCL_ERROR; |
| 6473 } |
| 6474 |
| 6475 iCksum1 += (iCksum1 << 3) + a; |
| 6476 } |
| 6477 rc = sqlite3_finalize(pStmt); |
| 6478 if( rc!=SQLITE_OK ) goto sql_error; |
| 6479 |
| 6480 rc = sqlite3_prepare_v2(db, zSql2, -1, &pStmt, 0); |
| 6481 if( rc!=SQLITE_OK ) goto sql_error; |
| 6482 for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){ |
| 6483 int a = sqlite3_column_int(pStmt, 0); |
| 6484 iCksum2 += (iCksum2 << 3) + a; |
| 6485 } |
| 6486 rc = sqlite3_finalize(pStmt); |
| 6487 if( rc!=SQLITE_OK ) goto sql_error; |
| 6488 |
| 6489 if( iCksum1!=iCksum2 ){ |
| 6490 Tcl_AppendResult(interp, "checksum mismatch", 0); |
| 6491 return TCL_ERROR; |
| 6492 } |
| 6493 |
| 6494 return TCL_OK; |
| 6495 sql_error: |
| 6496 Tcl_AppendResult(interp, "sql error: ", sqlite3_errmsg(db), 0); |
| 6497 return TCL_ERROR; |
| 6498 } |
| 6499 |
| 6500 |
| 6501 #ifdef SQLITE_USER_AUTHENTICATION |
| 6502 #include "sqlite3userauth.h" |
| 6503 /* |
| 6504 ** tclcmd: sqlite3_user_authenticate DB USERNAME PASSWORD |
| 6505 */ |
| 6506 static int test_user_authenticate( |
| 6507 ClientData clientData, /* Unused */ |
| 6508 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6509 int objc, /* Number of arguments */ |
| 6510 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6511 ){ |
| 6512 char *zUser = 0; |
| 6513 char *zPasswd = 0; |
| 6514 int nPasswd = 0; |
| 6515 sqlite3 *db; |
| 6516 int rc; |
| 6517 |
| 6518 if( objc!=4 ){ |
| 6519 Tcl_WrongNumArgs(interp, 1, objv, "DB USERNAME PASSWORD"); |
| 6520 return TCL_ERROR; |
| 6521 } |
| 6522 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 6523 return TCL_ERROR; |
| 6524 } |
| 6525 zUser = Tcl_GetString(objv[2]); |
| 6526 zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd); |
| 6527 rc = sqlite3_user_authenticate(db, zUser, zPasswd, nPasswd); |
| 6528 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6529 return TCL_OK; |
| 6530 } |
| 6531 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6532 |
| 6533 #ifdef SQLITE_USER_AUTHENTICATION |
| 6534 /* |
| 6535 ** tclcmd: sqlite3_user_add DB USERNAME PASSWORD ISADMIN |
| 6536 */ |
| 6537 static int test_user_add( |
| 6538 ClientData clientData, /* Unused */ |
| 6539 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6540 int objc, /* Number of arguments */ |
| 6541 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6542 ){ |
| 6543 char *zUser = 0; |
| 6544 char *zPasswd = 0; |
| 6545 int nPasswd = 0; |
| 6546 int isAdmin = 0; |
| 6547 sqlite3 *db; |
| 6548 int rc; |
| 6549 |
| 6550 if( objc!=5 ){ |
| 6551 Tcl_WrongNumArgs(interp, 1, objv, "DB USERNAME PASSWORD ISADMIN"); |
| 6552 return TCL_ERROR; |
| 6553 } |
| 6554 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 6555 return TCL_ERROR; |
| 6556 } |
| 6557 zUser = Tcl_GetString(objv[2]); |
| 6558 zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd); |
| 6559 Tcl_GetBooleanFromObj(interp, objv[4], &isAdmin); |
| 6560 rc = sqlite3_user_add(db, zUser, zPasswd, nPasswd, isAdmin); |
| 6561 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6562 return TCL_OK; |
| 6563 } |
| 6564 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6565 |
| 6566 #ifdef SQLITE_USER_AUTHENTICATION |
| 6567 /* |
| 6568 ** tclcmd: sqlite3_user_change DB USERNAME PASSWORD ISADMIN |
| 6569 */ |
| 6570 static int test_user_change( |
| 6571 ClientData clientData, /* Unused */ |
| 6572 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6573 int objc, /* Number of arguments */ |
| 6574 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6575 ){ |
| 6576 char *zUser = 0; |
| 6577 char *zPasswd = 0; |
| 6578 int nPasswd = 0; |
| 6579 int isAdmin = 0; |
| 6580 sqlite3 *db; |
| 6581 int rc; |
| 6582 |
| 6583 if( objc!=5 ){ |
| 6584 Tcl_WrongNumArgs(interp, 1, objv, "DB USERNAME PASSWORD ISADMIN"); |
| 6585 return TCL_ERROR; |
| 6586 } |
| 6587 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 6588 return TCL_ERROR; |
| 6589 } |
| 6590 zUser = Tcl_GetString(objv[2]); |
| 6591 zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd); |
| 6592 Tcl_GetBooleanFromObj(interp, objv[4], &isAdmin); |
| 6593 rc = sqlite3_user_change(db, zUser, zPasswd, nPasswd, isAdmin); |
| 6594 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6595 return TCL_OK; |
| 6596 } |
| 6597 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6598 |
| 6599 #ifdef SQLITE_USER_AUTHENTICATION |
| 6600 /* |
| 6601 ** tclcmd: sqlite3_user_delete DB USERNAME |
| 6602 */ |
| 6603 static int test_user_delete( |
| 6604 ClientData clientData, /* Unused */ |
| 6605 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6606 int objc, /* Number of arguments */ |
| 6607 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6608 ){ |
| 6609 char *zUser = 0; |
| 6610 sqlite3 *db; |
| 6611 int rc; |
| 6612 |
| 6613 if( objc!=3 ){ |
| 6614 Tcl_WrongNumArgs(interp, 1, objv, "DB USERNAME"); |
| 6615 return TCL_ERROR; |
| 6616 } |
| 6617 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 6618 return TCL_ERROR; |
| 6619 } |
| 6620 zUser = Tcl_GetString(objv[2]); |
| 6621 rc = sqlite3_user_delete(db, zUser); |
| 6622 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6623 return TCL_OK; |
| 6624 } |
| 6625 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6626 |
5483 /* | 6627 /* |
5484 ** Register commands with the TCL interpreter. | 6628 ** Register commands with the TCL interpreter. |
5485 */ | 6629 */ |
5486 int Sqlitetest1_Init(Tcl_Interp *interp){ | 6630 int Sqlitetest1_Init(Tcl_Interp *interp){ |
5487 extern int sqlite3_search_count; | 6631 extern int sqlite3_search_count; |
5488 extern int sqlite3_found_count; | 6632 extern int sqlite3_found_count; |
5489 extern int sqlite3_interrupt_count; | 6633 extern int sqlite3_interrupt_count; |
5490 extern int sqlite3_open_file_count; | 6634 extern int sqlite3_open_file_count; |
5491 extern int sqlite3_sort_count; | 6635 extern int sqlite3_sort_count; |
5492 extern int sqlite3_current_time; | 6636 extern int sqlite3_current_time; |
(...skipping 23 matching lines...) Expand all Loading... |
5516 { "sqlite3_snprintf_int", (Tcl_CmdProc*)test_snprintf_int }, | 6660 { "sqlite3_snprintf_int", (Tcl_CmdProc*)test_snprintf_int }, |
5517 { "sqlite3_last_insert_rowid", (Tcl_CmdProc*)test_last_rowid }, | 6661 { "sqlite3_last_insert_rowid", (Tcl_CmdProc*)test_last_rowid }, |
5518 { "sqlite3_exec_printf", (Tcl_CmdProc*)test_exec_printf }, | 6662 { "sqlite3_exec_printf", (Tcl_CmdProc*)test_exec_printf }, |
5519 { "sqlite3_exec_hex", (Tcl_CmdProc*)test_exec_hex }, | 6663 { "sqlite3_exec_hex", (Tcl_CmdProc*)test_exec_hex }, |
5520 { "sqlite3_exec", (Tcl_CmdProc*)test_exec }, | 6664 { "sqlite3_exec", (Tcl_CmdProc*)test_exec }, |
5521 { "sqlite3_exec_nr", (Tcl_CmdProc*)test_exec_nr }, | 6665 { "sqlite3_exec_nr", (Tcl_CmdProc*)test_exec_nr }, |
5522 #ifndef SQLITE_OMIT_GET_TABLE | 6666 #ifndef SQLITE_OMIT_GET_TABLE |
5523 { "sqlite3_get_table_printf", (Tcl_CmdProc*)test_get_table_printf }, | 6667 { "sqlite3_get_table_printf", (Tcl_CmdProc*)test_get_table_printf }, |
5524 #endif | 6668 #endif |
5525 { "sqlite3_close", (Tcl_CmdProc*)sqlite_test_close }, | 6669 { "sqlite3_close", (Tcl_CmdProc*)sqlite_test_close }, |
| 6670 { "sqlite3_close_v2", (Tcl_CmdProc*)sqlite_test_close_v2 }, |
5526 { "sqlite3_create_function", (Tcl_CmdProc*)test_create_function }, | 6671 { "sqlite3_create_function", (Tcl_CmdProc*)test_create_function }, |
5527 { "sqlite3_create_aggregate", (Tcl_CmdProc*)test_create_aggregate }, | 6672 { "sqlite3_create_aggregate", (Tcl_CmdProc*)test_create_aggregate }, |
5528 { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func }, | 6673 { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func }, |
5529 { "sqlite_abort", (Tcl_CmdProc*)sqlite_abort }, | 6674 { "sqlite_abort", (Tcl_CmdProc*)sqlite_abort }, |
5530 { "sqlite_bind", (Tcl_CmdProc*)test_bind }, | 6675 { "sqlite_bind", (Tcl_CmdProc*)test_bind }, |
5531 { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, | 6676 { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, |
5532 { "sqlite3_key", (Tcl_CmdProc*)test_key }, | 6677 { "sqlite3_key", (Tcl_CmdProc*)test_key }, |
5533 { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, | 6678 { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, |
5534 { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, | 6679 { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, |
5535 { "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt }, | 6680 { "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt }, |
5536 { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, | 6681 { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, |
5537 { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, | 6682 { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, |
5538 { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, | 6683 { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, |
5539 { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, | 6684 { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, |
5540 { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, | 6685 { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, |
5541 { "printf", (Tcl_CmdProc*)test_printf }, | 6686 { "printf", (Tcl_CmdProc*)test_printf }, |
5542 { "sqlite3IoTrace", (Tcl_CmdProc*)test_io_trace }, | 6687 { "sqlite3IoTrace", (Tcl_CmdProc*)test_io_trace }, |
| 6688 { "clang_sanitize_address", (Tcl_CmdProc*)clang_sanitize_address }, |
5543 }; | 6689 }; |
5544 static struct { | 6690 static struct { |
5545 char *zName; | 6691 char *zName; |
5546 Tcl_ObjCmdProc *xProc; | 6692 Tcl_ObjCmdProc *xProc; |
5547 void *clientData; | 6693 void *clientData; |
5548 } aObjCmd[] = { | 6694 } aObjCmd[] = { |
5549 { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, | 6695 { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, |
5550 { "sqlite3_bind_int", test_bind_int, 0 }, | 6696 { "sqlite3_bind_int", test_bind_int, 0 }, |
5551 { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, | 6697 { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, |
5552 { "sqlite3_bind_int64", test_bind_int64, 0 }, | 6698 { "sqlite3_bind_int64", test_bind_int64, 0 }, |
5553 { "sqlite3_bind_double", test_bind_double, 0 }, | 6699 { "sqlite3_bind_double", test_bind_double, 0 }, |
5554 { "sqlite3_bind_null", test_bind_null ,0 }, | 6700 { "sqlite3_bind_null", test_bind_null ,0 }, |
5555 { "sqlite3_bind_text", test_bind_text ,0 }, | 6701 { "sqlite3_bind_text", test_bind_text ,0 }, |
5556 { "sqlite3_bind_text16", test_bind_text16 ,0 }, | 6702 { "sqlite3_bind_text16", test_bind_text16 ,0 }, |
5557 { "sqlite3_bind_blob", test_bind_blob ,0 }, | 6703 { "sqlite3_bind_blob", test_bind_blob ,0 }, |
5558 { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, | 6704 { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, |
5559 { "sqlite3_bind_parameter_name", test_bind_parameter_name, 0}, | 6705 { "sqlite3_bind_parameter_name", test_bind_parameter_name, 0}, |
5560 { "sqlite3_bind_parameter_index", test_bind_parameter_index, 0}, | 6706 { "sqlite3_bind_parameter_index", test_bind_parameter_index, 0}, |
5561 { "sqlite3_clear_bindings", test_clear_bindings, 0}, | 6707 { "sqlite3_clear_bindings", test_clear_bindings, 0}, |
5562 { "sqlite3_sleep", test_sleep, 0}, | 6708 { "sqlite3_sleep", test_sleep, 0}, |
5563 { "sqlite3_errcode", test_errcode ,0 }, | 6709 { "sqlite3_errcode", test_errcode ,0 }, |
5564 { "sqlite3_extended_errcode", test_ex_errcode ,0 }, | 6710 { "sqlite3_extended_errcode", test_ex_errcode ,0 }, |
5565 { "sqlite3_errmsg", test_errmsg ,0 }, | 6711 { "sqlite3_errmsg", test_errmsg ,0 }, |
5566 { "sqlite3_errmsg16", test_errmsg16 ,0 }, | 6712 { "sqlite3_errmsg16", test_errmsg16 ,0 }, |
5567 { "sqlite3_open", test_open ,0 }, | 6713 { "sqlite3_open", test_open ,0 }, |
5568 { "sqlite3_open16", test_open16 ,0 }, | 6714 { "sqlite3_open16", test_open16 ,0 }, |
| 6715 { "sqlite3_open_v2", test_open_v2 ,0 }, |
5569 { "sqlite3_complete16", test_complete16 ,0 }, | 6716 { "sqlite3_complete16", test_complete16 ,0 }, |
5570 | 6717 |
5571 { "sqlite3_prepare", test_prepare ,0 }, | 6718 { "sqlite3_prepare", test_prepare ,0 }, |
5572 { "sqlite3_prepare16", test_prepare16 ,0 }, | 6719 { "sqlite3_prepare16", test_prepare16 ,0 }, |
5573 { "sqlite3_prepare_v2", test_prepare_v2 ,0 }, | 6720 { "sqlite3_prepare_v2", test_prepare_v2 ,0 }, |
5574 { "sqlite3_prepare_tkt3134", test_prepare_tkt3134, 0}, | 6721 { "sqlite3_prepare_tkt3134", test_prepare_tkt3134, 0}, |
5575 { "sqlite3_prepare16_v2", test_prepare16_v2 ,0 }, | 6722 { "sqlite3_prepare16_v2", test_prepare16_v2 ,0 }, |
5576 { "sqlite3_finalize", test_finalize ,0 }, | 6723 { "sqlite3_finalize", test_finalize ,0 }, |
5577 { "sqlite3_stmt_status", test_stmt_status ,0 }, | 6724 { "sqlite3_stmt_status", test_stmt_status ,0 }, |
5578 { "sqlite3_reset", test_reset ,0 }, | 6725 { "sqlite3_reset", test_reset ,0 }, |
5579 { "sqlite3_expired", test_expired ,0 }, | 6726 { "sqlite3_expired", test_expired ,0 }, |
5580 { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, | 6727 { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, |
5581 { "sqlite3_changes", test_changes ,0 }, | 6728 { "sqlite3_changes", test_changes ,0 }, |
5582 { "sqlite3_step", test_step ,0 }, | 6729 { "sqlite3_step", test_step ,0 }, |
5583 { "sqlite3_sql", test_sql ,0 }, | 6730 { "sqlite3_sql", test_sql ,0 }, |
5584 { "sqlite3_next_stmt", test_next_stmt ,0 }, | 6731 { "sqlite3_next_stmt", test_next_stmt ,0 }, |
5585 { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, | 6732 { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, |
| 6733 { "sqlite3_stmt_busy", test_stmt_busy ,0 }, |
| 6734 { "uses_stmt_journal", uses_stmt_journal ,0 }, |
5586 | 6735 |
5587 { "sqlite3_release_memory", test_release_memory, 0}, | 6736 { "sqlite3_release_memory", test_release_memory, 0}, |
| 6737 { "sqlite3_db_release_memory", test_db_release_memory, 0}, |
| 6738 { "sqlite3_db_filename", test_db_filename, 0}, |
| 6739 { "sqlite3_db_readonly", test_db_readonly, 0}, |
5588 { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, | 6740 { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, |
5589 { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, | 6741 { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, |
5590 { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, | 6742 { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, |
5591 | 6743 |
5592 { "sqlite3_load_extension", test_load_extension, 0}, | 6744 { "sqlite3_load_extension", test_load_extension, 0}, |
5593 { "sqlite3_enable_load_extension", test_enable_load, 0}, | 6745 { "sqlite3_enable_load_extension", test_enable_load, 0}, |
5594 { "sqlite3_extended_result_codes", test_extended_result_codes, 0}, | 6746 { "sqlite3_extended_result_codes", test_extended_result_codes, 0}, |
5595 { "sqlite3_limit", test_limit, 0}, | 6747 { "sqlite3_limit", test_limit, 0}, |
5596 | 6748 |
5597 { "save_prng_state", save_prng_state, 0 }, | 6749 { "save_prng_state", save_prng_state, 0 }, |
5598 { "restore_prng_state", restore_prng_state, 0 }, | 6750 { "restore_prng_state", restore_prng_state, 0 }, |
5599 { "reset_prng_state", reset_prng_state, 0 }, | 6751 { "reset_prng_state", reset_prng_state, 0 }, |
| 6752 { "database_never_corrupt", database_never_corrupt, 0}, |
| 6753 { "database_may_be_corrupt", database_may_be_corrupt, 0}, |
5600 { "optimization_control", optimization_control,0}, | 6754 { "optimization_control", optimization_control,0}, |
| 6755 #if SQLITE_OS_WIN |
| 6756 { "lock_win32_file", win32_file_lock, 0 }, |
| 6757 { "exists_win32_path", win32_exists_path, 0 }, |
| 6758 { "find_win32_file", win32_find_file, 0 }, |
| 6759 { "delete_win32_file", win32_delete_file, 0 }, |
| 6760 { "make_win32_dir", win32_mkdir, 0 }, |
| 6761 { "remove_win32_dir", win32_rmdir, 0 }, |
| 6762 #endif |
5601 { "tcl_objproc", runAsObjProc, 0 }, | 6763 { "tcl_objproc", runAsObjProc, 0 }, |
5602 | 6764 |
5603 /* sqlite3_column_*() API */ | 6765 /* sqlite3_column_*() API */ |
5604 { "sqlite3_column_count", test_column_count ,0 }, | 6766 { "sqlite3_column_count", test_column_count ,0 }, |
5605 { "sqlite3_data_count", test_data_count ,0 }, | 6767 { "sqlite3_data_count", test_data_count ,0 }, |
5606 { "sqlite3_column_type", test_column_type ,0 }, | 6768 { "sqlite3_column_type", test_column_type ,0 }, |
5607 { "sqlite3_column_blob", test_column_blob ,0 }, | 6769 { "sqlite3_column_blob", test_column_blob ,0 }, |
5608 { "sqlite3_column_double", test_column_double ,0 }, | 6770 { "sqlite3_column_double", test_column_double ,0 }, |
5609 { "sqlite3_column_int64", test_column_int64 ,0 }, | 6771 { "sqlite3_column_int64", test_column_int64 ,0 }, |
5610 { "sqlite3_column_text", test_stmt_utf8, (void*)sqlite3_column_text }, | 6772 { "sqlite3_column_text", test_stmt_utf8, (void*)sqlite3_column_text }, |
(...skipping 12 matching lines...) Expand all Loading... |
5623 #ifndef SQLITE_OMIT_UTF16 | 6785 #ifndef SQLITE_OMIT_UTF16 |
5624 { "sqlite3_column_bytes16", test_stmt_int, (void*)sqlite3_column_bytes16 }, | 6786 { "sqlite3_column_bytes16", test_stmt_int, (void*)sqlite3_column_bytes16 }, |
5625 { "sqlite3_column_text16", test_stmt_utf16, (void*)sqlite3_column_text16}, | 6787 { "sqlite3_column_text16", test_stmt_utf16, (void*)sqlite3_column_text16}, |
5626 { "sqlite3_column_name16", test_stmt_utf16, (void*)sqlite3_column_name16}, | 6788 { "sqlite3_column_name16", test_stmt_utf16, (void*)sqlite3_column_name16}, |
5627 { "add_alignment_test_collations", add_alignment_test_collations, 0 }, | 6789 { "add_alignment_test_collations", add_alignment_test_collations, 0 }, |
5628 #ifndef SQLITE_OMIT_DECLTYPE | 6790 #ifndef SQLITE_OMIT_DECLTYPE |
5629 { "sqlite3_column_decltype16",test_stmt_utf16,(void*)sqlite3_column_decltyp
e16}, | 6791 { "sqlite3_column_decltype16",test_stmt_utf16,(void*)sqlite3_column_decltyp
e16}, |
5630 #endif | 6792 #endif |
5631 #ifdef SQLITE_ENABLE_COLUMN_METADATA | 6793 #ifdef SQLITE_ENABLE_COLUMN_METADATA |
5632 {"sqlite3_column_database_name16", | 6794 {"sqlite3_column_database_name16", |
5633 test_stmt_utf16, sqlite3_column_database_name16}, | 6795 test_stmt_utf16, (void*)sqlite3_column_database_name16}, |
5634 {"sqlite3_column_table_name16", test_stmt_utf16, (void*)sqlite3_column_table_nam
e16}, | 6796 {"sqlite3_column_table_name16", test_stmt_utf16, (void*)sqlite3_column_table_nam
e16}, |
5635 {"sqlite3_column_origin_name16", test_stmt_utf16, (void*)sqlite3_column_origin_n
ame16}, | 6797 {"sqlite3_column_origin_name16", test_stmt_utf16, (void*)sqlite3_column_origin_n
ame16}, |
5636 #endif | 6798 #endif |
5637 #endif | 6799 #endif |
5638 { "sqlite3_create_collation_v2", test_create_collation_v2, 0 }, | 6800 { "sqlite3_create_collation_v2", test_create_collation_v2, 0 }, |
5639 { "sqlite3_global_recover", test_global_recover, 0 }, | 6801 { "sqlite3_global_recover", test_global_recover, 0 }, |
5640 { "working_64bit_int", working_64bit_int, 0 }, | 6802 { "working_64bit_int", working_64bit_int, 0 }, |
5641 { "vfs_unlink_test", vfs_unlink_test, 0 }, | 6803 { "vfs_unlink_test", vfs_unlink_test, 0 }, |
5642 { "vfs_initfail_test", vfs_initfail_test, 0 }, | 6804 { "vfs_initfail_test", vfs_initfail_test, 0 }, |
5643 { "vfs_unregister_all", vfs_unregister_all, 0 }, | 6805 { "vfs_unregister_all", vfs_unregister_all, 0 }, |
5644 { "vfs_reregister_all", vfs_reregister_all, 0 }, | 6806 { "vfs_reregister_all", vfs_reregister_all, 0 }, |
5645 { "file_control_test", file_control_test, 0 }, | 6807 { "file_control_test", file_control_test, 0 }, |
5646 { "file_control_lasterrno_test", file_control_lasterrno_test, 0 }, | 6808 { "file_control_lasterrno_test", file_control_lasterrno_test, 0 }, |
5647 { "file_control_lockproxy_test", file_control_lockproxy_test, 0 }, | 6809 { "file_control_lockproxy_test", file_control_lockproxy_test, 0 }, |
5648 { "file_control_chunksize_test", file_control_chunksize_test, 0 }, | 6810 { "file_control_chunksize_test", file_control_chunksize_test, 0 }, |
5649 { "file_control_sizehint_test", file_control_sizehint_test, 0 }, | 6811 { "file_control_sizehint_test", file_control_sizehint_test, 0 }, |
| 6812 #if SQLITE_OS_WIN |
| 6813 { "file_control_win32_av_retry", file_control_win32_av_retry, 0 }, |
| 6814 { "file_control_win32_set_handle", file_control_win32_set_handle, 0 }, |
| 6815 #endif |
| 6816 { "file_control_persist_wal", file_control_persist_wal, 0 }, |
| 6817 { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0}, |
| 6818 { "file_control_vfsname", file_control_vfsname, 0 }, |
| 6819 { "file_control_tempfilename", file_control_tempfilename, 0 }, |
5650 { "sqlite3_vfs_list", vfs_list, 0 }, | 6820 { "sqlite3_vfs_list", vfs_list, 0 }, |
5651 { "sqlite3_create_function_v2", test_create_function_v2, 0 }, | 6821 { "sqlite3_create_function_v2", test_create_function_v2, 0 }, |
5652 | 6822 |
5653 /* Functions from os.h */ | 6823 /* Functions from os.h */ |
5654 #ifndef SQLITE_OMIT_UTF16 | 6824 #ifndef SQLITE_OMIT_UTF16 |
5655 { "add_test_collate", test_collate, 0 }, | 6825 { "add_test_collate", test_collate, 0 }, |
5656 { "add_test_collate_needed", test_collate_needed, 0 }, | 6826 { "add_test_collate_needed", test_collate_needed, 0 }, |
5657 { "add_test_function", test_function, 0 }, | 6827 { "add_test_function", test_function, 0 }, |
| 6828 { "add_test_utf16bin_collate", test_utf16bin_collate, 0 }, |
5658 #endif | 6829 #endif |
5659 { "sqlite3_test_errstr", test_errstr, 0 }, | 6830 { "sqlite3_test_errstr", test_errstr, 0 }, |
5660 { "tcl_variable_type", tcl_variable_type, 0 }, | 6831 { "tcl_variable_type", tcl_variable_type, 0 }, |
5661 #ifndef SQLITE_OMIT_SHARED_CACHE | 6832 #ifndef SQLITE_OMIT_SHARED_CACHE |
5662 { "sqlite3_enable_shared_cache", test_enable_shared, 0 }, | 6833 { "sqlite3_enable_shared_cache", test_enable_shared, 0 }, |
5663 { "sqlite3_shared_cache_report", sqlite3BtreeSharedCacheReport, 0}, | 6834 { "sqlite3_shared_cache_report", sqlite3BtreeSharedCacheReport, 0}, |
5664 #endif | 6835 #endif |
5665 { "sqlite3_libversion_number", test_libversion_number, 0 }, | 6836 { "sqlite3_libversion_number", test_libversion_number, 0 }, |
5666 #ifdef SQLITE_ENABLE_COLUMN_METADATA | 6837 #ifdef SQLITE_ENABLE_COLUMN_METADATA |
5667 { "sqlite3_table_column_metadata", test_table_column_metadata, 0 }, | 6838 { "sqlite3_table_column_metadata", test_table_column_metadata, 0 }, |
5668 #endif | 6839 #endif |
5669 #ifndef SQLITE_OMIT_INCRBLOB | 6840 #ifndef SQLITE_OMIT_INCRBLOB |
5670 { "sqlite3_blob_read", test_blob_read, 0 }, | 6841 { "sqlite3_blob_read", test_blob_read, 0 }, |
5671 { "sqlite3_blob_write", test_blob_write, 0 }, | 6842 { "sqlite3_blob_write", test_blob_write, 0 }, |
5672 { "sqlite3_blob_reopen", test_blob_reopen, 0 }, | 6843 { "sqlite3_blob_reopen", test_blob_reopen, 0 }, |
5673 { "sqlite3_blob_bytes", test_blob_bytes, 0 }, | 6844 { "sqlite3_blob_bytes", test_blob_bytes, 0 }, |
5674 { "sqlite3_blob_close", test_blob_close, 0 }, | 6845 { "sqlite3_blob_close", test_blob_close, 0 }, |
5675 #endif | 6846 #endif |
5676 { "pcache_stats", test_pcache_stats, 0 }, | 6847 { "pcache_stats", test_pcache_stats, 0 }, |
5677 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY | 6848 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
5678 { "sqlite3_unlock_notify", test_unlock_notify, 0 }, | 6849 { "sqlite3_unlock_notify", test_unlock_notify, 0 }, |
5679 #endif | 6850 #endif |
5680 { "sqlite3_wal_checkpoint", test_wal_checkpoint, 0 }, | 6851 { "sqlite3_wal_checkpoint", test_wal_checkpoint, 0 }, |
5681 { "sqlite3_wal_checkpoint_v2",test_wal_checkpoint_v2, 0 }, | 6852 { "sqlite3_wal_checkpoint_v2",test_wal_checkpoint_v2, 0 }, |
5682 { "test_sqlite3_log", test_sqlite3_log, 0 }, | 6853 { "test_sqlite3_log", test_sqlite3_log, 0 }, |
5683 #ifndef SQLITE_OMIT_EXPLAIN | 6854 #ifndef SQLITE_OMIT_EXPLAIN |
5684 { "print_explain_query_plan", test_print_eqp, 0 }, | 6855 { "print_explain_query_plan", test_print_eqp, 0 }, |
5685 #endif | 6856 #endif |
| 6857 { "sqlite3_test_control", test_test_control }, |
| 6858 #if SQLITE_OS_UNIX |
| 6859 { "getrusage", test_getrusage }, |
| 6860 #endif |
| 6861 { "load_static_extension", tclLoadStaticExtensionCmd }, |
| 6862 { "sorter_test_fakeheap", sorter_test_fakeheap }, |
| 6863 { "sorter_test_sort4_helper", sorter_test_sort4_helper }, |
| 6864 #ifdef SQLITE_USER_AUTHENTICATION |
| 6865 { "sqlite3_user_authenticate", test_user_authenticate, 0 }, |
| 6866 { "sqlite3_user_add", test_user_add, 0 }, |
| 6867 { "sqlite3_user_change", test_user_change, 0 }, |
| 6868 { "sqlite3_user_delete", test_user_delete, 0 }, |
| 6869 #endif |
| 6870 |
5686 }; | 6871 }; |
5687 static int bitmask_size = sizeof(Bitmask)*8; | 6872 static int bitmask_size = sizeof(Bitmask)*8; |
5688 int i; | 6873 int i; |
5689 extern int sqlite3_sync_count, sqlite3_fullsync_count; | 6874 extern int sqlite3_sync_count, sqlite3_fullsync_count; |
5690 extern int sqlite3_opentemp_count; | 6875 extern int sqlite3_opentemp_count; |
5691 extern int sqlite3_like_count; | 6876 extern int sqlite3_like_count; |
5692 extern int sqlite3_xferopt_count; | 6877 extern int sqlite3_xferopt_count; |
5693 extern int sqlite3_pager_readdb_count; | 6878 extern int sqlite3_pager_readdb_count; |
5694 extern int sqlite3_pager_writedb_count; | 6879 extern int sqlite3_pager_writedb_count; |
5695 extern int sqlite3_pager_writej_count; | 6880 extern int sqlite3_pager_writej_count; |
5696 #if SQLITE_OS_WIN | 6881 #if SQLITE_OS_WIN |
5697 extern int sqlite3_os_type; | 6882 extern LONG volatile sqlite3_os_type; |
5698 #endif | 6883 #endif |
5699 #ifdef SQLITE_DEBUG | 6884 #ifdef SQLITE_DEBUG |
5700 extern int sqlite3WhereTrace; | 6885 extern int sqlite3WhereTrace; |
5701 extern int sqlite3OSTrace; | 6886 extern int sqlite3OSTrace; |
5702 extern int sqlite3VdbeAddopTrace; | |
5703 extern int sqlite3WalTrace; | 6887 extern int sqlite3WalTrace; |
5704 #endif | 6888 #endif |
5705 #ifdef SQLITE_TEST | 6889 #ifdef SQLITE_TEST |
5706 extern char sqlite3_query_plan[]; | |
5707 static char *query_plan = sqlite3_query_plan; | |
5708 #ifdef SQLITE_ENABLE_FTS3 | 6890 #ifdef SQLITE_ENABLE_FTS3 |
5709 extern int sqlite3_fts3_enable_parentheses; | 6891 extern int sqlite3_fts3_enable_parentheses; |
5710 #endif | 6892 #endif |
5711 #endif | 6893 #endif |
5712 | 6894 |
5713 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ | 6895 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ |
5714 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); | 6896 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); |
5715 } | 6897 } |
5716 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ | 6898 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
5717 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, | 6899 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, |
(...skipping 30 matching lines...) Expand all Loading... |
5748 #ifndef SQLITE_OMIT_UTF16 | 6930 #ifndef SQLITE_OMIT_UTF16 |
5749 Tcl_LinkVar(interp, "unaligned_string_counter", | 6931 Tcl_LinkVar(interp, "unaligned_string_counter", |
5750 (char*)&unaligned_string_counter, TCL_LINK_INT); | 6932 (char*)&unaligned_string_counter, TCL_LINK_INT); |
5751 #endif | 6933 #endif |
5752 #ifndef SQLITE_OMIT_UTF16 | 6934 #ifndef SQLITE_OMIT_UTF16 |
5753 Tcl_LinkVar(interp, "sqlite_last_needed_collation", | 6935 Tcl_LinkVar(interp, "sqlite_last_needed_collation", |
5754 (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY); | 6936 (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY); |
5755 #endif | 6937 #endif |
5756 #if SQLITE_OS_WIN | 6938 #if SQLITE_OS_WIN |
5757 Tcl_LinkVar(interp, "sqlite_os_type", | 6939 Tcl_LinkVar(interp, "sqlite_os_type", |
5758 (char*)&sqlite3_os_type, TCL_LINK_INT); | 6940 (char*)&sqlite3_os_type, TCL_LINK_LONG); |
5759 #endif | 6941 #endif |
5760 #ifdef SQLITE_TEST | 6942 #ifdef SQLITE_TEST |
5761 Tcl_LinkVar(interp, "sqlite_query_plan", | 6943 { |
5762 (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY); | 6944 static const char *query_plan = "*** OBSOLETE VARIABLE ***"; |
| 6945 Tcl_LinkVar(interp, "sqlite_query_plan", |
| 6946 (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY); |
| 6947 } |
5763 #endif | 6948 #endif |
5764 #ifdef SQLITE_DEBUG | 6949 #ifdef SQLITE_DEBUG |
5765 Tcl_LinkVar(interp, "sqlite_addop_trace", | |
5766 (char*)&sqlite3VdbeAddopTrace, TCL_LINK_INT); | |
5767 Tcl_LinkVar(interp, "sqlite_where_trace", | 6950 Tcl_LinkVar(interp, "sqlite_where_trace", |
5768 (char*)&sqlite3WhereTrace, TCL_LINK_INT); | 6951 (char*)&sqlite3WhereTrace, TCL_LINK_INT); |
5769 Tcl_LinkVar(interp, "sqlite_os_trace", | 6952 Tcl_LinkVar(interp, "sqlite_os_trace", |
5770 (char*)&sqlite3OSTrace, TCL_LINK_INT); | 6953 (char*)&sqlite3OSTrace, TCL_LINK_INT); |
5771 #ifndef SQLITE_OMIT_WAL | 6954 #ifndef SQLITE_OMIT_WAL |
5772 Tcl_LinkVar(interp, "sqlite_wal_trace", | 6955 Tcl_LinkVar(interp, "sqlite_wal_trace", |
5773 (char*)&sqlite3WalTrace, TCL_LINK_INT); | 6956 (char*)&sqlite3WalTrace, TCL_LINK_INT); |
5774 #endif | 6957 #endif |
5775 #endif | 6958 #endif |
5776 #ifndef SQLITE_OMIT_DISKIO | 6959 #ifndef SQLITE_OMIT_DISKIO |
5777 Tcl_LinkVar(interp, "sqlite_opentemp_count", | 6960 Tcl_LinkVar(interp, "sqlite_opentemp_count", |
5778 (char*)&sqlite3_opentemp_count, TCL_LINK_INT); | 6961 (char*)&sqlite3_opentemp_count, TCL_LINK_INT); |
5779 #endif | 6962 #endif |
5780 Tcl_LinkVar(interp, "sqlite_static_bind_value", | 6963 Tcl_LinkVar(interp, "sqlite_static_bind_value", |
5781 (char*)&sqlite_static_bind_value, TCL_LINK_STRING); | 6964 (char*)&sqlite_static_bind_value, TCL_LINK_STRING); |
5782 Tcl_LinkVar(interp, "sqlite_static_bind_nbyte", | 6965 Tcl_LinkVar(interp, "sqlite_static_bind_nbyte", |
5783 (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT); | 6966 (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT); |
5784 Tcl_LinkVar(interp, "sqlite_temp_directory", | 6967 Tcl_LinkVar(interp, "sqlite_temp_directory", |
5785 (char*)&sqlite3_temp_directory, TCL_LINK_STRING); | 6968 (char*)&sqlite3_temp_directory, TCL_LINK_STRING); |
| 6969 Tcl_LinkVar(interp, "sqlite_data_directory", |
| 6970 (char*)&sqlite3_data_directory, TCL_LINK_STRING); |
5786 Tcl_LinkVar(interp, "bitmask_size", | 6971 Tcl_LinkVar(interp, "bitmask_size", |
5787 (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY); | 6972 (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY); |
5788 Tcl_LinkVar(interp, "sqlite_sync_count", | 6973 Tcl_LinkVar(interp, "sqlite_sync_count", |
5789 (char*)&sqlite3_sync_count, TCL_LINK_INT); | 6974 (char*)&sqlite3_sync_count, TCL_LINK_INT); |
5790 Tcl_LinkVar(interp, "sqlite_fullsync_count", | 6975 Tcl_LinkVar(interp, "sqlite_fullsync_count", |
5791 (char*)&sqlite3_fullsync_count, TCL_LINK_INT); | 6976 (char*)&sqlite3_fullsync_count, TCL_LINK_INT); |
5792 #if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST) | 6977 #if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST) |
5793 Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses", | 6978 Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses", |
5794 (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT); | 6979 (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT); |
5795 #endif | 6980 #endif |
5796 return TCL_OK; | 6981 return TCL_OK; |
5797 } | 6982 } |
OLD | NEW |