LuaSQLite3

Check-in [a2e54aefb5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add changes from Ronny Dierckx
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a2e54aefb50df49b98ab90b6ef5d65380d70d9a1
User & Date: e@ecd9bf9a-ecc1-ed47-8102-3ce978d4cc14 2011-01-10 22:27:11
Context
2011-01-12
15:36
Add library documentation converted to fossil wiki format check-in: d1f5c49c17 user: e tags: trunk
2011-01-10
22:27
Add changes from Ronny Dierckx check-in: a2e54aefb5 user: e@ecd9bf9a-ecc1-ed47-8102-3ce978d4cc14 tags: trunk
2010-03-05
01:51
Fix db_exec_callback to be thread safe. Add rockspec. Cleanup; see HISTORY. check-in: ded1fb4786 user: e@ecd9bf9a-ecc1-ed47-8102-3ce978d4cc14 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to HISTORY.

1
2
3
4






5
6
7
8
9
10
11
12
2010-February-14

Version "0.7-devel"







Since the "0.6-devel" release of this Lua library...

Made db_exec_callback thread safe.
Thanks to Grant Robinson.

Bug fix in dbvm_bind_index error message.
Thanks to Dirk Feytons.

|

|

>
>
>
>
>
>
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2011-January-10

Version "0.8-devel"

Since the "0.7-devel" release of this Lua library...

Added a missing lua_pop in dbvm_bind_names()
Now dbvm_bind_index() binds a boolean as 1 or 0
Thanks to Ronny Dierckx

    Since the "0.6-devel" release of this Lua library...

Made db_exec_callback thread safe.
Thanks to Grant Robinson.

Bug fix in dbvm_bind_index error message.
Thanks to Dirk Feytons.

Changes to lsqlite3-0.7-1.rockspec.

1
2
3
4
5
6
7
8
9
10
11
package = "lsqlite3"
version = "0.7-1"
source = {
    url = "http://luaforge.net/frs/download.php/2565/lsqlite3-7.tar.gz"
}
description = {
    summary = "A binding for Lua to the SQLite3 database library",
    detailed = [[
        lsqlite3 is a thin wrapper around the public domain SQLite3 database engine. 
        The lsqlite3 module supports the creation and manipulation of SQLite3 databases. 
        After a require('lsqlite3') the exported functions are called with prefix sqlite3. 



|







1
2
3
4
5
6
7
8
9
10
11
package = "lsqlite3"
version = "0.7-1"
source = {
    url = "http://luaforge.net/frs/download.php/4472/lsqlite3-7.tar.gz"
}
description = {
    summary = "A binding for Lua to the SQLite3 database library",
    detailed = [[
        lsqlite3 is a thin wrapper around the public domain SQLite3 database engine. 
        The lsqlite3 module supports the creation and manipulation of SQLite3 databases. 
        After a require('lsqlite3') the exported functions are called with prefix sqlite3. 

Changes to lsqlite3.c.

445
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460
461
462
463
...
533
534
535
536
537
538
539

540
541
542
543
544
545
546

static int dbvm_bind_index(lua_State *L, sqlite3_stmt *vm, int index, int lindex) {
    switch (lua_type(L, lindex)) {
        case LUA_TSTRING:
            return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_strlen(L, lindex), SQLITE_TRANSIENT);
        case LUA_TNUMBER:
            return sqlite3_bind_double(vm, index, lua_tonumber(L, lindex));
        case LUA_TNONE:

        case LUA_TNIL:
        /* allow boolean values so i have a way to know which
        ** values were actually not set */
        case LUA_TBOOLEAN:
            return sqlite3_bind_null(vm, index);
        default:
            luaL_error(L, "index (%d) - invalid data type for bind (%s)", index, lua_typename(L, lua_type(L, lindex)));
            return SQLITE_MISUSE; /*!*/
    }
}

................................................................................

    for (n = 1; n <= count; ++n) {
        name = sqlite3_bind_parameter_name(vm, n);
        if (name && (name[0] == ':' || name[0] == '$')) {
            lua_pushstring(L, ++name);
            lua_gettable(L, 2);
            result = dbvm_bind_index(L, vm, n, -1);

        }
        else {
            lua_pushnumber(L, n);
            lua_gettable(L, 2);
            result = dbvm_bind_index(L, vm, n, -1);
            lua_pop(L, 1);
        }







|
>
|
<
<
|







 







>







445
446
447
448
449
450
451
452
453
454


455
456
457
458
459
460
461
462
...
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546

static int dbvm_bind_index(lua_State *L, sqlite3_stmt *vm, int index, int lindex) {
    switch (lua_type(L, lindex)) {
        case LUA_TSTRING:
            return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_strlen(L, lindex), SQLITE_TRANSIENT);
        case LUA_TNUMBER:
            return sqlite3_bind_double(vm, index, lua_tonumber(L, lindex));
        case LUA_TBOOLEAN:
            return sqlite3_bind_int(vm, index, lua_toboolean(L, lindex) ? 1 : 0);
        case LUA_TNONE:


        case LUA_TNIL:
            return sqlite3_bind_null(vm, index);
        default:
            luaL_error(L, "index (%d) - invalid data type for bind (%s)", index, lua_typename(L, lua_type(L, lindex)));
            return SQLITE_MISUSE; /*!*/
    }
}

................................................................................

    for (n = 1; n <= count; ++n) {
        name = sqlite3_bind_parameter_name(vm, n);
        if (name && (name[0] == ':' || name[0] == '$')) {
            lua_pushstring(L, ++name);
            lua_gettable(L, 2);
            result = dbvm_bind_index(L, vm, n, -1);
            lua_pop(L, 1);
        }
        else {
            lua_pushnumber(L, n);
            lua_gettable(L, 2);
            result = dbvm_bind_index(L, vm, n, -1);
            lua_pop(L, 1);
        }