Jump to content

Recommended Posts

Posted

Hi!

In last versions of sqlite it is possible to execute an UPDATE query with return values. I found that the _SqliteGetTable2d function executes the given query incorrectly while the _SQLite_GetTable2d function does correctly.

For example: UPDATE table SET Value = 'value' WHERE id IN (SELECT id FROM table WHERE Value > 0 LIMIT 5) RETURNING id'. After _SQLite_GetTable2d DB has 10 changes instead 5.

First 5 changes appear after this code execution (in the Sqlite.au3, _SQLite_GetTable2d func):

While True
        $iRval_Step = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_step", "ptr", $hQuery)
        If @error Then
            $iError = @error
            _SQLite_QueryFinalize($hQuery)
            Return SetError(3, $iError, $SQLITE_MISUSE) ; DllCall error
        EndIf
        Switch $iRval_Step[0]
            Case $SQLITE_ROW
                $iRows += 1
            Case $SQLITE_DONE
                ExitLoop
            Case Else
                _SQLite_QueryFinalize($hQuery)
                Return SetError(3, $iError, $iRval_Step[0])
        EndSwitch
    WEnd

And the last 5 changes appear after Finalize in the end of the func:

Return (_SQLite_QueryFinalize($hQuery))

So in the end we have 10 changes but only 5 returns (last changes)

Posted

Edit: I found that the _SqliteGetTable2d function executes the given query incorrectly while the _SQLite_GetTable function does correctly.

Posted

Our SQLite UDF predates the introduction of the RETURNING clause by several years, so it isn"t surprising nothing was setup at that time to support the newest versions of SQLite. I wouldn't call this a bug.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

The cause of the issue is that the current function performs the query twice: once for counting the output rows, once for populating the resulting array.

It's of course possible to rewrite _SQLiteGetTable2D() to change the way it works but I currently don't have much time to devote to this task. Given that the UDF has a number of really important issues (e.g. everything is returned as text instead of datatypes) I don't expect to fix this problem anytime soon, at least not in the next few months.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...