Jump to content
Sign in to follow this  
Gyzmok

SQLite3.dll

Recommended Posts

Gyzmok

Hi all,

I have a script that uses SQLite.

These includes are in the script :

..
#include <SQLite.au3>
#include <SQLite.dll.au3>
..

It was compiled with the Autoit v3.2.1.14 (beta)

Recently I recompiled the script to Autoit v3.2.3.14 (beta) and the script didn't work anymore. (the SQLite functions)

It took me some time before I found the cause :

Aparantly the (compiled) script creates a .dll file : C:\windows\system32\SQLite3.dll

(old SQLite3.dll date = 08/12/2006)

The problem : when executing the newer compiled version of the script it does not overwrite the older SQLite3.dll

To solve the problem, I had to delete/rename the old SQLite3.dll and then run the newly compiled script again.

(new SQLite.dll date = 02/13/2007)

I have to do this on several machines ...

Question :

Why does it not auto-overwrite the older SQLite3.dll ?

Is this normal behaviour of the embedded/wrapped SQLite functionality in Autoit ?


D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

Share this post


Link to post
Share on other sites
PsaltyDS

Look inside SQLite.au3 at the function _SQLite_Startup(). It checks the following places for the SQLite3.dll file:

1. @ScriptDir

2. @SystemDir

3. @WindowsDir

4. @WorkingDir

Only if SQLite3.dll is not found in any of those locations does it call another function from SQLite.dll.au3 called __SQLite_Inline_SQLite3Dll() with the binary copy of SQLite3.dll and write it to disk. There is no version checking on the existing .dll, only a test for existence.

I think you could change that yourself, or recommend the change to picasso and JPM:

;===============================================================================
;
; Function Name:    _SQLite_Startup
;
; Parameter(s):     $sDll_Filename - Optional, Dll Filename
; Description:      Loads SQLite.dll
; Requirement:      None
; Return Value(s):  On Success - Returns path to SQLite3.dll
;                   On Failure - Returns empty string
; @error Value(s):  1 - Error Loading Dll
;
; User CallTip:     _SQLite_Startup([$sDll_Filename]) Loads SQLite3.dll
; Author(s):        piccaso (Fida Florian), JPM
;
;===============================================================================

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Gyzmok

TNX !

Sorry that I didn't look any further.

Didn't think it would be in an include.

There are indeed some strange things about the code :

...
Func _SQLite_Startup($sDll_Filename = "") ; Loads SQLite Dll
    Local $hDll, $hFileDllOut = -1
    Local $fUseInline = True
    Local $vInlineVersion = Call('__' & 'SQLite_Inline_Version')
    If @error Then $fUseInline = False
    If IsKeyword($sDll_Filename) Or $sDll_Filename = "" Or $sDll_Filename = -1 Then
        $sDll_Filename = "sqlite3.dll"
        If __SQLite_VersCmp(@ScriptDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
            $sDll_Filename = @ScriptDir & "\" & $sDll_Filename
            $fUseInline = False
        ElseIf __SQLite_VersCmp(@SystemDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
            $sDll_Filename = @SystemDir & "\" & $sDll_Filename
            $fUseInline = False
        ElseIf __SQLite_VersCmp(@WindowsDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
            $sDll_Filename = @WindowsDir & "\" & $sDll_Filename
            $fUseInline = False
        ElseIf __SQLite_VersCmp(@WorkingDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
            $sDll_Filename = @WorkingDir & "\" & $sDll_Filename
            $fUseInline = False
        EndIf
        If $fUseInline Then
            $sDll_Filename = @SystemDir & "\SQLite3.dll"
            If Not FileExists($sDll_Filename) Then
                $hFileDllOut = FileOpen($sDll_Filename, 2)
            EndIf
            If $hFileDllOut = -1 Then
                $sDll_Filename = _TempFile(@TempDir, "~", ".dll")
                $hFileDllOut = FileOpen($sDll_Filename, 2)
                If $hFileDllOut = -1 Then Return SetError(1,0,"")
                _ArrayAdd($g_avSafeMode_SQLite[4], $sDll_Filename)
            EndIf
            FileWrite($hFileDllOut, Call('__' & 'SQLite_Inline_SQLite3Dll'))
            FileClose($hFileDllOut)
            FileSetTime($sDll_Filename, Call('__' & 'SQLite_Inline_Modified'), 0)
        EndIf
    EndIf
    $hDll = DllOpen($sDll_Filename)
    If $hDll = -1 Then
        Return SetError(1, 0, "")
    Else
        $g_hDll_SQLite = $hDll
        Return $sDll_Filename
    EndIf
EndFunc   ;==>_SQLite_Startup
...
Func __SQLite_VersCmp($sFile, $sVersion)
    Local $avRval = DllCall($sFile, "str:cdecl", "sqlite3_libversion")
    If @error Then Return $SQLITE_CORRUPT ; Not SQLite3.dll or Not found
    If $avRval[0] >= $sVersion Then Return $SQLITE_OK ; Version OK
    Return $SQLITE_MISMATCH ; Version Older
EndFunc   ;==>__SQLite_VersCmp
...

The OLD SQLite3.dll (08/12/2006) returns version "3.3.7"

The NEW SQLite3.dll (02/13/2007) returns version "3.3.13"

So the OLD version >= NEW version and returns $SQLITE_OK :)

But that's not all:

Supose it did return $SQLITE_MISMATCH (value = 20)

and $fUseInline remains TRUE

even then it would not be overwritten because of the "If Not FileExists($sDll_Filename)" condition ...

:D ?

It could be that I am missing something ...

Anyway, thanks for your time and for your great help !

I know the cause now and how to solve it... :D


D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×