Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | UTF-16 bugfixes and performance enhancements |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
0b55ce340148adab8121db35822f1286 |
User & Date: | rmsimpson 2005-08-06 06:46:09.000 |
Context
2005-08-16
| ||
19:09 | 1.0.14 Designer support check-in: f31df8c30b user: rmsimpson tags: sourceforge | |
2005-08-06
| ||
06:46 | UTF-16 bugfixes and performance enhancements check-in: 0b55ce3401 user: rmsimpson tags: sourceforge | |
01:47 | 1.0.12 repost check-in: 12b3901b7e user: rmsimpson tags: sourceforge | |
Changes
Changes to SQLite.Interop/interop.h.
︙ | ︙ | |||
248 249 250 251 252 253 254 | __declspec(dllexport) const char * __stdcall sqlite3_errmsg_interop(sqlite3 *db, int *plen) { const char *pval = sqlite3_errmsg(db); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } | | | > > | | > > | 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 278 279 280 | __declspec(dllexport) const char * __stdcall sqlite3_errmsg_interop(sqlite3 *db, int *plen) { const char *pval = sqlite3_errmsg(db); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } __declspec(dllexport) const void * __stdcall sqlite3_errmsg16_interop(sqlite3 *db, int *plen) { const void *pval = sqlite3_errmsg16(db); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t): 0; return pval; } __declspec(dllexport) int __stdcall sqlite3_prepare_interop(sqlite3 *db, const char *sql, int nbytes, sqlite3_stmt **ppstmt, const char **pztail, int *plen) { int n = sqlite3_prepare(db, sql, nbytes, ppstmt, pztail); *plen = (*pztail != 0) ? strlen(*pztail) : 0; return n; } __declspec(dllexport) int __stdcall sqlite3_prepare16_interop(sqlite3 *db, const void *sql, int nbytes, sqlite3_stmt **ppstmt, const void **pztail, int *plen) { int n = sqlite3_prepare16(db, sql, nbytes, ppstmt, pztail); *plen = (*pztail != 0) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0; return n; } __declspec(dllexport) int __stdcall sqlite3_bind_blob_interop(sqlite3_stmt *stmt, int iCol, const void *pv, int n, void(*cb)(void*)) { return sqlite3_bind_blob(stmt, iCol, pv, n, cb); } |
︙ | ︙ | |||
329 330 331 332 333 334 335 | __declspec(dllexport) const char * __stdcall sqlite3_column_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } | | | > > | | > > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | __declspec(dllexport) const char * __stdcall sqlite3_column_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } __declspec(dllexport) const void * __stdcall sqlite3_column_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_name16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } __declspec(dllexport) const char * __stdcall sqlite3_column_decltype_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_decltype(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } __declspec(dllexport) const void * __stdcall sqlite3_column_decltype16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_decltype16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } __declspec(dllexport) int __stdcall sqlite3_step_interop(sqlite3_stmt *stmt) { return sqlite3_step(stmt); } |
︙ | ︙ | |||
393 394 395 396 397 398 399 | __declspec(dllexport) const unsigned char * __stdcall sqlite3_column_text_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const unsigned char *pval = sqlite3_column_text(stmt, iCol); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } | | | > > | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | __declspec(dllexport) const unsigned char * __stdcall sqlite3_column_text_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const unsigned char *pval = sqlite3_column_text(stmt, iCol); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } __declspec(dllexport) const void * __stdcall sqlite3_column_text16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_text16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t): 0; return pval; } __declspec(dllexport) int __stdcall sqlite3_column_type_interop(sqlite3_stmt *stmt, int iCol) { return sqlite3_column_type(stmt, iCol); } |
︙ | ︙ | |||
531 532 533 534 535 536 537 | __declspec(dllexport) const unsigned char * __stdcall sqlite3_value_text_interop(sqlite3_value *val, int *plen) { const unsigned char *pval = sqlite3_value_text(val); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } | | | > > | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | __declspec(dllexport) const unsigned char * __stdcall sqlite3_value_text_interop(sqlite3_value *val, int *plen) { const unsigned char *pval = sqlite3_value_text(val); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } __declspec(dllexport) const void * __stdcall sqlite3_value_text16_interop(sqlite3_value *val, int *plen) { const void *pval = sqlite3_value_text16(val); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } __declspec(dllexport) int __stdcall sqlite3_value_type_interop(sqlite3_value *val) { return sqlite3_value_type(val); } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | ︙ | |||
28 29 30 31 32 33 34 | /// <returns>A .NET string</returns> public override string ToString(IntPtr b, int nbytelen) { if (nbytelen == 0) return ""; return Marshal.PtrToStringUni(b, nbytelen / 2); } | < | < < > | < | | | > > | > | | > > > > > > > | > | | > | > | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 117 118 119 120 121 122 | /// <returns>A .NET string</returns> public override string ToString(IntPtr b, int nbytelen) { if (nbytelen == 0) return ""; return Marshal.PtrToStringUni(b, nbytelen / 2); } internal override string Version { get { int len; return base.ToString(UnsafeNativeMethods.sqlite3_libversion_interop(out len), len); } } internal override void Open(string strFilename) { if (_sql != 0) return; int n = UnsafeNativeMethods.sqlite3_open16_interop(strFilename, out _sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); _functionsArray = SQLiteFunction.BindFunctions(this); } internal override string SQLiteLastError() { int len; return ToString(UnsafeNativeMethods.sqlite3_errmsg16_interop(_sql, out len), len); } internal override SQLiteStatement Prepare(string strSql, ref int nParamStart, out string strRemain) { int stmt; IntPtr ptr; int len; int n = UnsafeNativeMethods.sqlite3_prepare16_interop(_sql, strSql, strSql.Length, out stmt, out ptr, out len); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); strRemain = ToString(ptr, len); SQLiteStatement cmd = new SQLiteStatement(this, stmt, strSql.Substring(0, strSql.Length - strRemain.Length), ref nParamStart); return cmd; } internal override void Bind_DateTime(SQLiteStatement stmt, int index, DateTime dt) { Bind_Text(stmt, index, ToString(dt)); } internal override string Bind_ParamName(SQLiteStatement stmt, int index) { int len; return base.ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name_interop(stmt._sqlite_stmt, index, out len), len); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { int n = UnsafeNativeMethods.sqlite3_bind_text16_interop(stmt._sqlite_stmt, index, value, value.Length * 2, -1); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override string ColumnName(SQLiteStatement stmt, int index) { int len; return ToString(UnsafeNativeMethods.sqlite3_column_name16_interop(stmt._sqlite_stmt, index, out len), len); } internal override DateTime GetDateTime(SQLiteStatement stmt, int index) { return ToDateTime(GetText(stmt, index)); } internal override string GetText(SQLiteStatement stmt, int index) { int len; return ToString(UnsafeNativeMethods.sqlite3_column_text16_interop(stmt._sqlite_stmt, index, out len), len); } internal override string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity) { nAffinity = TypeAffinity.None; int len; IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype16_interop(stmt._sqlite_stmt, index, out len); if (p != IntPtr.Zero) return ToString(p, len); else { nAffinity = UnsafeNativeMethods.sqlite3_column_type_interop(stmt._sqlite_stmt, index); switch (nAffinity) { case TypeAffinity.Int64: return "BIGINT"; |
︙ | ︙ | |||
138 139 140 141 142 143 144 | if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override string GetParamValueText(int ptr) { | > | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override string GetParamValueText(int ptr) { int len; return ToString(UnsafeNativeMethods.sqlite3_value_text16_interop(ptr, out len), len); } internal override void ReturnError(int context, string value) { UnsafeNativeMethods.sqlite3_result_error16_interop(context, value, value.Length); } internal override void ReturnText(int context, string value) { UnsafeNativeMethods.sqlite3_result_text16_interop(context, value, value.Length, -1); } } } |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
208 209 210 211 212 213 214 | case DateTimeFormat.Ticks: return new DateTime(Convert.ToInt64(dateText, System.Globalization.CultureInfo.InvariantCulture)); default: return DateTime.ParseExact(dateText, _datetimeFormats, System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None); } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | case DateTimeFormat.Ticks: return new DateTime(Convert.ToInt64(dateText, System.Globalization.CultureInfo.InvariantCulture)); default: return DateTime.ParseExact(dateText, _datetimeFormats, System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None); } } /// <summary> /// Converts a DateTime to a string value, using the current DateTimeFormat specified for the connection when it was opened. /// </summary> /// <param name="dateValue">The DateTime value to convert</param> /// <returns>Either a string consisting of the tick count for DateTimeFormat.Ticks, or a date/time in ISO8601 format.</returns> public string ToString(DateTime dateValue) { |
︙ | ︙ | |||
357 358 359 360 361 362 363 | /// <param name="t">The SQLiteType to convert</param> /// <returns>Returns a .NET Type object</returns> internal static Type SQLiteTypeToType(SQLiteType t) { if (t.Type != DbType.Object) return SQLiteConvert.DbTypeToType(t.Type); | | > | | | < | < | | | > | > > > | | < | > | > | > > > | > > > > > | | | | | | | | | | | < < < | < < < < < < | < < | < < | | < < < | > | | | < | < | | < | | | | | < | < < | < < | | | | | | > | | | | < | > > > | | > | | | > > > | > | | | | | | | | | | < | | | | | | | | < | | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | /// <param name="t">The SQLiteType to convert</param> /// <returns>Returns a .NET Type object</returns> internal static Type SQLiteTypeToType(SQLiteType t) { if (t.Type != DbType.Object) return SQLiteConvert.DbTypeToType(t.Type); return _typeaffinities[(int)t.Affinity]; } static Type[] _typeaffinities = { null, typeof(Int64), typeof(Double), typeof(string), typeof(byte[]), typeof(DBNull), null, null, null, null, typeof(DateTime), }; /// <summary> /// For a given intrinsic type, return a DbType /// </summary> /// <param name="typ">The native type to convert</param> /// <returns>The corresponding (closest match) DbType</returns> internal static DbType TypeToDbType(Type typ) { TypeCode tc = Type.GetTypeCode(typ); if (tc == TypeCode.Object) { if (typ == typeof(byte[])) return DbType.Binary; if (typ == typeof(Guid)) return DbType.Guid; return DbType.String; } return _typetodbtype[(int)tc]; } private static DbType[] _typetodbtype = { DbType.Object, DbType.Binary, DbType.Object, DbType.Boolean, DbType.SByte, DbType.SByte, DbType.Byte, DbType.Int16, // 7 DbType.UInt16, DbType.Int32, DbType.UInt32, DbType.Int64, // 11 DbType.UInt64, DbType.Single, DbType.Double, DbType.Decimal, DbType.DateTime, DbType.Object, DbType.String, }; /// <summary> /// Convert a DbType to a Type /// </summary> /// <param name="typ">The DbType to convert from</param> /// <returns>The closest-match .NET type</returns> internal static Type DbTypeToType(DbType typ) { return _dbtypeToType[(int)typ]; } private static Type[] _dbtypeToType = { typeof(string), // 0 typeof(byte[]), // 1 typeof(byte), // 2 typeof(bool), // 3 typeof(decimal), // 4 typeof(DateTime), // 5 typeof(DateTime), // 6 typeof(decimal), // 7 typeof(double), // 8 typeof(Guid), // 9 typeof(Int16), typeof(Int32), typeof(Int64), typeof(object), typeof(sbyte), typeof(float), typeof(string), typeof(DateTime), typeof(UInt16), typeof(UInt32), typeof(UInt64), typeof(double), typeof(string), typeof(string), typeof(string), typeof(string), // 25 (Xml) }; /// <summary> /// For a given type, return the closest-match SQLite TypeAffinity, which only understands a very limited subset of types. /// </summary> /// <param name="typ">The type to evaluate</param> /// <returns>The SQLite type affinity for that type.</returns> internal static TypeAffinity TypeToAffinity(Type typ) { TypeCode tc = Type.GetTypeCode(typ); if (tc == TypeCode.Object) { if (typ == typeof(byte[])) return TypeAffinity.Blob; else return TypeAffinity.Text; } return _typecodeAffinities[(int)tc]; } private static TypeAffinity[] _typecodeAffinities = { TypeAffinity.Null, TypeAffinity.Blob, TypeAffinity.Null, TypeAffinity.Int64, TypeAffinity.Int64, TypeAffinity.Int64, TypeAffinity.Int64, TypeAffinity.Int64, // 7 TypeAffinity.Int64, TypeAffinity.Int64, TypeAffinity.Int64, TypeAffinity.Int64, // 11 TypeAffinity.Int64, TypeAffinity.Double, TypeAffinity.Double, TypeAffinity.Double, TypeAffinity.DateTime, TypeAffinity.Null, TypeAffinity.Text, }; /// <summary> /// For a given type name, return a closest-match .NET type /// </summary> /// <param name="Name">The name of the type to match</param> /// <returns>The .NET DBType the text evaluates to.</returns> internal static DbType TypeNameToDbType(string Name) |
︙ | ︙ |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
182 183 184 185 186 187 188 | [DllImport(SQLITE_DLL)] internal static extern int sqlite3_aggregate_context_interop(int context, int nBytes); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_realcolnames(int db, int bset); [DllImport(SQLITE_DLL)] | | | | | | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | [DllImport(SQLITE_DLL)] internal static extern int sqlite3_aggregate_context_interop(int context, int nBytes); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_realcolnames(int db, int bset); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text16_interop(int stmt, int index, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_open16_interop(string utf16Filename, out int db); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_errmsg16_interop(int db, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_prepare16_interop(int db, string strSql, int sqlLen, out int stmt, out IntPtr ptrRemain, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_bind_text16_interop(int stmt, int index, string value, int nlen, int nTransient); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_name16_interop(int stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_decltype16_interop(int stmt, int index, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_create_collation16_interop(int db, string strName, int nType, int nArgs, SQLiteCollation func, out int nCookie); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_create_function16_interop(int db, string strName, int nArgs, int nType, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal, out int nCookie); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text16_interop(int p, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern void sqlite3_result_error16_interop(int context, string strName, int nLen); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern void sqlite3_result_text16_interop(int context, string strName, int nLen, int pvReserved); } |
︙ | ︙ |