|
From: <cre...@us...> - 2006-10-08 06:52:11
|
Revision: 1549
http://svn.sourceforge.net/frontierkernel/?rev=1549&view=rev
Author: creecode
Date: 2006-10-07 23:51:28 -0700 (Sat, 07 Oct 2006)
Log Message:
-----------
Merged SQLite branch changes r1233:1547 into the trunk.
Modified Paths:
--------------
Frontier/trunk/Common/headers/kernelverbdefs.h
Frontier/trunk/Common/headers/kernelverbs.h
Frontier/trunk/Common/headers/langinternal.h
Frontier/trunk/Common/headers/versions.h
Frontier/trunk/Common/resources/Mac/kernelverbs.r
Frontier/trunk/Common/resources/Win32/WinLand.rc
Frontier/trunk/Common/resources/Win32/kernelverbs.rc
Frontier/trunk/Common/source/shell.c
Frontier/trunk/build_VC2K5/Frontier.sln
Frontier/trunk/build_VC2K5/Frontier.vcproj
Added Paths:
-----------
Frontier/trunk/Common/headers/langsqlite.h
Frontier/trunk/Common/source/langsqlite.c
Frontier/trunk/Common/sqlite3/
Frontier/trunk/Common/sqlite3/alter.c
Frontier/trunk/Common/sqlite3/analyze.c
Frontier/trunk/Common/sqlite3/attach.c
Frontier/trunk/Common/sqlite3/auth.c
Frontier/trunk/Common/sqlite3/btree.c
Frontier/trunk/Common/sqlite3/btree.h
Frontier/trunk/Common/sqlite3/build.c
Frontier/trunk/Common/sqlite3/callback.c
Frontier/trunk/Common/sqlite3/complete.c
Frontier/trunk/Common/sqlite3/date.c
Frontier/trunk/Common/sqlite3/delete.c
Frontier/trunk/Common/sqlite3/expr.c
Frontier/trunk/Common/sqlite3/func.c
Frontier/trunk/Common/sqlite3/hash.c
Frontier/trunk/Common/sqlite3/hash.h
Frontier/trunk/Common/sqlite3/insert.c
Frontier/trunk/Common/sqlite3/keywordhash.h
Frontier/trunk/Common/sqlite3/legacy.c
Frontier/trunk/Common/sqlite3/loadext.c
Frontier/trunk/Common/sqlite3/main.c
Frontier/trunk/Common/sqlite3/opcodes.c
Frontier/trunk/Common/sqlite3/opcodes.h
Frontier/trunk/Common/sqlite3/os.c
Frontier/trunk/Common/sqlite3/os.h
Frontier/trunk/Common/sqlite3/os_common.h
Frontier/trunk/Common/sqlite3/os_os2.c
Frontier/trunk/Common/sqlite3/os_unix.c
Frontier/trunk/Common/sqlite3/os_win.c
Frontier/trunk/Common/sqlite3/pager.c
Frontier/trunk/Common/sqlite3/pager.h
Frontier/trunk/Common/sqlite3/parse.c
Frontier/trunk/Common/sqlite3/parse.h
Frontier/trunk/Common/sqlite3/pragma.c
Frontier/trunk/Common/sqlite3/prepare.c
Frontier/trunk/Common/sqlite3/printf.c
Frontier/trunk/Common/sqlite3/random.c
Frontier/trunk/Common/sqlite3/select.c
Frontier/trunk/Common/sqlite3/shell.c
Frontier/trunk/Common/sqlite3/sqlite3.def
Frontier/trunk/Common/sqlite3/sqlite3.h
Frontier/trunk/Common/sqlite3/sqlite3ext.h
Frontier/trunk/Common/sqlite3/sqliteInt.h
Frontier/trunk/Common/sqlite3/table.c
Frontier/trunk/Common/sqlite3/tclsqlite.c
Frontier/trunk/Common/sqlite3/tokenize.c
Frontier/trunk/Common/sqlite3/trigger.c
Frontier/trunk/Common/sqlite3/update.c
Frontier/trunk/Common/sqlite3/utf.c
Frontier/trunk/Common/sqlite3/util.c
Frontier/trunk/Common/sqlite3/vacuum.c
Frontier/trunk/Common/sqlite3/vdbe.c
Frontier/trunk/Common/sqlite3/vdbe.h
Frontier/trunk/Common/sqlite3/vdbeInt.h
Frontier/trunk/Common/sqlite3/vdbeapi.c
Frontier/trunk/Common/sqlite3/vdbeaux.c
Frontier/trunk/Common/sqlite3/vdbefifo.c
Frontier/trunk/Common/sqlite3/vdbemem.c
Frontier/trunk/Common/sqlite3/vtab.c
Frontier/trunk/Common/sqlite3/where.c
Frontier/trunk/build_XCode/Frontier.xcodeproj/
Frontier/trunk/build_XCode/Frontier.xcodeproj/project.pbxproj
Removed Paths:
-------------
Frontier/trunk/Common/sqlite3/alter.c
Frontier/trunk/Common/sqlite3/analyze.c
Frontier/trunk/Common/sqlite3/attach.c
Frontier/trunk/Common/sqlite3/auth.c
Frontier/trunk/Common/sqlite3/btree.c
Frontier/trunk/Common/sqlite3/btree.h
Frontier/trunk/Common/sqlite3/build.c
Frontier/trunk/Common/sqlite3/callback.c
Frontier/trunk/Common/sqlite3/complete.c
Frontier/trunk/Common/sqlite3/date.c
Frontier/trunk/Common/sqlite3/delete.c
Frontier/trunk/Common/sqlite3/expr.c
Frontier/trunk/Common/sqlite3/func.c
Frontier/trunk/Common/sqlite3/hash.c
Frontier/trunk/Common/sqlite3/hash.h
Frontier/trunk/Common/sqlite3/insert.c
Frontier/trunk/Common/sqlite3/keywordhash.h
Frontier/trunk/Common/sqlite3/legacy.c
Frontier/trunk/Common/sqlite3/loadext.c
Frontier/trunk/Common/sqlite3/main.c
Frontier/trunk/Common/sqlite3/opcodes.c
Frontier/trunk/Common/sqlite3/opcodes.h
Frontier/trunk/Common/sqlite3/os.c
Frontier/trunk/Common/sqlite3/os.h
Frontier/trunk/Common/sqlite3/os_common.h
Frontier/trunk/Common/sqlite3/os_os2.c
Frontier/trunk/Common/sqlite3/os_unix.c
Frontier/trunk/Common/sqlite3/os_win.c
Frontier/trunk/Common/sqlite3/pager.c
Frontier/trunk/Common/sqlite3/pager.h
Frontier/trunk/Common/sqlite3/parse.c
Frontier/trunk/Common/sqlite3/parse.h
Frontier/trunk/Common/sqlite3/pragma.c
Frontier/trunk/Common/sqlite3/prepare.c
Frontier/trunk/Common/sqlite3/printf.c
Frontier/trunk/Common/sqlite3/random.c
Frontier/trunk/Common/sqlite3/select.c
Frontier/trunk/Common/sqlite3/shell.c
Frontier/trunk/Common/sqlite3/sqlite3.def
Frontier/trunk/Common/sqlite3/sqlite3.h
Frontier/trunk/Common/sqlite3/sqlite3ext.h
Frontier/trunk/Common/sqlite3/sqliteInt.h
Frontier/trunk/Common/sqlite3/table.c
Frontier/trunk/Common/sqlite3/tclsqlite.c
Frontier/trunk/Common/sqlite3/tokenize.c
Frontier/trunk/Common/sqlite3/trigger.c
Frontier/trunk/Common/sqlite3/update.c
Frontier/trunk/Common/sqlite3/utf.c
Frontier/trunk/Common/sqlite3/util.c
Frontier/trunk/Common/sqlite3/vacuum.c
Frontier/trunk/Common/sqlite3/vdbe.c
Frontier/trunk/Common/sqlite3/vdbe.h
Frontier/trunk/Common/sqlite3/vdbeInt.h
Frontier/trunk/Common/sqlite3/vdbeapi.c
Frontier/trunk/Common/sqlite3/vdbeaux.c
Frontier/trunk/Common/sqlite3/vdbefifo.c
Frontier/trunk/Common/sqlite3/vdbemem.c
Frontier/trunk/Common/sqlite3/vtab.c
Frontier/trunk/Common/sqlite3/where.c
Frontier/trunk/build_XCode/Frontier.xcode/
Frontier/trunk/build_XCode/Frontier.xcodeproj/project.pbxproj
Modified: Frontier/trunk/Common/headers/kernelverbdefs.h
===================================================================
--- Frontier/trunk/Common/headers/kernelverbdefs.h 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/headers/kernelverbdefs.h 2006-10-08 06:51:28 UTC (rev 1549)
@@ -51,4 +51,4 @@
#define idregexpverbs 1023 /*2003-04-22 AR: regular expression verbs*/
#define idmathverbs 1024 /*2004-12-29 SMD: extended math verbs*/
#define idcryptverbs 1025 /* 2006-03-07 creedon: crypt verbs */
-
+#define idsqliteverbs 1026 /* 2006-03-15 gewirtz sqlite verbs */
Modified: Frontier/trunk/Common/headers/kernelverbs.h
===================================================================
--- Frontier/trunk/Common/headers/kernelverbs.h 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/headers/kernelverbs.h 2006-10-08 06:51:28 UTC (rev 1549)
@@ -56,3 +56,4 @@
extern boolean cryptinitverbs (void); /* langcrypt.c */
+extern boolean sqliteinitverbs (void); /* langsqlite.c */
\ No newline at end of file
Modified: Frontier/trunk/Common/headers/langinternal.h
===================================================================
--- Frontier/trunk/Common/headers/langinternal.h 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/headers/langinternal.h 2006-10-08 06:51:28 UTC (rev 1549)
@@ -202,6 +202,8 @@
#define frnonexistantgroupnameerror 160
#define replaceitemerror 161 /* 2005-09-26 creedon */
#define cmdshellnotfounderror 162 /* 2006-03-10 aradke */
+#define sqliteopenerror 163 /* 2006-03-17 gewirtz */
+#define sqlitedberror 164 /* 2006-03-17 gewirtz */
#define langstacklist 137
Copied: Frontier/trunk/Common/headers/langsqlite.h (from rev 1547, Frontier/branches/SQLite/Common/headers/langsqlite.h)
===================================================================
--- Frontier/trunk/Common/headers/langsqlite.h (rev 0)
+++ Frontier/trunk/Common/headers/langsqlite.h 2006-10-08 06:51:28 UTC (rev 1549)
@@ -0,0 +1,69 @@
+
+/* $Id: langsqlite.h,v 1.1.2.1 2006/03/24 01:31:35 davidgewirtz Exp $ */
+
+/******************************************************************************
+
+ UserLand Frontier(tm) -- High performance Web content management,
+ object database, system-level and Internet scripting environment,
+ including source code editing and debugging.
+
+ Copyright (C) 1992-2004 UserLand Software, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+******************************************************************************/
+
+/* prototypes */
+
+extern boolean sqliteopenverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-03-15 gewirtz */
+
+extern boolean sqlitecloseverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-03-17 gewirtz */
+
+extern boolean sqlitecompilequeryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqliteclearqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqliteresetqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
+
+extern boolean sqlitestepqueryverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
+
+extern boolean sqlitegetcolumncountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumntypeverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumnintverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumndoubleverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumntextverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumnnameverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-18 gewirtz */
+
+extern boolean sqlitegetcolumnverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-20 gewirtz */
+
+extern boolean sqlitegetrowverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-08-31 gewirtz */
+
+extern boolean sqlitegeterrormessageverb (hdltreenode, tyvaluerecord *, bigstring); /* 2006-04-20 gewirtz */
+
+extern boolean sqliteinitverbs (void); /* 2006-03-15 gewirtz */
+
+/* boolean hmacmd5 (unsigned char *, int, unsigned char *, int, unsigned char *);*/ /* 2006-03-05 creedon */
+
+/* boolean hmacsha1 (unsigned char *, int, unsigned char *, int, unsigned char *);*/ /* 2006-03-12 creedon */
+
+/* SQLITE MESSAGES */
+#define SQLITE_COLUMN_ERROR_0 "\xe9""SQLite column error. Frontier uses a base-1 index. Columns must be specified with 1 indicating the first column. This is different from the SQLite API, which requires that columns must be specified with 0 indicating the first column."
+#define SQLITE_COLUMN_ERROR_MAX "\x50""SQLite column error. An attempt was made to access a column that does not exist."
+#define SQLITE_COLUMN_ERROR_UNDEFINED "\x29""SQLite returned an undefined column type."
\ No newline at end of file
Modified: Frontier/trunk/Common/headers/versions.h
===================================================================
--- Frontier/trunk/Common/headers/versions.h 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/headers/versions.h 2006-10-08 06:51:28 UTC (rev 1549)
@@ -69,10 +69,10 @@
#define APP_SUBMINOR_VERSION_BCD 0x10 /* sub and minor version in BCD notation */
#define APP_STAGE_CODE 0x40 /* dev = 0x20, alpha = 0x40, beta = 0x60, final = 0x80 */
- #define APP_REVISION_LEVEL 10 /* for non-final releases only */
- #define APP_BUILD_NUMBER 10 /* increment by one for every release, final or not */
+ #define APP_REVISION_LEVEL 11 /* for non-final releases only */
+ #define APP_BUILD_NUMBER 11 /* increment by one for every release, final or not */
- #define APP_VERSION_STRING "10.1a10"
+ #define APP_VERSION_STRING "10.1a11"
#else
@@ -95,10 +95,10 @@
#define APP_SUBMINOR_VERSION_BCD 0x10 /* sub and minor version in BCD notation */
#define APP_STAGE_CODE 0x40 /* dev = 0x20, alpha = 0x40, beta = 0x60, final = 0x80 */
- #define APP_REVISION_LEVEL 10 /* for non-final releases only */
- #define APP_BUILD_NUMBER 10 /* increment by one for every release, final or not */
+ #define APP_REVISION_LEVEL 11 /* for non-final releases only */
+ #define APP_BUILD_NUMBER 11 /* increment by one for every release, final or not */
- #define APP_VERSION_STRING "10.1a10"
+ #define APP_VERSION_STRING "10.1a11"
#endif
#else
@@ -121,10 +121,10 @@
#define APP_SUBMINOR_VERSION_BCD 0x10 /* sub and minor version in BCD notation */
#define APP_STAGE_CODE 0x40 /* dev = 0x20, alpha = 0x40, beta = 0x60, final = 0x80 */
- #define APP_REVISION_LEVEL 10 /* for non-final releases only */
- #define APP_BUILD_NUMBER 10 /* increment by one for every release, final or not */
+ #define APP_REVISION_LEVEL 11 /* for non-final releases only */
+ #define APP_BUILD_NUMBER 11 /* increment by one for every release, final or not */
- #define APP_VERSION_STRING "10.1a10"
+ #define APP_VERSION_STRING "10.1a11"
#endif
Modified: Frontier/trunk/Common/resources/Mac/kernelverbs.r
===================================================================
--- Frontier/trunk/Common/resources/Mac/kernelverbs.r 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/resources/Mac/kernelverbs.r 2006-10-08 06:51:28 UTC (rev 1549)
@@ -1140,3 +1140,26 @@
}
};
+resource 'EFP#' (idsqliteverbs, "sqlite") { /* 2006-08-31 gewirtz sqlite verbs */
+ {
+ "sqlite", false, {
+
+ "open",
+ "compileQuery",
+ "clearQuery",
+ "resetQuery",
+ "stepQuery",
+ "getColumnCount",
+ "getColumnType",
+ "getColumnInt",
+ "getColumnDouble",
+ "getColumnText",
+ "getColumnName",
+ "getColumn",
+ "getRow",
+ "getErrorMessage",
+ "close" // 2006-09-07 - kw - renamed from getClose
+ }
+ }
+};
+
Modified: Frontier/trunk/Common/resources/Win32/WinLand.rc
===================================================================
--- Frontier/trunk/Common/resources/Win32/WinLand.rc 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/resources/Win32/WinLand.rc 2006-10-08 06:51:28 UTC (rev 1549)
@@ -1533,6 +1533,8 @@
160 Lang_Errors DISCARDABLE BEGIN "Can't execute command because the replacement string contains a non-existant group name at character #^0.\0" END
161 Lang_Errors DISCARDABLE BEGIN "An item named \042^0\042 already exists.\0" END // Replace it or create a duplicate?" /* 2005-09-26 creedon */
162 Lang_Errors DISCARDABLE BEGIN "Can't run shell command because the shell \042^0\042 was not found.\0" END /* 2006-03-10 aradke */
+ 163 Lang_Errors DISCARDABLE BEGIN "Can't open database: ^0.\0" END /* 2006-03-17 gewirtz */
+ 164 Lang_Errors DISCARDABLE BEGIN "Database error: ^0.\0" END /* 2006-03-17 gewirtz */
1 Mac_Errors DISCARDABLE BEGIN "The \042^0\042 folder is full.\0" END
2 Mac_Errors DISCARDABLE BEGIN "The disk is full.\0" END
Modified: Frontier/trunk/Common/resources/Win32/kernelverbs.rc
===================================================================
--- Frontier/trunk/Common/resources/Win32/kernelverbs.rc 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/resources/Win32/kernelverbs.rc 2006-10-08 06:51:28 UTC (rev 1549)
@@ -1077,3 +1077,26 @@
"hmacSHA1\0",
END
+1026 /* sqliteverbs */ EFP DISCARDABLE
+ BEGIN
+ 1, // Number of "blocks" in this resource
+ "sqlite\0", // Function Processor name
+ false, // Window required
+ 15, // Count of verbs
+ "open\0",
+ "compileQuery\0",
+ "clearQuery\0",
+ "resetQuery\0",
+ "stepQuery\0",
+ "getColumnCount\0",
+ "getColumnType\0",
+ "getColumnInt\0",
+ "getColumnDouble\0",
+ "getColumnText\0",
+ "getColumnName\0",
+ "getColumn\0",
+ "getRow\0",
+ "getErrorMessage\0",
+ "close\0"
+ END
+
Copied: Frontier/trunk/Common/source/langsqlite.c (from rev 1547, Frontier/branches/SQLite/Common/source/langsqlite.c)
===================================================================
--- Frontier/trunk/Common/source/langsqlite.c (rev 0)
+++ Frontier/trunk/Common/source/langsqlite.c 2006-10-08 06:51:28 UTC (rev 1549)
@@ -0,0 +1,920 @@
+
+/* $Id: langsqlite.c,v 1.1.2.1 2006/03/24 01:32:31 davidgewirtz Exp $ */
+
+/******************************************************************************
+
+ UserLand Frontier(tm) -- High performance Web content management,
+ object database, system-level and Internet scripting environment,
+ including source code editing and debugging.
+
+ Copyright (C) 1992-2004 UserLand Software, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+******************************************************************************/
+
+#include "frontier.h"
+#include "standard.h"
+
+#include "frontierconfig.h"
+
+#include "error.h"
+#include "ops.h"
+#include "langinternal.h"
+#include "kernelverbs.h"
+#include "kernelverbdefs.h"
+#include "resources.h"
+#include "strings.h"
+#include "tablestructure.h"
+#include "lang.h"
+#include "oplist.h"
+#include "langsystem7.h"
+#include "langexternal.h"
+
+#include "langsqlite.h"
+#include <sqlite3.h>
+
+/* Building SQLite into Frontier
+
+The SQLite source distribution is compiled into the Frontier code as part of this
+module. A key goal in this implementation was to avoid touching any of the SQLite
+source files. SQLite is pretty complex in its coding, and I didn't want to take a
+chance that any changes to the original SQLite code would muck up the database
+functionality.
+
+To include the latest SQLite distribution (we're implementing SQLite 3 here),
+download the SQLite source code from http://www.sqlite.org/download.html.
+
+Move all the SQLite source files into the \Common\sqlite3 folder. If you need to
+include new files in the SQLite project, be sure that shell.c and tclsqlite.c are
+NOT included in the Frontier project.
+
+That's it. For further tips, see the Frontier Lab Notebook article at:
+
+http://manila.zatz.com/frontierkernel/stories/storyReader$29
+
+-- DG
+
+*/
+
+typedef enum tysqliteverbtoken { /* verbs that are processed by langsqlite.c */
+
+ openfunc,
+ compilequeryfunc,
+ clearqueryfunc,
+ resetqueryfunc,
+ stepqueryfunc,
+ getcolumncountfunc,
+ getcolumntypefunc,
+ getcolumnintfunc,
+ getcolumndoublefunc,
+ getcolumntextfunc,
+ getcolumnnamefunc,
+ getcolumnfunc,
+ getrowfunc,
+ geterrormessagefunc,
+ closefunc,
+ ctsqliteverbs
+ } tysqliteverbtoken;
+
+
+static boolean sqlitefunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+
+ /*
+ 2006-03-15 gewirtz: created, cribbed from langcrypt, itself cribbed from htmlfunctionvalue
+ */
+
+ hdltreenode hp1 = hparam1;
+ tyvaluerecord *v = vreturned;
+
+ setbooleanvalue (false, v); /* by default, sqlite functions return false */
+
+ switch (token) {
+
+ case openfunc: { /* 2006-03-14 gewirtz: open an SQLite db */
+
+ return (sqliteopenverb (hp1, v, bserror));
+ } /* openfunc */
+
+ case compilequeryfunc: { /* 2006-04-18 gewirtz: prepare an SQLite statement */
+
+ return (sqlitecompilequeryverb (hp1, v, bserror));
+ } /* compilequeryfunc */
+
+ case clearqueryfunc: { /* 2006-04-18 gewirtz: finalize an SQLite statement */
+
+ return (sqliteclearqueryverb (hp1, v, bserror));
+ } /* clearqueryfunc */
+
+ case resetqueryfunc: { /* 2006-08-31 gewirtz: reset an SQLite query statement */
+
+ return (sqliteresetqueryverb (hp1, v, bserror));
+ } /* resetqueryfunc */
+
+ case stepqueryfunc: { /* 2006-08-31 gewirtz: move the cursor one step after the query */
+
+ return (sqlitestepqueryverb (hp1, v, bserror));
+ } /* stepqueryfunc */
+
+ case getcolumncountfunc: { /* 2006-04-18 gewirtz: get the number of columns */
+
+ return (sqlitegetcolumncountverb (hp1, v, bserror));
+ } /* getcolumncountfunc */
+
+ case getcolumntypefunc: { /* 2006-04-18 gewirtz: get the type of the referenced column */
+ /* this version returns Frontier strings */
+ return (sqlitegetcolumntypeverb (hp1, v, bserror));
+ } /* getcolumntypefunc */
+
+ case getcolumnintfunc: { /* 2006-04-18 gewirtz: get an int value from the column */
+
+ return (sqlitegetcolumnintverb (hp1, v, bserror));
+ } /* getcolumnintfunc */
+
+ case getcolumndoublefunc: { /* 2006-04-18 gewirtz: get a double value from the column */
+
+ return (sqlitegetcolumndoubleverb (hp1, v, bserror));
+ } /* getcolumndoublefunc */
+
+ case getcolumntextfunc: { /* 2006-04-18 gewirtz: get a text value from the column */
+
+ return (sqlitegetcolumntextverb (hp1, v, bserror));
+ } /* getcolumntextfunc */
+
+ case getcolumnnamefunc: { /* 2006-04-18 gewirtz: get the field name of the column */
+
+ return (sqlitegetcolumnnameverb (hp1, v, bserror));
+ } /* getcolumnnamefunc */
+
+ case getcolumnfunc: { /* 2006-04-20 gewirtz: get the value of the column */
+
+ return (sqlitegetcolumnverb (hp1, v, bserror));
+ } /* getcolumnfunc */
+
+ case getrowfunc: { /* 2006-08-31 gewirtz: get the values in a row */
+
+ return (sqlitegetrowverb (hp1, v, bserror));
+ } /* getrowfunc */
+
+ case geterrormessagefunc: { /* 2006-04-20 gewirtz: get the SQLite error message */
+
+ return (sqlitegeterrormessageverb (hp1, v, bserror));
+ } /* geterrormessagefunc */
+
+ case closefunc: { /* 2006-03-15 gewirtz: close an SQLite db */
+
+ return (sqlitecloseverb (hp1, v, bserror));
+ } /* closefunc */
+
+ default:
+ getstringlist (langerrorlist, unimplementedverberror, bserror);
+
+ return (false);
+ } /* switch */
+ } /* sqlitefunctionvalue */
+
+
+boolean sqliteinitverbs (void) {
+
+ /* 2006-03-15 gewirtz: created, cribbed from cryptinitverbs */
+
+ return (loadfunctionprocessor (idsqliteverbs, &sqlitefunctionvalue));
+ } /* sqliteinitverbs */
+
+static void sqliteOpenError (const char *errmsg, bigstring bserror) {
+ bigstring bserrmsg;
+
+ copyctopstring (errmsg, bserrmsg); /* This creates a pstring at bserrmsg */
+ getstringlist (langerrorlist, sqliteopenerror, bserror);
+ parsedialogstring (bserror, bserrmsg, nil, nil, nil, bserror);
+
+ return;
+ } /*sqliteOpenError*/
+
+static void sqliteDatabaseError (const char *errmsg, bigstring bserror) {
+ bigstring bserrmsg;
+
+ copyctopstring (errmsg, bserrmsg); /* This creates a pstring at bserrmsg */
+ getstringlist (langerrorlist, sqlitedberror, bserror);
+ parsedialogstring (bserror, bserrmsg, nil, nil, nil, bserror);
+
+ return;
+ } /*sqliteDatabaseError*/
+
+static void sqliteScriptError (const char *errmsg, bigstring bserror) {
+ bigstring bserrmsg;
+
+ copyctopstring (errmsg, bserrmsg); /* This creates a pstring at bserrmsg */
+ getstringlist (langerrorlist, notfunctionerror, bserror);
+ parsedialogstring (bserror, bserrmsg, nil, nil, nil, bserror);
+
+ return;
+ } /*sqliteScriptError*/
+
+
+boolean sqliteopenverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ Handle dbfile; /* path to database file */
+ sqlite3 *dbid; /* the SQLite database handle */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.open(dbfile)
+
+ Action: opens a SQLite database
+ Params: a file path to the database file
+ Returns: a value that corresponds to the opened database ID
+ Usage: call in a try statement
+ Notes: do not pass the opened database ID across threads
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_open.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!gettextvalue (hparam1, 1, &dbfile)) /* get the param */
+ return (false);
+
+ pushcharhandle (0x00, dbfile); /* convert *dbfile to a string */
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_open(*dbfile, &dbid);
+ if(returnCode) {
+ sqliteOpenError(sqlite3_errmsg(dbid), bserror); /* send database open error */
+ sqlite3_close(dbid);
+ return (false);
+ }
+
+ /* return the db address to the scripter */
+// return (setheapvalue ((Handle) dbid, longvaluetype, vreturned));
+ // 2006-09-06 - kw - simply return a long
+ return (setlongvalue ((long) dbid, vreturned));
+
+} /* sqliteopenverb */
+
+boolean sqlitecloseverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ sqlite3 *dbid; /* the SQLite database handle */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.close(dbid)
+
+ Action: close an SQLite database
+ Params: a database id
+ Returns: an SQLite result code
+ Usage: check result code for success or failure
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_close.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_close(dbid);
+
+ return setlongvalue (returnCode, vreturned);
+
+} /* sqlitecloseverb */
+
+boolean sqlitecompilequeryverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ Handle query; /* the SQL query passed to the SQLite engine */
+ sqlite3 *dbid; /* the SQLite database handle */
+ sqlite3_stmt *queryid = 0; /* the compiled query */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.compileQuery(dbid, query)
+
+ Action: compile an SQLite query
+ Params: a database id and a query string
+ Returns: a query id
+ Usage: call in a try statement
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_prepare.
+
+ Code that is a good example of prepare in use:
+ http://souptonuts.sourceforge.net/code/eatblob.c.html
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getreadonlytextvalue (hparam1, 2, &query)) /* get the query param */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_prepare(dbid, *query, gethandlesize(query), &queryid, 0);
+ if(returnCode != SQLITE_OK || queryid == NULL) {
+ sqliteDatabaseError(sqlite3_errmsg(dbid), bserror); /* send database error */
+ return (false);
+ }
+
+ return (setlongvalue ((long) queryid, vreturned)); /* return the db address to the scripter */
+
+} /* sqlitecompilequeryverb */
+
+boolean sqliteclearqueryverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.clearQuery(queryid)
+
+ Action: clear an SQLite query
+ Params: a query id
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_finalize.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_finalize(queryid);
+
+ return setlongvalue (returnCode, vreturned);
+
+} /* sqliteclearqueryverb */
+
+boolean sqliteresetqueryverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.resetQuery(queryid)
+
+ Action: reset an SQLite query, so you can scan again from the beginning
+ Params: a query id
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_reset.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_reset(queryid);
+
+ return setlongvalue (returnCode, vreturned);
+
+} /* sqliteresetqueryverb */
+
+boolean sqlitestepqueryverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.stepQuery(queryid)
+
+ Action: perform the query, moving the query cursor to the next row of results
+ Params: a query id
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_step.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_step(queryid);
+
+ return setlongvalue (returnCode, vreturned);
+
+} /* sqlitestepqueryverb */
+
+boolean sqlitegetcolumntypeverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber; /* column number */
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+ int columnCount;
+
+ /*
+ sqlite.getColumnType(queryid, columnNumber)
+
+ Action: Retrieve the type of the specified column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_type.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ returnCode = sqlite3_column_type(queryid, (int) columnNumber);
+
+ switch(returnCode) {
+
+ case SQLITE_INTEGER: {
+ return setostypevalue (langgettypeid (longvaluetype), vreturned);
+ }
+ case SQLITE_FLOAT: {
+ return setostypevalue (langgettypeid (doublevaluetype), vreturned);
+ }
+ case SQLITE_TEXT: {
+ return setostypevalue (langgettypeid (stringvaluetype), vreturned);
+ }
+ case SQLITE_BLOB: {
+ return setostypevalue (langgettypeid (binaryvaluetype), vreturned);
+ }
+ case SQLITE_NULL: {
+ return setostypevalue (langgettypeid (novaluetype), vreturned);
+ }
+ default: {
+ /* SQLite spec says sqlite3_column_type only returns the above 5 types. But,
+ just in case it lied, we'll return an error type to help Frontier avoid
+ getting a case of return value indigestion. */
+ langerrormessage (SQLITE_COLUMN_ERROR_UNDEFINED);
+ return (false);
+ }
+ } /* switch */
+
+} /* sqlitegetcolumntypeverb */
+
+boolean sqlitegetcolumnnameverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber; /* column number */
+ Handle returnH;
+ const char *column_name;
+ sqlite3_stmt *queryid;
+ int columnCount;
+
+ /*
+ sqlite.getColumnName(queryid, columnNumber)
+
+ Action: Retrieve the name of the specified column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_name.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ column_name = sqlite3_column_name(queryid, (int) columnNumber);
+
+ /* Exit the verb, converting column_name back to Frontier handle */
+ if (!newfilledhandle ((ptrvoid) column_name, strlen (column_name), &returnH))
+ return false; /* Allocation failed */
+
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+} /* sqlitegetcolumnnameverb */
+
+boolean sqlitegetcolumncountverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ sqlite3_stmt *queryid;
+ int returnCode; /* return code from SQLite call */
+
+ /*
+ sqlite.getColumnCount(queryid)
+
+ Action: Retrieve number of columns returned in a query
+ Params: a query id
+ Returns: the number of columns in the result set returned by the prepared SQL statement.
+ Notes: do not pass the opened database ID across threads.
+ returns 0 if pStmt is an SQL statement that does not return data (for example an UPDATE).
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_count.
+ */
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ returnCode = sqlite3_column_count(queryid);
+
+ return setlongvalue (returnCode, vreturned);
+
+} /* sqlitegetcolumncountverb */
+
+boolean sqlitegetcolumnintverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber;
+ sqlite3_stmt *queryid;
+ long returnCode; /* return code from SQLite call */
+ int columnCount;
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ returnCode = sqlite3_column_int(queryid, (int) columnNumber);
+
+ return (setlongvalue ((long) returnCode, vreturned));
+
+} /* sqlitegetcolumnintverb */
+
+boolean sqlitegetcolumndoubleverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber;
+ sqlite3_stmt *queryid;
+ double returnDouble; /* double value returned from SQLite call */
+ int columnCount;
+
+ /*
+ sqlite.getColumnDouble(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified double-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_double.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ returnDouble = sqlite3_column_double(queryid, (int) columnNumber);
+
+ return (setdoublevalue (returnDouble, vreturned));
+
+} /* sqlitegetcolumndoubleverb */
+
+boolean sqlitegetcolumntextverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber;
+ sqlite3_stmt *queryid;
+ Handle returnH;
+ const unsigned char *column_text;
+ int columnCount;
+
+ /*
+ sqlite.getColumnText(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified text-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_text.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ column_text = sqlite3_column_text(queryid, (int) columnNumber);
+
+ /* Exit the verb, converting column_name back to Frontier handle */
+ if (!newfilledhandle ((ptrvoid) column_text, strlen (column_text), &returnH))
+ return false; /* Allocation failed */
+
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+} /* sqlitegetcolumntextverb */
+
+boolean sqlitegetcolumnverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber; /* column number */
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+ double returnDouble; /* double value returned from SQLite call */
+ Handle returnH;
+ int columnCount;
+ const unsigned char *column_text;
+ /* const unsigned char *column_blob; */
+
+ /*
+ sqlite.getColumn(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified column element
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+ this implementation does not support blobs. If a blob column is requested, 0 is returned.
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ /* Enter the verb, convert the param to null-terminated string */
+ if (!getlongvalue (hparam1, 2, &columnNumber))
+ return (false);
+
+ /* Validate the column number */
+ if (columnNumber < 1) {
+ langerrormessage (SQLITE_COLUMN_ERROR_0);
+ return (false);
+ }
+ columnCount = sqlite3_column_count(queryid);
+ if (columnNumber > columnCount) {
+ langerrormessage (SQLITE_COLUMN_ERROR_MAX);
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ --columnNumber; /* Frontier uses base 1, but SQLite uses a base of 0 for its column numbering */
+ returnCode = sqlite3_column_type(queryid, (int) columnNumber);
+
+ switch(returnCode) {
+
+ case SQLITE_INTEGER: {
+ returnCode = sqlite3_column_int(queryid, (int) columnNumber);
+ return (setlongvalue ((long) returnCode, vreturned));
+ }
+ case SQLITE_FLOAT: {
+ returnDouble = sqlite3_column_double(queryid, (int) columnNumber);
+ return (setdoublevalue (returnDouble, vreturned));
+ }
+ case SQLITE_TEXT: {
+ column_text = sqlite3_column_text(queryid, (int) columnNumber);
+
+ /* Exit the verb, converting column_name back to Frontier handle */
+ if (!newfilledhandle ((ptrvoid) column_text, strlen (column_text), &returnH))
+ return false; /* Allocation failed */
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+ }
+ case SQLITE_BLOB: {
+ return (setlongvalue ((long) 0, vreturned));
+
+ /* The following code is ignored. Andre suggested returning actual binary
+ data to Frontier, but I'm concerned about reliability, moving that data
+ back and forth, so in this implementation, I'm explicitly making blob
+ data not supported -- DG */
+
+ // column_blob = sqlite3_column_blob(queryid, (int) columnNumber);
+
+ /* Exit the verb, converting column_name back to Frontier handle */
+ //if (!newfilledhandle ((ptrvoid) column_blob, strlen (column_blob), &returnH))
+ // return false; /* Allocation failed */
+ //return (setbinaryvalue (returnH, '\?\?\?\?', vreturned));
+ }
+ case SQLITE_NULL: {
+ return (setlongvalue ((long) 0, vreturned));
+ }
+ default: {
+ /* SQLite spec says sqlite3_column_type only returns the above 5 types. But,
+ just in case it lied, we'll return an error type to help Frontier avoid
+ getting a case of return value indigestion. */
+ langerrormessage ("\x29""SQLite returned an undefined column type.");
+ return (false);
+ }
+ } /* switch */
+
+} /* sqlitegetcolumn */
+
+boolean sqlitegetrowverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ long columnNumber; /* column number */
+ int columnCount; /* number of columns */
+ sqlite3_stmt *queryid; /* query id */
+ int returnCode; /* return code from SQLite call */
+ double returnDouble; /* double value returned from SQLite call */
+ Handle returnH;
+ const unsigned char *column_text;
+ hdllistrecord hlist;
+ tyvaluerecord val;
+
+ /*
+ sqlite.getRow(queryid)
+
+ Action: Retrieve a row as a list
+ Params: a query id
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+ this implementation does not support blobs. If a blob column is requested, 0 is returned.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the queryid pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ columnCount = sqlite3_column_count(queryid); /* first, figure out how many columns we've got */
+
+ if (columnCount == 0) {
+ langerrormessage ("\x2F""SQLite.getRow requires a minimum of one column.");
+ return (false);
+ }
+
+ if (!opnewlist (&hlist, false)) /* fail out if we can't create the list */
+ return (false);
+
+ for (columnNumber = 0 ; columnNumber < columnCount ; ++columnNumber) {
+
+ returnCode = sqlite3_column_type(queryid, (int) columnNumber);
+
+ switch(returnCode) {
+
+ case SQLITE_INTEGER: {
+ returnCode = sqlite3_column_int(queryid, (int) columnNumber);
+ if (!langpushlistlong (hlist, (long) returnCode))
+ goto error;
+ break;
+ }
+ case SQLITE_FLOAT: {
+ returnDouble = sqlite3_column_double(queryid, (int) columnNumber);
+ if (!setdoublevalue (returnDouble, &val))
+ goto error;
+ if (!langpushlistval (hlist, nil, &val))
+ goto error;
+ break;
+ }
+ case SQLITE_TEXT: {
+ column_text = sqlite3_column_text(queryid, (int) columnNumber);
+
+ /* Exit the verb, converting column_name back to Frontier handle */
+ if (!newfilledhandle ((ptrvoid) column_text, strlen (column_text), &returnH))
+ return false; /* Allocation failed */
+ if (!setheapvalue (returnH, stringvaluetype, &val)) /* convert handle to value */
+ goto error;
+ if (!langpushlistval (hlist, nil, &val))
+ goto error;
+ break;
+ }
+ case SQLITE_BLOB: {
+ if (!langpushlistlong (hlist, (long) 0))
+ goto error;
+ break;
+ }
+ case SQLITE_NULL: {
+ if (!langpushlistlong (hlist, (long) 0))
+ goto error;
+ break;
+ }
+ default: {
+ /* SQLite spec says sqlite3_column_type only returns the above 5 types. But,
+ just in case it lied, this time we return a 0, so the rest of the fields
+ can be read properly. */
+ if (!langpushlistlong (hlist, (long) 0))
+ goto error;
+ }
+ } /* switch */
+ } /* for */
+
+ return (setheapvalue ((Handle) hlist, listvaluetype, vreturned));
+
+ error: {
+ opdisposelist (hlist);
+ return (false);
+ }
+
+} /* sqlitegetrow */
+
+boolean sqlitegeterrormessageverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ const char *sqliteError; /* pointer to the error message */
+ sqlite3 *db; /* the SQLite database handle */
+ Handle returnH = nil; /* The handle being returned back to Frontier */
+
+ /*
+ Frontier verb: sqlite.getErrorMessage(dbfile)
+
+ Returns the error message for the most recent SQLite API call.
+ Takes a database ID.
+ Returns a string containing the error message.
+ NOTE: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_errmsg.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &db)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ /* Process the SQLite sequence */
+ sqliteError = sqlite3_errmsg(db);
+
+ /* Exit the verb, converting errMsg back to Frontier handle */
+ if(!newfilledhandle ((ptrvoid) sqliteError, strlen (sqliteError), &returnH))
+ return false; /* Allocation failed */
+
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+} /* sqlitegeterrormessageverb */
\ No newline at end of file
Modified: Frontier/trunk/Common/source/shell.c
===================================================================
--- Frontier/trunk/Common/source/shell.c 2006-10-08 05:54:23 UTC (rev 1548)
+++ Frontier/trunk/Common/source/shell.c 2006-10-08 06:51:28 UTC (rev 1549)
@@ -1319,6 +1319,8 @@
htmlinitverbs ();
+ sqliteinitverbs (); /* 2006-03-15 gewirtz: langsqlite.c */
+
#ifdef flregexpverbs
regexpinitverbs (); /* 2003-04-23 AR: langregexp.c */
#endif
Copied: Frontier/trunk/Common/sqlite3 (from rev 1547, Frontier/branches/SQLite/Common/sqlite3)
Deleted: Frontier/trunk/Common/sqlite3/alter.c
===================================================================
--- Frontier/branches/SQLite/Common/sqlite3/alter.c 2006-10-05 19:16:57 UTC (rev 1547)
+++ Frontier/trunk/Common/sqlite3/alter.c 2006-10-08 06:51:28 UTC (rev 1549)
@@ -1,575 +0,0 @@
-/*
-** 2005 February 15
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** This file contains C code routines that used to generate VDBE code
-** that implements the ALTER TABLE command.
-**
-** $Id: alter.c,v 1.21 2006/06/21 12:36:25 danielk1977 Exp $
-*/
-#include "sqliteInt.h"
-#include <ctype.h>
-
-/*
-** The code in this file only exists if we are not omitting the
-** ALTER TABLE logic from the build.
-*/
-#ifndef SQLITE_OMIT_ALTERTABLE
-
-
-/*
-** This function is used by SQL generated to implement the
-** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
-** CREATE INDEX command. The second is a table name. The table name in
-** the CREATE TABLE or CREATE INDEX statement is replaced with the second
-** argument and the result returned. Examples:
-**
-** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
-** -> 'CREATE TABLE def(a, b, c)'
-**
-** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')
-** -> 'CREATE INDEX i ON def(a, b, c)'
-*/
-static void renameTableFunc(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- unsigned char const *zSql = sqlite3_value_text(argv[0]);
- unsigned char const *zTableName = sqlite3_value_text(argv[1]);
-
- int token;
- Token tname;
- unsigned char const *zCsr = zSql;
- int len = 0;
- char *zRet;
-
- /* The principle used to locate the table name in the CREATE TABLE
- ** statement is that the table name is the first token that is immediatedly
- ** followed by a left parenthesis - TK_LP.
- */
- if( zSql ){
- do {
- /* Store the token that zCsr points to in tname. */
- tname.z = zCsr;
- tname.n = len;
-
- /* Advance zCsr to the next token. Store that token type in 'token',
- ** and it's length in 'len' (to be used next iteration of this loop).
- */
- do {
- zCsr += len;
- len = sqlite3GetToken(zCsr, &token);
- } while( token==TK_SPACE );
- assert( len>0 );
- } while( token!=TK_LP );
-
- zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql,
- zTableName, tname.z+tname.n);
- sqlite3_result_text(context, zRet, -1, sqlite3FreeX);
- }
-}
-
-#ifndef SQLITE_OMIT_TRIGGER
-/* This function is used by SQL generated to implement the ALTER TABLE
-** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
-** statement. The second is a table name. The table name in the CREATE
-** TRIGGER statement is replaced with the second argument and the result
-** returned. This is analagous to renameTableFunc() above, except for CREATE
-** TRIGGER, not CREATE INDEX and CREATE TABLE.
-*/
-static void renameTriggerFunc(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- unsigned char const *zSql = sqlite3_value_text(argv[0]);
- unsigned char const *zTableName = sqlite3_value_text(argv[1]);
-
- int token;
- Token tname;
- int dist = 3;
- unsigned char const *zCsr = zSql;
- int len = 0;
- char *zRet;
-
- /* The principle used to locate the table name in the CREATE TRIGGER
- ** statement is that the table name is the first token that is immediatedly
- ** preceded by either TK_ON or TK_DOT and immediatedly followed by one
- ** of TK_WHEN, TK_BEGIN or TK_FOR.
- */
- if( zSql ){
- do {
- /* Store the token that zCsr points to in tname. */
- tname.z = zCsr;
- tname.n = len;
-
- /* Advance zCsr to the next token. Store that token type in 'token',
- ** and it's length in 'len' (to be used next iteration of this loop).
- */
- do {
- zCsr += len;
- len = sqlite3GetToken(zCsr, &token);
- }while( token==TK_SPACE );
- assert( len>0 );
-
- /* Variable 'dist' stores the number of tokens read since the most
- ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
- ** token is read and 'dist' equals 2, the condition stated above
- ** to be met.
- **
- ** Note that ON cannot be a database, table or column name, so
- ** there is no need to worry about syntax like
- ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
- */
- dist++;
- if( token==TK_DOT || token==TK_ON ){
- dist = 0;
- }
- } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );
-
- /* Variable tname now contains the token that is the old table-name
- ** in the CREATE TRIGGER statement.
- */
- zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql,
- zTableName, tname.z+tname.n);
- sqlite3_result_text(context, zRet, -1, sqlite3FreeX);
- }
-}
-#endif /* !SQLITE_OMIT_TRIGGER */
-
-/*
-** Register built-in functions used to help implement ALTER TABLE
-*/
-void sqlite3AlterFunctions(sqlite3 *db){
- static const struct {
- char *zName;
- signed char nArg;
- void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
- } aFuncs[] = {
- { "sqlite_rename_table", 2, renameTableFunc},
-#ifndef SQLITE_OMIT_TRIGGER
- { "sqlite_rename_trigger", 2, renameTriggerFunc},
-#endif
- };
- int i;
-
- for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
- sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
- SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0);
- }
-}
-
-/*
-** Generate the text of a WHERE expression which can be used to select all
-** temporary triggers on table pTab from the sqlite_temp_master table. If
-** table pTab has no temporary triggers, or is itself stored in the
-** temporary database, NULL is returned.
-*/
-static char *whereTempTriggers(Parse *pParse, Table *pTab){
- Trigger *pTrig;
- char *zWhere = 0;
- char *tmp = 0;
- const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
-
- /* If the table is not located in the temp-db (in which case NULL is
- ** returned, loop through the tables list of triggers. For each trigger
- ** that is not part of the temp-db schema, add a clause to the WHERE
- ** expression being built up in zWhere.
- */
- if( pTab->pSchema!=pTempSchema ){
- for( pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext ){
- if( pTrig->pSchema==pTempSchema ){
- if( !zWhere ){
- zWhere = sqlite3MPrintf("name=%Q", pTrig->name);
- }else{
- tmp = zWhere;
- zWhere = sqlite3MPrintf("%s OR name=%Q", zWhere, pTrig->name);
- sqliteFree(tmp);
- }
- }
- }
- }
- return zWhere;
-}
-
-/*
-** Generate code to drop and reload the internal representation of table
-** pTab from the database, including triggers and temporary triggers.
-** Argument zName is the name of the table in the database schema at
-** the time the generated code is executed. This can be different from
-** pTab->zName if this function is being called to code part of an
-** "ALTER TABLE RENAME TO" statement.
-*/
-static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
- Vdbe *v;
- char *zWhere;
- int iDb; /* Index of database containing pTab */
-#ifndef SQLITE_OMIT_TRIGGER
- Trigger *pTrig;
-#endif
-
- v = sqlite3GetVdbe(pParse);
- if( !v ) return;
- iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
- assert( iDb>=0 );
-
-#ifndef SQLITE_OMIT_TRIGGER
- /* Drop any table triggers from the internal schema. */
- for(pTrig=pTab->pTrigger; pTrig; pTrig=pTrig->pNext){
- int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
- assert( iTrigDb==iDb || iTrigDb==1 );
- sqlite3VdbeOp3(v, OP_DropTrigger, iTrigDb, 0, pTrig->name, 0);
- }
-#endif
-
- /* Drop the table and index from the internal schema */
- sqlite3VdbeOp3(v, OP_DropTable, iDb, 0, pTab->zName, 0);
-
- /* Reload the table, index and permanent trigger schemas. */
- zWhere = sqlite3MPrintf("tbl_name=%Q", zName);
- if( !zWhere ) return;
- sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0, zWhere, P3_DYNAMIC);
-
-#ifndef SQLITE_OMIT_TRIGGER
- /* Now, if the table is not stored in the temp database, reload any temp
- ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.
- */
- if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
- sqlite3VdbeOp3(v, OP_ParseSchema, 1, 0, zWhere, P3_DYNAMIC);
- }
-#endif
-}
-
-/*
-** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
-** command.
-*/
-void sqlite3AlterRenameTable(
- Parse *pParse, /* Parser context. */
- SrcList *pSrc, /* The table to rename. */
- Token *pName /* The new table name. */
-){
- int iDb; /* Database that contains the table */
- char *zDb; /* Name of database iDb */
- Table *pTab; /* Table being renamed */
- char *zName = 0; /* NULL-terminated version of pName */
- sqlite3 *db = pParse->db; /* Database connection */
- Vdbe *v;
-#ifndef SQLITE_OMIT_TRIGGER
- char *zWhere = 0; /* Where clause to locate temp triggers */
-#endif
-
- if( sqlite3MallocFailed() ) goto exit_rename_table;
- assert( pSrc->nSrc==1 );
-
- pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);
- if( !pTab ) goto exit_rename_table;
-#ifndef SQLITE_OMIT_VIRTUALTABLE
- if( IsVirtual(pTab) ){
- sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
- goto exit_rename_table;
- }
-#endif
- iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
- zDb = db->aDb[iDb].zName;
-
- /* Get a NULL terminated version of the new table name. */
- zName = sqlite3NameFromToken(pName);
- if( !zName ) goto exit_rename_table;
-
- /* Check that a table or index named 'zName' does not already exist
- ** in database iDb. If so, this is an error.
- */
- if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){
- sqlite3ErrorMsg(pParse,
- "there is already another table or index with this name: %s", zName);
- goto exit_rename_table;
- }
-
- /* Make sure it is not a system table being altered, or a reserved name
- ** that the table is being renamed to.
- */
- if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){
- sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
- goto exit_rename_table;
- }
- if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
- goto exit_rename_table;
- }
-
-#ifndef SQLITE_OMIT_AUTHORIZATION
- /* Invoke the authorization callback. */
- if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
- goto exit_rename_table;
- }
-#endif
-
- /* Begin a transaction and code the VerifyCookie for database iDb.
- ** Then modify the schema cookie (since the ALTER TABLE modifies the
- ** schema).
- */
- v = sqlite3GetVdbe(pParse);
- if( v==0 ){
- goto exit_rename_table;
- }
- sqlite3Be...
[truncated message content] |