Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Globalization updates |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
d54fc9e9fb99a42f85281d7c89b48e27 |
User & Date: | rmsimpson 2005-08-17 21:14:15.000 |
Context
2005-08-18
| ||
03:46 | Updated to reflect 1.0.14 build changes check-in: e14de90abe user: rmsimpson tags: sourceforge | |
2005-08-17
| ||
21:14 | Globalization updates check-in: d54fc9e9fb user: rmsimpson tags: sourceforge | |
21:13 | Event optimizations using generics check-in: 1b0be7f408 user: rmsimpson tags: sourceforge | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
37 38 39 40 41 42 43 | } internal override void Close() { if (_sql != 0) { int n = UnsafeNativeMethods.sqlite3_close_interop(_sql); | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | } internal override void Close() { if (_sql != 0) { int n = UnsafeNativeMethods.sqlite3_close_interop(_sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); SQLiteFunction.UnbindFunctions(this, _functionsArray); } _sql = 0; } internal override void Cancel() { |
︙ | ︙ | |||
69 70 71 72 73 74 75 | } } internal override void Open(string strFilename) { if (_sql != 0) return; int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), out _sql); | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | } } internal override void Open(string strFilename) { if (_sql != 0) return; int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), out _sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); _functionsArray = SQLiteFunction.BindFunctions(this); } internal override void SetTimeout(int nTimeoutMS) { int n = UnsafeNativeMethods.sqlite3_busy_timeout_interop(_sql, nTimeoutMS); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Execute(string strSql) { IntPtr p; string str = strSql; int len; |
︙ | ︙ | |||
118 119 120 121 122 123 124 | // An error occurred, attempt to reset the statement. If the reset worked because the // schema has changed, re-try the step again. If it errored our because the database // is locked, then keep retrying until the command timeout occurs. r = Reset(stmt); if (r == 0) | | | | | 118 119 120 121 122 123 124 125 126 127 128 129 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 | // An error occurred, attempt to reset the statement. If the reset worked because the // schema has changed, re-try the step again. If it errored our because the database // is locked, then keep retrying until the command timeout occurs. r = Reset(stmt); if (r == 0) throw new SQLiteException(n, SQLiteLastError()); else if (r == 6 && stmt._command != null) // SQLITE_LOCKED { // Keep trying if (dwtick == 0) // First time we've encountered the lock { dwtick = DateTime.Now.Ticks + (stmt._command._commandTimeout * 10000000); rnd = new Random(); } // If we've exceeded the command's timeout, give up and throw an error if (DateTime.Now.Ticks - dwtick > 0) { throw new SQLiteException(r, SQLiteLastError()); } else { // Otherwise sleep for a random amount of time up to 250ms UnsafeNativeMethods.Sleep((uint)rnd.Next(1, 250)); } } } } } internal override void FinalizeStatement(SQLiteStatement stmt) { if (stmt._sqlite_stmt > 0) { int n = UnsafeNativeMethods.sqlite3_finalize_interop(stmt._sqlite_stmt); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } stmt._sqlite_stmt = 0; } internal override int Reset(SQLiteStatement stmt) { int n; |
︙ | ︙ | |||
184 185 186 187 188 189 190 | } return -1; // Reset was OK, with schema change } else if (n == 6) // SQLITE_LOCKED return n; if (n > 0) | | | | | | | | | | | 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 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 | } return -1; // Reset was OK, with schema change } else if (n == 6) // SQLITE_LOCKED return n; if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return 0; // We reset OK, no schema changes } internal override string SQLiteLastError() { int len; return ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(_sql, out len), len); } internal override SQLiteStatement Prepare(string strSql, ref int nParamStart, out string strRemain) { int stmt; IntPtr ptr; int len; byte[] b = ToUTF8(strSql); int n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, b, b.Length - 1, out stmt, out ptr, out len); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); strRemain = ToString(ptr, len); SQLiteStatement cmd = null; if (stmt > 0) cmd = new SQLiteStatement(this, stmt, strSql.Substring(0, strSql.Length - strRemain.Length), ref nParamStart); return cmd; } internal override void Bind_Double(SQLiteStatement stmt, int index, double value) { int n = UnsafeNativeMethods.sqlite3_bind_double_interop(stmt._sqlite_stmt, index, ref value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Int32(SQLiteStatement stmt, int index, int value) { int n = UnsafeNativeMethods.sqlite3_bind_int_interop(stmt._sqlite_stmt, index, value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Int64(SQLiteStatement stmt, int index, long value) { int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(stmt._sqlite_stmt, index, ref value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { byte[] b = ToUTF8(value); int n = UnsafeNativeMethods.sqlite3_bind_text_interop(stmt._sqlite_stmt, index, b, b.Length - 1, -1); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_DateTime(SQLiteStatement stmt, int index, DateTime dt) { byte[] b = ToUTF8(dt); int n = UnsafeNativeMethods.sqlite3_bind_text_interop(stmt._sqlite_stmt, index, b, b.Length - 1, -1); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Blob(SQLiteStatement stmt, int index, byte[] blobData) { int n = UnsafeNativeMethods.sqlite3_bind_blob_interop(stmt._sqlite_stmt, index, blobData, blobData.Length, -1); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Null(SQLiteStatement stmt, int index) { int n = UnsafeNativeMethods.sqlite3_bind_null_interop(stmt._sqlite_stmt, index); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override int Bind_ParamCount(SQLiteStatement stmt) { return UnsafeNativeMethods.sqlite3_bind_parameter_count_interop(stmt._sqlite_stmt); } |
︙ | ︙ | |||
408 409 410 411 412 413 414 | } internal override int CreateFunction(string strFunction, int nArgs, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal) { int nCookie; int n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, func, funcstep, funcfinal, out nCookie); | | | | 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 | } internal override int CreateFunction(string strFunction, int nArgs, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal) { int nCookie; int n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, func, funcstep, funcfinal, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override int CreateCollation(string strCollation, SQLiteCollation func) { int nCookie; int n = UnsafeNativeMethods.sqlite3_create_collation_interop(_sql, ToUTF8(strCollation), 1, 0, func, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override void FreeFunction(int nCookie) { UnsafeNativeMethods.sqlite3_function_free_callbackcookie(nCookie); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
162 163 164 165 166 167 168 | { foreach (DataRow row in tbl.Rows) { str = row[0].ToString(); if (String.Compare(str, "main", true, CultureInfo.InvariantCulture) != 0 && String.Compare(str, "temp", true, CultureInfo.InvariantCulture) != 0) { | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | { foreach (DataRow row in tbl.Rows) { str = row[0].ToString(); if (String.Compare(str, "main", true, CultureInfo.InvariantCulture) != 0 && String.Compare(str, "temp", true, CultureInfo.InvariantCulture) != 0) { _sql.Execute(String.Format(CultureInfo.InvariantCulture, "ATTACH DATABASE '{0}' AS [{1}]", row[1], row[0])); } } } } } #if PLATFORM_COMPACTFRAMEWORK |
︙ | ︙ | |||
900 901 902 903 904 905 906 | using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] NOT LIKE 'index'", strCatalog), this)) { using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader()) { while (rd.Read()) { | | | | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | using (SQLiteCommand cmd = new SQLiteCommand(String.Format(CultureInfo.CurrentCulture, "SELECT * FROM [{0}].[sqlite_master] WHERE [type] NOT LIKE 'index'", strCatalog), this)) { using (SQLiteDataReader rd = (SQLiteDataReader)cmd.ExecuteReader()) { while (rd.Read()) { strItem = rd.GetString(0); if (String.Compare(rd.GetString(2), 0, "SQLITE_", 0, 7, true, CultureInfo.CurrentCulture) == 0) strItem = "SYSTEM_TABLE"; if (String.Compare(strType, strItem, true, CultureInfo.CurrentCulture) == 0 || strType == null) { if (String.Compare(rd.GetString(2), strTable, true, CultureInfo.CurrentCulture) == 0 || strTable == null) |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | <IsCaseSensitive>false</IsCaseSensitive> <IsFixedLength>false</IsFixedLength> <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>true</IsLong> <IsNullable>true</IsNullable> <IsSearchable>false</IsSearchable> <IsSearchableWithLike>false</IsSearchableWithLike> </DataTypes> <DataTypes> <TypeName>System.String</TypeName> <ProviderDbType>16</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateParameters>max length</CreateParameters> <DataType>System.String</DataType> | > > | 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 | <IsCaseSensitive>false</IsCaseSensitive> <IsFixedLength>false</IsFixedLength> <IsFixedPrecisionScale>false</IsFixedPrecisionScale> <IsLong>true</IsLong> <IsNullable>true</IsNullable> <IsSearchable>false</IsSearchable> <IsSearchableWithLike>false</IsSearchableWithLike> <LiteralPrefix>X'</LiteralPrefix> <LiteralSuffix>'</LiteralSuffix> </DataTypes> <DataTypes> <TypeName>System.String</TypeName> <ProviderDbType>16</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateParameters>max length</CreateParameters> <DataType>System.String</DataType> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
208 209 210 211 212 213 214 | /// <param name="dateText">The string containing either a Tick value or an ISO8601-format string</param> /// <returns>A DateTime value</returns> public DateTime ToDateTime(string dateText) { switch (_datetimeFormat) { case SQLiteDateFormats.Ticks: | | | | | | 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 | /// <param name="dateText">The string containing either a Tick value or an ISO8601-format string</param> /// <returns>A DateTime value</returns> public DateTime ToDateTime(string dateText) { switch (_datetimeFormat) { case SQLiteDateFormats.Ticks: return new DateTime(Convert.ToInt64(dateText, CultureInfo.InvariantCulture)); default: return DateTime.ParseExact(dateText, _datetimeFormats, DateTimeFormatInfo.InvariantInfo, 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) { switch (_datetimeFormat) { case SQLiteDateFormats.Ticks: return dateValue.Ticks.ToString(CultureInfo.InvariantCulture); default: return dateValue.ToString(_datetimeFormats[0], CultureInfo.InvariantCulture); } } /// <summary> /// Internal function to convert a UTF-8 encoded IntPtr of the specified length to a DateTime. /// </summary> /// <remarks> |
︙ | ︙ | |||
479 480 481 482 483 484 485 | /// </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) { if (String.IsNullOrEmpty(Name)) return DbType.Object; | < < | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | /// </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) { if (String.IsNullOrEmpty(Name)) return DbType.Object; int x = _typeNames.Length; for (int n = 0; n < x; n++) { if (String.Compare(Name, 0, _typeNames[n].typeName, 0, _typeNames[n].typeName.Length, true, CultureInfo.CurrentCulture) == 0) return _typeNames[n].dataType; } return DbType.Object; } #endregion private static SQLiteTypeNames[] _typeNames = { |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteFunction.cs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; /// <summary> /// The type of user-defined function to declare /// </summary> public enum FunctionType { /// <summary> | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Globalization; /// <summary> /// The type of user-defined function to declare /// </summary> public enum FunctionType { /// <summary> |
︙ | ︙ | |||
274 275 276 277 278 279 280 | switch (SQLiteConvert.TypeToAffinity(t)) { case TypeAffinity.Null: _base.ReturnNull(context); return; case TypeAffinity.Int64: | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | switch (SQLiteConvert.TypeToAffinity(t)) { case TypeAffinity.Null: _base.ReturnNull(context); return; case TypeAffinity.Int64: _base.ReturnInt64(context, Convert.ToInt64(returnValue, CultureInfo.CurrentCulture)); return; case TypeAffinity.Double: _base.ReturnDouble(context, Convert.ToDouble(returnValue, CultureInfo.CurrentCulture)); return; case TypeAffinity.Text: _base.ReturnText(context, returnValue.ToString()); return; case TypeAffinity.Blob: _base.ReturnBlob(context, (byte[])returnValue); return; |
︙ | ︙ |