Topic: enconding and sqlitepass clob information.

Currently, database file encoding and page size is not set correctly at creating database file except Kexi format.

unction TSqlitePassDatabase.CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType;
                                            Encoding: TSqlitePassEncoding = UTF_8; PageSize: TSqlitePassPageSize = 4096;
                                            AutoVacuum: TSqlitePassAutoVacuumType = 0): Boolean;
...
        ExecSQL('PRAGMA encoding = ' + EncodingStr+';');             
        ExecSQL('PRAGMA page_size = ' + IntToStr(PageSize)+';');
        ExecSQL('PRAGMA Auto_Vacuum = ' + IntToStr(AutoVacuum)+';');

        { Creates system tables for Kexi }
        if DbType = dbtKexi then
           begin
           ExecSQL(KexiDb_CreateSQLStmt);
           ExecSQL(KexiParts_CreateSQLStmt);
           ExecSQL(KexiObjects_CreateSQLStmt);
           ExecSQL(KexiObjectData_CreateSQLStmt);
           ExecSQL(KexiFields_CreateSQLStmt);
           ExecSQL(KexiBlobs_CreateSQLStmt);
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("kexidb_major_ver", "1");');
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("kexidb_minor_ver", "8");');
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("kexiproject_major_ver", "1");');
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("kexiproject_minor_ver", "0");');
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("project_caption", "");');
           ExecSQL('INSERT INTO "kexi__db" (db_property, db_value) VALUES ("project_desc", "");');
           end else
            // for other format
            ExecSQL('CREATE TABLE "sqlitepass__dummy" (dummy TEXT(1));');           
...

Last sql statment is correctly set encoding and pagesize of database file except kexi format.

At different encoding,  'SQLitePass__DbSettings' table's information is not read correctly in utf-16 encodings.

procedure TSqlitePassRecordset.GetRecords(Sql: String);
...
ColumnStr : string;
ColumnSize : integer;
begin
...
         { No fields are defined, so we store all the values as string }
         else begin
              ColumnSize := SqliteDbv3_column_Bytes(PSqliteData,ColumnIndex);
              SetLength(ColumnStr,ColumnSize);
              system.Move(pansichar(SqliteDbv3_column_Blob(PSqliteData,ColumnIndex))^,ColumnStr[1],ColumnSize);
              AddString(Buffer, ColumnStr);
              SetFieldNullValue(RecordIndex, ColumnIndex, False);
              Inc(Buffer, SizeOf(Integer));
              end;
      end; { for }
...

And sqlite3_open function protorype declaration is invalid.

SqliteDbv3_open: function(dbname: PChar; var db:pointer):integer; cdecl;
...
procedure TSqlitePassEngine.OpenDatabase(FullName, LibraryFile: String);
begin
FLibraryLoaded := LoadSqliteLibrary(LibraryFile);
CheckResult(SqliteDbv3_Open(Pchar(FullName), FConnectionHandle));
end;
...

Sorry for short explanation.

I'm not English well neutral

Re: enconding and sqlitepass clob information.

At loading kexi db,

Following procedure raise range check exception.

procedure TSqlitePassBitArray.Reset;
var
Start, i, FItemsLength: integer;
S: string;
begin
FInternalItems.Clear;
i := 1;
FItemsLength := Length(FItems);
While i < FItemsLength do
    begin
    Start := i;
    // fix range check exception
    While i <= FItemsLength do
      if (not (FItems[i] in [',' , ';'])) then
        inc(i)
        else Break;
    s := System.Copy(FItems, Start, i-Start);
    FInternalItems.Add(System.Copy(FItems, Start, i-Start)+'=0');
    Inc(i);
    end;
end;

smile

Last edited by parcel (2009-03-29 14:26:21)

Re: enconding and sqlitepass clob information.

Ok Parcel,

I changed the RangeCheck error in TSqlitePassBitArray and have to work on TSqlitePassDatabase.CreateDatabase qnd GetRecord

as soon as I have enough time....

Luc

Re: enconding and sqlitepass clob information.

Thank you, luckylazarus smile