os/persistentdata/persistentstorage/sql/TEST/t_sqldefect2.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/TEST/t_sqldefect2.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,552 @@
     1.4 +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32test.h>
    1.20 +#include <f32file.h>
    1.21 +#include <sqldb.h>
    1.22 +#include <f32file.h>
    1.23 +///////////////////////////////////////////////////////////////////////////////////////
    1.24 +
    1.25 +static RFs TheFs;
    1.26 +static RTest TheTest(_L("t_sqldefect2 test"));
    1.27 +static RSqlDatabase TheDb1;
    1.28 +static RSqlDatabase TheDb2;
    1.29 +
    1.30 +_LIT(KTestDir, "c:\\test\\");
    1.31 +_LIT(KTestDatabase1, "c:\\test\\t_sqldefect2.db");
    1.32 +_LIT(KTestDatabaseJournal1, "c:\\test\\t_sqldefect2.db-journal");
    1.33 +_LIT(KServerTempDir, "c:\\private\\10281e17\\temp\\");
    1.34 +
    1.35 +///////////////////////////////////////////////////////////////////////////////////////
    1.36 +
    1.37 +//Deletes all created test files.
    1.38 +void DestroyTestEnv()
    1.39 +	{
    1.40 +    TheDb2.Close();
    1.41 +    TheDb1.Close();
    1.42 +	(void)RSqlDatabase::Delete(KTestDatabase1);
    1.43 +	TheFs.Close();
    1.44 +	}
    1.45 +
    1.46 +///////////////////////////////////////////////////////////////////////////////////////
    1.47 +///////////////////////////////////////////////////////////////////////////////////////
    1.48 +//Test macros and functions
    1.49 +void Check1(TInt aValue, TInt aLine)
    1.50 +	{
    1.51 +	if(!aValue)
    1.52 +		{
    1.53 +		DestroyTestEnv();
    1.54 +		RDebug::Print(_L("*** Line %d\r\n"), aLine);
    1.55 +		TheTest(EFalse, aLine);
    1.56 +		}
    1.57 +	}
    1.58 +void Check2(TInt aValue, TInt aExpected, TInt aLine)
    1.59 +	{
    1.60 +	if(aValue != aExpected)
    1.61 +		{
    1.62 +		DestroyTestEnv();
    1.63 +		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    1.64 +		TheTest(EFalse, aLine);
    1.65 +		}
    1.66 +	}
    1.67 +#define TEST(arg) ::Check1((arg), __LINE__)
    1.68 +#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
    1.69 +
    1.70 +///////////////////////////////////////////////////////////////////////////////////////
    1.71 +
    1.72 +//Creates file session instance and the test directory
    1.73 +void CreateTestEnv()
    1.74 +    {
    1.75 +	TInt err = TheFs.Connect();
    1.76 +	TEST2(err, KErrNone);
    1.77 +
    1.78 +	err = TheFs.MkDir(KTestDir);
    1.79 +	TEST(err == KErrNone || err == KErrAlreadyExists);
    1.80 +	}
    1.81 +
    1.82 +/**
    1.83 +@SYMTestCaseID          PDS-SQL-CT-4154
    1.84 +@SYMTestCaseDesc        Test for DEF143062: SQL, "CREATE INDEX" sql crashes SQL server.
    1.85 +                        The test creates a database with one empty table and establishes two connections
    1.86 +                        to that database. Then, while the first connection is at the middle of a read
    1.87 +                        transaction, the second connection attempts to create an index.
    1.88 +                        If the defect is not fixed, the SQL server will crash.
    1.89 +@SYMTestPriority        High
    1.90 +@SYMTestActions         DEF143062: SQL, "CREATE INDEX" sql crashes SQL server.
    1.91 +@SYMTestExpectedResults Test must not fail
    1.92 +@SYMDEF                 DEF143062
    1.93 +*/
    1.94 +void DEF143062()
    1.95 +    {
    1.96 +    (void)RSqlDatabase::Delete(KTestDatabase1);
    1.97 +    TInt err = TheDb1.Create(KTestDatabase1);
    1.98 +    TEST2(err, KErrNone);
    1.99 +    err = TheDb1.Exec(_L("CREATE TABLE T0(Thread INTEGER, LocalIndex INTEGER, Inserts INTEGER, Updates INTEGER, IndexMod8 INTEGER)"));
   1.100 +    TEST(err >= 0);
   1.101 +    
   1.102 +    err = TheDb2.Open(KTestDatabase1);
   1.103 +    TEST2(err, KErrNone);
   1.104 +
   1.105 +    RSqlStatement stmt;
   1.106 +    err = stmt.Prepare(TheDb1, _L8("SELECT COUNT(Thread) FROM T0 WHERE Thread = 0"));
   1.107 +    TEST2(err, KErrNone);
   1.108 +    err = stmt.Next();
   1.109 +    TEST2(err, KSqlAtRow);
   1.110 +    
   1.111 +    err = TheDb2.Exec(_L8("CREATE INDEX T0INDEX ON T0(Thread,IndexMod8)"));//crashes the SQL server if the defect is not fixed 
   1.112 +    TEST2(err, KSqlErrLocked);
   1.113 +    
   1.114 +    stmt.Close();
   1.115 +    
   1.116 +    TheDb2.Close();
   1.117 +    TheDb1.Close();
   1.118 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.119 +    TEST2(err, KErrNone);
   1.120 +    }
   1.121 +
   1.122 +/**
   1.123 +@SYMTestCaseID          PDS-SQL-CT-4155
   1.124 +@SYMTestCaseDesc        Test for DEF143061: SQL, SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT value is too big.
   1.125 +                                         The test verifies that after comitting a big transaction, the journal file size is made equal the 
   1.126 +                                          max journal file size limit of 64Kb.
   1.127 +@SYMTestPriority        High
   1.128 +@SYMTestActions         DEF143061: SQL, SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT value is too big..
   1.129 +@SYMTestExpectedResults Test must not fail
   1.130 +@SYMDEF                 DEF143061
   1.131 +*/
   1.132 +void DEF143061()
   1.133 +    {
   1.134 +    (void)RSqlDatabase::Delete(KTestDatabase1);
   1.135 +    //"Auto" compaction is used in order to see how the journal file is immediatelly used.
   1.136 +    _LIT8(KConfig, "compaction=auto");
   1.137 +    TInt err = TheDb1.Create(KTestDatabase1, &KConfig);
   1.138 +    TEST2(err, KErrNone);
   1.139 +    err = TheDb1.Exec(_L("CREATE TABLE A(I INTEGER, B BLOB)"));
   1.140 +    TEST(err >= 0);
   1.141 +
   1.142 +    const TInt KBlobSize = 100000;//bigger than the journal size limit
   1.143 +    HBufC8* buf = HBufC8::New(KBlobSize);
   1.144 +    TEST(buf != NULL);
   1.145 +    TPtr8 ptr = buf->Des();
   1.146 +    ptr.SetLength(KBlobSize);
   1.147 +        
   1.148 +    RSqlStatement stmt;
   1.149 +    err = stmt.Prepare(TheDb1, _L("INSERT INTO A VALUES(1, :Prm)"));
   1.150 +    TEST2(err, KErrNone);
   1.151 +    ptr.Fill(TChar('N'));
   1.152 +    err = stmt.BindBinary(0, ptr);
   1.153 +    TEST2(err, KErrNone);
   1.154 +    err = stmt.Exec();
   1.155 +    TEST2(err, 1);
   1.156 +    stmt.Close();
   1.157 +    
   1.158 +    //Try to update the BLOB in the record that was just inserted. This operation should create a big journal file.
   1.159 +    err = stmt.Prepare(TheDb1, _L("UPDATE A SET B=:Prm WHERE I=1"));
   1.160 +    TEST2(err, KErrNone);
   1.161 +    ptr.Fill(TChar('Y'));
   1.162 +    err = stmt.BindBinary(0, ptr);
   1.163 +    TEST2(err, KErrNone);
   1.164 +    err = stmt.Exec();
   1.165 +    TEST2(err, 1);
   1.166 +    stmt.Close();
   1.167 +    
   1.168 +    //Check the journal file size. It should be less than the 64Kb limit defined in sqlite_macro.mmh file.  
   1.169 +    TEntry entry;
   1.170 +    err = TheFs.Entry(KTestDatabaseJournal1, entry);
   1.171 +    TEST2(err, KErrNone);
   1.172 +    TInt64 fsize = entry.FileSize();
   1.173 +    TEST(fsize <= SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT);
   1.174 +    
   1.175 +    delete buf;
   1.176 +    TheDb1.Close();
   1.177 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.178 +    TEST2(err, KErrNone);
   1.179 +    }
   1.180 +
   1.181 +/**
   1.182 +@SYMTestCaseID          PDS-SQL-CT-4156
   1.183 +@SYMTestCaseDesc        Test for DEF143150: SQL, strftime() returns incorrect result.
   1.184 +                        The test takes the current universal time (using TTime) 
   1.185 +                        and the current time retrieved from the SQL  server.
   1.186 +                        The test compares the times and expects the difference to be no more than
   1.187 +                        1 second. 
   1.188 +@SYMTestPriority        High
   1.189 +@SYMTestActions         DEF143150: SQL, strftime() returns incorrect result
   1.190 +@SYMTestExpectedResults Test must not fail
   1.191 +@SYMDEF                 DEF143150
   1.192 +*/
   1.193 +void DEF143150()
   1.194 +    {
   1.195 +    (void)RSqlDatabase::Delete(KTestDatabase1);
   1.196 +    TInt err = TheDb1.Create(KTestDatabase1);
   1.197 +    TEST2(err, KErrNone);
   1.198 +
   1.199 +    //Home date & time
   1.200 +    TBuf<50> dtstr1;
   1.201 +    TTime time;
   1.202 +    time.UniversalTime();
   1.203 +    TDateTime dt = time.DateTime();
   1.204 +    
   1.205 +    RSqlStatement stmt;
   1.206 +    err = stmt.Prepare(TheDb1, _L("SELECT strftime('%Y-%m-%d,%H:%M:%S','now')"));
   1.207 +    TEST2(err, KErrNone);
   1.208 +    err = stmt.Next();
   1.209 +    TEST2(err, KSqlAtRow);
   1.210 +    
   1.211 +    //SQLite date & time
   1.212 +    TBuf<50> dtstr2;
   1.213 +    err = stmt.ColumnText(0, dtstr2);
   1.214 +    TEST2(err, KErrNone);
   1.215 +    stmt.Close();
   1.216 +
   1.217 +    TheDb1.Close();
   1.218 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.219 +    TEST2(err, KErrNone);
   1.220 +    
   1.221 +    dtstr1.Format(_L("%04d-%02d-%02d,%02d:%02d:%02d"), dt.Year(), dt.Month() + 1, dt.Day() + 1, dt.Hour(), dt.Minute(), dt.Second());
   1.222 +    TheTest.Printf(_L("Universal date&time=\"%S\"\n"), &dtstr1);
   1.223 +    TheTest.Printf(_L("SQLite    date&time=\"%S\"\n"), &dtstr2);
   1.224 +    
   1.225 +    //Comapare and fail if dates are not equal (+- 1 second)
   1.226 +    TLex lex;
   1.227 +    lex = dtstr2.Mid(0, 4);
   1.228 +    TInt sqlyear;
   1.229 +    err = lex.Val(sqlyear);
   1.230 +    TEST2(err, KErrNone);
   1.231 +    
   1.232 +    lex = dtstr2.Mid(5, 2);
   1.233 +    TInt sqlmonth;
   1.234 +    err = lex.Val(sqlmonth);
   1.235 +    TEST2(err, KErrNone);
   1.236 +    
   1.237 +    lex = dtstr2.Mid(8, 2);
   1.238 +    TInt sqlday;
   1.239 +    err = lex.Val(sqlday);
   1.240 +    TEST2(err, KErrNone);
   1.241 +    
   1.242 +    lex = dtstr2.Mid(11, 2);
   1.243 +    TInt sqlhour;
   1.244 +    err = lex.Val(sqlhour);
   1.245 +    TEST2(err, KErrNone);
   1.246 +    
   1.247 +    lex = dtstr2.Mid(14, 2);
   1.248 +    TInt sqlminute;
   1.249 +    err = lex.Val(sqlminute);
   1.250 +    TEST2(err, KErrNone);
   1.251 +    
   1.252 +    lex = dtstr2.Mid(17, 2);
   1.253 +    TInt sqlsecond;
   1.254 +    err = lex.Val(sqlsecond);
   1.255 +    TEST2(err, KErrNone);
   1.256 +    
   1.257 +    TDateTime sqldt(sqlyear, (TMonth)(sqlmonth - 1), sqlday - 1, sqlhour, sqlminute, sqlsecond, 0);
   1.258 +    TTime sqltime(sqldt);
   1.259 +    TTimeIntervalSeconds diff;
   1.260 +    err = sqltime.SecondsFrom(time, diff);
   1.261 +    TEST2(err, KErrNone);
   1.262 +    TEST(diff.Int() <= 1);
   1.263 +    }
   1.264 +
   1.265 +static TInt KillProcess(const TDesC& aProcessName)
   1.266 +    {
   1.267 +    TFullName name;
   1.268 +    TBuf<64> pattern(aProcessName);
   1.269 +    TInt length = pattern.Length();
   1.270 +    pattern += _L("*");
   1.271 +    TFindProcess procFinder(pattern);
   1.272 +
   1.273 +    while (procFinder.Next(name) == KErrNone)
   1.274 +        {
   1.275 +        if (name.Length() > length)
   1.276 +            {//If found name is a string containing aProcessName string.
   1.277 +            TChar c(name[length]);
   1.278 +            if (c.IsAlphaDigit() ||
   1.279 +                c == TChar('_') ||
   1.280 +                c == TChar('-'))
   1.281 +                {
   1.282 +                // If the found name is other valid application name
   1.283 +                // starting with aProcessName string.
   1.284 +                continue;
   1.285 +                }
   1.286 +            }
   1.287 +        RProcess proc;
   1.288 +        if (proc.Open(name) == KErrNone)
   1.289 +            {
   1.290 +            proc.Kill(0);
   1.291 +            }
   1.292 +        proc.Close();
   1.293 +        }
   1.294 +    return KErrNone;
   1.295 +    }
   1.296 +
   1.297 +/**
   1.298 +@SYMTestCaseID          PDS-SQL-CT-4210
   1.299 +@SYMTestCaseDesc        Test for the change "Temp files created during sql operations are not deleted after rebooting the phone" 
   1.300 +@SYMTestPriority        High
   1.301 +@SYMTestActions         Kill the sql server
   1.302 +                        Create two temp files in sql server's private directory
   1.303 +                        Start the sql server
   1.304 +                        Test that the temp files do not exist.
   1.305 +@SYMTestExpectedResults Test must not fail
   1.306 +*/
   1.307 +void DeleteTempFile()
   1.308 +    {   
   1.309 +    _LIT(KSqlSrvName, "sqlsrv.exe");
   1.310 +    _LIT(KTempFile1, "TMP00052.$$$");
   1.311 +    _LIT(KTempFile2, "TMP00044.$$$");
   1.312 +    
   1.313 +    KillProcess(KSqlSrvName);
   1.314 + 
   1.315 +    //Create two temp file in c:\\private\\10281e17\\temp\\ folder
   1.316 +    TInt err = TheFs.MkDir(KServerTempDir);
   1.317 +    TEST(err == KErrNone || err == KErrAlreadyExists);
   1.318 +    RFile file;
   1.319 +    TFileName filename1(KServerTempDir);
   1.320 +    TFileName filename2(KServerTempDir);
   1.321 +    filename1.Append(KTempFile1);
   1.322 +    filename2.Append(KTempFile2);
   1.323 +    err = file.Replace(TheFs, filename1, 0);
   1.324 +    file.Close();
   1.325 +    TEST2(err, KErrNone);
   1.326 +    err = file.Replace(TheFs, filename2, 0);
   1.327 +    file.Close();
   1.328 +    TEST2(err, KErrNone);
   1.329 +    
   1.330 +    //Create a database that should start sql server
   1.331 +    err = TheDb1.Create(KTestDatabase1);
   1.332 +    TEST(err == KErrNone || err == KErrAlreadyExists);
   1.333 +    //Test that the temp files have been deleted during server's start-up
   1.334 +    TUint dummy;
   1.335 +    err = TheFs.Att(filename1, dummy);
   1.336 +    TEST2(err, KErrNotFound);
   1.337 +    err = TheFs.Att(filename2, dummy);
   1.338 +    TEST2(err, KErrNotFound);
   1.339 +    
   1.340 +    TheDb1.Close();
   1.341 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.342 +    TEST2(err, KErrNone);
   1.343 +    }
   1.344 +
   1.345 +TInt TempFilesCount()
   1.346 +	{
   1.347 +    _LIT(KServerTempDirMask, "c:\\private\\10281e17\\temp\\*.*");
   1.348 +	CDir* dir = NULL;
   1.349 +	TInt err = TheFs.GetDir(KServerTempDirMask, KEntryAttNormal, ESortNone, dir);
   1.350 +	TEST2(err, KErrNone);
   1.351 +	TInt tmpFileCount = dir->Count();
   1.352 +	delete dir;
   1.353 +	return tmpFileCount;
   1.354 +	}
   1.355 +
   1.356 +/**
   1.357 +@SYMTestCaseID          PDS-SQL-CT-4211
   1.358 +@SYMTestCaseDesc        Test for the change "Temp files created during sql operations are not deleted after rebooting the phone" 
   1.359 +@SYMTestPriority        High
   1.360 +@SYMTestActions         The test creates a database and runs a set of statements that
   1.361 +						will lead to a delayed creation of a temp file.
   1.362 +						At the end the test checks that the temp file was created.
   1.363 +@SYMTestExpectedResults Test must not fail
   1.364 +*/
   1.365 +void TempFileTest()
   1.366 +	{
   1.367 +    (void)RSqlDatabase::Delete(KTestDatabase1);
   1.368 +    TInt err = TheDb1.Create(KTestDatabase1);
   1.369 +    TEST2(err, KErrNone);
   1.370 +    //Get the number of the files in the SQL temp directory 
   1.371 +	TInt tmpFileCount = TempFilesCount();
   1.372 +    //    
   1.373 +    err = TheDb1.Exec(_L("CREATE TABLE t1(x UNIQUE); INSERT INTO t1 VALUES(1)"));
   1.374 +    TEST(err >= 0);
   1.375 +    err = TheDb1.Exec(_L("BEGIN; UPDATE t1 SET x = 2; UPDATE t1 SET x = 3; COMMIT"));
   1.376 +    TEST(err >= 0);
   1.377 +    //Check that a temp file really was created
   1.378 +	TInt tmpFileCount2 = TempFilesCount();
   1.379 +	TEST(tmpFileCount2 > tmpFileCount);
   1.380 +    //
   1.381 +    TheDb1.Close();
   1.382 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.383 +    TEST2(err, KErrNone);
   1.384 +	}
   1.385 +
   1.386 +/**
   1.387 +@SYMTestCaseID          PDS-SQL-CT-4213
   1.388 +@SYMTestCaseDesc        Tests the ability of the SQL server to store empty strings and retrieve them as 
   1.389 +						text column values, not NULLs.
   1.390 +						Change: ou1cimx1#504388. 
   1.391 +@SYMTestPriority        High
   1.392 +@SYMTestActions         The test creates a database and a table and stores there empty strings.
   1.393 +						Then the test retrieves the stored column values and verifies that the column type is
   1.394 +						"text", not "null".
   1.395 +@SYMTestExpectedResults Test must not fail
   1.396 +*/
   1.397 +void EmptyTextColumnTest()
   1.398 +	{
   1.399 +	_LIT8(KEncUtf16, "encoding=\"UTF-16\"");
   1.400 +	_LIT8(KEncUtf8, "encoding=\"UTF-8\"");
   1.401 +	TPtrC8 enc[] = {KEncUtf16(), KEncUtf8()};
   1.402 +	for(TInt i=0;i<(sizeof(enc)/sizeof(enc[0]));++i)
   1.403 +		{
   1.404 +		(void)RSqlDatabase::Delete(KTestDatabase1);
   1.405 +		TInt err = TheDb1.Create(KTestDatabase1, &enc[i]);
   1.406 +		TEST2(err, KErrNone);
   1.407 +		//Insert records with empty text column values using RSqlDatabase::Exec()
   1.408 +	    err = TheDb1.Exec(_L("CREATE TABLE A(ID INTEGER, T TEXT)"));
   1.409 +	    TEST(err >= 0);
   1.410 +	    err = TheDb1.Exec(_L("INSERT INTO A VALUES(1, '')"));
   1.411 +	    TEST2(err, 1);
   1.412 +	    err = TheDb1.Exec(_L8("INSERT INTO A VALUES(2, '')"));
   1.413 +	    TEST2(err, 1);
   1.414 +		//Insert a record with empty text column value using RSqlParamWriteStream
   1.415 +	    RSqlStatement stmt;
   1.416 +	    err = stmt.Prepare(TheDb1, _L("INSERT INTO A(ID, T) VALUES(:P1, :P2)"));
   1.417 +	    TEST2(err, KErrNone);
   1.418 +		err = stmt.BindInt(0, 3);
   1.419 +	    TEST2(err, KErrNone);
   1.420 +	    RSqlParamWriteStream strm;
   1.421 +	    err = strm.BindText(stmt, 1);
   1.422 +	    TEST2(err, KErrNone);
   1.423 +	    TRAP(err, strm.WriteL(KNullDesC));
   1.424 +	    TEST2(err, KErrNone);
   1.425 +	    strm.Close();
   1.426 +	    err = stmt.Exec();
   1.427 +	    TEST2(err, 1);
   1.428 +	    stmt.Close();
   1.429 +		//Insert records with empty text column values using RSqlStatement::Bind()
   1.430 +	    err = stmt.Prepare(TheDb1, _L("INSERT INTO A(ID, T) VALUES(:P1, :P2)"));
   1.431 +	    TEST2(err, KErrNone);
   1.432 +		err = stmt.BindInt(0, 4);
   1.433 +	    TEST2(err, KErrNone);
   1.434 +		err = stmt.BindText(1, KNullDesC);
   1.435 +	    TEST2(err, KErrNone);
   1.436 +	    err = stmt.Exec();
   1.437 +	    TEST2(err, 1);
   1.438 +	    //
   1.439 +	    err = stmt.Reset();
   1.440 +	    TEST2(err, KErrNone);
   1.441 +		err = stmt.BindInt(0, 5);
   1.442 +	    TEST2(err, KErrNone);
   1.443 +	    _LIT(KEmptyStr, "");
   1.444 +		err = stmt.BindText(1, KEmptyStr);
   1.445 +	    TEST2(err, KErrNone);
   1.446 +	    err = stmt.Exec();
   1.447 +	    TEST2(err, 1);
   1.448 +	    stmt.Close();
   1.449 +	    //Read the empty text column values
   1.450 +	    err = stmt.Prepare(TheDb1, _L("SELECT T FROM A"));
   1.451 +	    TEST2(err, KErrNone);
   1.452 +	    TInt cnt = 0;
   1.453 +	    while((err = stmt.Next()) == KSqlAtRow)
   1.454 +	    	{
   1.455 +			++cnt;
   1.456 +			TPtrC val;
   1.457 +			err = stmt.ColumnText(0, val);
   1.458 +			TEST2(err, KErrNone);
   1.459 +			TEST2(val.Length(), 0);
   1.460 +			TSqlColumnType type = stmt.ColumnType(0);
   1.461 +			TEST2(type, ESqlText);
   1.462 +	    	}
   1.463 +	    stmt.Close();
   1.464 +	    TEST2(err, KSqlAtEnd);
   1.465 +	    TEST2(cnt, 5);
   1.466 +	    //
   1.467 +	    TheDb1.Close();
   1.468 +	    err = RSqlDatabase::Delete(KTestDatabase1);
   1.469 +	    TEST2(err, KErrNone);
   1.470 +		}
   1.471 +	}
   1.472 +
   1.473 +/**
   1.474 +@SYMTestCaseID          PDS-SQL-CT-4214
   1.475 +@SYMTestCaseDesc        Test for the change "After *#7370# Java apps are not preinstalled again" 
   1.476 +@SYMTestPriority        High
   1.477 +@SYMTestActions         The test makes sure there are no issues if the temp folder is removed after the server 
   1.478 +                        has already started. The test performs the following actions - 
   1.479 +                        1. Delete the 'temp' directory.
   1.480 +                        2. Create a transaction which creates temp files.
   1.481 +                        3. Check 'temp' folder exists at the end
   1.482 +@SYMTestExpectedResults Test must not fail
   1.483 +*/
   1.484 +void DeleteTempFolder()
   1.485 +    {
   1.486 +    //1. Delete 'temp' folder
   1.487 +    TInt err = TheFs.RmDir(KServerTempDir);
   1.488 +    TEST2(err, KErrNone);
   1.489 +	
   1.490 +    //2. Create a transaction which creates temp files.
   1.491 +    (void)RSqlDatabase::Delete(KTestDatabase1);
   1.492 +    err = TheDb1.Create(KTestDatabase1);
   1.493 +    TEST2(err, KErrNone);
   1.494 +    
   1.495 +    err = TheDb1.Exec(_L("CREATE TABLE t1(x UNIQUE); INSERT INTO t1 VALUES(1)"));
   1.496 +    TEST(err >= 0);
   1.497 +    err = TheDb1.Exec(_L("BEGIN; UPDATE t1 SET x = 2; UPDATE t1 SET x = 3; COMMIT"));
   1.498 +    TEST(err >= 0);
   1.499 +    
   1.500 +    TheDb1.Close();
   1.501 +    err = RSqlDatabase::Delete(KTestDatabase1);
   1.502 +    TEST2(err, KErrNone);
   1.503 +    
   1.504 +    //3. Check 'temp' folder exists
   1.505 +    err = TheFs.MkDir(KServerTempDir);
   1.506 +    TEST2(err, KErrAlreadyExists);
   1.507 +    }	
   1.508 +	
   1.509 +void DoTestsL()
   1.510 +	{
   1.511 +	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-4154 DEF143062: SQL, \"CREATE INDEX\" sql crashes SQL server"));
   1.512 +	DEF143062();
   1.513 +
   1.514 +    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-4155 DEF143061: SQL, SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT value is too big"));
   1.515 +    DEF143061();
   1.516 +
   1.517 +    TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-4156 DEF143150: SQL, strftime() returns incorrect result"));
   1.518 +    DEF143150();
   1.519 +    
   1.520 +    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4210 Temp files created during sql operations are not deleted after rebooting the phone - 1"));
   1.521 +    DeleteTempFile();
   1.522 +    
   1.523 +    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4211 Temp files created during sql operations are not deleted after rebooting the phone - 2"));
   1.524 +    TempFileTest();
   1.525 +    
   1.526 +    TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4213 No support to store an empty string in symbian's sqlite."));
   1.527 +    EmptyTextColumnTest();
   1.528 +	
   1.529 +	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4214 After *#7370# Java apps are not preinstalled again"));
   1.530 +    DeleteTempFolder();
   1.531 +	}
   1.532 +
   1.533 +TInt E32Main()
   1.534 +	{
   1.535 +	TheTest.Title();
   1.536 +	
   1.537 +	CTrapCleanup* tc = CTrapCleanup::New();
   1.538 +	
   1.539 +	__UHEAP_MARK;
   1.540 +	
   1.541 +	CreateTestEnv();
   1.542 +	TRAPD(err, DoTestsL());
   1.543 +	DestroyTestEnv();
   1.544 +	TEST2(err, KErrNone);
   1.545 +
   1.546 +	__UHEAP_MARKEND;
   1.547 +	
   1.548 +	TheTest.End();
   1.549 +	TheTest.Close();
   1.550 +	
   1.551 +	delete tc;
   1.552 +
   1.553 +	User::Heap().Check();
   1.554 +	return KErrNone;
   1.555 +	}