sl@0: sl@0: // //////////////////////////////////////////////////////////////////////// sl@0: // sl@0: // Configuration tests - try changing the values of the default encoding sl@0: // and cache_size and page_size. From an integration test we can't really sl@0: // detect an effect of the _size settings, though we can read them back sl@0: // with the 'pragma' syntax. sl@0: // sl@0: // First check the defaults. If these change it will confuse the other tests sl@0: // so we might as well detect that change and generate a failure ASAP... sl@0: [CheckDefaults] sl@0: // First open a zero length database to check the defaults. sl@0: NoOperation0= sl@0: Open1=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: Function2=ScalarFullSelect sl@0: Method2=SelectTextL sl@0: Result2=UTF-16le sl@0: Use_Set2=0 sl@0: Statement2=PRAGMA encoding; sl@0: sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectIntL sl@0: Result3=1024 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA page_size; sl@0: sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=DEFAULT_SOFT_HEAP_LIMIT sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA cache_size; sl@0: Close5= sl@0: EndBlock6= sl@0: sl@0: // Check that gibberish in the configuration string prevents Create from sl@0: // working. sl@0: [CheckOverride1] sl@0: DefineConfig0=this is a load of old rubbish which should have no effect on settings sl@0: Delete1=C:\ConfigTest1.db sl@0: ExpectedError1=KErrNotFound sl@0: Create2=C:\ConfigTest1.db sl@0: ExpectedError2=KErrArgument sl@0: // The next line will PANIC the client because the Create will have failed due sl@0: // to the bad configuration line. That's ok, we're expecting it. sl@0: Exec3=Select * from SomeTable; sl@0: EndBlock4= sl@0: sl@0: // Check that properly formatted configuration options work, but that sl@0: // page_size can't be changed for a pre-existing db, and a bad encoding sl@0: // has no effect. The cache_size is also not affected. sl@0: [CheckOverride2] sl@0: DefineConfig0=page_size=2048;cache_size=64;encoding=hatstand sl@0: // On a pre-existing database we can't change the page size, plus the sl@0: // bad encoding will have been ignored. sl@0: Open1=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: sl@0: // encoding will not have been changed from its default of utf-16 sl@0: Function2=ScalarFullSelect sl@0: Method2=SelectTextL sl@0: Result2=UTF-16le sl@0: Use_Set2=1 sl@0: Statement2=PRAGMA encoding; sl@0: sl@0: // page_size will not have been changed from its default of 1024.. sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectIntL sl@0: Result3=1024 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA page_size; sl@0: sl@0: // cache_size WILL NOT have changed. sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=64 sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA cache_size; sl@0: sl@0: Close5= sl@0: EndBlock6= sl@0: sl@0: // Try changing all three config items to legal values, and check them. sl@0: [CheckOverride3] sl@0: DefineConfig0=page_size=2048;cache_size=34;encoding=UTF-8 sl@0: // On a new database we can change the page size and the encoding. sl@0: // Not the cache_size. sl@0: Delete1=C:\ConfigTest2.db sl@0: ExpectedError1=KErrNotFound sl@0: sl@0: Create2=C:\ConfigTest2.db sl@0: sl@0: // encoding will not have been changed from its default of utf-16 sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectTextL sl@0: Result3=UTF-8 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA encoding; sl@0: sl@0: // page_size will have been changed from its default of 1024.. sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=2048 sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA page_size; sl@0: sl@0: // cache_size WILL have changed to 34.. sl@0: Function5=ScalarFullSelect sl@0: Method5=SelectIntL sl@0: Result5=34 sl@0: Use_Set5=1 sl@0: Statement5=PRAGMA cache_size; sl@0: sl@0: Close6= sl@0: Delete7=C:\ConfigTest2.db sl@0: EndBlock8= sl@0: sl@0: // Try setting page_size to a non-power-of-two (no effect), stick in some sl@0: // properly formatted by useless extras (no effect) and attempt to set sl@0: // cache_size (works) and an unsupported encoding (doesn't work). sl@0: [CheckOverride4] sl@0: DefineConfig0=page_size=4095;x=y;i=j;cache_size=43;encoding=UTF-16be sl@0: // On a new database we can change the page size and the encoding. sl@0: // But page_size is supposed to be a power of 2. sl@0: Delete1=C:\ConfigTest3.db sl@0: ExpectedError1=KErrNotFound sl@0: sl@0: Create2=C:\ConfigTest3.db sl@0: sl@0: // encoding will not have been changed from its default of utf-16 sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectTextL sl@0: Result3=UTF-16le sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA encoding; sl@0: sl@0: // page_size will not have been changed from its default of 1024.. sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=1024 sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA page_size; sl@0: sl@0: // cache_size WILL have changed. sl@0: Function5=ScalarFullSelect sl@0: Method5=SelectIntL sl@0: Result5=43 sl@0: Use_Set5=1 sl@0: Statement5=PRAGMA cache_size; sl@0: sl@0: Close6= sl@0: Delete7=C:\ConfigTest3.db sl@0: EndBlock8= sl@0: sl@0: sl@0: // Try setting a legal page_size (works), a cache_size (doesn't work) and sl@0: // a legal character encoding (works). sl@0: [CheckOverride5] sl@0: DefineConfig0=page_size=512;cache_size=432;encoding=UTF-8 sl@0: // On a new database we can change the page size, cache size and the sl@0: // encoding. sl@0: Delete1=C:\ConfigTest4.db sl@0: ExpectedError1=KErrNotFound sl@0: sl@0: Create2=C:\ConfigTest4.db sl@0: sl@0: // encoding will not have been changed from its default of utf-16 sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectTextL sl@0: Result3=UTF-8 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA encoding; sl@0: sl@0: // page_size will not have been changed from its default of 1024.. sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=512 sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA page_size; sl@0: sl@0: // cache_size WILL have changed. sl@0: Function5=ScalarFullSelect sl@0: Method5=SelectIntL sl@0: Result5=432 sl@0: Use_Set5=1 sl@0: Statement5=PRAGMA cache_size; sl@0: sl@0: Close6= sl@0: Delete7=C:\ConfigTest4.db sl@0: EndBlock8= sl@0: sl@0: // ///////////////////////////////////////////////////////////////////////// sl@0: sl@0: // The following tests create two functionally identical databases but one sl@0: // block uses UTF-8. Then check that the file sizes differ. sl@0: sl@0: // Create a database with a single table containing a single cell containing sl@0: // the text content of the reference1.txt text file. Set UTF-16. sl@0: [WriteTextDB-16bit] sl@0: Delete0=C:\ConfigTest5.db sl@0: ExpectedError0=KErrNotFound sl@0: Create1=C:\ConfigTest5.db sl@0: sl@0: // First check for our expected defaults. sl@0: Function2=ScalarFullSelect sl@0: Method2=SelectTextL sl@0: Result2=UTF-16le sl@0: Use_Set2=1 sl@0: Statement2=PRAGMA encoding; sl@0: sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectIntL sl@0: Result3=1024 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA page_size; sl@0: sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=DEFAULT_SOFT_HEAP_LIMIT sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA cache_size; sl@0: sl@0: Exec5=Create Table Sometable(f1 text); sl@0: Prepare6=Insert into Sometable values(:val); sl@0: ParameterIndex7=:val sl@0: StreamWriteBindText8=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Exec9= sl@0: Reset10= sl@0: St_Close11= sl@0: sl@0: Prepare12=select f1 from Sometable; sl@0: ColumnIndex13=f1 sl@0: Next14=KSqlAtRow sl@0: ColumnSize15=0,3626 sl@0: St_Close16= sl@0: Close17= sl@0: EndBlock18= sl@0: sl@0: // Create a database with a single table containing a single cell containing sl@0: // the text content of the reference1.txt text file. Set UTF-8. sl@0: [WriteTextDB-8bit] sl@0: Delete0=C:\ConfigTest6.db sl@0: ExpectedError0=KErrNotFound sl@0: DefineConfig1=encoding=UTF-8 sl@0: Create2=C:\ConfigTest6.db sl@0: sl@0: // Check the defaults (plus our changed character encoding) sl@0: Function3=ScalarFullSelect sl@0: Method3=SelectTextL sl@0: Result3=UTF-8 sl@0: Use_Set3=1 sl@0: Statement3=PRAGMA encoding; sl@0: sl@0: Function4=ScalarFullSelect sl@0: Method4=SelectIntL sl@0: Result4=1024 sl@0: Use_Set4=1 sl@0: Statement4=PRAGMA page_size; sl@0: sl@0: Function5=ScalarFullSelect sl@0: Method5=SelectIntL sl@0: Result5=DEFAULT_SOFT_HEAP_LIMIT sl@0: Use_Set5=1 sl@0: Statement5=PRAGMA cache_size; sl@0: sl@0: Exec6=Create Table Sometable(f1 text); sl@0: Prepare7=Insert into Sometable values(:val); sl@0: ParameterIndex8=:val sl@0: StreamWriteBindText9=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Exec10= sl@0: Reset11= sl@0: St_Close12= sl@0: sl@0: Prepare13=select f1 from Sometable; sl@0: ColumnIndex14=f1 sl@0: Next15=KSqlAtRow sl@0: ColumnSize16=0,3626 sl@0: St_Close17= sl@0: Close18= sl@0: EndBlock19= sl@0: sl@0: // Check that the two databases created above (which are exactly equivalent) sl@0: // differ in size. That will suggest that the UTF-8/UTF-16 sl@0: // encoding options have done their work. Through the SQLite APIs they generate sl@0: // identical output. It seems kind of overkill to have a whole code-driven sl@0: // test function to do this but I see no other way.. sl@0: // Attempt an attach of UTF-16 to UTF-8 database - it will fail, that's an sl@0: // illegal operation. sl@0: [FilesDiffer] sl@0: Function0=FilesDifferBySize sl@0: FileA0=C:\ConfigTest5.db sl@0: FileB0=C:\ConfigTest6.db sl@0: Open1=C:\ConfigTest5.db sl@0: Exec2=Attach "C:\ConfigTest6.db" as ThatOne; sl@0: ExpectedError2=KSqlErrGeneral sl@0: LastErrorMessage3=attached databases must use the same text encoding as main database sl@0: // Delete will succeed because the attach didn't. sl@0: Delete4=C:\ConfigTest6.db sl@0: Close5= sl@0: Delete6=C:\ConfigTest5.db sl@0: EndBlock7=