1695 TheTest.Printf(_L(" The test has succeeded with SELECT statement count=%d\r\n"), cnt); |
1695 TheTest.Printf(_L(" The test has succeeded with SELECT statement count=%d\r\n"), cnt); |
1696 break; |
1696 break; |
1697 } |
1697 } |
1698 } |
1698 } |
1699 |
1699 |
|
1700 /** |
|
1701 @SYMTestCaseID PDS-SQL-CT-4198 |
|
1702 @SYMTestCaseDesc Expired SQL statements test. |
|
1703 The test creates a database and opens 2 connections to that database. |
|
1704 Connection 2 prepares couple of SELECT and INSERT statements (8-bit and 16-bit). |
|
1705 Then connection 1 renames the table used in the already prepared statements. |
|
1706 Connection 2 attempts to execute the prepared statements. The execution should fail |
|
1707 because the statements are expired, the database schema has changed after they |
|
1708 were prepared. |
|
1709 @SYMTestActions Expired SQL statements test. |
|
1710 @SYMTestExpectedResults Test must not fail |
|
1711 @SYMTestPriority High |
|
1712 @SYMDEF DEF145236 |
|
1713 */ |
|
1714 void ExpiredStmtTest() |
|
1715 { |
|
1716 (void)RSqlDatabase::Delete(KTestDbName1); |
|
1717 //Create a database and create db connection 1. |
|
1718 TInt err = TheDb.Create(KTestDbName1); |
|
1719 TEST2(err, KErrNone); |
|
1720 err = TheDb.Exec(_L("CREATE TABLE A(C1 INTEGER)")); |
|
1721 TEST(err >= 0); |
|
1722 err = TheDb.Exec(_L("INSERT INTO A(C1) VALUES(1)")); |
|
1723 TEST2(err, 1); |
|
1724 |
|
1725 //Create db connection 2 to the same database, as db connection 1. |
|
1726 RSqlDatabase db2; |
|
1727 err = db2.Open(KTestDbName1); |
|
1728 TEST2(err, KErrNone); |
|
1729 |
|
1730 //Db connection 2. Prepare SELECT and INSERT, 8-bit and 16-bit statements. |
|
1731 RSqlStatement stmt1, stmt2, stmt3, stmt4; |
|
1732 err = stmt1.Prepare(db2, _L("SELECT * FROM A")); |
|
1733 TEST2(err, KErrNone); |
|
1734 err = stmt2.Prepare(db2, _L8("SELECT * FROM A")); |
|
1735 TEST2(err, KErrNone); |
|
1736 err = stmt3.Prepare(db2, _L("INSERT INTO A(C1) VALUES(2)")); |
|
1737 TEST2(err, KErrNone); |
|
1738 err = stmt4.Prepare(db2, _L8("INSERT INTO A(C1) VALUES(3)")); |
|
1739 TEST2(err, KErrNone); |
|
1740 |
|
1741 //Modify the A table structure from the other connection |
|
1742 //err = TheDb.Exec(_L("ALTER TABLE A ADD C2 INTEGER")); |
|
1743 err = TheDb.Exec(_L("ALTER TABLE A RENAME TO B")); |
|
1744 TEST(err >= 0); |
|
1745 |
|
1746 //Try to execute the already prepared statements. |
|
1747 err = stmt1.Next(); |
|
1748 TEST2(err, KSqlErrSchema); |
|
1749 err = stmt1.Next(); |
|
1750 TEST2(err, KSqlErrStmtExpired); |
|
1751 err = stmt2.Next(); |
|
1752 TEST2(err, KSqlErrStmtExpired); |
|
1753 err = stmt3.Exec(); |
|
1754 TEST2(err, KSqlErrStmtExpired); |
|
1755 err = stmt4.Exec(); |
|
1756 TEST2(err, KSqlErrStmtExpired); |
|
1757 // |
|
1758 stmt4.Close(); |
|
1759 stmt3.Close(); |
|
1760 stmt2.Close(); |
|
1761 stmt1.Close(); |
|
1762 db2.Close(); |
|
1763 TheDb.Close(); |
|
1764 err = RSqlDatabase::Delete(KTestDbName1); |
|
1765 TEST2(err, KErrNone); |
|
1766 } |
|
1767 |
1700 void DoTestsL() |
1768 void DoTestsL() |
1701 { |
1769 { |
1702 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3512 RSqlStatement::ColumnCount() tests ")); |
1770 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3512 RSqlStatement::ColumnCount() tests ")); |
1703 ColumnCountTest(); |
1771 ColumnCountTest(); |
1704 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3513 RSqlStatement::ColumnCount(), non-SELECT tests ")); |
1772 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3513 RSqlStatement::ColumnCount(), non-SELECT tests ")); |