Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes toward reducing code size when SQLITE_OMIT_UTF16 is enabled. (CVS 2099) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
59a0a8b7cebc011731654bd0545cf8d1 |
User & Date: | drh 2004-11-14 04:04:17.000 |
Context
2004-11-14
| ||
21:56 | The SQLITE_OMIT_UTF16 macro now removes lots of code and all tests still pass. (CVS 2100) (check-in: 98c7a55478 user: drh tags: trunk) | |
04:04 | Changes toward reducing code size when SQLITE_OMIT_UTF16 is enabled. (CVS 2099) (check-in: 59a0a8b7ce user: drh tags: trunk) | |
2004-11-13
| ||
15:59 | More compile-time options for removing components. (CVS 2098) (check-in: dcbc0c22cf user: drh tags: trunk) | |
Changes
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.113 2004/11/14 04:04:17 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | " FILENAME\"", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, ifnullFunc, 0, 0); /* Use the sqlite3_create_function16() API here. Mainly for fun, but also ** because it is not tested anywhere else. */ if( rc==SQLITE_OK ){ pVal = sqlite3ValueNew(); sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC); rc = sqlite3_create_function16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE), 1, SQLITE_UTF16, db, sqlite3ExecFunc, 0, 0); sqlite3ValueFree(pVal); } if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } /* ** Routines to implement the x_count() aggregate function. */ | > > > | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | " FILENAME\"", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, ifnullFunc, 0, 0); #ifndef SQLITE_OMIT_UTF16 /* Use the sqlite3_create_function16() API here. Mainly for fun, but also ** because it is not tested anywhere else. */ if( rc==SQLITE_OK ){ pVal = sqlite3ValueNew(); sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC); rc = sqlite3_create_function16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE), 1, SQLITE_UTF16, db, sqlite3ExecFunc, 0, 0); sqlite3ValueFree(pVal); } #endif if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } /* ** Routines to implement the x_count() aggregate function. */ |
︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 | sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3ErrStr(rc), 0); return TCL_ERROR; } return TCL_OK; } | | | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3ErrStr(rc), 0); return TCL_ERROR; } return TCL_OK; } #ifndef SQLITE_OMIT_UTF16 /* ** Usage: add_test_collate <db ptr> <utf8> <utf16le> <utf16be> ** ** This function is used to test that SQLite selects the correct collation ** sequence callback when multiple versions (for different text encodings) ** are available. ** |
︙ | ︙ | |||
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; bad_args: Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL_ERROR; } /* ** Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be> ** ** This function is used to test that SQLite selects the correct user ** function callback when multiple versions (for different text encodings) ** are available. | > | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; bad_args: Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL_ERROR; } #endif /* SQLITE_OMIT_UTF16 */ /* ** Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be> ** ** This function is used to test that SQLite selects the correct user ** function callback when multiple versions (for different text encodings) ** are available. |
︙ | ︙ | |||
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | ** Where <enc> is one of UTF-8, UTF-16LE or UTF16BE, and <arg> is the ** single argument passed to the SQL function. The value returned by ** the TCL script is used as the return value of the SQL function. It ** is passed to SQLite using UTF-16BE for a UTF-8 test_function(), UTF-8 ** for a UTF-16LE test_function(), and UTF-16LE for an implementation that ** prefers UTF-16BE. */ static void test_function_utf8( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ Tcl_Interp *interp; Tcl_Obj *pX; | > | 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 | ** Where <enc> is one of UTF-8, UTF-16LE or UTF16BE, and <arg> is the ** single argument passed to the SQL function. The value returned by ** the TCL script is used as the return value of the SQL function. It ** is passed to SQLite using UTF-16BE for a UTF-8 test_function(), UTF-8 ** for a UTF-16LE test_function(), and UTF-16LE for an implementation that ** prefers UTF-16BE. */ #ifndef SQLITE_OMIT_UTF16 static void test_function_utf8( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ Tcl_Interp *interp; Tcl_Obj *pX; |
︙ | ︙ | |||
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | pVal = sqlite3ValueNew(); sqlite3ValueSetStr(pVal, -1, Tcl_GetStringResult(interp), SQLITE_UTF8, SQLITE_STATIC); sqlite3_result_text16le(pCtx, sqlite3_value_text16le(pVal), -1, SQLITE_TRANSIENT); sqlite3ValueFree(pVal); } static int test_function( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; int val; if( objc!=5 ) goto bad_args; if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR; | > > | 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 | pVal = sqlite3ValueNew(); sqlite3ValueSetStr(pVal, -1, Tcl_GetStringResult(interp), SQLITE_UTF8, SQLITE_STATIC); sqlite3_result_text16le(pCtx, sqlite3_value_text16le(pVal), -1, SQLITE_TRANSIENT); sqlite3ValueFree(pVal); } #endif /* SQLITE_OMIT_UTF16 */ static int test_function( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3 *db; int val; if( objc!=5 ) goto bad_args; if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR; |
︙ | ︙ | |||
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | interp, test_function_utf16be, 0, 0); } return TCL_OK; bad_args: Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0); return TCL_ERROR; } /* ** Usage: test_errstr <err code> ** ** Test that the english language string equivalents for sqlite error codes | > | 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 | interp, test_function_utf16be, 0, 0); } return TCL_OK; bad_args: Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <DB> <utf8> <utf16le> <utf16be>", 0); #endif /* SQLITE_OMIT_UTF16 */ return TCL_ERROR; } /* ** Usage: test_errstr <err code> ** ** Test that the english language string equivalents for sqlite error codes |
︙ | ︙ | |||
1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | */ static int test_bind_text16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int idx; int bytes; char *value; int rc; if( objc!=5 ){ | > | 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 | */ static int test_bind_text16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3_stmt *pStmt; int idx; int bytes; char *value; int rc; if( objc!=5 ){ |
︙ | ︙ | |||
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 | rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, SQLITE_TRANSIENT); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite3_bind_blob STMT N DATA BYTES ** ** Test the sqlite3_bind_blob interface. STMT is a prepared statement. | > | 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, SQLITE_TRANSIENT); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ return TCL_ERROR; } #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_bind_blob STMT N DATA BYTES ** ** Test the sqlite3_bind_blob interface. STMT is a prepared statement. |
︙ | ︙ | |||
1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 | */ static int test_errmsg16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; const void *zErr; int bytes; if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " DB", 0); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; zErr = sqlite3_errmsg16(db); bytes = sqlite3utf16ByteLen(zErr, -1); Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zErr, bytes)); return TCL_OK; } /* ** Usage: sqlite3_prepare DB sql bytes tailvar ** ** Compile up to <bytes> bytes of the supplied SQL string <sql> using | > > | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 | */ static int test_errmsg16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3 *db; const void *zErr; int bytes; if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " DB", 0); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; zErr = sqlite3_errmsg16(db); bytes = sqlite3utf16ByteLen(zErr, -1); Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zErr, bytes)); #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_prepare DB sql bytes tailvar ** ** Compile up to <bytes> bytes of the supplied SQL string <sql> using |
︙ | ︙ | |||
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 | */ static int test_prepare16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; const void *zSql; const void *zTail = 0; Tcl_Obj *pTail = 0; sqlite3_stmt *pStmt = 0; char zBuf[50]; int rc; | > | 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 | */ static int test_prepare16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3 *db; const void *zSql; const void *zTail = 0; Tcl_Obj *pTail = 0; sqlite3_stmt *pStmt = 0; char zBuf[50]; int rc; |
︙ | ︙ | |||
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 | Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); Tcl_DecrRefCount(pTail); if( pStmt ){ if( makePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; } Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: sqlite3_open filename ?options-list? */ static int test_open( | > | 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 | Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0); Tcl_DecrRefCount(pTail); if( pStmt ){ if( makePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; } Tcl_AppendResult(interp, zBuf, 0); #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_open filename ?options-list? */ static int test_open( |
︙ | ︙ | |||
1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | */ static int test_open16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const void *zFilename; sqlite3 *db; int rc; char zBuf[100]; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " filename options-list", 0); return TCL_ERROR; } zFilename = Tcl_GetByteArrayFromObj(objv[1], 0); rc = sqlite3_open16(zFilename, &db); if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: sqlite3_complete16 <UTF-16 string> ** ** Return 1 if the supplied argument is a complete SQL statement, or zero ** otherwise. */ static int test_complete16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ char *zBuf; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "<utf-16 sql>"); return TCL_ERROR; } zBuf = Tcl_GetByteArrayFromObj(objv[1], 0); Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_complete16(zBuf))); return TCL_OK; } /* ** Usage: sqlite3_step STMT ** ** Advance the statement to the next row. | > > > > | 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | */ static int test_open16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 const void *zFilename; sqlite3 *db; int rc; char zBuf[100]; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " filename options-list", 0); return TCL_ERROR; } zFilename = Tcl_GetByteArrayFromObj(objv[1], 0); rc = sqlite3_open16(zFilename, &db); if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_complete16 <UTF-16 string> ** ** Return 1 if the supplied argument is a complete SQL statement, or zero ** otherwise. */ static int test_complete16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 char *zBuf; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "<utf-16 sql>"); return TCL_ERROR; } zBuf = Tcl_GetByteArrayFromObj(objv[1], 0); Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_complete16(zBuf))); #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_step STMT ** ** Advance the statement to the next row. |
︙ | ︙ | |||
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 | */ static int test_stmt_utf16( void * clientData, /* Pointer to SQLite API function to be invoked */ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int col; Tcl_Obj *pRet; const void *zName16; const void *(*xFunc)(sqlite3_stmt*, int) = clientData; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; zName16 = xFunc(pStmt, col); if( zName16 ){ pRet = Tcl_NewByteArrayObj(zName16, sqlite3utf16ByteLen(zName16, -1)+2); Tcl_SetObjResult(interp, pRet); } return TCL_OK; } /* ** Usage: sqlite3_column_int STMT column ** | > > | 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 | */ static int test_stmt_utf16( void * clientData, /* Pointer to SQLite API function to be invoked */ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3_stmt *pStmt; int col; Tcl_Obj *pRet; const void *zName16; const void *(*xFunc)(sqlite3_stmt*, int) = clientData; if( objc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " STMT column", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; zName16 = xFunc(pStmt, col); if( zName16 ){ pRet = Tcl_NewByteArrayObj(zName16, sqlite3utf16ByteLen(zName16, -1)+2); Tcl_SetObjResult(interp, pRet); } #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** Usage: sqlite3_column_int STMT column ** |
︙ | ︙ | |||
2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 | { "sqlite3OsOpenReadWrite",test_sqlite3OsOpenReadWrite, 0 }, { "sqlite3OsClose", test_sqlite3OsClose, 0 }, { "sqlite3OsLock", test_sqlite3OsLock, 0 }, { "sqlite3OsTempFileName", test_sqlite3OsTempFileName, 0 }, /* Custom test interfaces */ { "sqlite3OsUnlock", test_sqlite3OsUnlock, 0 }, { "add_test_collate", test_collate, 0 }, { "add_test_collate_needed", test_collate_needed, 0 }, { "add_test_function", test_function, 0 }, { "sqlite3_crashparams", sqlite3_crashparams, 0 }, { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, }; int i; extern int sqlite3_os_trace; | > > | 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 | { "sqlite3OsOpenReadWrite",test_sqlite3OsOpenReadWrite, 0 }, { "sqlite3OsClose", test_sqlite3OsClose, 0 }, { "sqlite3OsLock", test_sqlite3OsLock, 0 }, { "sqlite3OsTempFileName", test_sqlite3OsTempFileName, 0 }, /* Custom test interfaces */ { "sqlite3OsUnlock", test_sqlite3OsUnlock, 0 }, #ifndef SQLITE_OMIT_UTF16 { "add_test_collate", test_collate, 0 }, { "add_test_collate_needed", test_collate_needed, 0 }, { "add_test_function", test_function, 0 }, #endif { "sqlite3_crashparams", sqlite3_crashparams, 0 }, { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, }; int i; extern int sqlite3_os_trace; |
︙ | ︙ |
Changes to test/autovacuum.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # # $Id: autovacuum.test,v 1.12 2004/11/14 04:04:18 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build of the library does not support auto-vacuum, omit this # whole file. ifcapable {!autovacuum} { |
︙ | ︙ | |||
78 79 80 81 82 83 84 | set ::tbl_data [list] foreach i [lsort -integer [eval concat $delete_order]] { execsql "INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')" lappend ::tbl_data [make_str $i $ENTRY_LEN] } # Make sure the integrity check passes with the initial data. | > | | | | | > > | | | | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | set ::tbl_data [list] foreach i [lsort -integer [eval concat $delete_order]] { execsql "INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')" lappend ::tbl_data [make_str $i $ENTRY_LEN] } # Make sure the integrity check passes with the initial data. ifcapable {integrityck} { do_test autovacuum-1.$tn.1 { execsql { pragma integrity_check } } {ok} } # set btree_trace 1 foreach delete $delete_order { # Delete one set of rows from the table. do_test autovacuum-1.$tn.($delete).1 { execsql " DELETE FROM av1 WHERE oid IN ([join $delete ,]) " } {} # Do the integrity check. ifcapable {integrityck} { do_test autovacuum-1.$tn.($delete).2 { execsql { pragma integrity_check } } {ok} } # Ensure the data remaining in the table is what was expected. foreach d $delete { set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]] set ::tbl_data [lreplace $::tbl_data $idx $idx] } do_test autovacuum-1.$tn.($delete).3 { execsql { |
︙ | ︙ | |||
482 483 484 485 486 487 488 | execsql { DROP TABLE av1; } file_pages } [expr $AUTOVACUUM?1:2] finish_test | < | 485 486 487 488 489 490 491 | execsql { DROP TABLE av1; } file_pages } [expr $AUTOVACUUM?1:2] finish_test |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # # $Id: capi3.test,v 1.22 2004/11/14 04:04:18 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 | do_test capi3-1.6 { sqlite3_errcode $DB } {SQLITE_ERROR} do_test capi3-1.7 { sqlite3_errmsg $DB } {no such column: namex} do_test capi3-2.1 { set sql16 [utf16 {SELECT name FROM sqlite_master}] set STMT [sqlite3_prepare16 $DB $sql16 -1 ::TAIL] sqlite3_finalize $STMT utf8 $::TAIL } {} do_test capi3-2.2 { | > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | do_test capi3-1.6 { sqlite3_errcode $DB } {SQLITE_ERROR} do_test capi3-1.7 { sqlite3_errmsg $DB } {no such column: namex} ifcapable {utf16} { do_test capi3-2.1 { set sql16 [utf16 {SELECT name FROM sqlite_master}] set STMT [sqlite3_prepare16 $DB $sql16 -1 ::TAIL] sqlite3_finalize $STMT utf8 $::TAIL } {} do_test capi3-2.2 { |
︙ | ︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | } {1} do_test capi3-2.4 { sqlite3_errcode $DB } {SQLITE_ERROR} do_test capi3-2.5 { sqlite3_errmsg $DB } {no such column: namex} # rename sqlite3_open sqlite3_open_old # proc sqlite3_open {fname options} {sqlite3_open_new $fname $options} do_test capi3-3.1 { set db2 [sqlite3_open test.db {}] sqlite3_errcode $db2 | > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | } {1} do_test capi3-2.4 { sqlite3_errcode $DB } {SQLITE_ERROR} do_test capi3-2.5 { sqlite3_errmsg $DB } {no such column: namex} } ;# endif utf16 # rename sqlite3_open sqlite3_open_old # proc sqlite3_open {fname options} {sqlite3_open_new $fname $options} do_test capi3-3.1 { set db2 [sqlite3_open test.db {}] sqlite3_errcode $db2 |
︙ | ︙ | |||
128 129 130 131 132 133 134 | } {SQLITE_CANTOPEN} do_test capi3-3.4 { sqlite3_errmsg $db2 } {unable to open database file} do_test capi3-3.5 { sqlite3_close $db2 } {SQLITE_OK} | | | > | | | > > > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | } {SQLITE_CANTOPEN} do_test capi3-3.4 { sqlite3_errmsg $db2 } {unable to open database file} do_test capi3-3.5 { sqlite3_close $db2 } {SQLITE_OK} do_test capi3-3.6.1 { sqlite3_close $db2 } {SQLITE_MISUSE} do_test capi3-3.6.2 { sqlite3_errmsg $db2 } {library routine called out of sequence} ifcapable {utf16} { do_test capi3-3.6.3 { utf8 [sqlite3_errmsg16 $db2] } {library routine called out of sequence} } # rename sqlite3_open "" # rename sqlite3_open_old sqlite3_open ifcapable {utf16} { do_test capi3-4.1 { set db2 [sqlite3_open16 [utf16 test.db] {}] sqlite3_errcode $db2 } {SQLITE_OK} # FIX ME: Should test the db handle works. do_test capi3-4.2 { sqlite3_close $db2 } {SQLITE_OK} do_test capi3-4.3 { catch { set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}] } sqlite3_errcode $db2 } {SQLITE_CANTOPEN} do_test capi3-4.4 { utf8 [sqlite3_errmsg16 $db2] } {unable to open database file} do_test capi3-4.5 { sqlite3_close $db2 } {SQLITE_OK} } ;# utf16 # This proc is used to test the following API calls: # # sqlite3_column_count # sqlite3_column_name # sqlite3_column_name16 # sqlite3_column_decltype |
︙ | ︙ | |||
197 198 199 200 201 202 203 | do_test $test.1 { set cnamelist [list] foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} set cnamelist } $names # Column names in UTF-16 | > | | | | | | | > > | | | | | | | > > | | | | | | | | > > | | | | | | | | | | | > | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | do_test $test.1 { set cnamelist [list] foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} set cnamelist } $names # Column names in UTF-16 ifcapable {utf16} { do_test $test.2 { set cnamelist [list] foreach i $idxlist { lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]] } set cnamelist } $names } # Column names in UTF-8 do_test $test.3 { set cnamelist [list] foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} set cnamelist } $names # Column names in UTF-16 ifcapable {utf16} { do_test $test.4 { set cnamelist [list] foreach i $idxlist { lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]] } set cnamelist } $names } # Column names in UTF-8 do_test $test.5 { set cnamelist [list] foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]} set cnamelist } $decltypes # Column declaration types in UTF-16 ifcapable {utf16} { do_test $test.6 { set cnamelist [list] foreach i $idxlist { lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]] } set cnamelist } $decltypes } # Test some out of range conditions: ifcapable {utf16} { do_test $test.7 { list \ [sqlite3_column_name $STMT -1] \ [sqlite3_column_name16 $STMT -1] \ [sqlite3_column_decltype $STMT -1] \ [sqlite3_column_decltype16 $STMT -1] \ [sqlite3_column_name $STMT $numcols] \ [sqlite3_column_name16 $STMT $numcols] \ [sqlite3_column_decltype $STMT $numcols] \ [sqlite3_column_decltype16 $STMT $numcols] } {{} {} {} {} {} {} {} {}} } } # This proc is used to test the following APIs: # # sqlite3_data_count # sqlite3_column_type |
︙ | ︙ | |||
348 349 350 351 352 353 354 | do_test $test.7 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } $doubles # UTF-16 | > | | | | | > | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | do_test $test.7 { set utf8 [list] foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]} set utf8 } $doubles # UTF-16 ifcapable {utf16} { do_test $test.8 { set utf8 [list] foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]} set utf8 } $strings } # Integers do_test $test.9 { set ints [list] foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]} set ints } $ints |
︙ | ︙ | |||
597 598 599 600 601 602 603 | catchsql { select * from sqlite_master; } } {1 {out of memory}} do_test capi3-10-2 { sqlite3_errmsg $::DB } {out of memory} | > | | | > | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | catchsql { select * from sqlite_master; } } {1 {out of memory}} do_test capi3-10-2 { sqlite3_errmsg $::DB } {out of memory} ifcapable {utf16} { do_test capi3-10-3 { utf8 [sqlite3_errmsg16 $::DB] } {out of memory} } db close sqlite_malloc_fail 0 } # The following tests - capi3-11.* - test that a COMMIT or ROLLBACK # statement issued while there are still outstanding VMs that are part of # the transaction fails. |
︙ | ︙ |
Changes to test/enc2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # | | > > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # # $Id: enc2.test,v 1.19 2004/11/14 04:04:18 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If UTF16 support is disabled, ignore the tests in this file # ifcapable {!utf16} { finish_test return } # The rough organisation of tests in this file is: # # enc2.1.*: Simple tests with a UTF-8 db. # enc2.2.*: Simple tests with a UTF-16LE db. # enc2.3.*: Simple tests with a UTF-16BE db. # enc2.4.*: Test that attached databases must have the same text encoding |
︙ | ︙ |
Changes to test/interrupt.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 Feb 8 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 Feb 8 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # # $Id: interrupt.test,v 1.8 2004/11/14 04:04:18 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Compute a checksum on the entire database. # |
︙ | ︙ | |||
98 99 100 101 102 103 104 | interrupt_test interrupt-2.2 {VACUUM} {} 100 } do_test interrupt-2.3 { execsql { SELECT md5sum(a || b) FROM t1; } } $cksum | | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | interrupt_test interrupt-2.2 {VACUUM} {} 100 } do_test interrupt-2.3 { execsql { SELECT md5sum(a || b) FROM t1; } } $cksum ifcapable {vacuum && !default_autovacuum} { do_test interrupt-2.4 { expr {$::origsize>[file size test.db]} } 1 } integrity_check interrupt-2.5 # Ticket #594. If an interrupt occurs in the middle of a transaction |
︙ | ︙ |
Changes to test/tester.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # # $Id: tester.tcl,v 1.42 2004/11/14 04:04:18 drh Exp $ # Make sure tclsqlite3 was compiled correctly. Abort now with an # error message if not. # if {[sqlite3 -tcl-uses-utf]} { if {"\u1234"=="u1234"} { puts stderr "***** BUILD PROBLEM *****" |
︙ | ︙ | |||
237 238 239 240 241 242 243 | } } # Evaluate a boolean expression of capabilities. If true, execute the # code. Omit the code if false. # proc ifcapable {expr code} { | | < | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | } } # Evaluate a boolean expression of capabilities. If true, execute the # code. Omit the code if false. # proc ifcapable {expr code} { regsub -all {[a-z_0-9]+} $expr {$::sqlite_options(&)} e2 if !($e2) return return -code [catch {uplevel 1 $code}] } # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set # to non-zero, then set the global variable $AUTOVACUUM to 1. set AUTOVACUUM $sqlite_options(default_autovacuum) |