From d662eab5fd8af7d26536a3595aa2cedfe658b980 Mon Sep 17 00:00:00 2001 From: Stewart Adcock Date: Fri, 17 Aug 2012 12:05:01 +0100 Subject: [PATCH 01/18] Remove several variables that are declared/assigned, but their values are unused, to eliminate some build warnings with Mono. --- .../TestDriver_src/SQLiteClientTestDriver.cs | 6 +----- .../src/SqliteCommand.cs | 2 +- .../src/SqliteConnection.cs | 2 +- .../src/SqliteDataReader.cs | 2 +- Community.CsharpSqlite/src/attach_c.cs | 9 ++++---- Community.CsharpSqlite/src/btree_c.cs | 7 +++---- Community.CsharpSqlite/src/build_c.cs | 2 +- Community.CsharpSqlite/src/crypto.cs | 2 +- Community.CsharpSqlite/src/delete_c.cs | 6 ++---- Community.CsharpSqlite/src/expr_c.cs | 21 +++++++++---------- Community.CsharpSqlite/src/func_c.cs | 8 +++---- Community.CsharpSqlite/src/insert_c.cs | 10 ++++----- Community.CsharpSqlite/src/main_c.cs | 4 ++-- Community.CsharpSqlite/src/memjournal_c.cs | 17 +++++++-------- Community.CsharpSqlite/src/pager_c.cs | 18 +++++++--------- Community.CsharpSqlite/src/random_c.cs | 2 +- Community.CsharpSqlite/src/resolve_c.cs | 4 +--- Community.CsharpSqlite/src/select_c.cs | 5 ++--- Community.CsharpSqlite/src/vdbe_c.cs | 3 +-- Community.CsharpSqlite/src/vdbeapi_c.cs | 4 ++-- Community.CsharpSqlite/src/vdbeaux_c.cs | 8 +++---- Community.CsharpSqlite/src/vdbetrace_c.cs | 1 - Community.CsharpSqlite/src/vtab_c.cs | 4 ++-- Community.CsharpSqlite/src/where_c.cs | 2 +- 24 files changed, 66 insertions(+), 83 deletions(-) diff --git a/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs b/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs index bfb7b1c..5506465 100644 --- a/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs +++ b/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs @@ -13,8 +13,6 @@ namespace SQLiteClientTests { public class SQLiteClientTestDriver { - StringBuilder TempDirectory = new StringBuilder( "B:/TEMP/" ); - public void Test1() { Console.WriteLine( "Test1 Start." ); @@ -537,8 +535,6 @@ private void MultiInsertsSameThread_T7() private void T7_ThreadStart( object iSequence ) { int aValue = (int)iSequence * 1000; - int op = aValue % 2; - int rows = 0; SqliteConnection con = new SqliteConnection(); con.ConnectionString = connstring_T7; @@ -549,7 +545,7 @@ private void T7_ThreadStart( object iSequence ) cmd.CommandText = commandt; try { - rows = cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); Console.WriteLine( "Created table: ATABLE" + aValue ); } catch ( Exception ex ) diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteCommand.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteCommand.cs index 8586823..20c76ca 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteCommand.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteCommand.cs @@ -315,7 +315,7 @@ private void BindParameters3( Sqlite3.Vdbe pStmt ) private void GetNextStatement( string pzStart, ref string pzTail, ref Sqlite3.Vdbe pStmt ) { - UTF8Encoding encoding = new UTF8Encoding(); + ////UTF8Encoding encoding = new UTF8Encoding(); SqliteError err = (SqliteError)Sqlite3.sqlite3_prepare_v2( parent_conn.Handle2, pzStart, pzStart.Length, ref pStmt, ref pzTail ); if ( err != SqliteError.OK ) throw new SqliteSyntaxException( parent_conn.Handle2.errCode, GetError3() ); diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs index 48eb95d..8849472 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs @@ -343,8 +343,8 @@ public override void Open () return; } - IntPtr errmsg = IntPtr.Zero; /* + IntPtr errmsg = IntPtr.Zero; if (Version == 2){ try { sqlite_handle = Sqlite.sqlite_open(db_file, db_mode, out errmsg); diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs index 79b4dc1..c9e88fc 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs @@ -198,7 +198,7 @@ internal void ReadpVm (Sqlite3.Vdbe pVm, int version, SqliteCommand cmd) else data_row[i] = DateTime.Parse((string)data_row[i], System.Globalization.CultureInfo.InvariantCulture); break; case 4: - int blobbytes = Sqlite3.sqlite3_column_bytes16 (pVm, i); + //int blobbytes = Sqlite3.sqlite3_column_bytes16 (pVm, i); byte[] blob = Sqlite3.sqlite3_column_blob(pVm, i); //byte[] blob = new byte[blobbytes]; //Marshal.Copy (blobptr, blob, 0, blobbytes); diff --git a/Community.CsharpSqlite/src/attach_c.cs b/Community.CsharpSqlite/src/attach_c.cs index 98ed2d5..775a2be 100644 --- a/Community.CsharpSqlite/src/attach_c.cs +++ b/Community.CsharpSqlite/src/attach_c.cs @@ -375,7 +375,6 @@ static void codeAttach( Expr pKey /* Database key for encryption extension */ ) { - int rc; NameContext sName; Vdbe v; sqlite3 db = pParse.db; @@ -385,9 +384,9 @@ static void codeAttach( sName.pParse = pParse; if ( - SQLITE_OK != ( rc = resolveAttachExpr( sName, pFilename ) ) || - SQLITE_OK != ( rc = resolveAttachExpr( sName, pDbname ) ) || - SQLITE_OK != ( rc = resolveAttachExpr( sName, pKey ) ) + SQLITE_OK != resolveAttachExpr( sName, pFilename ) || + SQLITE_OK != resolveAttachExpr( sName, pDbname ) || + SQLITE_OK != resolveAttachExpr( sName, pKey ) ) { pParse.nErr++; @@ -402,7 +401,7 @@ static void codeAttach( }else{ zAuthArg = 0; } -rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0); +int rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0); if(rc!=SQLITE_OK ){ goto attach_end; } diff --git a/Community.CsharpSqlite/src/btree_c.cs b/Community.CsharpSqlite/src/btree_c.cs index 75edc08..a197839 100644 --- a/Community.CsharpSqlite/src/btree_c.cs +++ b/Community.CsharpSqlite/src/btree_c.cs @@ -2666,7 +2666,7 @@ static int lockBtree( BtShared pBt ) MemPage pPage1 = null; /* Page 1 of the database file */ Pgno nPage; /* Number of pages in the database */ Pgno nPageFile = 0; /* Number of pages in the database file */ - Pgno nPageHeader; /* Number of pages in the database according to hdr */ + ////Pgno nPageHeader; /* Number of pages in the database according to hdr */ Debug.Assert( sqlite3_mutex_held( pBt.mutex ) ); Debug.Assert( pBt.pPage1 == null ); @@ -2680,7 +2680,7 @@ static int lockBtree( BtShared pBt ) /* Do some checking to help insure the file we opened really is ** a valid database file. */ - nPage = nPageHeader = sqlite3Get4byte( pPage1.aData, 28 );//get4byte(28+(u8*)pPage1->aData); + nPage = sqlite3Get4byte( pPage1.aData, 28 );//get4byte(28+(u8*)pPage1->aData); sqlite3PagerPagecount( pBt.pPager, out nPageFile ); if ( nPage == 0 || memcmp( pPage1.aData, 24, pPage1.aData, 92, 4 ) != 0 )//memcmp(24 + (u8*)pPage1.aData, 92 + (u8*)pPage1.aData, 4) != 0) { @@ -7755,7 +7755,7 @@ static int balance( BtCursor pCur ) ** copied either into the body of a database page or into the new ** pSpace buffer passed to the latter call to balance_nonroot(). */ - u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); + ////u8[] pSpace = new u8[pCur.pBt.pageSize];// u8 pSpace = sqlite3PageMalloc( pCur.pBt.pageSize ); rc = balance_nonroot( pParent, iIdx, null, iPage == 1 ? 1 : 0 ); //if (pFree != null) //{ @@ -9201,7 +9201,6 @@ ref int pnErr /* Write number of errors seen to this variable */ int nRef; IntegrityCk sCheck = new IntegrityCk(); BtShared pBt = p.pBt; - StringBuilder zErr = new StringBuilder( 100 );//char zErr[100]; sqlite3BtreeEnter( p ); Debug.Assert( p.inTrans > TRANS_NONE && pBt.inTransaction > TRANS_NONE ); diff --git a/Community.CsharpSqlite/src/build_c.cs b/Community.CsharpSqlite/src/build_c.cs index 679000a..f59d080 100644 --- a/Community.CsharpSqlite/src/build_c.cs +++ b/Community.CsharpSqlite/src/build_c.cs @@ -2648,7 +2648,7 @@ int flags /* Conflict resolution algorithms. */ { for ( i = 0; i < nCol; i++ ) { - int n = sqlite3Strlen30( pToCol.a[i].zName ); + ////int n = sqlite3Strlen30( pToCol.a[i].zName ); if ( pFKey.aCol[i] == null ) pFKey.aCol[i] = new FKey.sColMap(); pFKey.aCol[i].zCol = pToCol.a[i].zName; diff --git a/Community.CsharpSqlite/src/crypto.cs b/Community.CsharpSqlite/src/crypto.cs index f8c1f98..f41c215 100644 --- a/Community.CsharpSqlite/src/crypto.cs +++ b/Community.CsharpSqlite/src/crypto.cs @@ -548,7 +548,7 @@ static int sqlite3CodecAttach( sqlite3 db, int nDb, string zKey, int nKey ) #endif codec_ctx ctx; int rc; - Pager pPager = pDb.pBt.pBt.pPager; + ////Pager pPager = pDb.pBt.pBt.pPager; sqlite3_file fd; ctx = new codec_ctx();//sqlite3Malloc(sizeof(codec_ctx); diff --git a/Community.CsharpSqlite/src/delete_c.cs b/Community.CsharpSqlite/src/delete_c.cs index 380e2e5..8ee2636 100644 --- a/Community.CsharpSqlite/src/delete_c.cs +++ b/Community.CsharpSqlite/src/delete_c.cs @@ -259,7 +259,6 @@ Expr pWhere /* The WHERE clause. May be null */ { Vdbe v; /* The virtual database engine */ Table pTab; /* The table from which records will be deleted */ - string zDb; /* Name of database holding pTab */ int end, addr = 0; /* A couple addresses of generated code */ int i; /* Loop counter */ WhereInfo pWInfo; /* Information about the WHERE clause */ @@ -323,9 +322,9 @@ Expr pWhere /* The WHERE clause. May be null */ } iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); Debug.Assert( iDb < db.nDb ); - zDb = db.aDb[iDb].zName; #if !SQLITE_OMIT_AUTHORIZATION -rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); + string zDb = db.aDb[iDb].zName; /* Name of database holding pTab */ + rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); #else rcauth = SQLITE_OK; #endif @@ -382,7 +381,6 @@ Expr pWhere /* The WHERE clause. May be null */ goto delete_from_cleanup; } - /* Initialize the counter of the number of rows deleted, if ** we are counting rows. */ diff --git a/Community.CsharpSqlite/src/expr_c.cs b/Community.CsharpSqlite/src/expr_c.cs index e257e35..486b5f1 100644 --- a/Community.CsharpSqlite/src/expr_c.cs +++ b/Community.CsharpSqlite/src/expr_c.cs @@ -943,7 +943,7 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) if ( p != null ) { bool isReduced = ( flags & EXPRDUP_REDUCE ) != 0; - Expr zAlloc = new Expr(); + ////Expr zAlloc = new Expr(); u32 staticFlag = 0; Debug.Assert( pzBuffer == null || isReduced ); @@ -961,14 +961,14 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) // (Expr)zAlloc; //if ( pNew != null ) - { + ////{ /* Set nNewSize to the size allocated for the structure pointed to ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed ** by the copy of the p->u.zToken string (if any). */ int nStructSize = dupedExprStructSize( p, flags ); - int nNewSize = nStructSize & 0xfff; + ////int nNewSize = nStructSize & 0xfff; int nToken; if ( !ExprHasProperty( p, EP_IntValue ) && !String.IsNullOrEmpty( p.u.zToken ) ) { @@ -985,7 +985,7 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) } else { - int nSize = exprStructSize( p ); + ////int nSize = exprStructSize( p ); //memcpy( zAlloc, p, nSize ); pNew = p.Copy(); //memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); @@ -1000,11 +1000,11 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) pNew.flags |= (ushort)staticFlag; /* Copy the p->u.zToken string, if any. */ - if ( nToken != 0 ) - { - string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; - zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); - } + ////if ( nToken != 0 ) + ////{ + //// string zToken;// = pNew.u.zToken = (char)&zAlloc[nNewSize]; + //// zToken = p.u.zToken.Substring( 0, nToken );// memcpy( zToken, p.u.zToken, nToken ); + ////} if ( 0 == ( ( p.flags | pNew.flags ) & EP_TokenOnly ) ) { @@ -1042,7 +1042,7 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) pNew.pRight = sqlite3ExprDup( db, p.pRight, 0 ); } } - } + ////} } return pNew; } @@ -1233,7 +1233,6 @@ static ExprList sqlite3ExprListAppend( Expr pExpr /* Expression to be appended. Might be NULL */ ) { - sqlite3 db = pParse.db; if ( pList == null ) { pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; diff --git a/Community.CsharpSqlite/src/func_c.cs b/Community.CsharpSqlite/src/func_c.cs index b6a4c32..59a1980 100644 --- a/Community.CsharpSqlite/src/func_c.cs +++ b/Community.CsharpSqlite/src/func_c.cs @@ -1260,8 +1260,6 @@ sqlite3_value[] argv string zRep; /* The replacement string C */ string zOut = null; /* The output */ int nStr; /* Size of zStr */ - int nPattern; /* Size of zPattern */ - int nRep; /* Size of zRep */ int nOut; /* Maximum size of zOut */ //int loopLimit; /* Last zStr[] that might match zPattern[] */ int i, j = 0; /* Loop counters */ @@ -1287,17 +1285,19 @@ sqlite3_value[] argv sqlite3_result_value( context, argv[0] ); return; } - nPattern = sqlite3_value_bytes( argv[1] ); + ////nPattern = sqlite3_value_bytes( argv[1] ); Debug.Assert( zPattern == sqlite3_value_text( argv[1] ) ); /* No encoding change */ zRep = sqlite3_value_text( argv[2] ); if ( zRep == null ) return; - nRep = sqlite3_value_bytes( argv[2] ); + ////nRep = sqlite3_value_bytes( argv[2] ); Debug.Assert( zRep == sqlite3_value_text( argv[2] ) ); nOut = nStr + 1; Debug.Assert( nOut < SQLITE_MAX_LENGTH ); if ( nOut <= sqlite3_context_db_handle( context ).aLimit[SQLITE_LIMIT_LENGTH] ) { + //int nPattern; /* Size of zPattern */ + //int nRep; /* Size of zRep */ //zOut = contextMalloc(context, (i64)nOut); //if( zOut==0 ){ // return; diff --git a/Community.CsharpSqlite/src/insert_c.cs b/Community.CsharpSqlite/src/insert_c.cs index cda4225..78bf0ff 100644 --- a/Community.CsharpSqlite/src/insert_c.cs +++ b/Community.CsharpSqlite/src/insert_c.cs @@ -503,7 +503,6 @@ int onError /* How to handle constraint errors */ sqlite3 db; /* The main database structure */ Table pTab; /* The table to insert into. aka TABLE */ string zTab; /* Name of the table into which we are inserting */ - string zDb; /* Name of the database holding this table */ int i = 0; int j = 0; int idx = 0; /* Loop counters */ @@ -563,11 +562,12 @@ int onError /* How to handle constraint errors */ iDb = sqlite3SchemaToIndex( db, pTab.pSchema ); Debug.Assert( iDb < db.nDb ); pDb = db.aDb[iDb]; - zDb = pDb.zName; #if !SQLITE_OMIT_AUTHORIZATION -if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab.zName, 0, zDb) ){ -goto insert_cleanup; -} + string zDb; /* Name of the database holding this table */ + zDb = pDb.zName; + if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab.zName, 0, zDb) ){ + goto insert_cleanup; + } #endif /* Figure out if we have any triggers and if the table being ** inserted into is a view diff --git a/Community.CsharpSqlite/src/main_c.cs b/Community.CsharpSqlite/src/main_c.cs index f77d35f..7e6773b 100644 --- a/Community.CsharpSqlite/src/main_c.cs +++ b/Community.CsharpSqlite/src/main_c.cs @@ -256,7 +256,7 @@ static public int sqlite3_initialize() memset( pHash, 0, sizeof( sqlite3GlobalFunctions ) ); #else sqlite3GlobalFunctions = new FuncDefHash(); - FuncDefHash pHash = sqlite3GlobalFunctions; + ////FuncDefHash pHash = sqlite3GlobalFunctions; #endif sqlite3RegisterGlobalFunctions(); if ( sqlite3GlobalConfig.isPCacheInit == 0 ) @@ -859,7 +859,7 @@ static int nocaseCollatingFunc( int nKey2, string pKey2 ) { - int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; + ////int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2; int r = sqlite3StrNICmp( pKey1, pKey2, ( nKey1 < nKey2 ) ? nKey1 : nKey2 ); UNUSED_PARAMETER( NotUsed ); if ( 0 == r ) diff --git a/Community.CsharpSqlite/src/memjournal_c.cs b/Community.CsharpSqlite/src/memjournal_c.cs index 4c3f5fc..6e5ed67 100644 --- a/Community.CsharpSqlite/src/memjournal_c.cs +++ b/Community.CsharpSqlite/src/memjournal_c.cs @@ -218,16 +218,16 @@ sqlite3_int64 iOfst /* Begin writing at this offset into the file */ static int memjrnlTruncate( sqlite3_file pJfd, sqlite3_int64 size ) { MemJournal p = (MemJournal)pJfd; - FileChunk pChunk; + ////FileChunk pChunk; Debug.Assert( size == 0 ); UNUSED_PARAMETER( size ); - pChunk = p.pFirst; - while ( pChunk != null ) - { - FileChunk pTmp = pChunk; - pChunk = pChunk.pNext; - //sqlite3_free( ref pTmp ); - } + ////pChunk = p.pFirst; + ////while ( pChunk != null ) + ////{ + ////FileChunk pTmp = pChunk; + ////pChunk = pChunk.pNext; + ////sqlite3_free( ref pTmp ); + ////} sqlite3MemJournalOpen( pJfd ); return SQLITE_OK; } @@ -241,7 +241,6 @@ static int memjrnlClose( MemJournal pJfd ) return SQLITE_OK; } - /* ** Sync the file. ** diff --git a/Community.CsharpSqlite/src/pager_c.cs b/Community.CsharpSqlite/src/pager_c.cs index cc24d74..c8faf88 100644 --- a/Community.CsharpSqlite/src/pager_c.cs +++ b/Community.CsharpSqlite/src/pager_c.cs @@ -4252,7 +4252,6 @@ static int pagerSyncHotJournal( Pager pPager ) */ static int sqlite3PagerClose( Pager pPager ) { - u8[] pTmp = pPager.pTmpSpace; #if SQLITE_TEST disable_simulated_io_errors(); #endif @@ -4260,17 +4259,16 @@ static int sqlite3PagerClose( Pager pPager ) /* pPager.errCode = 0; */ pPager.exclusiveMode = false; #if !SQLITE_OMIT_WAL -sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp); -pPager.pWal = 0; + u8[] pTmp = pPager.pTmpSpace; + sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp); + pPager.pWal = 0; #endif pager_reset( pPager ); - if ( #if SQLITE_OMIT_MEMORYDB -1==MEMDB + if ( 1 == MEMDB ) #else - 1 == pPager.memDb + if ( 1 == pPager.memDb ) #endif - ) { pager_unlock( pPager ); } @@ -4924,7 +4922,6 @@ dxReiniter xReinit /* Function to reinitialize pages */ */ if ( !String.IsNullOrEmpty( zFilename ) ) { - string z; nPathname = pVfs.mxPathname + 1; zPathname = new StringBuilder( nPathname * 2 );// sqlite3Malloc( nPathname * 2 ); //if ( zPathname == null ) @@ -4935,13 +4932,14 @@ dxReiniter xReinit /* Function to reinitialize pages */ rc = sqlite3OsFullPathname( pVfs, zFilename, nPathname, zPathname ); nPathname = sqlite3Strlen30( zPathname ); - z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); + zUri = zFilename; + //string z = zUri = zFilename;//.Substring(sqlite3Strlen30( zFilename ) ); //while ( *z ) //{ // z += sqlite3Strlen30( z ) + 1; // z += sqlite3Strlen30( z ) + 1; //} - nUri = zUri.Length;// &z[1] - zUri; + //nUri = zUri.Length;// &z[1] - zUri; if ( rc == SQLITE_OK && nPathname + 8 > pVfs.mxPathname ) { /* This branch is taken when the journal path required by diff --git a/Community.CsharpSqlite/src/random_c.cs b/Community.CsharpSqlite/src/random_c.cs index 0e45f81..1db1d8d 100644 --- a/Community.CsharpSqlite/src/random_c.cs +++ b/Community.CsharpSqlite/src/random_c.cs @@ -137,7 +137,7 @@ struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); */ static void sqlite3_randomness( int N, ref i64 pBuf ) { - u8[] zBuf = new u8[N]; + //u8[] zBuf = new u8[N]; pBuf = 0; #if SQLITE_THREADSAFE sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_PRNG ); diff --git a/Community.CsharpSqlite/src/resolve_c.cs b/Community.CsharpSqlite/src/resolve_c.cs index cba9d0b..43be2c7 100644 --- a/Community.CsharpSqlite/src/resolve_c.cs +++ b/Community.CsharpSqlite/src/resolve_c.cs @@ -1116,8 +1116,6 @@ static int resolveSelectStep( Walker pWalker, Select p ) int i; /* Loop counter */ ExprList pGroupBy; /* The GROUP BY clause */ Select pLeftmost; /* Left-most of SELECT of a compound */ - sqlite3 db; /* Database connection */ - Debug.Assert( p != null ); if ( ( p.selFlags & SF_Resolved ) != 0 ) @@ -1126,7 +1124,7 @@ static int resolveSelectStep( Walker pWalker, Select p ) } pOuterNC = pWalker.u.pNC; pParse = pWalker.pParse; - db = pParse.db; + //sqlite3 db = pParse.db; /* Normally sqlite3SelectExpand() will be called first and will have ** already expanded this SELECT. However, if this is a subquery within diff --git a/Community.CsharpSqlite/src/select_c.cs b/Community.CsharpSqlite/src/select_c.cs index 6fe9fcd..c4d78f0 100644 --- a/Community.CsharpSqlite/src/select_c.cs +++ b/Community.CsharpSqlite/src/select_c.cs @@ -1584,7 +1584,7 @@ static void selectAddColumnTypeAndCollation( Select pSelect /* SELECT used to determine types and collations */ ) { - sqlite3 db = pParse.db; + //sqlite3 db = pParse.db; NameContext sNC; Column pCol; CollSeq pColl; @@ -4041,10 +4041,9 @@ static void sqlite3SelectPrep( NameContext pOuterNC /* Name context for container */ ) { - sqlite3 db; if ( NEVER( p == null ) ) return; - db = pParse.db; + //sqlite3 db = pParse.db; if ( ( p.selFlags & SF_HasTypeInfo ) != 0 ) return; sqlite3SelectExpand( pParse, p ); diff --git a/Community.CsharpSqlite/src/vdbe_c.cs b/Community.CsharpSqlite/src/vdbe_c.cs index 6b01f73..7396eed 100644 --- a/Community.CsharpSqlite/src/vdbe_c.cs +++ b/Community.CsharpSqlite/src/vdbe_c.cs @@ -3132,7 +3132,6 @@ Vdbe p /* The VDBE */ { int p1; /* Value of P1 operand */ string zName; /* Name of savepoint */ - int nName; Savepoint pNew; Savepoint pSavepoint; Savepoint pTmp; @@ -3163,7 +3162,7 @@ Vdbe p /* The VDBE */ } else { - nName = sqlite3Strlen30( zName ); + ////nName = sqlite3Strlen30( zName ); #if !SQLITE_OMIT_VIRTUALTABLE /* This call is Ok even if this savepoint is actually a transaction diff --git a/Community.CsharpSqlite/src/vdbeapi_c.cs b/Community.CsharpSqlite/src/vdbeapi_c.cs index 6635520..039a8ff 100644 --- a/Community.CsharpSqlite/src/vdbeapi_c.cs +++ b/Community.CsharpSqlite/src/vdbeapi_c.cs @@ -806,8 +806,8 @@ object pAux if ( null == pVdbeFunc || pVdbeFunc.nAux <= iArg ) { int nAux = ( pVdbeFunc != null ? pVdbeFunc.nAux : 0 ); - int nMalloc = iArg; - ;//VdbeFunc+ sizeof(struct AuxData)*iArg; + ////int nMalloc = iArg; + ////VdbeFunc+ sizeof(struct AuxData)*iArg; if ( pVdbeFunc == null ) { //pVdbeFunc = (VdbeFunc)sqlite3DbRealloc( pCtx.s.db, pVdbeFunc, nMalloc ); diff --git a/Community.CsharpSqlite/src/vdbeaux_c.cs b/Community.CsharpSqlite/src/vdbeaux_c.cs index cde6fe5..3d9191e 100644 --- a/Community.CsharpSqlite/src/vdbeaux_c.cs +++ b/Community.CsharpSqlite/src/vdbeaux_c.cs @@ -1121,9 +1121,9 @@ static void sqlite3VdbeChangeP4( Vdbe p, int addr, union_p4 _p4, int n ) else if ( n == P4_KEYINFO ) { KeyInfo pKeyInfo; - int nField, nByte; + int nByte; - nField = _p4.pKeyInfo.nField; + //int nField = _p4.pKeyInfo.nField; //nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo.aColl[0]) + nField; pKeyInfo = new KeyInfo();//sqlite3DbMallocRaw(0, nByte); pOp.p4.pKeyInfo = pKeyInfo; @@ -1551,7 +1551,7 @@ static void releaseMemArray( Mem[] p, int starting, int N ) if ( p != null && p.Length > starting && p[starting] != null && N != 0 ) { Mem pEnd; - sqlite3 db = p[starting].db; + //sqlite3 db = p[starting].db; //u8 malloc_failed = db.mallocFailed; //if ( db != null ) //&& db.pnBytesFreed != 0 ) //{ @@ -3987,7 +3987,7 @@ UnpackedRecord pPKey2 /* Right key */ int nField; int rc = 0; - byte[] aKey1 = new byte[pKey1.Length - offset]; + //byte[] aKey1 = new byte[pKey1.Length - offset]; //Buffer.BlockCopy( pKey1, offset, aKey1, 0, aKey1.Length ); KeyInfo pKeyInfo; diff --git a/Community.CsharpSqlite/src/vdbetrace_c.cs b/Community.CsharpSqlite/src/vdbetrace_c.cs index 3d89e5c..82849ad 100644 --- a/Community.CsharpSqlite/src/vdbetrace_c.cs +++ b/Community.CsharpSqlite/src/vdbetrace_c.cs @@ -98,7 +98,6 @@ string zRawSql /* Raw text of the SQL statement */ int i; /* Loop counter */ Mem pVar; /* Value of a host parameter */ StrAccum _out = new StrAccum( 1000 ); /* Accumulate the _output here */ - StringBuilder zBase = new StringBuilder( 100 ); /* Initial working space */ int izRawSql = 0; db = p.db; diff --git a/Community.CsharpSqlite/src/vtab_c.cs b/Community.CsharpSqlite/src/vtab_c.cs index ae468f7..19b1407 100644 --- a/Community.CsharpSqlite/src/vtab_c.cs +++ b/Community.CsharpSqlite/src/vtab_c.cs @@ -376,9 +376,9 @@ static void addArgumentToVtab( Parse pParse ) if ( pParse.sArg.z != null && ALWAYS( pParse.pNewTable ) ) { string z = pParse.sArg.z.Substring( 0, pParse.sArg.n ); - int n = pParse.sArg.n; + ////int n = pParse.sArg.n; sqlite3 db = pParse.db; - addModuleArgument( db, pParse.pNewTable, z );///sqlite3DbStrNDup( db, z, n ) ); + addModuleArgument( db, pParse.pNewTable, z );////sqlite3DbStrNDup( db, z, n ) ); } } diff --git a/Community.CsharpSqlite/src/where_c.cs b/Community.CsharpSqlite/src/where_c.cs index 06b55b6..4e1b3f4 100644 --- a/Community.CsharpSqlite/src/where_c.cs +++ b/Community.CsharpSqlite/src/where_c.cs @@ -456,7 +456,7 @@ static int whereClauseInsert( WhereClause pWC, Expr p, u8 wtFlags ) if ( pWC.nTerm >= pWC.nSlot ) { //WhereTerm pOld = pWC.a; - sqlite3 db = pWC.pParse.db; + //sqlite3 db = pWC.pParse.db; Array.Resize( ref pWC.a, pWC.nSlot * 2 ); //pWC.a = sqlite3DbMallocRaw(db, sizeof(pWC.a[0])*pWC.nSlot*2 ); //if( pWC.a==null ){ From 1d116da2dd0a336b6d65fb4f9790f36666720f1e Mon Sep 17 00:00:00 2001 From: Stewart Adcock Date: Fri, 17 Aug 2012 12:11:26 +0100 Subject: [PATCH 02/18] Fixed Issue 153 - SqliteConnectionStringBuilder separates with ; but SqliteConnection expects , --- .../src/SqliteConnection.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs index 8849472..129e505 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteConnection.cs @@ -174,15 +174,10 @@ private void SetConnectionString(string connstring) db_file = null; db_mode = 0644; - string[] conn_pieces = connstring.Split (','); + string[] conn_pieces = connstring.Split(new char[]{',',';'}, StringSplitOptions.RemoveEmptyEntries); for ( int i = 0; i < conn_pieces.Length; i++ ) { string piece = conn_pieces[i].Trim(); - // ignore empty elements - if ( piece.Length == 0 ) - { - continue; - } int firstEqual = piece.IndexOf( '=' ); if ( firstEqual == -1 ) { From 52d59e1a389240ce8fad54ba351fd414b1e36ee0 Mon Sep 17 00:00:00 2001 From: Stewart Adcock Date: Mon, 20 Aug 2012 14:47:33 +0100 Subject: [PATCH 03/18] Partial fix for bug 138 - accept '@' as prefix for parameters. --- .../src/SqliteParameterCollection.cs | 599 +++++++++--------- 1 file changed, 300 insertions(+), 299 deletions(-) diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteParameterCollection.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteParameterCollection.cs index 4f40199..cdaa53e 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteParameterCollection.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteParameterCollection.cs @@ -1,299 +1,300 @@ -// -// Community.CsharpSqlite.SQLiteClient.SqliteParameterCollection.cs -// -// Represents a collection of parameters relevant to a SqliteCommand as well as -// their respective mappings to columns in a DataSet. -// -//Author(s): Vladimir Vukicevic -// Everaldo Canuto -// Chris Turchin -// Jeroen Zwartepoorte -// Thomas Zoechling -// Alex West -// -// Copyright (C) 2002 Vladimir Vukicevic -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Data; -using System.Data.Common; -using System.Collections; -using System.Collections.Generic ; - -namespace Community.CsharpSqlite.SQLiteClient -{ - public class SqliteParameterCollection : DbParameterCollection - { - - #region Fields - - List numeric_param_list = new List(); - Dictionary named_param_hash = new Dictionary(); - - #endregion - - #region Private Methods - - private void CheckSqliteParam (object value) - { - if (!(value is SqliteParameter)) - throw new InvalidCastException ("Can only use SqliteParameter objects"); - SqliteParameter sqlp = value as SqliteParameter; - if (sqlp.ParameterName == null || sqlp.ParameterName.Length == 0) - sqlp.ParameterName = this.GenerateParameterName(); - } - - private void RecreateNamedHash () - { - for (int i = 0; i < numeric_param_list.Count; i++) - { - named_param_hash[((SqliteParameter) numeric_param_list[i]).ParameterName] = i; - } - } - - //FIXME: if the user is calling Insert at various locations with unnamed parameters, this is not going to work.... - private string GenerateParameterName() - { - int index = this.Count + 1; - string name = String.Empty; - - while (index > 0) - { - name = ":" + index.ToString(); - if (this.IndexOf(name) == -1) - index = -1; - else - index++; - } - return name; - } - - #endregion - - #region Properties - - private bool isPrefixed (string parameterName) - { - return parameterName.Length > 1 && (parameterName[0] == ':' || parameterName[0] == '$'); - } - - protected override DbParameter GetParameter (int parameterIndex) - { - if (this.Count >= parameterIndex+1) - return (SqliteParameter) numeric_param_list[parameterIndex]; - else - throw new IndexOutOfRangeException("The specified parameter index does not exist: " + parameterIndex.ToString()); - } - - protected override DbParameter GetParameter (string parameterName) - { - if (this.Contains(parameterName)) - return this[(int) named_param_hash[parameterName]]; - else if (isPrefixed(parameterName) && this.Contains(parameterName.Substring(1))) - return this[(int) named_param_hash[parameterName.Substring(1)]]; - else - throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName); - } - - protected override void SetParameter (int parameterIndex, DbParameter parameter) - { - if (this.Count >= parameterIndex+1) - numeric_param_list[parameterIndex] = (SqliteParameter)parameter; - else - throw new IndexOutOfRangeException("The specified parameter index does not exist: " + parameterIndex.ToString()); - } - - protected override void SetParameter (string parameterName, DbParameter parameter) - { - if (this.Contains(parameterName)) - numeric_param_list[(int)named_param_hash[parameterName]] = (SqliteParameter)parameter; - else if (parameterName.Length > 1 && this.Contains(parameterName.Substring(1))) - numeric_param_list[(int) named_param_hash[parameterName.Substring(1)]] = (SqliteParameter)parameter; - else - throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName); - } - - public override int Count - { - get - { - return this.numeric_param_list.Count; - } - } - - public override bool IsSynchronized - { - get { return ((IList)this.numeric_param_list).IsSynchronized ; } - } - - public override bool IsFixedSize - { - get { return ((IList)this.numeric_param_list).IsFixedSize; } - } - - public override bool IsReadOnly - { - get { return ((IList)this.numeric_param_list).IsReadOnly; } - } - - public override object SyncRoot - { - get { return ((IList)this.numeric_param_list).SyncRoot ; } - } - - #endregion - - #region Public Methods - - public override void AddRange (Array values) - { - if (values == null || values.Length == 0) - return; - - foreach (object value in values) - Add (value); - } - - public override int Add (object value) - { - CheckSqliteParam (value); - SqliteParameter sqlp = value as SqliteParameter; - if (named_param_hash.ContainsKey(sqlp.ParameterName)) - throw new DuplicateNameException ("Parameter collection already contains the a SqliteParameter with the given ParameterName."); - numeric_param_list.Add(sqlp); - named_param_hash.Add(sqlp.ParameterName, numeric_param_list.IndexOf(sqlp)); - return (int) named_param_hash[sqlp.ParameterName]; - } - - public SqliteParameter Add (SqliteParameter param) - { - Add ((object)param); - return param; - } - - public SqliteParameter Add (string name, object value) - { - return Add (new SqliteParameter (name, value)); - } - - public SqliteParameter Add (string name, DbType type) - { - return Add (new SqliteParameter (name, type)); - } - - public override void Clear () - { - numeric_param_list.Clear (); - named_param_hash.Clear (); - } - - public override void CopyTo (Array array, int index) - { - this.numeric_param_list.CopyTo((SqliteParameter[])array, index); - } - - public override bool Contains (object value) - { - return Contains ((SqliteParameter) value); - } - - public override bool Contains (string parameterName) - { - return named_param_hash.ContainsKey(parameterName); - } - - public bool Contains (SqliteParameter param) - { - return Contains (param.ParameterName); - } - - public override IEnumerator GetEnumerator() - { - return this.numeric_param_list.GetEnumerator(); - } - - public override int IndexOf (object param) - { - return IndexOf ((SqliteParameter) param); - } - - public override int IndexOf (string parameterName) - { - if (isPrefixed (parameterName)){ - string sub = parameterName.Substring (1); - if (named_param_hash.ContainsKey(sub)) - return (int) named_param_hash [sub]; - } - if (named_param_hash.ContainsKey(parameterName)) - return (int) named_param_hash[parameterName]; - else - return -1; - } - - public int IndexOf (SqliteParameter param) - { - return IndexOf (param.ParameterName); - } - - public override void Insert (int index, object value) - { - CheckSqliteParam (value); - if (numeric_param_list.Count == index) - { - Add (value); - return; - } - - numeric_param_list.Insert(index,(SqliteParameter) value); - RecreateNamedHash (); - } - - public override void Remove (object value) - { - CheckSqliteParam (value); - RemoveAt ((SqliteParameter) value); - } - - public override void RemoveAt (int index) - { - RemoveAt (((SqliteParameter) numeric_param_list[index]).ParameterName); - } - - public override void RemoveAt (string parameterName) - { - if (!named_param_hash.ContainsKey (parameterName)) - throw new ApplicationException ("Parameter " + parameterName + " not found"); - - numeric_param_list.RemoveAt((int) named_param_hash[parameterName]); - named_param_hash.Remove (parameterName); - - RecreateNamedHash (); - } - - public void RemoveAt (SqliteParameter param) - { - RemoveAt (param.ParameterName); - } - - #endregion - } -} +// +// Community.CsharpSqlite.SQLiteClient.SqliteParameterCollection.cs +// +// Represents a collection of parameters relevant to a SqliteCommand as well as +// their respective mappings to columns in a DataSet. +// +//Author(s): Vladimir Vukicevic +// Everaldo Canuto +// Chris Turchin +// Jeroen Zwartepoorte +// Thomas Zoechling +// Alex West +// Stewart Adcock +// +// Copyright (C) 2002 Vladimir Vukicevic +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Data; +using System.Data.Common; +using System.Collections; +using System.Collections.Generic ; + +namespace Community.CsharpSqlite.SQLiteClient +{ + public class SqliteParameterCollection : DbParameterCollection + { + + #region Fields + + List numeric_param_list = new List(); + Dictionary named_param_hash = new Dictionary(); + + #endregion + + #region Private Methods + + private void CheckSqliteParam (object value) + { + if (!(value is SqliteParameter)) + throw new InvalidCastException ("Can only use SqliteParameter objects"); + SqliteParameter sqlp = value as SqliteParameter; + if (sqlp.ParameterName == null || sqlp.ParameterName.Length == 0) + sqlp.ParameterName = this.GenerateParameterName(); + } + + private void RecreateNamedHash () + { + for (int i = 0; i < numeric_param_list.Count; i++) + { + named_param_hash[((SqliteParameter) numeric_param_list[i]).ParameterName] = i; + } + } + + //FIXME: if the user is calling Insert at various locations with unnamed parameters, this is not going to work.... + private string GenerateParameterName() + { + int index = this.Count + 1; + string name = String.Empty; + + while (index > 0) + { + name = ":" + index.ToString(); + if (this.IndexOf(name) == -1) + index = -1; + else + index++; + } + return name; + } + + #endregion + + #region Properties + + private bool isPrefixed (string parameterName) + { + return parameterName.Length > 1 && (parameterName[0] == ':' || parameterName[0] == '$' || parameterName[0] == '@'); + } + + protected override DbParameter GetParameter (int parameterIndex) + { + if (this.Count >= parameterIndex+1) + return (SqliteParameter) numeric_param_list[parameterIndex]; + else + throw new IndexOutOfRangeException("The specified parameter index does not exist: " + parameterIndex.ToString()); + } + + protected override DbParameter GetParameter (string parameterName) + { + if (this.Contains(parameterName)) + return this[(int) named_param_hash[parameterName]]; + else if (isPrefixed(parameterName) && this.Contains(parameterName.Substring(1))) + return this[(int) named_param_hash[parameterName.Substring(1)]]; + else + throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName); + } + + protected override void SetParameter (int parameterIndex, DbParameter parameter) + { + if (this.Count >= parameterIndex+1) + numeric_param_list[parameterIndex] = (SqliteParameter)parameter; + else + throw new IndexOutOfRangeException("The specified parameter index does not exist: " + parameterIndex.ToString()); + } + + protected override void SetParameter (string parameterName, DbParameter parameter) + { + if (this.Contains(parameterName)) + numeric_param_list[(int)named_param_hash[parameterName]] = (SqliteParameter)parameter; + else if (parameterName.Length > 1 && this.Contains(parameterName.Substring(1))) + numeric_param_list[(int) named_param_hash[parameterName.Substring(1)]] = (SqliteParameter)parameter; + else + throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName); + } + + public override int Count + { + get + { + return this.numeric_param_list.Count; + } + } + + public override bool IsSynchronized + { + get { return ((IList)this.numeric_param_list).IsSynchronized ; } + } + + public override bool IsFixedSize + { + get { return ((IList)this.numeric_param_list).IsFixedSize; } + } + + public override bool IsReadOnly + { + get { return ((IList)this.numeric_param_list).IsReadOnly; } + } + + public override object SyncRoot + { + get { return ((IList)this.numeric_param_list).SyncRoot ; } + } + + #endregion + + #region Public Methods + + public override void AddRange (Array values) + { + if (values == null || values.Length == 0) + return; + + foreach (object value in values) + Add (value); + } + + public override int Add (object value) + { + CheckSqliteParam (value); + SqliteParameter sqlp = value as SqliteParameter; + if (named_param_hash.ContainsKey(sqlp.ParameterName)) + throw new DuplicateNameException ("Parameter collection already contains the a SqliteParameter with the given ParameterName."); + numeric_param_list.Add(sqlp); + named_param_hash.Add(sqlp.ParameterName, numeric_param_list.IndexOf(sqlp)); + return (int) named_param_hash[sqlp.ParameterName]; + } + + public SqliteParameter Add (SqliteParameter param) + { + Add ((object)param); + return param; + } + + public SqliteParameter Add (string name, object value) + { + return Add (new SqliteParameter (name, value)); + } + + public SqliteParameter Add (string name, DbType type) + { + return Add (new SqliteParameter (name, type)); + } + + public override void Clear () + { + numeric_param_list.Clear (); + named_param_hash.Clear (); + } + + public override void CopyTo (Array array, int index) + { + this.numeric_param_list.CopyTo((SqliteParameter[])array, index); + } + + public override bool Contains (object value) + { + return Contains ((SqliteParameter) value); + } + + public override bool Contains (string parameterName) + { + return named_param_hash.ContainsKey(parameterName); + } + + public bool Contains (SqliteParameter param) + { + return Contains (param.ParameterName); + } + + public override IEnumerator GetEnumerator() + { + return this.numeric_param_list.GetEnumerator(); + } + + public override int IndexOf (object param) + { + return IndexOf ((SqliteParameter) param); + } + + public override int IndexOf (string parameterName) + { + if (isPrefixed (parameterName)){ + string sub = parameterName.Substring (1); + if (named_param_hash.ContainsKey(sub)) + return (int) named_param_hash [sub]; + } + if (named_param_hash.ContainsKey(parameterName)) + return (int) named_param_hash[parameterName]; + else + return -1; + } + + public int IndexOf (SqliteParameter param) + { + return IndexOf (param.ParameterName); + } + + public override void Insert (int index, object value) + { + CheckSqliteParam (value); + if (numeric_param_list.Count == index) + { + Add (value); + return; + } + + numeric_param_list.Insert(index,(SqliteParameter) value); + RecreateNamedHash (); + } + + public override void Remove (object value) + { + CheckSqliteParam (value); + RemoveAt ((SqliteParameter) value); + } + + public override void RemoveAt (int index) + { + RemoveAt (((SqliteParameter) numeric_param_list[index]).ParameterName); + } + + public override void RemoveAt (string parameterName) + { + if (!named_param_hash.ContainsKey (parameterName)) + throw new ApplicationException ("Parameter " + parameterName + " not found"); + + numeric_param_list.RemoveAt((int) named_param_hash[parameterName]); + named_param_hash.Remove (parameterName); + + RecreateNamedHash (); + } + + public void RemoveAt (SqliteParameter param) + { + RemoveAt (param.ParameterName); + } + + #endregion + } +} From 6b3c68f6d019f779292c453a59fa69fd2c873a54 Mon Sep 17 00:00:00 2001 From: Stewart Adcock Date: Mon, 20 Aug 2012 15:13:13 +0100 Subject: [PATCH 04/18] Minor change just to simplify some logic. --- Community.CsharpSqlite/src/pcache1_c.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Community.CsharpSqlite/src/pcache1_c.cs b/Community.CsharpSqlite/src/pcache1_c.cs index 5e0db1f..ae0f193 100644 --- a/Community.CsharpSqlite/src/pcache1_c.cs +++ b/Community.CsharpSqlite/src/pcache1_c.cs @@ -729,17 +729,18 @@ static sqlite3_pcache pcache1Create( int szPage, bool bPurgeable ) //sz = sizeof( PCache1 ) + sizeof( PGroup ) * separateCache; pCache = new PCache1();//(PCache1)sqlite3_malloc( sz ); //if ( pCache != null ) - { + //{ //memset( pCache, 0, sz ); - if ( separateCache != 0 ) - { - //pGroup = new PGroup();//(PGroup)pCache[1]; - //pGroup.mxPinned = 10; - } - else + if ( separateCache == 0 ) { pGroup = pcache1.grp; } + ////else + ////{ + ////pGroup = new PGroup();//(PGroup)pCache[1]; + ////pGroup.mxPinned = 10; + ////} + pCache.pGroup = pGroup; pCache.szPage = szPage; pCache.bPurgeable = bPurgeable;//( bPurgeable ? 1 : 0 ); @@ -751,7 +752,7 @@ static sqlite3_pcache pcache1Create( int szPage, bool bPurgeable ) pGroup.mxPinned = pGroup.nMaxPage + 10 - pGroup.nMinPage; pcache1LeaveMutex( pGroup ); } - } + //} return (sqlite3_pcache)pCache; } @@ -1168,4 +1169,4 @@ static void sqlite3PcacheStats( } #endif } -} \ No newline at end of file +} From db14d83eb0801e578b67179ee7b5eac67235476e Mon Sep 17 00:00:00 2001 From: Stewart Adcock Date: Thu, 23 Aug 2012 13:54:36 +0100 Subject: [PATCH 05/18] Remove a few MonoDevelop build warnings. Remove some redundant code. Handle case of null expression argument (zTopken) gracefully. --- Community.CsharpSqlite/src/expr_c.cs | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Community.CsharpSqlite/src/expr_c.cs b/Community.CsharpSqlite/src/expr_c.cs index 486b5f1..c6637ab 100644 --- a/Community.CsharpSqlite/src/expr_c.cs +++ b/Community.CsharpSqlite/src/expr_c.cs @@ -502,8 +502,8 @@ int dequote /* True to dequote */ //pNew.u.zToken = (char)&pNew[1]; if ( pToken.n > 0 ) pNew.u.zToken = pToken.z.Substring( 0, pToken.n );//memcpy(pNew.u.zToken, pToken.z, pToken.n); - else if ( pToken.n == 0 && pToken.z == "" ) - pNew.u.zToken = ""; + else if ( pToken.n == 0 && string.IsNullOrEmpty(pToken.z)) + pNew.u.zToken = string.Empty; //pNew.u.zToken[pToken.n] = 0; if ( dequote != 0 && nExtra >= 3 && ( ( c = pToken.z[0] ) == '\'' || c == '"' || c == '[' || c == '`' ) ) @@ -537,7 +537,7 @@ string zToken /* Token argument. Might be NULL */ { Token x = new Token(); x.z = zToken; - x.n = !String.IsNullOrEmpty( zToken ) ? sqlite3Strlen30( zToken ) : 0; + x.n = !string.IsNullOrEmpty( zToken ) ? sqlite3Strlen30( zToken ) : 0; return sqlite3ExprAlloc( db, op, x, 0 ); } @@ -961,7 +961,7 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) // (Expr)zAlloc; //if ( pNew != null ) - ////{ + { /* Set nNewSize to the size allocated for the structure pointed to ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed @@ -969,26 +969,26 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) */ int nStructSize = dupedExprStructSize( p, flags ); ////int nNewSize = nStructSize & 0xfff; - int nToken; - if ( !ExprHasProperty( p, EP_IntValue ) && !String.IsNullOrEmpty( p.u.zToken ) ) - { - nToken = sqlite3Strlen30( p.u.zToken ); - } - else - { - nToken = 0; - } + ////int nToken; + ////if ( !ExprHasProperty( p, EP_IntValue ) && !string.IsNullOrEmpty( p.u.zToken ) ) + ////{ + //// nToken = sqlite3Strlen30( p.u.zToken ); + ////} + ////else + ////{ + //// nToken = 0; + ////} if ( isReduced ) { Debug.Assert( !ExprHasProperty( p, EP_Reduced ) ); - pNew = p.Copy( EXPR_TOKENONLYSIZE );//memcpy( zAlloc, p, nNewSize ); + pNew = p.Copy( EXPR_TOKENONLYSIZE );////memcpy( zAlloc, p, nNewSize ); } else { ////int nSize = exprStructSize( p ); - //memcpy( zAlloc, p, nSize ); + ////memcpy( zAlloc, p, nSize ); pNew = p.Copy(); - //memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); + ////memset( &zAlloc[nSize], 0, EXPR_FULLSIZE - nSize ); } /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ @@ -1042,7 +1042,7 @@ static Expr exprDup( sqlite3 db, Expr p, int flags, ref Expr pzBuffer ) pNew.pRight = sqlite3ExprDup( db, p.pRight, 0 ); } } - ////} + } } return pNew; } @@ -1075,7 +1075,7 @@ static ExprList sqlite3ExprListDup( sqlite3 db, ExprList p, int flags ) ExprList pNew; ExprList_item pItem; ExprList_item pOldItem; - int i; + if ( p == null ) return null; pNew = new ExprList();//sqlite3DbMallocRaw(db, sizeof(*pNew) ); @@ -1088,7 +1088,7 @@ static ExprList sqlite3ExprListDup( sqlite3 db, ExprList p, int flags ) // return null; //} //pOldItem = p.a; - for ( i = 0; i < p.nExpr; i++ ) + for (int i = 0; i < p.nExpr; i++ ) {//pItem++, pOldItem++){ pItem = pNew.a[i] = new ExprList_item(); pOldItem = p.a[i]; @@ -1114,7 +1114,6 @@ static ExprList sqlite3ExprListDup( sqlite3 db, ExprList p, int flags ) static SrcList sqlite3SrcListDup( sqlite3 db, SrcList p, int flags ) { SrcList pNew; - int i; int nByte; if ( p == null ) return null; @@ -1125,7 +1124,7 @@ static SrcList sqlite3SrcListDup( sqlite3 db, SrcList p, int flags ) if ( pNew == null ) return null; pNew.nSrc = pNew.nAlloc = p.nSrc; - for ( i = 0; i < p.nSrc; i++ ) + for (int i = 0; i < p.nSrc; i++ ) { pNew.a[i] = new SrcList_item(); SrcList_item pNewItem = pNew.a[i]; @@ -1233,6 +1232,7 @@ static ExprList sqlite3ExprListAppend( Expr pExpr /* Expression to be appended. Might be NULL */ ) { + ////sqlite3 db = pParse.db; if ( pList == null ) { pList = new ExprList(); //sqlite3DbMallocZero(db, ExprList).Length; @@ -1294,7 +1294,7 @@ int dequote /* True to cause the name to be dequoted */ pItem = pList.a[pList.nExpr - 1]; Debug.Assert( pItem.zName == null ); pItem.zName = pName.z.Substring( 0, pName.n );//sqlite3DbStrNDup(pParse.db, pName.z, pName.n); - if ( dequote != 0 && !String.IsNullOrEmpty( pItem.zName ) ) + if ( dequote != 0 && !string.IsNullOrEmpty( pItem.zName ) ) sqlite3Dequote( ref pItem.zName ); } } @@ -1949,7 +1949,7 @@ static int sqlite3CodeSubselect( if ( pParse.explain == 2 ) { string zMsg = sqlite3MPrintf( - pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? "" : "CORRELATED ", + pParse.db, "EXECUTE %s%s SUBQUERY %d", testAddr != 0 ? string.Empty : "CORRELATED ", pExpr.op == TK_IN ? "LIST" : "SCALAR", pParse.iNextSelectId ); sqlite3VdbeAddOp4( v, OP_Explain, pParse.iSelectId, 0, 0, zMsg, P4_DYNAMIC ); @@ -2316,7 +2316,7 @@ static void sqlite3ExprCodeIN( */ static void codeReal( Vdbe v, string z, bool negateFlag, int iMem ) { - if ( ALWAYS( !String.IsNullOrEmpty( z ) ) ) + if ( ALWAYS( !string.IsNullOrEmpty( z ) ) ) { double value = 0; //string zV; @@ -2352,7 +2352,7 @@ static void codeInteger( Parse pParse, Expr pExpr, bool negFlag, int iMem ) int c; i64 value = 0; string z = pExpr.u.zToken; - Debug.Assert( !String.IsNullOrEmpty( z ) ); + Debug.Assert( !string.IsNullOrEmpty( z ) ); c = sqlite3Atoi64( z, ref value, sqlite3Strlen30( z ), SQLITE_UTF8 ); if ( c == 0 || ( c == 2 && negFlag ) ) { @@ -2366,7 +2366,7 @@ static void codeInteger( Parse pParse, Expr pExpr, bool negFlag, int iMem ) else { #if SQLITE_OMIT_FLOATING_POINT -sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z); +sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : string.Empty, z); #else codeReal( v, z, negFlag, iMem ); #endif From 7d35c1a01b4d501ca8b31e095618c31496a7aa96 Mon Sep 17 00:00:00 2001 From: Uygar Yilmaz Date: Sun, 25 Nov 2012 17:50:37 +0200 Subject: [PATCH 06/18] Fixed: Issue 173 - SqliteDataReader.GetBoolean(int i) throws exception. --- Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs index c9e88fc..b73b01e 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteDataReader.cs @@ -323,7 +323,8 @@ public override bool Read () public override bool GetBoolean (int i) { - return Convert.ToBoolean (((object[]) rows[current_row])[i]); + int result = Convert.ToInt32(((object[])rows[current_row])[i]); + return Convert.ToBoolean(result); } public override byte GetByte (int i) From 0289b544e7ae2273d7ef7b7bb0a43fa926c5816f Mon Sep 17 00:00:00 2001 From: Uygar Yilmaz Date: Sun, 25 Nov 2012 17:50:51 +0200 Subject: [PATCH 07/18] Fixed: Issue 174 - Community.CsharpSqlite.SQLiteClient should be switched to AnyCPU. --- .../Community.CsharpSqlite.SQLiteClient.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Community.CsharpSqlite.SQLiteClient/Community.CsharpSqlite.SQLiteClient.csproj b/Community.CsharpSqlite.SQLiteClient/Community.CsharpSqlite.SQLiteClient.csproj index e24dd4b..d3c4583 100644 --- a/Community.CsharpSqlite.SQLiteClient/Community.CsharpSqlite.SQLiteClient.csproj +++ b/Community.CsharpSqlite.SQLiteClient/Community.CsharpSqlite.SQLiteClient.csproj @@ -44,7 +44,7 @@ prompt 4 0168 ; 0169; 0414; 0618; 0649 - x86 + AnyCPU true AllRules.ruleset From ab7f81485c47e5350bfc6f9ceae6dfb4fa7d5da6 Mon Sep 17 00:00:00 2001 From: Uygar Yilmaz Date: Mon, 26 Nov 2012 08:12:44 +0200 Subject: [PATCH 08/18] Added XML documentation comments to SqliteExceptions. --- .../src/SqliteExceptions.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Community.CsharpSqlite.SQLiteClient/src/SqliteExceptions.cs b/Community.CsharpSqlite.SQLiteClient/src/SqliteExceptions.cs index d0f9f50..4cebf8d 100644 --- a/Community.CsharpSqlite.SQLiteClient/src/SqliteExceptions.cs +++ b/Community.CsharpSqlite.SQLiteClient/src/SqliteExceptions.cs @@ -4,7 +4,9 @@ namespace Community.CsharpSqlite.SQLiteClient { - //This is the base exception of all sqlite exceptions + /// + /// Base exception for all Sqlite exceptions. + /// public class SqliteException : DbException { public int SqliteErrorCode { get; protected set; } @@ -26,7 +28,9 @@ public SqliteException(string message) } } - // This exception is raised whenever a statement cannot be compiled. + /// + /// The exception that is raised whenever a statement cannot be compiled. + /// public class SqliteSyntaxException : SqliteException { public SqliteSyntaxException(int errcode) @@ -44,8 +48,9 @@ public SqliteSyntaxException(string message) } } - // This exception is raised whenever the execution - // of a statement fails. + /// + /// The exception that is raised whenever the execution of a statement fails. + /// public class SqliteExecutionException : SqliteException { public SqliteExecutionException() @@ -66,8 +71,9 @@ public SqliteExecutionException(string message) } } - // This exception is raised whenever Sqlite says it - // cannot run a command because something is busy. + /// + /// The exception that is raised whenever Sqlite reports it cannot run a command due to being busy. + /// public class SqliteBusyException : SqliteException { public SqliteBusyException() From 7fa20106df238f4150b55e0a8558c2233d784cac Mon Sep 17 00:00:00 2001 From: stewart Date: Wed, 19 Dec 2012 12:38:04 +0000 Subject: [PATCH 09/18] Add a text file that reminds explicitly of the license conditions and copyrights. --- License | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 License diff --git a/License b/License new file mode 100644 index 0000000..f1f67c0 --- /dev/null +++ b/License @@ -0,0 +1,12 @@ +C#-SQLite is an independent reimplementation of the SQLite software library. +SQLite® is a registered trademark of Hipp, Wyrick & Company, Inc. + +The overall C#-SQLite package is distributed under the terms of the MIT License, given below. Some parts are distributed under more permissive licenses, see individual source files for details. + +Copyright (c) 2009-2012 Noah Hart and others, see individual source files for details. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From bf731fefedf081e7248067752616d2b5cfbbe1d8 Mon Sep 17 00:00:00 2001 From: stewart Date: Wed, 19 Dec 2012 12:58:31 +0000 Subject: [PATCH 10/18] Some pedantic fixes: Let VS reformat file ; Spelling corrections ; Remove unneed using statements ; Correct the "Press Enter to Continue" message. --- .../TestDriver_src/SQLiteClientTestDriver.cs | 563 +++++++++--------- 1 file changed, 281 insertions(+), 282 deletions(-) diff --git a/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs b/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs index 5506465..080c109 100644 --- a/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs +++ b/Community.CsharpSqlite.SQLiteClient/TestDriver_src/SQLiteClientTestDriver.cs @@ -1,13 +1,12 @@ using System; +using System.Collections.Generic; using System.Data; -using System.Data.Common; +using System.Globalization; using System.IO; -using System.Text; using System.Threading; -using System.Collections.Generic; + using Community.CsharpSqlite; using Community.CsharpSqlite.SQLiteClient; -using System.Globalization; namespace SQLiteClientTests { @@ -15,36 +14,36 @@ public class SQLiteClientTestDriver { public void Test1() { - Console.WriteLine( "Test1 Start." ); + Console.WriteLine("Test1 Start."); - Console.WriteLine( "Create connection..." ); + Console.WriteLine("Create connection..."); SqliteConnection con = new SqliteConnection(); string dbFilename = @"SqliteTest3.db"; - string cs = string.Format( "Version=3,uri=file:{0}", dbFilename ); + string cs = string.Format("Version=3,uri=file:{0}", dbFilename); - Console.WriteLine( "Set connection String: {0}", cs ); + Console.WriteLine("Set connection String: {0}", cs); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); con.ConnectionString = cs; - Console.WriteLine( "Open database..." ); + Console.WriteLine("Open database..."); con.Open(); - Console.WriteLine( "create command..." ); + Console.WriteLine("create command..."); IDbCommand cmd = con.CreateCommand(); - Console.WriteLine( "create table TEST_TABLE..." ); + Console.WriteLine("create table TEST_TABLE..."); cmd.CommandText = "CREATE TABLE TEST_TABLE ( COLA INTEGER, COLB TEXT, COLC DATETIME )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 1..." ); + Console.WriteLine("insert row 1..."); cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (123,'ABC','2008-12-31 18:19:20' )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 2..." ); + Console.WriteLine("insert row 2..."); cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (124,'DEF', '2009-11-16 13:35:36' )"; cmd.ExecuteNonQuery(); @@ -52,75 +51,75 @@ public void Test1() //cmd.CommandText = "COMMIT"; //cmd.ExecuteNonQuery(); - Console.WriteLine( "SELECT data from TEST_TABLE..." ); + Console.WriteLine("SELECT data from TEST_TABLE..."); cmd.CommandText = "SELECT COLA, COLB, COLC FROM TEST_TABLE"; IDataReader reader = cmd.ExecuteReader(); int r = 0; - Console.WriteLine( "Read the data..." ); - while ( reader.Read() ) + Console.WriteLine("Read the data..."); + while (reader.Read()) { - Console.WriteLine( " Row: {0}", r ); - int i = reader.GetInt32( reader.GetOrdinal( "COLA" ) ); - Console.WriteLine( " COLA: {0}", i ); + Console.WriteLine(" Row: {0}", r); + int i = reader.GetInt32(reader.GetOrdinal("COLA")); + Console.WriteLine(" COLA: {0}", i); - string s = reader.GetString( reader.GetOrdinal( "COLB" ) ); - Console.WriteLine( " COLB: {0}", s ); + string s = reader.GetString(reader.GetOrdinal("COLB")); + Console.WriteLine(" COLB: {0}", s); - DateTime dt = reader.GetDateTime( reader.GetOrdinal( "COLC" ) ); - Console.WriteLine( " COLB: {0}", dt.ToString( "MM/dd/yyyy HH:mm:ss" ) ); + DateTime dt = reader.GetDateTime(reader.GetOrdinal("COLC")); + Console.WriteLine(" COLB: {0}", dt.ToString("MM/dd/yyyy HH:mm:ss")); r++; } - Console.WriteLine( "Rows retrieved: {0}", r ); + Console.WriteLine("Rows retrieved: {0}", r); -//alxwest: DataTable & SqliteDataAdapter currently unavailable for Silverlight -#if !SQLITE_SILVERLIGHT - SqliteCommand command = new SqliteCommand( "PRAGMA table_info('TEST_TABLE')", con ); + //alxwest: DataTable & SqliteDataAdapter currently unavailable for Silverlight +#if !SQLITE_SILVERLIGHT + SqliteCommand command = new SqliteCommand("PRAGMA table_info('TEST_TABLE')", con); DataTable dataTable = new DataTable(); SqliteDataAdapter dataAdapter = new SqliteDataAdapter(); dataAdapter.SelectCommand = command; - dataAdapter.Fill( dataTable ); - DisplayDataTable( dataTable, "Columns" ); + dataAdapter.Fill(dataTable); + DisplayDataTable(dataTable, "Columns"); #endif - Console.WriteLine( "Close and cleanup..." ); + Console.WriteLine("Close and cleanup..."); con.Close(); con = null; - Console.WriteLine( "Test1 Done." ); + Console.WriteLine("Test1 Done."); } public void Test2() { - Console.WriteLine( "Test2 Start." ); + Console.WriteLine("Test2 Start."); - Console.WriteLine( "Create connection..." ); + Console.WriteLine("Create connection..."); SqliteConnection con = new SqliteConnection(); string dbFilename = @"SqliteTest3.db"; - string cs = string.Format( "Version=3,uri=file:{0}", dbFilename ); + string cs = string.Format("Version=3,uri=file:{0}", dbFilename); - Console.WriteLine( "Set connection String: {0}", cs ); + Console.WriteLine("Set connection String: {0}", cs); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); con.ConnectionString = cs; - Console.WriteLine( "Open database..." ); + Console.WriteLine("Open database..."); con.Open(); - Console.WriteLine( "create command..." ); + Console.WriteLine("create command..."); IDbCommand cmd = con.CreateCommand(); - Console.WriteLine( "create table TEST_TABLE..." ); + Console.WriteLine("create table TEST_TABLE..."); cmd.CommandText = "CREATE TABLE TBL ( ID NUMBER, NAME TEXT)"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 1..." ); + Console.WriteLine("insert row 1..."); cmd.CommandText = "INSERT INTO TBL ( ID, NAME ) VALUES (1, 'ONE' )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 2..." ); + Console.WriteLine("insert row 2..."); cmd.CommandText = "INSERT INTO TBL ( ID, NAME ) VALUES (2, '中文' )"; cmd.ExecuteNonQuery(); @@ -128,67 +127,67 @@ public void Test2() //cmd.CommandText = "COMMIT"; //cmd.ExecuteNonQuery(); - Console.WriteLine( "SELECT data from TBL..." ); + Console.WriteLine("SELECT data from TBL..."); cmd.CommandText = "SELECT id,NAME FROM tbl WHERE name = '中文'"; IDataReader reader = cmd.ExecuteReader(); int r = 0; - Console.WriteLine( "Read the data..." ); - while ( reader.Read() ) + Console.WriteLine("Read the data..."); + while (reader.Read()) { - Console.WriteLine( " Row: {0}", r ); - int i = reader.GetInt32( reader.GetOrdinal( "ID" ) ); - Console.WriteLine( " ID: {0}", i ); + Console.WriteLine(" Row: {0}", r); + int i = reader.GetInt32(reader.GetOrdinal("ID")); + Console.WriteLine(" ID: {0}", i); - string s = reader.GetString( reader.GetOrdinal( "NAME" ) ); - Console.WriteLine( " NAME: {0} = {1}", s, s == "中文" ); + string s = reader.GetString(reader.GetOrdinal("NAME")); + Console.WriteLine(" NAME: {0} = {1}", s, s == "中文"); r++; } - Console.WriteLine( "Rows retrieved: {0}", r ); + Console.WriteLine("Rows retrieved: {0}", r); //alxwest: DataTable & SqliteDataAdapter currently unavailable for Silverlight -#if !SQLITE_SILVERLIGHT - SqliteCommand command = new SqliteCommand( "PRAGMA table_info('TEST_TABLE')", con ); +#if !SQLITE_SILVERLIGHT + SqliteCommand command = new SqliteCommand("PRAGMA table_info('TEST_TABLE')", con); DataTable dataTable = new DataTable(); SqliteDataAdapter dataAdapter = new SqliteDataAdapter(); dataAdapter.SelectCommand = command; - dataAdapter.Fill( dataTable ); - DisplayDataTable( dataTable, "Columns" ); + dataAdapter.Fill(dataTable); + DisplayDataTable(dataTable, "Columns"); #endif - Console.WriteLine( "Close and cleanup..." ); + Console.WriteLine("Close and cleanup..."); con.Close(); con = null; - Console.WriteLine( "Test1 Done." ); + Console.WriteLine("Test1 Done."); } public void Test3() { - Console.WriteLine( "Test3 (Date Paramaters) Start." ); + Console.WriteLine("Test3 (Date Parameters) Start."); - Console.WriteLine( "Create connection..." ); + Console.WriteLine("Create connection..."); SqliteConnection con = new SqliteConnection(); string dbFilename = @"SqliteTest3.db"; - string cs = string.Format( "Version=3,uri=file:{0}", dbFilename ); + string cs = string.Format("Version=3,uri=file:{0}", dbFilename); - Console.WriteLine( "Set connection String: {0}", cs ); + Console.WriteLine("Set connection String: {0}", cs); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); con.ConnectionString = cs; - Console.WriteLine( "Open database..." ); + Console.WriteLine("Open database..."); con.Open(); - Console.WriteLine( "create command..." ); + Console.WriteLine("create command..."); IDbCommand cmd = con.CreateCommand(); - Console.WriteLine( "create table TEST_TABLE..." ); + Console.WriteLine("create table TEST_TABLE..."); cmd.CommandText = "CREATE TABLE TBL ( ID NUMBER, DATE_TEXT REAL)"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert ..." ); + Console.WriteLine("insert ..."); cmd.CommandText = "INSERT INTO TBL ( ID, DATE_TEXT) VALUES ( 1, @DATETEXT)"; cmd.Parameters.Add( new SqliteParameter @@ -201,29 +200,29 @@ public void Test3() cmd.ExecuteNonQuery(); - Console.WriteLine( "SELECT data from TBL..." ); + Console.WriteLine("SELECT data from TBL..."); cmd.CommandText = "SELECT * FROM tbl"; IDataReader reader = cmd.ExecuteReader(); int r = 0; - Console.WriteLine( "Read the data..." ); - while ( reader.Read() ) + Console.WriteLine("Read the data..."); + while (reader.Read()) { - Console.WriteLine( " Row: {0}", r ); - int i = reader.GetInt32( reader.GetOrdinal( "ID" ) ); - Console.WriteLine( " ID: {0}", i ); + Console.WriteLine(" Row: {0}", r); + int i = reader.GetInt32(reader.GetOrdinal("ID")); + Console.WriteLine(" ID: {0}", i); - string s = reader.GetString( reader.GetOrdinal( "DATE_TEXT" ) ); - Console.WriteLine( " DATE_TEXT: {0}", s ); + string s = reader.GetString(reader.GetOrdinal("DATE_TEXT")); + Console.WriteLine(" DATE_TEXT: {0}", s); r++; } - Console.WriteLine( "Rows retrieved: {0}", r ); + Console.WriteLine("Rows retrieved: {0}", r); - Console.WriteLine( "Close and cleanup..." ); + Console.WriteLine("Close and cleanup..."); con.Close(); con = null; - Console.WriteLine( "Test3 Done." ); + Console.WriteLine("Test3 Done."); } //nSoftware code for Threading @@ -231,23 +230,23 @@ public void Test3() public void Test4() { string dbFilename = "threading_t4.db"; - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); connstring_T4 = @"Version=3,busy_timeout=100,uri=file:" + dbFilename; Setup_T4(); InsertSameTable_T4(); //concurrent inserts SelectorWrite_T4(); //concurrent selects and inserts - Console.WriteLine( "Testing for Threading done. Press enter to continue" ); + Console.WriteLine("Testing for Threading done. Press enter to continue"); Console.In.Read(); } private void SelectorWrite_T4() { //concurrent reads/writes in the same table, if there were only Selects it would be preferable for the sqlite engine not to lock internally. - for ( int i = 0; i < 10; i++ ) + for (int i = 0; i < 10; i++) { - Console.WriteLine( "SELECT/INSERT ON Thread {0}", i ); - Thread worker = new Thread( () => + Console.WriteLine("SELECT/INSERT ON Thread {0}", i); + Thread worker = new Thread(() => { // Cannot use value of i, since it exceeds the scope of this thread and will be // reused by multiple threads @@ -259,28 +258,28 @@ private void SelectorWrite_T4() con.Open(); IDbCommand cmd = con.CreateCommand(); cmd = con.CreateCommand(); - if ( op == 0 ) + if (op == 0) { - cmd.CommandText = String.Format( "Select * FROM ATABLE" ); + cmd.CommandText = String.Format("Select * FROM ATABLE"); cmd.ExecuteReader(); } else { - cmd.CommandText = String.Format( "INSERT INTO ATABLE ( A, B, C ) VALUES ({0},'threader', '1' )", aValue ); - Console.WriteLine( cmd.CommandText ); + cmd.CommandText = String.Format("INSERT INTO ATABLE ( A, B, C ) VALUES ({0},'threader', '1' )", aValue); + Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); } - } ); + }); worker.Start(); } } //we need concurrency support on a table level inside of the database file. private void InsertSameTable_T4() { - for ( int i = 0; i < 10; i++ ) + for (int i = 0; i < 10; i++) { - Console.WriteLine( "INSERTING ON Thread {0}", i ); - Thread worker = new Thread( () => + Console.WriteLine("INSERTING ON Thread {0}", i); + Thread worker = new Thread(() => { // Cannot use value of i, since it exceeds the scope of this thread and will be // reused by multiple threads @@ -292,8 +291,8 @@ private void InsertSameTable_T4() con.Open(); IDbCommand cmd = con.CreateCommand(); cmd = con.CreateCommand(); - cmd.CommandText = String.Format( "INSERT INTO ATABLE ( A, B, C ) VALUES ({0},'threader', '1' )", aValue ); - Console.WriteLine( cmd.CommandText ); + cmd.CommandText = String.Format("INSERT INTO ATABLE ( A, B, C ) VALUES ({0},'threader', '1' )", aValue); + Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); } ); @@ -312,7 +311,7 @@ private void Setup_T4() cmd.ExecuteNonQuery(); cmd.CommandText = "CREATE TABLE IF NOT EXISTS BTABLE(A integer primary key , B varchar (50), C integer)"; cmd.ExecuteNonQuery(); - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )" ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )"); cmd.ExecuteNonQuery(); } @@ -321,22 +320,22 @@ private void Setup_T4() public void Test5() { string dbFilename = "threading_t5.db"; - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); connstring_T5 = @"Version=3,busy_timeout=2500,uri=file:" + dbFilename; Setup_T5(); MultiInsertsSameThread_T5(); //concurrent inserts - Console.WriteLine( "Threads are running..." ); + Console.WriteLine("Threads are running..."); Console.In.Read(); } private void MultiInsertsSameThread_T5() { - for ( int i = 0; i < 10; i++ ) + for (int i = 0; i < 10; i++) { //Console.WriteLine( "SELECT/INSERT ON Thread {0}", i ); - Thread worker = new Thread( () => + Thread worker = new Thread(() => { string commandt = String.Empty; try @@ -351,39 +350,39 @@ private void MultiInsertsSameThread_T5() con.Open(); IDbCommand cmd = con.CreateCommand(); cmd = con.CreateCommand(); - if ( op == 0 ) + if (op == 0) { - for ( int j = 0; j < 1000; j++ ) + for (int j = 0; j < 1000; j++) { int rows; int retry = 0; - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES ({0},'threader', '1' )", ( aValue * 10000 ) + j ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES ({0},'threader', '1' )", (aValue * 10000) + j); commandt = cmd.CommandText; do { rows = cmd.ExecuteNonQuery(); - if ( rows == 0 ) + if (rows == 0) { retry += 1; // Insert Failed - Console.WriteLine( cmd.CommandText ); - Console.WriteLine( "retry {0}", retry ); - Console.WriteLine( ( (SqliteCommand)cmd ).GetLastError() ); + Console.WriteLine(cmd.CommandText); + Console.WriteLine("retry {0}", retry); + Console.WriteLine(((SqliteCommand)cmd).GetLastError()); } - } while ( rows == 0 && retry < 5 ); + } while (rows == 0 && retry < 5); } } else { - cmd.CommandText = String.Format( "Select * FROM ATABLE" ); + cmd.CommandText = String.Format("Select * FROM ATABLE"); commandt = cmd.CommandText; cmd.ExecuteReader(); } } - catch ( Exception ex ) + catch (Exception ex) { - Console.WriteLine( String.Format( "Command {0} threw exception {1}", commandt, ex.Message ) ); + Console.WriteLine(String.Format("Command {0} threw exception {1}", commandt, ex.Message)); } - } ); + }); worker.Start(); } @@ -400,7 +399,7 @@ private void Setup_T5() cmd.ExecuteNonQuery(); cmd.CommandText = "CREATE TABLE IF NOT EXISTS BTABLE(A integer primary key , B varchar (50), C integer)"; cmd.ExecuteNonQuery(); - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )" ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )"); cmd.ExecuteNonQuery(); } @@ -409,28 +408,28 @@ private void Setup_T5() public void Test6() { string dbFilename = "threading_t6.db"; - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); connstring_T6 = @"Version=3,busy_timeout=2000,uri=file:" + dbFilename; Setup_T6(); MultiInsertsTransactionsSameThread_T6(); //concurrent inserts - Console.WriteLine( "Threads are running..." ); + Console.WriteLine("Threads are running..."); Console.In.Read(); } static Random rnd = new Random(); private void MultiInsertsTransactionsSameThread_T6() { - for ( int i = 0; i < 20; i++ ) + for (int i = 0; i < 20; i++) { - Thread.Sleep( rnd.Next( 100, 1000 ) ); - Console.WriteLine( "Launching Thread {0}", i ); - Thread worker = new Thread( SQLiteClientTestDriver.T6_ThreadStart ); - worker.Start( i ); + Thread.Sleep(rnd.Next(100, 1000)); + Console.WriteLine("Launching Thread {0}", i); + Thread worker = new Thread(SQLiteClientTestDriver.T6_ThreadStart); + worker.Start(i); } } - private static void T6_ThreadStart( object data ) + private static void T6_ThreadStart(object data) { string commandt = String.Empty; int i = (int)data; @@ -444,38 +443,38 @@ private static void T6_ThreadStart( object data ) con.Open(); IDbCommand cmd = con.CreateCommand(); cmd = con.CreateCommand(); - if ( op == 0 ) + if (op == 0) { SqliteTransaction trans = (SqliteTransaction)con.BeginTransaction(); - for ( int j = 0; j < 5000; j++ ) + for (int j = 0; j < 5000; j++) { int rows; int retry = 0; - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES ({0},'threader', '1' )", ( aValue * 10000 ) + j ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES ({0},'threader', '1' )", (aValue * 10000) + j); commandt = cmd.CommandText; do { rows = cmd.ExecuteNonQuery(); - if ( rows == 0 ) + if (rows == 0) { retry += 1; // Insert Failed - Console.WriteLine( "retry {0}:{1}:{2}", retry, ( (SqliteCommand)cmd ).GetLastError(), cmd.CommandText ); - Thread.Sleep( rnd.Next( 50, 1000 ) ); + Console.WriteLine("retry {0}:{1}:{2}", retry, ((SqliteCommand)cmd).GetLastError(), cmd.CommandText); + Thread.Sleep(rnd.Next(50, 1000)); } - } while ( rows == 0 && retry < 10 ); + } while (rows == 0 && retry < 10); } trans.Commit(); } else { - cmd.CommandText = String.Format( "Select * FROM ATABLE" ); + cmd.CommandText = String.Format("Select * FROM ATABLE"); commandt = cmd.CommandText; cmd.ExecuteReader(); } } - catch ( Exception ex ) + catch (Exception ex) { - Console.WriteLine( String.Format( "Command {0} threw exception {1}", commandt, ex.Message ) ); + Console.WriteLine(String.Format("Command {0} threw exception {1}", commandt, ex.Message)); } } private void Setup_T6() @@ -489,7 +488,7 @@ private void Setup_T6() cmd.ExecuteNonQuery(); cmd.CommandText = "CREATE TABLE IF NOT EXISTS BTABLE(A integer primary key , B varchar (50), C integer)"; cmd.ExecuteNonQuery(); - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )" ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )"); cmd.ExecuteNonQuery(); } //nSoftware code for Threading @@ -497,42 +496,42 @@ private void Setup_T6() public void Test7() { string dbFilename = "threading_t7.db"; - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); connstring_T7 = @"Version=3,busy_timeout=1000,uri=file:" + dbFilename; MultiInsertsSameThread_T7(); //concurrent table creation - Console.WriteLine( "Threads are running..." ); + Console.WriteLine("Threads are running..."); Console.In.Read(); } private void MultiInsertsSameThread_T7() { List lthread = new List(); - for ( int i = 0; i < 70; i++ ) + for (int i = 0; i < 70; i++) { - Thread.Sleep( rnd.Next( 100, 1000 ) ); - Console.WriteLine( "Launching Thread {0}", i ); - Thread worker = new Thread( this.T7_ThreadStart ); - lthread.Add( worker ); - worker.Start( i ); + Thread.Sleep(rnd.Next(100, 1000)); + Console.WriteLine("Launching Thread {0}", i); + Thread worker = new Thread(this.T7_ThreadStart); + lthread.Add(worker); + worker.Start(i); } bool alldone = false; - while ( !alldone ) + while (!alldone) { alldone = true; - for ( int i = 0; i < lthread.Count; i++ ) + for (int i = 0; i < lthread.Count; i++) { - if ( lthread[i].ThreadState == ThreadState.Running ) + if (lthread[i].ThreadState == ThreadState.Running) alldone = false; - Thread.Sleep( 100 ); + Thread.Sleep(100); } } - Console.WriteLine( "finished" ); + Console.WriteLine("finished"); } - private void T7_ThreadStart( object iSequence ) + private void T7_ThreadStart(object iSequence) { int aValue = (int)iSequence * 1000; @@ -541,16 +540,16 @@ private void T7_ThreadStart( object iSequence ) con.Open(); IDbCommand cmd = con.CreateCommand(); cmd = con.CreateCommand(); - string commandt = String.Format( "CREATE TABLE IF NOT EXISTS ATABLE{0}(A integer primary key , B varchar (50), C integer, D varchar (500))", aValue ); + string commandt = String.Format("CREATE TABLE IF NOT EXISTS ATABLE{0}(A integer primary key , B varchar (50), C integer, D varchar (500))", aValue); cmd.CommandText = commandt; try { cmd.ExecuteNonQuery(); - Console.WriteLine( "Created table: ATABLE" + aValue ); + Console.WriteLine("Created table: ATABLE" + aValue); } - catch ( Exception ex ) + catch (Exception ex) { - Console.WriteLine( String.Format( "Command {0} threw exception {1}", commandt, ex.Message ) ); + Console.WriteLine(String.Format("Command {0} threw exception {1}", commandt, ex.Message)); } } @@ -565,7 +564,7 @@ private void Setup_T7() cmd.ExecuteNonQuery(); cmd.CommandText = "CREATE TABLE IF NOT EXISTS BTABLE(A integer primary key , B varchar (50), C integer)"; cmd.ExecuteNonQuery(); - cmd.CommandText = String.Format( "INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )" ); + cmd.CommandText = String.Format("INSERT INTO BTABLE ( A, B, C ) VALUES (6,'threader', '1' )"); cmd.ExecuteNonQuery(); } @@ -576,20 +575,20 @@ public void Issue_65() //string datasource = "file://" + TempDirectory.ToString() + "myBigDb.s3db"; string datasource = "file://" + "myBigDb.s3db"; - using ( IDbConnection conn = new SqliteConnection( "uri=" + datasource ) ) + using (IDbConnection conn = new SqliteConnection("uri=" + datasource)) { - long targetFileSize = (long)Math.Pow( 2, 32 ) - 1; + long targetFileSize = (long)Math.Pow(2, 32) - 1; int rowLength = 1024; // 2^10 - long loopCount = (int)( targetFileSize / rowLength ) + 10000; + long loopCount = (int)(targetFileSize / rowLength) + 10000; char[] chars = new char[rowLength]; - for ( int i = 0; i < rowLength; i++ ) + for (int i = 0; i < rowLength; i++) { chars[i] = 'A'; } - string row = new string( chars ); + string row = new string(chars); conn.Open(); IDbCommand cmd = conn.CreateCommand(); @@ -606,14 +605,14 @@ public void Issue_65() cmd.ExecuteNonQuery(); cmd.CommandText = "insert into [MyTable] ([MyField]) VALUES ('" + row + "')"; - for ( int i = 0; i < loopCount; i++ ) + for (int i = 0; i < loopCount; i++) { cmd.ExecuteNonQuery(); } } - catch + catch { - Console.WriteLine( ( (SqliteCommand)cmd ).GetLastError() ); + Console.WriteLine(((SqliteCommand)cmd).GetLastError()); } finally { @@ -628,133 +627,133 @@ public void Issue_65() //Issue 76 Encryption is not implemented in C#SQLite client connection and command objects public void Issue_76() { - Console.WriteLine( "Test for Issue_76 Start." ); + Console.WriteLine("Test for Issue_76 Start."); - Console.WriteLine( "Create connection..." ); + Console.WriteLine("Create connection..."); SqliteConnection con = new SqliteConnection(); string dbFilename = @"SqliteTest3.db"; - string cs = string.Format( "Version=3,uri=file:{0}", dbFilename ); + string cs = string.Format("Version=3,uri=file:{0}", dbFilename); - Console.WriteLine( "Set connection String: {0}", cs ); + Console.WriteLine("Set connection String: {0}", cs); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); con.ConnectionString = cs; - Console.WriteLine( "Open database..." ); + Console.WriteLine("Open database..."); con.Open(); - Console.WriteLine( "create command..." ); + Console.WriteLine("create command..."); IDbCommand cmd = con.CreateCommand(); cmd.CommandText = "pragma hexkey='0x73656372657470617373776F72640f11'"; - Console.WriteLine( cmd.CommandText ); + Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); cmd.CommandText = "create table a (b); insert into a values ('row 1');select * from a;"; - Console.WriteLine( cmd.CommandText ); - Console.WriteLine( "Result {0}", cmd.ExecuteScalar() ); + Console.WriteLine(cmd.CommandText); + Console.WriteLine("Result {0}", cmd.ExecuteScalar()); - Console.WriteLine( "Close & Reopen Connection" ); + Console.WriteLine("Close & Reopen Connection"); con.Close(); con.Open(); cmd.CommandText = "select * from a;"; - Console.WriteLine( cmd.CommandText ); - Console.WriteLine( "Result {0}", cmd.ExecuteScalar() ); + Console.WriteLine(cmd.CommandText); + Console.WriteLine("Result {0}", cmd.ExecuteScalar()); - Console.WriteLine( "Close & Reopen Connection" ); + Console.WriteLine("Close & Reopen Connection"); con.Close(); con.Open(); cmd.CommandText = "pragma hexkey='0x73656372657470617373776F72640f11'"; - Console.WriteLine( cmd.CommandText ); + Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); cmd.CommandText = "select * from a;"; - Console.WriteLine( cmd.CommandText ); - Console.WriteLine( "Result {0}", cmd.ExecuteScalar() ); + Console.WriteLine(cmd.CommandText); + Console.WriteLine("Result {0}", cmd.ExecuteScalar()); - Console.WriteLine( "Close & Reopen Connection with password" ); + Console.WriteLine("Close & Reopen Connection with password"); con.Close(); con.ConnectionString = cs + ",Password=0x73656372657470617373776F72640f11"; con.Open(); cmd.CommandText = "select * from a;"; - Console.WriteLine( cmd.CommandText ); - Console.WriteLine( "Result {0}", cmd.ExecuteScalar() ); + Console.WriteLine(cmd.CommandText); + Console.WriteLine("Result {0}", cmd.ExecuteScalar()); con = null; - Console.WriteLine( "Issue_76 Done." ); + Console.WriteLine("Issue_76 Done."); } //Multi thread execution special command or ddl command results in exception.. public void Issue_86() { AppDomain.CurrentDomain.UnhandledException += - ( sender, eventArgs ) => + (sender, eventArgs) => { - Console.WriteLine( eventArgs.ExceptionObject ); + Console.WriteLine(eventArgs.ExceptionObject); }; int flags = Sqlite3.SQLITE_OPEN_NOMUTEX | Sqlite3.SQLITE_OPEN_READWRITE | Sqlite3.SQLITE_OPEN_CREATE; - for ( int i = 0; i < 10; i++ ) + for (int i = 0; i < 10; i++) { - Console.WriteLine( "Running Thread {0}", i ); + Console.WriteLine("Running Thread {0}", i); var t = new Thread( () => { - string dbFilename = string.Format( "db{0}.sqlite", Thread.CurrentThread.ManagedThreadId ); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); - Console.WriteLine( "Using Database {0}", dbFilename ); + string dbFilename = string.Format("db{0}.sqlite", Thread.CurrentThread.ManagedThreadId); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); + Console.WriteLine("Using Database {0}", dbFilename); Sqlite3.sqlite3 db = null; - Sqlite3.sqlite3_open_v2( dbFilename, out db, flags, null ); - var command = string.Format( "create table [t{0}] (id, name, amount)", Thread.CurrentThread.ManagedThreadId ); - ExecuteCommand( db, command ); - Sqlite3.sqlite3_close( db ); - } ); + Sqlite3.sqlite3_open_v2(dbFilename, out db, flags, null); + var command = string.Format("create table [t{0}] (id, name, amount)", Thread.CurrentThread.ManagedThreadId); + ExecuteCommand(db, command); + Sqlite3.sqlite3_close(db); + }); t.Start(); } } - private static void ExecuteCommand( Sqlite3.sqlite3 db, string command ) + private static void ExecuteCommand(Sqlite3.sqlite3 db, string command) { int rc; Sqlite3.Vdbe vm = null; - if ( Sqlite3.sqlite3_prepare_v2( db, command, command.Length, ref vm, 0 ) != Sqlite3.SQLITE_OK ) + if (Sqlite3.sqlite3_prepare_v2(db, command, command.Length, ref vm, 0) != Sqlite3.SQLITE_OK) { - throw new InvalidOperationException( string.Format( "Query failed ({0}), message: {1}.", db.errCode, Sqlite3.sqlite3_errmsg( db ) ) ); + throw new InvalidOperationException(string.Format("Query failed ({0}), message: {1}.", db.errCode, Sqlite3.sqlite3_errmsg(db))); } - rc = Sqlite3.sqlite3_step( vm ); - if ( rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW ) + rc = Sqlite3.sqlite3_step(vm); + if (rc != Sqlite3.SQLITE_DONE && rc != Sqlite3.SQLITE_ROW) { - throw new InvalidOperationException( string.Format( "Query failed ({0}), message: {1}.", db.errCode, Sqlite3.sqlite3_errmsg( db ) ) ); + throw new InvalidOperationException(string.Format("Query failed ({0}), message: {1}.", db.errCode, Sqlite3.sqlite3_errmsg(db))); } - Sqlite3.sqlite3_finalize( vm ); + Sqlite3.sqlite3_finalize(vm); } -//alxwest: DataTable & SqliteDataAdapter currently unavailable for Silverlight -#if !SQLITE_SILVERLIGHT - public void DisplayDataTable( DataTable table, string name ) + //alxwest: DataTable & SqliteDataAdapter currently unavailable for Silverlight +#if !SQLITE_SILVERLIGHT + public void DisplayDataTable(DataTable table, string name) { - Console.WriteLine( "Display DataTable: {0}", name ); + Console.WriteLine("Display DataTable: {0}", name); int r = 0; - foreach ( DataRow row in table.Rows ) + foreach (DataRow row in table.Rows) { - Console.WriteLine( "Row {0}", r ); + Console.WriteLine("Row {0}", r); int c = 0; - foreach ( DataColumn col in table.Columns ) + foreach (DataColumn col in table.Columns) { - Console.WriteLine( " Col {0}: {1} {2}", c, col.ColumnName, col.DataType ); - Console.WriteLine( " Value: {0}", row[col] ); + Console.WriteLine(" Col {0}: {1} {2}", c, col.ColumnName, col.DataType); + Console.WriteLine(" Value: {0}", row[col]); c++; } r++; } - Console.WriteLine( "Rows in data table: {0}", r ); + Console.WriteLine("Rows in data table: {0}", r); } #endif @@ -762,75 +761,75 @@ public void DisplayDataTable( DataTable table, string name ) public void Issue_119() { - Console.WriteLine( "Test Start." ); + Console.WriteLine("Test Start."); - Console.WriteLine( "Create connection..." ); + Console.WriteLine("Create connection..."); SqliteConnection con = new SqliteConnection(); string dbFilename = @"=SqliteTest3=.db"; - string cs = string.Format( "Version=3,uri=file:{0}", dbFilename ); + string cs = string.Format("Version=3,uri=file:{0}", dbFilename); - Console.WriteLine( "Set connection String: {0}", cs ); + Console.WriteLine("Set connection String: {0}", cs); - if ( File.Exists( dbFilename ) ) - File.Delete( dbFilename ); + if (File.Exists(dbFilename)) + File.Delete(dbFilename); con.ConnectionString = cs; - Console.WriteLine( "Open database..." ); + Console.WriteLine("Open database..."); con.Open(); - Console.WriteLine( "create command..." ); + Console.WriteLine("create command..."); IDbCommand cmd = con.CreateCommand(); - Console.WriteLine( "create table TEST_TABLE..." ); + Console.WriteLine("create table TEST_TABLE..."); cmd.CommandText = "CREATE TABLE TEST_TABLE ( COLA INTEGER, COLB TEXT, COLC DATETIME )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 1..." ); + Console.WriteLine("insert row 1..."); cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (123,'ABC','2008-12-31 18:19:20' )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "insert row 2..." ); + Console.WriteLine("insert row 2..."); cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (124,'DEF', '2009-11-16 13:35:36' )"; cmd.ExecuteNonQuery(); - Console.WriteLine( "SELECT data from TEST_TABLE..." ); + Console.WriteLine("SELECT data from TEST_TABLE..."); cmd.CommandText = "SELECT RowID, COLA, COLB, COLC FROM TEST_TABLE"; IDataReader reader = cmd.ExecuteReader(); int r = 0; - Console.WriteLine( "Read the data..." ); - while ( reader.Read() ) + Console.WriteLine("Read the data..."); + while (reader.Read()) { - Console.WriteLine( " Row: {0}", r ); - int rowid = reader.GetInt32( reader.GetOrdinal( "RowID" ) ); - Console.WriteLine( " RowID: {0}", rowid ); + Console.WriteLine(" Row: {0}", r); + int rowid = reader.GetInt32(reader.GetOrdinal("RowID")); + Console.WriteLine(" RowID: {0}", rowid); - int i = reader.GetInt32( reader.GetOrdinal( "COLA" ) ); - Console.WriteLine( " COLA: {0}", i ); + int i = reader.GetInt32(reader.GetOrdinal("COLA")); + Console.WriteLine(" COLA: {0}", i); - string s = reader.GetString( reader.GetOrdinal( "COLB" ) ); - Console.WriteLine( " COLB: {0}", s ); + string s = reader.GetString(reader.GetOrdinal("COLB")); + Console.WriteLine(" COLB: {0}", s); - DateTime dt = reader.GetDateTime( reader.GetOrdinal( "COLC" ) ); - Console.WriteLine( " COLB: {0}", dt.ToString( "MM/dd/yyyy HH:mm:ss" ) ); + DateTime dt = reader.GetDateTime(reader.GetOrdinal("COLC")); + Console.WriteLine(" COLB: {0}", dt.ToString("MM/dd/yyyy HH:mm:ss")); r++; } - Console.WriteLine( "Close and cleanup..." ); + Console.WriteLine("Close and cleanup..."); con.Close(); con = null; - Console.WriteLine( "Test Done." ); + Console.WriteLine("Test Done."); } public void Issue_124() { - Console.WriteLine( "Test Start." ); + Console.WriteLine("Test Start."); Sqlite3.sqlite3 db = null; - Sqlite3.sqlite3_open( ":memory:", out db ); + Sqlite3.sqlite3_open(":memory:", out db); Sqlite3.Vdbe stmt = null; string zero = null; string val; @@ -839,72 +838,72 @@ public void Issue_124() //create table { - Sqlite3.sqlite3_prepare_v2( db, "create table Test (val REAL NOT NULL)", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - Sqlite3.sqlite3_finalize( stmt ); + Sqlite3.sqlite3_prepare_v2(db, "create table Test (val REAL NOT NULL)", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + Sqlite3.sqlite3_finalize(stmt); } //insert 0.1 { - Sqlite3.sqlite3_prepare_v2( db, "insert into Test(val) values ('0.1')", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - Sqlite3.sqlite3_finalize( stmt ); + Sqlite3.sqlite3_prepare_v2(db, "insert into Test(val) values ('0.1')", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + Sqlite3.sqlite3_finalize(stmt); } //insert 0.1 { - Sqlite3.sqlite3_prepare_v2( db, "insert into Test(val) values ('0.2')", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - Sqlite3.sqlite3_finalize( stmt ); + Sqlite3.sqlite3_prepare_v2(db, "insert into Test(val) values ('0.2')", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + Sqlite3.sqlite3_finalize(stmt); } //insert 0.000000001 { - Sqlite3.sqlite3_prepare_v2( db, "insert into Test(val) values ('0.000000001')", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - Sqlite3.sqlite3_finalize( stmt ); + Sqlite3.sqlite3_prepare_v2(db, "insert into Test(val) values ('0.000000001')", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + Sqlite3.sqlite3_finalize(stmt); } //invariant culture { - System.Console.WriteLine( "invariant culture" ); - Sqlite3.sqlite3_prepare_v2( db, "select val from Test", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - val = Sqlite3.sqlite3_column_text( stmt, 0 ); - System.Console.WriteLine( "value: " + val ); - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture( "ru" ); - Sqlite3.sqlite3_step( stmt ); - val = Sqlite3.sqlite3_column_text( stmt, 0 ); - System.Console.WriteLine( "value: " + val ); - Sqlite3.sqlite3_step( stmt ); - val = Sqlite3.sqlite3_column_text( stmt, 0 ); - System.Console.WriteLine( "value: " + val ); - Sqlite3.sqlite3_finalize( stmt ); + System.Console.WriteLine("invariant culture"); + Sqlite3.sqlite3_prepare_v2(db, "select val from Test", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + val = Sqlite3.sqlite3_column_text(stmt, 0); + System.Console.WriteLine("value: " + val); + Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ru"); + Sqlite3.sqlite3_step(stmt); + val = Sqlite3.sqlite3_column_text(stmt, 0); + System.Console.WriteLine("value: " + val); + Sqlite3.sqlite3_step(stmt); + val = Sqlite3.sqlite3_column_text(stmt, 0); + System.Console.WriteLine("value: " + val); + Sqlite3.sqlite3_finalize(stmt); } //ru-ru culture { - System.Console.WriteLine( "ru" ); - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture( "ru" ); - Sqlite3.sqlite3_prepare_v2( db, "select val from Test", -1, ref stmt, ref zero ); - Sqlite3.sqlite3_step( stmt ); - val = Sqlite3.sqlite3_column_text( stmt, 0 ); - System.Console.WriteLine( "value: " + val ); - Sqlite3.sqlite3_step( stmt ); - val = Sqlite3.sqlite3_column_text( stmt, 0 ); - System.Console.WriteLine( "value: " + val ); - Sqlite3.sqlite3_finalize( stmt ); + System.Console.WriteLine("ru"); + Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ru"); + Sqlite3.sqlite3_prepare_v2(db, "select val from Test", -1, ref stmt, ref zero); + Sqlite3.sqlite3_step(stmt); + val = Sqlite3.sqlite3_column_text(stmt, 0); + System.Console.WriteLine("value: " + val); + Sqlite3.sqlite3_step(stmt); + val = Sqlite3.sqlite3_column_text(stmt, 0); + System.Console.WriteLine("value: " + val); + Sqlite3.sqlite3_finalize(stmt); } - Console.WriteLine( "Test Done." ); + Console.WriteLine("Test Done."); } - public static int Main( string[] args ) + public static int Main(string[] args) { SQLiteClientTestDriver tests = new SQLiteClientTestDriver(); - int Test = 124; - switch ( Test ) + int Test = 1; + switch (Test) { case 1: tests.Test1(); @@ -943,7 +942,7 @@ public static int Main( string[] args ) tests.Issue_124(); break; } - Console.WriteLine( "Press Enter to Continue" ); + Console.WriteLine("Press Any Key to Continue"); Console.ReadKey(); tests = null; From 2026abf81d4a86720525a21ce6ba383558efff66 Mon Sep 17 00:00:00 2001 From: stewart Date: Wed, 19 Dec 2012 13:18:57 +0000 Subject: [PATCH 11/18] Consistent namespace used in UnitTest (xUnit) project. --- .../Community.CsharpSQLite.UnitTests.csproj | 13 ++++++++----- .../Properties/AssemblyInfo.cs | 10 +++++----- Community.CsharpSqlite.UnitTests/Stress.cs | 6 +++--- Community.CsharpSqlite.UnitTests/app.config | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Community.CsharpSqlite.UnitTests/Community.CsharpSQLite.UnitTests.csproj b/Community.CsharpSqlite.UnitTests/Community.CsharpSQLite.UnitTests.csproj index a0294bd..4c173ec 100644 --- a/Community.CsharpSqlite.UnitTests/Community.CsharpSQLite.UnitTests.csproj +++ b/Community.CsharpSqlite.UnitTests/Community.CsharpSQLite.UnitTests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -8,14 +8,17 @@ {59E27BF3-3D31-42E5-BA21-FAEE135E699F} Library Properties - Community.Data.SQLite.UnitTests - Community.Data.SQLite.UnitTests + Community.Data.Sqlite.UnitTests + Community.Data.Sqlite.UnitTests v3.5 512 - - + + + + + 3.5 true diff --git a/Community.CsharpSqlite.UnitTests/Properties/AssemblyInfo.cs b/Community.CsharpSqlite.UnitTests/Properties/AssemblyInfo.cs index ada7fe9..e17ff8e 100644 --- a/Community.CsharpSqlite.UnitTests/Properties/AssemblyInfo.cs +++ b/Community.CsharpSqlite.UnitTests/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle( "Community.CsharpSQLite.UnitTests.Properties" )] +[assembly: AssemblyTitle("Community.CsharpSqlite.UnitTests.Properties")] [assembly: AssemblyDescription( "" )] [assembly: AssemblyConfiguration( "" )] -[assembly: AssemblyCompany( "Microsoft" )] -[assembly: AssemblyProduct( "Community.CsharpSQLite.UnitTests.Properties" )] -[assembly: AssemblyCopyright( "Copyright © Microsoft 2010" )] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Community.CsharpSqlite.UnitTests.Properties")] +[assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark( "" )] [assembly: AssemblyCulture( "" )] @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("3.7.5.0")] +[assembly: AssemblyVersion("3.7.7.1")] [assembly: AssemblyFileVersion( "1.0.0.0" )] diff --git a/Community.CsharpSqlite.UnitTests/Stress.cs b/Community.CsharpSqlite.UnitTests/Stress.cs index 51b67b2..7496c1e 100644 --- a/Community.CsharpSqlite.UnitTests/Stress.cs +++ b/Community.CsharpSqlite.UnitTests/Stress.cs @@ -1,11 +1,11 @@ using System.Diagnostics; using System.IO; -using Community.CsharpSQLite; -using Xunit; using Community.CsharpSqlite; -namespace Community.CsharpSQLite.UnitTests +using Xunit; + +namespace Community.CsharpSqlite.UnitTests { public class Stress { diff --git a/Community.CsharpSqlite.UnitTests/app.config b/Community.CsharpSqlite.UnitTests/app.config index b7db281..73859b0 100644 --- a/Community.CsharpSqlite.UnitTests/app.config +++ b/Community.CsharpSqlite.UnitTests/app.config @@ -1,3 +1,3 @@ - + - + From 7a88ce08e6b219f485e755a386a848e0334da32b Mon Sep 17 00:00:00 2001 From: stewart Date: Wed, 19 Dec 2012 13:19:53 +0000 Subject: [PATCH 12/18] Add patch for bug 169 http://code.google.com/p/csharp-sqlite/issues/detail?id=169 suggested by Chris Tacke. --- System.Data.Ersatz/src/System.Data/DbType.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/System.Data.Ersatz/src/System.Data/DbType.cs b/System.Data.Ersatz/src/System.Data/DbType.cs index ec0797b..3e70796 100644 --- a/System.Data.Ersatz/src/System.Data/DbType.cs +++ b/System.Data.Ersatz/src/System.Data/DbType.cs @@ -13,6 +13,14 @@ public enum DbType Int64, Byte, Binary, - Decimal + Decimal, + UInt16, + UInt32, + UInt64, + Object, + AnsiString, + AnsiStringFixedLength, + StringFixedLength, + Time } } From 791590dcf72a554eba59342ad24a0260d3df3a89 Mon Sep 17 00:00:00 2001 From: mattleibowmail Date: Sun, 10 Mar 2013 14:25:35 +0200 Subject: [PATCH 13/18] Added the SQLITE_ENABLE_COLUMN_METADATA preprocessor constant and made the sqlite3_table_column_metadata method public as in the official sqlite3 library. --- .../Community.CsharpSqlite.Silverlight.csproj | 4 ++-- Community.CsharpSqlite/src/main_c.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Community.CsharpSqlite.Silverlight/Community.CsharpSqlite.Silverlight.csproj b/Community.CsharpSqlite.Silverlight/Community.CsharpSqlite.Silverlight.csproj index dc4a398..51d0271 100644 --- a/Community.CsharpSqlite.Silverlight/Community.CsharpSqlite.Silverlight.csproj +++ b/Community.CsharpSqlite.Silverlight/Community.CsharpSqlite.Silverlight.csproj @@ -51,7 +51,7 @@ full false Bin\Debug - TRACE;DEBUG;SQLITE_SILVERLIGHT NET_40 TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF SQLITE_HAS_CODEC + TRACE;DEBUG;SQLITE_SILVERLIGHT NET_40 TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF SQLITE_HAS_CODEC SQLITE_ENABLE_COLUMN_METADATA true true prompt @@ -63,7 +63,7 @@ pdbonly true Bin\Release - SQLITE_SILVERLIGHT TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF + SQLITE_SILVERLIGHT TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF SQLITE_ENABLE_COLUMN_METADATA true true prompt diff --git a/Community.CsharpSqlite/src/main_c.cs b/Community.CsharpSqlite/src/main_c.cs index 7e6773b..164eed0 100644 --- a/Community.CsharpSqlite/src/main_c.cs +++ b/Community.CsharpSqlite/src/main_c.cs @@ -2931,7 +2931,7 @@ void sqlite3_thread_cleanup() */ #if SQLITE_ENABLE_COLUMN_METADATA - static int sqlite3_table_column_metadata( + public static int sqlite3_table_column_metadata( sqlite3 db, /* Connection handle */ string zDbName, /* Database name or NULL */ string zTableName, /* Table name */ From 78298d70b453d0473554adfb99a4de06e35da4b7 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 10 Mar 2013 14:49:27 +0200 Subject: [PATCH 14/18] Added the SQLITE_ENABLE_COLUMN_METADATA preprocessor constant for Windows Phone --- .../Community.CsharpSqlite.WinPhone.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Community.CsharpSqlite.WinPhone/Community.CsharpSqlite.WinPhone.csproj b/Community.CsharpSqlite.WinPhone/Community.CsharpSqlite.WinPhone.csproj index 3c55ef4..d7f6acd 100644 --- a/Community.CsharpSqlite.WinPhone/Community.CsharpSqlite.WinPhone.csproj +++ b/Community.CsharpSqlite.WinPhone/Community.CsharpSqlite.WinPhone.csproj @@ -24,7 +24,7 @@ full false Bin\Debug - TRACE;DEBUG;SQLITE_SILVERLIGHT NET_40 TRUE WIN32 _MSC_VER SQLITE_DEBUG NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF WINDOWS_PHONE + TRACE;DEBUG;SQLITE_SILVERLIGHT NET_40 TRUE WIN32 _MSC_VER SQLITE_DEBUG NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_VIRTUALTABLE SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF WINDOWS_PHONE SQLITE_ENABLE_COLUMN_METADATA true true prompt From 1072d6c349cbe92c222da2503c397d00e3b8e670 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 17 Mar 2013 20:48:04 +0200 Subject: [PATCH 15/18] Fixed the temporary paths for WinRT/SL/WP as they do not have access to the Path.GetTempPath() members: - WinRT = ApplicationData.Current.LocalFolder - SL/WP = sqlite3_temp_directory - others = Path.GetTempPath() --- Community.CsharpSqlite/src/os_win_c.cs | 34 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Community.CsharpSqlite/src/os_win_c.cs b/Community.CsharpSqlite/src/os_win_c.cs index 42ea9a6..30e2f59 100644 --- a/Community.CsharpSqlite/src/os_win_c.cs +++ b/Community.CsharpSqlite/src/os_win_c.cs @@ -2524,6 +2524,8 @@ static int getTempname( int nBuf, StringBuilder zBuf ) // zBuf[j] = 0; #if SQLITE_WINRT zBuf.Append( Path.Combine(ApplicationData.Current.LocalFolder.Path, SQLITE_TEMP_FILE_PREFIX + zRandom.ToString()) ); +#elif SQLITE_SILVERLIGHT + zBuf.Append(Path.Combine(sqlite3_temp_directory, SQLITE_TEMP_FILE_PREFIX + zRandom.ToString())); #else zBuf.Append( Path.GetTempPath() + SQLITE_TEMP_FILE_PREFIX + zRandom.ToString() ); #endif @@ -3088,19 +3090,35 @@ static int winAccess( attr = FileAttributes.Normal; } #else -#if WINDOWS_PHONE || WINDOWS_MOBILE || SQLITE_SILVERLIGHT +#if WINDOWS_MOBILE if (new DirectoryInfo(zFilename).Exists) +#elif SQLITE_WINRT + if (HelperMethods.DirectoryExists(zFilename)) +#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT + if (System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().DirectoryExists(zFilename)) #else - attr = File.GetAttributes( zFilename );// GetFileAttributesW( (WCHAR)zConverted ); - if ( attr == FileAttributes.Directory ) + if (Directory.Exists( zFilename )) #endif { try { - string name = Path.Combine( Path.GetTempPath(), Path.GetTempFileName() ); + var tempName = new StringBuilder(); + getTempname(MAX_PATH + 1, tempName); + string name = Path.Combine(zFilename, Path.GetFileNameWithoutExtension(tempName.ToString())); + +#if SQLITE_WINRT + Task fileTask = StorageFolder.GetFolderFromPathAsync(path).AsTask(); + fileTask.Wait(); + attr = fileTask.Attributes; +#elif WINDOWS_PHONE || SQLITE_SILVERLIGHT + var stream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(name); + stream.Close(); + IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(name); +#else FileStream fs = File.Create( name ); fs.Close(); File.Delete( name ); +#endif attr = FileAttributes.Normal; } catch ( IOException e ) @@ -3130,10 +3148,18 @@ static int winAccess( { case SQLITE_ACCESS_READ: case SQLITE_ACCESS_EXISTS: +#if SQLITE_WINRT + rc = attr == FileAttributes.Normal ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; +#else rc = attr != 0 ? 1 : 0;// != INVALID_FILE_ATTRIBUTES; +#endif break; case SQLITE_ACCESS_READWRITE: +#if SQLITE_WINRT + rc = attr != FileAttributes.Normal ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; +#else rc = attr == 0 ? 0 : (int)( attr & FileAttributes.ReadOnly ) != 0 ? 0 : 1; //FILE_ATTRIBUTE_READONLY ) == 0; +#endif break; default: Debug.Assert( "" == "Invalid flags argument" ); From 1cd6303bffffa3041304b3a12fa9a455382ed71d Mon Sep 17 00:00:00 2001 From: Megax Date: Wed, 10 Jul 2013 14:19:06 +0200 Subject: [PATCH 16/18] =?UTF-8?q?*=20.gitignore=20hozz=C3=A1adva.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ .hgignore | 32 ----------------------------- 2 files changed, 59 insertions(+), 32 deletions(-) create mode 100755 .gitignore delete mode 100644 .hgignore diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..d4421fc --- /dev/null +++ b/.gitignore @@ -0,0 +1,59 @@ +# Autosave files +*~ + +*.pc +*.gmo +*.obj +*.pidb +*.mdb +*/bin/* +Run/ + +# ignore thumbnails created by windows +Thumbs.db +# Ignore files build by Visual Studio +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +UpgradeLog.XML +UpgradeLog.htm +*.ReSharper +*.userprefs + +# http://www.gnu.org/software/automake + +Makefile +Makefile.in + +# http://www.gnu.org/software/autoconf + +/autom4te.cache +/aclocal.m4 +/compile +/configure +/depcomp +/install-sh +/missing +/config.status diff --git a/.hgignore b/.hgignore deleted file mode 100644 index faed30a..0000000 --- a/.hgignore +++ /dev/null @@ -1,32 +0,0 @@ -# Ignore file for Visual Studio 2008 - -# use glob syntax -syntax: glob - -# Ignore Visual Studio 2008 files -*~*.* -*_*.* -*_p.c -*.aps -*.bak -*.cache -*.exe -*.ilk -*.log -*.lib -*.ncb -*.obj -*.pch -*.pdb -*.sbr -*.scc -*.suo -*.tlb -*.tlh -*.user -*.vspscc -[Bb]in -[Db]ebug/ -obj/ -[Rr]elease/ -glob:.hgignore From 4324cae9e88c90a8382c2a6181689e5fdf41587f Mon Sep 17 00:00:00 2001 From: Megax Date: Wed, 10 Jul 2013 14:23:47 +0200 Subject: [PATCH 17/18] =?UTF-8?q?*=20A=20nekem=20sz=C3=BCks=C3=A9ges=20r?= =?UTF-8?q?=C3=A9szek=20friss=C3=ADtve.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Community.CsharpSqlite.csproj | 75 +------------------ Community.CsharpSqlite/app.config | 3 - 2 files changed, 2 insertions(+), 76 deletions(-) delete mode 100644 Community.CsharpSqlite/app.config diff --git a/Community.CsharpSqlite/Community.CsharpSqlite.csproj b/Community.CsharpSqlite/Community.CsharpSqlite.csproj index 3b83a2e..c6a215c 100644 --- a/Community.CsharpSqlite/Community.CsharpSqlite.csproj +++ b/Community.CsharpSqlite/Community.CsharpSqlite.csproj @@ -10,30 +10,6 @@ Properties Community.CsharpSqlite Community.CsharpSqlite - - - - - 3.5 - - - v3.5 - Client - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true true @@ -58,31 +34,9 @@ 0168 ; 0169; 0414; 0618; 0649 AllRules.ruleset - - true - bin\x86\Debug\ - DEBUG;SQLITE_DEBUG TRUE WIN32 _MSC_VER NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_W32 SQLITE_THREADSAFE SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF - 0168 ; 0169; 0414; 0618; 0649 - full - x86 - prompt - AllRules.ruleset - - - bin\x86\Release\ - TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_ENABLE_OVERSIZE_CELL_CHECK SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF - true - 0168 ; 0169; 0414; 0618; 0649 - pdbonly - x86 - prompt - AllRules.ruleset - - - 3.5 - + @@ -252,31 +206,6 @@ - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Microsoft Visual Basic PowerPacks 10.0 - true - - - False - Windows Installer 3.1 - true - - - \ No newline at end of file + diff --git a/Community.CsharpSqlite/app.config b/Community.CsharpSqlite/app.config deleted file mode 100644 index 73859b0..0000000 --- a/Community.CsharpSqlite/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - From a6ff5b064eded5fcfaeb689b6a93a61fdf25baac Mon Sep 17 00:00:00 2001 From: Megax Date: Wed, 10 Jul 2013 15:54:54 +0200 Subject: [PATCH 18/18] =?UTF-8?q?*=20Egy=C3=A9b.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Community.CsharpSqlite/Community.CsharpSqlite.csproj | 11 +++-------- Community.CsharpSqlite/Community.CsharpSqlite.sln | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Community.CsharpSqlite/Community.CsharpSqlite.csproj b/Community.CsharpSqlite/Community.CsharpSqlite.csproj index c6a215c..9133f92 100644 --- a/Community.CsharpSqlite/Community.CsharpSqlite.csproj +++ b/Community.CsharpSqlite/Community.CsharpSqlite.csproj @@ -19,27 +19,22 @@ DEBUG;SQLITE_DEBUG TRUE WIN32 _MSC_VER NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_HAS_CODEC SQLITE_MEM_POOL SQLITE_MUTEX_W32 SQLITE_THREADSAFE SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF prompt 4 - 0168 ; 0169; 0414; 0618; 0649 - AnyCPU - AllRules.ruleset + 0168;0169;0414;0618;0649 - pdbonly true bin\Release\ TRUE WIN32 _MSC_VER NDEBUG NO_TCL SQLITE_ASCII SQLITE_DISABLE_LFS SQLITE_ENABLE_OVERSIZE_CELL_CHECK SQLITE_MUTEX_OMIT SQLITE_OMIT_AUTHORIZATION SQLITE_OMIT_DEPRECATED SQLITE_OMIT_GET_TABLE SQLITE_OMIT_INCRBLOB SQLITE_OMIT_LOOKASIDE SQLITE_OMIT_SHARED_CACHE SQLITE_OMIT_UTF16 SQLITE_OMIT_WAL SQLITE_OS_WIN SQLITE_SYSTEM_MALLOC VDBE_PROFILE_OFF prompt 4 - x86 - 0168 ; 0169; 0414; 0618; 0649 - AllRules.ruleset + 0168;0169;0414;0618;0649 - + diff --git a/Community.CsharpSqlite/Community.CsharpSqlite.sln b/Community.CsharpSqlite/Community.CsharpSqlite.sln index 0e7cb6b..785f5cd 100644 --- a/Community.CsharpSqlite/Community.CsharpSqlite.sln +++ b/Community.CsharpSqlite/Community.CsharpSqlite.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community.CsharpSqlite", "Community.CsharpSqlite.csproj", "{F1653F20-D47D-4F29-8C55-3C835542AF5F}" EndProject Global