D:/Papagan/490.2006/490.2006/korsan/Papagan/490.2006/korsan/Papagan/sqlite3.h

Go to the documentation of this file.
00001 /*
00002 ** 2001 September 15
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 *************************************************************************
00012 ** This header file defines the interface that the SQLite library
00013 ** presents to client programs.
00014 **
00015 ** @(#) $Id: sqlite3.h,v 1.1 2006-03-29 21:55:53 e1347731 Exp $
00016 */
00017 #ifndef _SQLITE3_H_
00018 #define _SQLITE3_H_
00019 #include <stdarg.h>     /* Needed for the definition of va_list */
00020 
00021 /*
00022 ** Make sure we can call this stuff from C++.
00023 */
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /*
00029 ** The version of the SQLite library.
00030 */
00031 #ifdef SQLITE_VERSION
00032 # undef SQLITE_VERSION
00033 #endif
00034 #define SQLITE_VERSION         "3.3.4"
00035 
00036 /*
00037 ** The format of the version string is "X.Y.Z<trailing string>", where
00038 ** X is the major version number, Y is the minor version number and Z
00039 ** is the release number. The trailing string is often "alpha" or "beta".
00040 ** For example "3.1.1beta".
00041 **
00042 ** The SQLITE_VERSION_NUMBER is an integer with the value 
00043 ** (X*100000 + Y*1000 + Z). For example, for version "3.1.1beta", 
00044 ** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using 
00045 ** version 3.1.1 or greater at compile time, programs may use the test 
00046 ** (SQLITE_VERSION_NUMBER>=3001001).
00047 */
00048 #ifdef SQLITE_VERSION_NUMBER
00049 # undef SQLITE_VERSION_NUMBER
00050 #endif
00051 #define SQLITE_VERSION_NUMBER 3003004
00052 
00053 /*
00054 ** The version string is also compiled into the library so that a program
00055 ** can check to make sure that the lib*.a file and the *.h file are from
00056 ** the same version.  The sqlite3_libversion() function returns a pointer
00057 ** to the sqlite3_version variable - useful in DLLs which cannot access
00058 ** global variables.
00059 */
00060 extern const char sqlite3_version[];
00061 const char *sqlite3_libversion(void);
00062 
00063 /*
00064 ** Return the value of the SQLITE_VERSION_NUMBER macro when the
00065 ** library was compiled.
00066 */
00067 int sqlite3_libversion_number(void);
00068 
00069 /*
00070 ** Each open sqlite database is represented by an instance of the
00071 ** following opaque structure.
00072 */
00073 typedef struct sqlite3 sqlite3;
00074 
00075 
00076 /*
00077 ** Some compilers do not support the "long long" datatype.  So we have
00078 ** to do a typedef that for 64-bit integers that depends on what compiler
00079 ** is being used.
00080 */
00081 #if defined(_MSC_VER) || defined(__BORLANDC__)
00082   typedef __int64 sqlite_int64;
00083   typedef unsigned __int64 sqlite_uint64;
00084 #else
00085   typedef long long int sqlite_int64;
00086   typedef unsigned long long int sqlite_uint64;
00087 #endif
00088 
00089 /*
00090 ** If compiling for a processor that lacks floating point support,
00091 ** substitute integer for floating-point
00092 */
00093 #ifdef SQLITE_OMIT_FLOATING_POINT
00094 # define double sqlite_int64
00095 #endif
00096 
00097 /*
00098 ** A function to close the database.
00099 **
00100 ** Call this function with a pointer to a structure that was previously
00101 ** returned from sqlite3_open() and the corresponding database will by closed.
00102 **
00103 ** All SQL statements prepared using sqlite3_prepare() or
00104 ** sqlite3_prepare16() must be deallocated using sqlite3_finalize() before
00105 ** this routine is called. Otherwise, SQLITE_BUSY is returned and the
00106 ** database connection remains open.
00107 */
00108 int sqlite3_close(sqlite3 *);
00109 
00110 /*
00111 ** The type for a callback function.
00112 */
00113 typedef int (*sqlite3_callback)(void*,int,char**, char**);
00114 
00115 /*
00116 ** A function to executes one or more statements of SQL.
00117 **
00118 ** If one or more of the SQL statements are queries, then
00119 ** the callback function specified by the 3rd parameter is
00120 ** invoked once for each row of the query result.  This callback
00121 ** should normally return 0.  If the callback returns a non-zero
00122 ** value then the query is aborted, all subsequent SQL statements
00123 ** are skipped and the sqlite3_exec() function returns the SQLITE_ABORT.
00124 **
00125 ** The 4th parameter is an arbitrary pointer that is passed
00126 ** to the callback function as its first parameter.
00127 **
00128 ** The 2nd parameter to the callback function is the number of
00129 ** columns in the query result.  The 3rd parameter to the callback
00130 ** is an array of strings holding the values for each column.
00131 ** The 4th parameter to the callback is an array of strings holding
00132 ** the names of each column.
00133 **
00134 ** The callback function may be NULL, even for queries.  A NULL
00135 ** callback is not an error.  It just means that no callback
00136 ** will be invoked.
00137 **
00138 ** If an error occurs while parsing or evaluating the SQL (but
00139 ** not while executing the callback) then an appropriate error
00140 ** message is written into memory obtained from malloc() and
00141 ** *errmsg is made to point to that message.  The calling function
00142 ** is responsible for freeing the memory that holds the error
00143 ** message.   Use sqlite3_free() for this.  If errmsg==NULL,
00144 ** then no error message is ever written.
00145 **
00146 ** The return value is is SQLITE_OK if there are no errors and
00147 ** some other return code if there is an error.  The particular
00148 ** return value depends on the type of error. 
00149 **
00150 ** If the query could not be executed because a database file is
00151 ** locked or busy, then this function returns SQLITE_BUSY.  (This
00152 ** behavior can be modified somewhat using the sqlite3_busy_handler()
00153 ** and sqlite3_busy_timeout() functions below.)
00154 */
00155 int sqlite3_exec(
00156   sqlite3*,                     /* An open database */
00157   const char *sql,              /* SQL to be executed */
00158   sqlite3_callback,             /* Callback function */
00159   void *,                       /* 1st argument to callback function */
00160   char **errmsg                 /* Error msg written here */
00161 );
00162 
00163 /*
00164 ** Return values for sqlite3_exec() and sqlite3_step()
00165 */
00166 #define SQLITE_OK           0   /* Successful result */
00167 /* beginning-of-error-codes */
00168 #define SQLITE_ERROR        1   /* SQL error or missing database */
00169 #define SQLITE_INTERNAL     2   /* NOT USED. Internal logic error in SQLite */
00170 #define SQLITE_PERM         3   /* Access permission denied */
00171 #define SQLITE_ABORT        4   /* Callback routine requested an abort */
00172 #define SQLITE_BUSY         5   /* The database file is locked */
00173 #define SQLITE_LOCKED       6   /* A table in the database is locked */
00174 #define SQLITE_NOMEM        7   /* A malloc() failed */
00175 #define SQLITE_READONLY     8   /* Attempt to write a readonly database */
00176 #define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
00177 #define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
00178 #define SQLITE_CORRUPT     11   /* The database disk image is malformed */
00179 #define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */
00180 #define SQLITE_FULL        13   /* Insertion failed because database is full */
00181 #define SQLITE_CANTOPEN    14   /* Unable to open the database file */
00182 #define SQLITE_PROTOCOL    15   /* Database lock protocol error */
00183 #define SQLITE_EMPTY       16   /* Database is empty */
00184 #define SQLITE_SCHEMA      17   /* The database schema changed */
00185 #define SQLITE_TOOBIG      18   /* NOT USED. Too much data for one row */
00186 #define SQLITE_CONSTRAINT  19   /* Abort due to contraint violation */
00187 #define SQLITE_MISMATCH    20   /* Data type mismatch */
00188 #define SQLITE_MISUSE      21   /* Library used incorrectly */
00189 #define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
00190 #define SQLITE_AUTH        23   /* Authorization denied */
00191 #define SQLITE_FORMAT      24   /* Auxiliary database format error */
00192 #define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
00193 #define SQLITE_NOTADB      26   /* File opened that is not a database file */
00194 #define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
00195 #define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
00196 /* end-of-error-codes */
00197 
00198 /*
00199 ** Each entry in an SQLite table has a unique integer key.  (The key is
00200 ** the value of the INTEGER PRIMARY KEY column if there is such a column,
00201 ** otherwise the key is generated at random.  The unique key is always
00202 ** available as the ROWID, OID, or _ROWID_ column.)  The following routine
00203 ** returns the integer key of the most recent insert in the database.
00204 **
00205 ** This function is similar to the mysql_insert_id() function from MySQL.
00206 */
00207 sqlite_int64 sqlite3_last_insert_rowid(sqlite3*);
00208 
00209 /*
00210 ** This function returns the number of database rows that were changed
00211 ** (or inserted or deleted) by the most recent called sqlite3_exec().
00212 **
00213 ** All changes are counted, even if they were later undone by a
00214 ** ROLLBACK or ABORT.  Except, changes associated with creating and
00215 ** dropping tables are not counted.
00216 **
00217 ** If a callback invokes sqlite3_exec() recursively, then the changes
00218 ** in the inner, recursive call are counted together with the changes
00219 ** in the outer call.
00220 **
00221 ** SQLite implements the command "DELETE FROM table" without a WHERE clause
00222 ** by dropping and recreating the table.  (This is much faster than going
00223 ** through and deleting individual elements form the table.)  Because of
00224 ** this optimization, the change count for "DELETE FROM table" will be
00225 ** zero regardless of the number of elements that were originally in the
00226 ** table. To get an accurate count of the number of rows deleted, use
00227 ** "DELETE FROM table WHERE 1" instead.
00228 */
00229 int sqlite3_changes(sqlite3*);
00230 
00231 /*
00232 ** This function returns the number of database rows that have been
00233 ** modified by INSERT, UPDATE or DELETE statements since the database handle
00234 ** was opened. This includes UPDATE, INSERT and DELETE statements executed
00235 ** as part of trigger programs. All changes are counted as soon as the
00236 ** statement that makes them is completed (when the statement handle is
00237 ** passed to sqlite3_reset() or sqlite_finalise()).
00238 **
00239 ** SQLite implements the command "DELETE FROM table" without a WHERE clause
00240 ** by dropping and recreating the table.  (This is much faster than going
00241 ** through and deleting individual elements form the table.)  Because of
00242 ** this optimization, the change count for "DELETE FROM table" will be
00243 ** zero regardless of the number of elements that were originally in the
00244 ** table. To get an accurate count of the number of rows deleted, use
00245 ** "DELETE FROM table WHERE 1" instead.
00246 */
00247 int sqlite3_total_changes(sqlite3*);
00248 
00249 /* This function causes any pending database operation to abort and
00250 ** return at its earliest opportunity.  This routine is typically
00251 ** called in response to a user action such as pressing "Cancel"
00252 ** or Ctrl-C where the user wants a long query operation to halt
00253 ** immediately.
00254 */
00255 void sqlite3_interrupt(sqlite3*);
00256 
00257 
00258 /* These functions return true if the given input string comprises
00259 ** one or more complete SQL statements. For the sqlite3_complete() call,
00260 ** the parameter must be a nul-terminated UTF-8 string. For
00261 ** sqlite3_complete16(), a nul-terminated machine byte order UTF-16 string
00262 ** is required.
00263 **
00264 ** The algorithm is simple.  If the last token other than spaces
00265 ** and comments is a semicolon, then return true.  otherwise return
00266 ** false.
00267 */
00268 int sqlite3_complete(const char *sql);
00269 int sqlite3_complete16(const void *sql);
00270 
00271 /*
00272 ** This routine identifies a callback function that is invoked
00273 ** whenever an attempt is made to open a database table that is
00274 ** currently locked by another process or thread.  If the busy callback
00275 ** is NULL, then sqlite3_exec() returns SQLITE_BUSY immediately if
00276 ** it finds a locked table.  If the busy callback is not NULL, then
00277 ** sqlite3_exec() invokes the callback with three arguments.  The
00278 ** second argument is the name of the locked table and the third
00279 ** argument is the number of times the table has been busy.  If the
00280 ** busy callback returns 0, then sqlite3_exec() immediately returns
00281 ** SQLITE_BUSY.  If the callback returns non-zero, then sqlite3_exec()
00282 ** tries to open the table again and the cycle repeats.
00283 **
00284 ** The default busy callback is NULL.
00285 **
00286 ** Sqlite is re-entrant, so the busy handler may start a new query. 
00287 ** (It is not clear why anyone would every want to do this, but it
00288 ** is allowed, in theory.)  But the busy handler may not close the
00289 ** database.  Closing the database from a busy handler will delete 
00290 ** data structures out from under the executing query and will 
00291 ** probably result in a coredump.
00292 */
00293 int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
00294 
00295 /*
00296 ** This routine sets a busy handler that sleeps for a while when a
00297 ** table is locked.  The handler will sleep multiple times until 
00298 ** at least "ms" milleseconds of sleeping have been done.  After
00299 ** "ms" milleseconds of sleeping, the handler returns 0 which
00300 ** causes sqlite3_exec() to return SQLITE_BUSY.
00301 **
00302 ** Calling this routine with an argument less than or equal to zero
00303 ** turns off all busy handlers.
00304 */
00305 int sqlite3_busy_timeout(sqlite3*, int ms);
00306 
00307 /*
00308 ** This next routine is really just a wrapper around sqlite3_exec().
00309 ** Instead of invoking a user-supplied callback for each row of the
00310 ** result, this routine remembers each row of the result in memory
00311 ** obtained from malloc(), then returns all of the result after the
00312 ** query has finished. 
00313 **
00314 ** As an example, suppose the query result where this table:
00315 **
00316 **        Name        | Age
00317 **        -----------------------
00318 **        Alice       | 43
00319 **        Bob         | 28
00320 **        Cindy       | 21
00321 **
00322 ** If the 3rd argument were &azResult then after the function returns
00323 ** azResult will contain the following data:
00324 **
00325 **        azResult[0] = "Name";
00326 **        azResult[1] = "Age";
00327 **        azResult[2] = "Alice";
00328 **        azResult[3] = "43";
00329 **        azResult[4] = "Bob";
00330 **        azResult[5] = "28";
00331 **        azResult[6] = "Cindy";
00332 **        azResult[7] = "21";
00333 **
00334 ** Notice that there is an extra row of data containing the column
00335 ** headers.  But the *nrow return value is still 3.  *ncolumn is
00336 ** set to 2.  In general, the number of values inserted into azResult
00337 ** will be ((*nrow) + 1)*(*ncolumn).
00338 **
00339 ** After the calling function has finished using the result, it should 
00340 ** pass the result data pointer to sqlite3_free_table() in order to 
00341 ** release the memory that was malloc-ed.  Because of the way the 
00342 ** malloc() happens, the calling function must not try to call 
00343 ** free() directly.  Only sqlite3_free_table() is able to release 
00344 ** the memory properly and safely.
00345 **
00346 ** The return value of this routine is the same as from sqlite3_exec().
00347 */
00348 int sqlite3_get_table(
00349   sqlite3*,               /* An open database */
00350   const char *sql,       /* SQL to be executed */
00351   char ***resultp,       /* Result written to a char *[]  that this points to */
00352   int *nrow,             /* Number of result rows written here */
00353   int *ncolumn,          /* Number of result columns written here */
00354   char **errmsg          /* Error msg written here */
00355 );
00356 
00357 /*
00358 ** Call this routine to free the memory that sqlite3_get_table() allocated.
00359 */
00360 void sqlite3_free_table(char **result);
00361 
00362 /*
00363 ** The following routines are variants of the "sprintf()" from the
00364 ** standard C library.  The resulting string is written into memory
00365 ** obtained from malloc() so that there is never a possiblity of buffer
00366 ** overflow.  These routines also implement some additional formatting
00367 ** options that are useful for constructing SQL statements.
00368 **
00369 ** The strings returned by these routines should be freed by calling
00370 ** sqlite3_free().
00371 **
00372 ** All of the usual printf formatting options apply.  In addition, there
00373 ** is a "%q" option.  %q works like %s in that it substitutes a null-terminated
00374 ** string from the argument list.  But %q also doubles every '\'' character.
00375 ** %q is designed for use inside a string literal.  By doubling each '\''
00376 ** character it escapes that character and allows it to be inserted into
00377 ** the string.
00378 **
00379 ** For example, so some string variable contains text as follows:
00380 **
00381 **      char *zText = "It's a happy day!";
00382 **
00383 ** We can use this text in an SQL statement as follows:
00384 **
00385 **      char *z = sqlite3_mprintf("INSERT INTO TABLES('%q')", zText);
00386 **      sqlite3_exec(db, z, callback1, 0, 0);
00387 **      sqlite3_free(z);
00388 **
00389 ** Because the %q format string is used, the '\'' character in zText
00390 ** is escaped and the SQL generated is as follows:
00391 **
00392 **      INSERT INTO table1 VALUES('It''s a happy day!')
00393 **
00394 ** This is correct.  Had we used %s instead of %q, the generated SQL
00395 ** would have looked like this:
00396 **
00397 **      INSERT INTO table1 VALUES('It's a happy day!');
00398 **
00399 ** This second example is an SQL syntax error.  As a general rule you
00400 ** should always use %q instead of %s when inserting text into a string 
00401 ** literal.
00402 */
00403 char *sqlite3_mprintf(const char*,...);
00404 char *sqlite3_vmprintf(const char*, va_list);
00405 void sqlite3_free(char *z);
00406 char *sqlite3_snprintf(int,char*,const char*, ...);
00407 
00408 #ifndef SQLITE_OMIT_AUTHORIZATION
00409 /*
00410 ** This routine registers a callback with the SQLite library.  The
00411 ** callback is invoked (at compile-time, not at run-time) for each
00412 ** attempt to access a column of a table in the database.  The callback
00413 ** returns SQLITE_OK if access is allowed, SQLITE_DENY if the entire
00414 ** SQL statement should be aborted with an error and SQLITE_IGNORE
00415 ** if the column should be treated as a NULL value.
00416 */
00417 int sqlite3_set_authorizer(
00418   sqlite3*,
00419   int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
00420   void *pUserData
00421 );
00422 #endif
00423 
00424 /*
00425 ** The second parameter to the access authorization function above will
00426 ** be one of the values below.  These values signify what kind of operation
00427 ** is to be authorized.  The 3rd and 4th parameters to the authorization
00428 ** function will be parameters or NULL depending on which of the following
00429 ** codes is used as the second parameter.  The 5th parameter is the name
00430 ** of the database ("main", "temp", etc.) if applicable.  The 6th parameter
00431 ** is the name of the inner-most trigger or view that is responsible for
00432 ** the access attempt or NULL if this access attempt is directly from 
00433 ** input SQL code.
00434 **
00435 **                                          Arg-3           Arg-4
00436 */
00437 #define SQLITE_COPY                  0   /* Table Name      File Name       */
00438 #define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
00439 #define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */
00440 #define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */
00441 #define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */
00442 #define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */
00443 #define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */
00444 #define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */
00445 #define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */
00446 #define SQLITE_DELETE                9   /* Table Name      NULL            */
00447 #define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */
00448 #define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */
00449 #define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */
00450 #define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */
00451 #define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */
00452 #define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */
00453 #define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */
00454 #define SQLITE_DROP_VIEW            17   /* View Name       NULL            */
00455 #define SQLITE_INSERT               18   /* Table Name      NULL            */
00456 #define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */
00457 #define SQLITE_READ                 20   /* Table Name      Column Name     */
00458 #define SQLITE_SELECT               21   /* NULL            NULL            */
00459 #define SQLITE_TRANSACTION          22   /* NULL            NULL            */
00460 #define SQLITE_UPDATE               23   /* Table Name      Column Name     */
00461 #define SQLITE_ATTACH               24   /* Filename        NULL            */
00462 #define SQLITE_DETACH               25   /* Database Name   NULL            */
00463 #define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */
00464 #define SQLITE_REINDEX              27   /* Index Name      NULL            */
00465 #define SQLITE_ANALYZE              28   /* Table Name      NULL            */
00466 
00467 
00468 /*
00469 ** The return value of the authorization function should be one of the
00470 ** following constants:
00471 */
00472 /* #define SQLITE_OK  0   // Allow access (This is actually defined above) */
00473 #define SQLITE_DENY   1   /* Abort the SQL statement with an error */
00474 #define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
00475 
00476 /*
00477 ** Register a function for tracing SQL command evaluation.  The function
00478 ** registered by sqlite3_trace() is invoked at the first sqlite3_step()
00479 ** for the evaluation of an SQL statement.  The function registered by
00480 ** sqlite3_profile() runs at the end of each SQL statement and includes
00481 ** information on how long that statement ran.
00482 **
00483 ** The sqlite3_profile() API is currently considered experimental and
00484 ** is subject to change.
00485 */
00486 void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
00487 void *sqlite3_profile(sqlite3*,
00488    void(*xProfile)(void*,const char*,sqlite_uint64), void*);
00489 
00490 /*
00491 ** This routine configures a callback function - the progress callback - that
00492 ** is invoked periodically during long running calls to sqlite3_exec(),
00493 ** sqlite3_step() and sqlite3_get_table(). An example use for this API is to 
00494 ** keep a GUI updated during a large query.
00495 **
00496 ** The progress callback is invoked once for every N virtual machine opcodes,
00497 ** where N is the second argument to this function. The progress callback
00498 ** itself is identified by the third argument to this function. The fourth
00499 ** argument to this function is a void pointer passed to the progress callback
00500 ** function each time it is invoked.
00501 **
00502 ** If a call to sqlite3_exec(), sqlite3_step() or sqlite3_get_table() results 
00503 ** in less than N opcodes being executed, then the progress callback is not
00504 ** invoked.
00505 ** 
00506 ** To remove the progress callback altogether, pass NULL as the third
00507 ** argument to this function.
00508 **
00509 ** If the progress callback returns a result other than 0, then the current 
00510 ** query is immediately terminated and any database changes rolled back. If the
00511 ** query was part of a larger transaction, then the transaction is not rolled
00512 ** back and remains active. The sqlite3_exec() call returns SQLITE_ABORT. 
00513 **
00514 ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
00515 */
00516 void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
00517 
00518 /*
00519 ** Register a callback function to be invoked whenever a new transaction
00520 ** is committed.  The pArg argument is passed through to the callback.
00521 ** callback.  If the callback function returns non-zero, then the commit
00522 ** is converted into a rollback.
00523 **
00524 ** If another function was previously registered, its pArg value is returned.
00525 ** Otherwise NULL is returned.
00526 **
00527 ** Registering a NULL function disables the callback.
00528 **
00529 ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
00530 */
00531 void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
00532 
00533 /*
00534 ** Open the sqlite database file "filename".  The "filename" is UTF-8
00535 ** encoded for sqlite3_open() and UTF-16 encoded in the native byte order
00536 ** for sqlite3_open16().  An sqlite3* handle is returned in *ppDb, even
00537 ** if an error occurs. If the database is opened (or created) successfully,
00538 ** then SQLITE_OK is returned. Otherwise an error code is returned. The
00539 ** sqlite3_errmsg() or sqlite3_errmsg16()  routines can be used to obtain
00540 ** an English language description of the error.
00541 **
00542 ** If the database file does not exist, then a new database is created.
00543 ** The encoding for the database is UTF-8 if sqlite3_open() is called and
00544 ** UTF-16 if sqlite3_open16 is used.
00545 **
00546 ** Whether or not an error occurs when it is opened, resources associated
00547 ** with the sqlite3* handle should be released by passing it to
00548 ** sqlite3_close() when it is no longer required.
00549 */
00550 int sqlite3_open(
00551   const char *filename,   /* Database filename (UTF-8) */
00552   sqlite3 **ppDb          /* OUT: SQLite db handle */
00553 );
00554 int sqlite3_open16(
00555   const void *filename,   /* Database filename (UTF-16) */
00556   sqlite3 **ppDb          /* OUT: SQLite db handle */
00557 );
00558 
00559 /*
00560 ** Return the error code for the most recent sqlite3_* API call associated
00561 ** with sqlite3 handle 'db'. SQLITE_OK is returned if the most recent 
00562 ** API call was successful.
00563 **
00564 ** Calls to many sqlite3_* functions set the error code and string returned
00565 ** by sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16()
00566 ** (overwriting the previous values). Note that calls to sqlite3_errcode(),
00567 ** sqlite3_errmsg() and sqlite3_errmsg16() themselves do not affect the
00568 ** results of future invocations.
00569 **
00570 ** Assuming no other intervening sqlite3_* API calls are made, the error
00571 ** code returned by this function is associated with the same error as
00572 ** the strings  returned by sqlite3_errmsg() and sqlite3_errmsg16().
00573 */
00574 int sqlite3_errcode(sqlite3 *db);
00575 
00576 /*
00577 ** Return a pointer to a UTF-8 encoded string describing in english the
00578 ** error condition for the most recent sqlite3_* API call. The returned
00579 ** string is always terminated by an 0x00 byte.
00580 **
00581 ** The string "not an error" is returned when the most recent API call was
00582 ** successful.
00583 */
00584 const char *sqlite3_errmsg(sqlite3*);
00585 
00586 /*
00587 ** Return a pointer to a UTF-16 native byte order encoded string describing
00588 ** in english the error condition for the most recent sqlite3_* API call.
00589 ** The returned string is always terminated by a pair of 0x00 bytes.
00590 **
00591 ** The string "not an error" is returned when the most recent API call was
00592 ** successful.
00593 */
00594 const void *sqlite3_errmsg16(sqlite3*);
00595 
00596 /*
00597 ** An instance of the following opaque structure is used to represent
00598 ** a compiled SQL statment.
00599 */
00600 typedef struct sqlite3_stmt sqlite3_stmt;
00601 
00602 /*
00603 ** To execute an SQL query, it must first be compiled into a byte-code
00604 ** program using one of the following routines. The only difference between
00605 ** them is that the second argument, specifying the SQL statement to
00606 ** compile, is assumed to be encoded in UTF-8 for the sqlite3_prepare()
00607 ** function and UTF-16 for sqlite3_prepare16().
00608 **
00609 ** The first parameter "db" is an SQLite database handle. The second
00610 ** parameter "zSql" is the statement to be compiled, encoded as either
00611 ** UTF-8 or UTF-16 (see above). If the next parameter, "nBytes", is less
00612 ** than zero, then zSql is read up to the first nul terminator.  If
00613 ** "nBytes" is not less than zero, then it is the length of the string zSql
00614 ** in bytes (not characters).
00615 **
00616 ** *pzTail is made to point to the first byte past the end of the first
00617 ** SQL statement in zSql.  This routine only compiles the first statement
00618 ** in zSql, so *pzTail is left pointing to what remains uncompiled.
00619 **
00620 ** *ppStmt is left pointing to a compiled SQL statement that can be
00621 ** executed using sqlite3_step().  Or if there is an error, *ppStmt may be
00622 ** set to NULL.  If the input text contained no SQL (if the input is and
00623 ** empty string or a comment) then *ppStmt is set to NULL.
00624 **
00625 ** On success, SQLITE_OK is returned.  Otherwise an error code is returned.
00626 */
00627 int sqlite3_prepare(
00628   sqlite3 *db,            /* Database handle */
00629   const char *zSql,       /* SQL statement, UTF-8 encoded */
00630   int nBytes,             /* Length of zSql in bytes. */
00631   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
00632   const char **pzTail     /* OUT: Pointer to unused portion of zSql */
00633 );
00634 int sqlite3_prepare16(
00635   sqlite3 *db,            /* Database handle */
00636   const void *zSql,       /* SQL statement, UTF-16 encoded */
00637   int nBytes,             /* Length of zSql in bytes. */
00638   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
00639   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
00640 );
00641 
00642 /*
00643 ** Pointers to the following two opaque structures are used to communicate
00644 ** with the implementations of user-defined functions.
00645 */
00646 typedef struct sqlite3_context sqlite3_context;
00647 typedef struct Mem sqlite3_value;
00648 
00649 /*
00650 ** In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(),
00651 ** one or more literals can be replace by parameters "?" or ":AAA" or
00652 ** "$VVV" where AAA is an identifer and VVV is a variable name according
00653 ** to the syntax rules of the TCL programming language.
00654 ** The value of these parameters (also called "host parameter names") can
00655 ** be set using the routines listed below.
00656 **
00657 ** In every case, the first parameter is a pointer to the sqlite3_stmt
00658 ** structure returned from sqlite3_prepare().  The second parameter is the
00659 ** index of the parameter.  The first parameter as an index of 1.  For
00660 ** named parameters (":AAA" or "$VVV") you can use 
00661 ** sqlite3_bind_parameter_index() to get the correct index value given
00662 ** the parameters name.  If the same named parameter occurs more than
00663 ** once, it is assigned the same index each time.
00664 **
00665 ** The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and
00666 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
00667 ** text after SQLite has finished with it.  If the fifth argument is the
00668 ** special value SQLITE_STATIC, then the library assumes that the information
00669 ** is in static, unmanaged space and does not need to be freed.  If the
00670 ** fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its
00671 ** own private copy of the data.
00672 **
00673 ** The sqlite3_bind_* routine must be called before sqlite3_step() after
00674 ** an sqlite3_prepare() or sqlite3_reset().  Unbound parameterss are
00675 ** interpreted as NULL.
00676 */
00677 int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
00678 int sqlite3_bind_double(sqlite3_stmt*, int, double);
00679 int sqlite3_bind_int(sqlite3_stmt*, int, int);
00680 int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite_int64);
00681 int sqlite3_bind_null(sqlite3_stmt*, int);
00682 int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
00683 int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
00684 int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
00685 
00686 /*
00687 ** Return the number of parameters in a compiled SQL statement.  This
00688 ** routine was added to support DBD::SQLite.
00689 */
00690 int sqlite3_bind_parameter_count(sqlite3_stmt*);
00691 
00692 /*
00693 ** Return the name of the i-th parameter.  Ordinary parameters "?" are
00694 ** nameless and a NULL is returned.  For parameters of the form :AAA or
00695 ** $VVV the complete text of the parameter name is returned, including
00696 ** the initial ":" or "$".  NULL is returned if the index is out of range.
00697 */
00698 const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
00699 
00700 /*
00701 ** Return the index of a parameter with the given name.  The name
00702 ** must match exactly.  If no parameter with the given name is found,
00703 ** return 0.
00704 */
00705 int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
00706 
00707 /*
00708 ** Set all the parameters in the compiled SQL statement to NULL.
00709 */
00710 int sqlite3_clear_bindings(sqlite3_stmt*);
00711 
00712 /*
00713 ** Return the number of columns in the result set returned by the compiled
00714 ** SQL statement. This routine returns 0 if pStmt is an SQL statement
00715 ** that does not return data (for example an UPDATE).
00716 */
00717 int sqlite3_column_count(sqlite3_stmt *pStmt);
00718 
00719 /*
00720 ** The first parameter is a compiled SQL statement. This function returns
00721 ** the column heading for the Nth column of that statement, where N is the
00722 ** second function parameter.  The string returned is UTF-8 for
00723 ** sqlite3_column_name() and UTF-16 for sqlite3_column_name16().
00724 */
00725 const char *sqlite3_column_name(sqlite3_stmt*,int);
00726 const void *sqlite3_column_name16(sqlite3_stmt*,int);
00727 
00728 /*
00729 ** The first parameter to the following calls is a compiled SQL statement.
00730 ** These functions return information about the Nth column returned by 
00731 ** the statement, where N is the second function argument.
00732 **
00733 ** If the Nth column returned by the statement is not a column value,
00734 ** then all of the functions return NULL. Otherwise, the return the 
00735 ** name of the attached database, table and column that the expression
00736 ** extracts a value from.
00737 **
00738 ** As with all other SQLite APIs, those postfixed with "16" return UTF-16
00739 ** encoded strings, the other functions return UTF-8. The memory containing
00740 ** the returned strings is valid until the statement handle is finalized().
00741 **
00742 ** These APIs are only available if the library was compiled with the 
00743 ** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
00744 */
00745 const char *sqlite3_column_database_name(sqlite3_stmt*,int);
00746 const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
00747 const char *sqlite3_column_table_name(sqlite3_stmt*,int);
00748 const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
00749 const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
00750 const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
00751 
00752 /*
00753 ** The first parameter is a compiled SQL statement. If this statement
00754 ** is a SELECT statement, the Nth column of the returned result set 
00755 ** of the SELECT is a table column then the declared type of the table
00756 ** column is returned. If the Nth column of the result set is not at table
00757 ** column, then a NULL pointer is returned. The returned string is always
00758 ** UTF-8 encoded. For example, in the database schema:
00759 **
00760 ** CREATE TABLE t1(c1 VARIANT);
00761 **
00762 ** And the following statement compiled:
00763 **
00764 ** SELECT c1 + 1, c1 FROM t1;
00765 **
00766 ** Then this routine would return the string "VARIANT" for the second
00767 ** result column (i==1), and a NULL pointer for the first result column
00768 ** (i==0).
00769 */
00770 const char *sqlite3_column_decltype(sqlite3_stmt *, int i);
00771 
00772 /*
00773 ** The first parameter is a compiled SQL statement. If this statement
00774 ** is a SELECT statement, the Nth column of the returned result set 
00775 ** of the SELECT is a table column then the declared type of the table
00776 ** column is returned. If the Nth column of the result set is not at table
00777 ** column, then a NULL pointer is returned. The returned string is always
00778 ** UTF-16 encoded. For example, in the database schema:
00779 **
00780 ** CREATE TABLE t1(c1 INTEGER);
00781 **
00782 ** And the following statement compiled:
00783 **
00784 ** SELECT c1 + 1, c1 FROM t1;
00785 **
00786 ** Then this routine would return the string "INTEGER" for the second
00787 ** result column (i==1), and a NULL pointer for the first result column
00788 ** (i==0).
00789 */
00790 const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
00791 
00792 /* 
00793 ** After an SQL query has been compiled with a call to either
00794 ** sqlite3_prepare() or sqlite3_prepare16(), then this function must be
00795 ** called one or more times to execute the statement.
00796 **
00797 ** The return value will be either SQLITE_BUSY, SQLITE_DONE, 
00798 ** SQLITE_ROW, SQLITE_ERROR, or SQLITE_MISUSE.
00799 **
00800 ** SQLITE_BUSY means that the database engine attempted to open
00801 ** a locked database and there is no busy callback registered.
00802 ** Call sqlite3_step() again to retry the open.
00803 **
00804 ** SQLITE_DONE means that the statement has finished executing
00805 ** successfully.  sqlite3_step() should not be called again on this virtual
00806 ** machine.
00807 **
00808 ** If the SQL statement being executed returns any data, then 
00809 ** SQLITE_ROW is returned each time a new row of data is ready
00810 ** for processing by the caller. The values may be accessed using
00811 ** the sqlite3_column_*() functions described below. sqlite3_step()
00812 ** is called again to retrieve the next row of data.
00813 ** 
00814 ** SQLITE_ERROR means that a run-time error (such as a constraint
00815 ** violation) has occurred.  sqlite3_step() should not be called again on
00816 ** the VM. More information may be found by calling sqlite3_errmsg().
00817 **
00818 ** SQLITE_MISUSE means that the this routine was called inappropriately.
00819 ** Perhaps it was called on a virtual machine that had already been
00820 ** finalized or on one that had previously returned SQLITE_ERROR or
00821 ** SQLITE_DONE.  Or it could be the case the the same database connection
00822 ** is being used simulataneously by two or more threads.
00823 */
00824 int sqlite3_step(sqlite3_stmt*);
00825 
00826 /*
00827 ** Return the number of values in the current row of the result set.
00828 **
00829 ** After a call to sqlite3_step() that returns SQLITE_ROW, this routine
00830 ** will return the same value as the sqlite3_column_count() function.
00831 ** After sqlite3_step() has returned an SQLITE_DONE, SQLITE_BUSY or
00832 ** error code, or before sqlite3_step() has been called on a 
00833 ** compiled SQL statement, this routine returns zero.
00834 */
00835 int sqlite3_data_count(sqlite3_stmt *pStmt);
00836 
00837 /*
00838 ** Values are stored in the database in one of the following fundamental
00839 ** types.
00840 */
00841 #define SQLITE_INTEGER  1
00842 #define SQLITE_FLOAT    2
00843 /* #define SQLITE_TEXT  3  // See below */
00844 #define SQLITE_BLOB     4
00845 #define SQLITE_NULL     5
00846 
00847 /*
00848 ** SQLite version 2 defines SQLITE_TEXT differently.  To allow both
00849 ** version 2 and version 3 to be included, undefine them both if a
00850 ** conflict is seen.  Define SQLITE3_TEXT to be the version 3 value.
00851 */
00852 #ifdef SQLITE_TEXT
00853 # undef SQLITE_TEXT
00854 #else
00855 # define SQLITE_TEXT     3
00856 #endif
00857 #define SQLITE3_TEXT     3
00858 
00859 /*
00860 ** The next group of routines returns information about the information
00861 ** in a single column of the current result row of a query.  In every
00862 ** case the first parameter is a pointer to the SQL statement that is being
00863 ** executed (the sqlite_stmt* that was returned from sqlite3_prepare()) and
00864 ** the second argument is the index of the column for which information 
00865 ** should be returned.  iCol is zero-indexed.  The left-most column as an
00866 ** index of 0.
00867 **
00868 ** If the SQL statement is not currently point to a valid row, or if the
00869 ** the colulmn index is out of range, the result is undefined.
00870 **
00871 ** These routines attempt to convert the value where appropriate.  For
00872 ** example, if the internal representation is FLOAT and a text result
00873 ** is requested, sprintf() is used internally to do the conversion
00874 ** automatically.  The following table details the conversions that
00875 ** are applied:
00876 **
00877 **    Internal Type    Requested Type     Conversion
00878 **    -------------    --------------    --------------------------
00879 **       NULL             INTEGER         Result is 0
00880 **       NULL             FLOAT           Result is 0.0
00881 **       NULL             TEXT            Result is an empty string
00882 **       NULL             BLOB            Result is a zero-length BLOB
00883 **       INTEGER          FLOAT           Convert from integer to float
00884 **       INTEGER          TEXT            ASCII rendering of the integer
00885 **       INTEGER          BLOB            Same as for INTEGER->TEXT
00886 **       FLOAT            INTEGER         Convert from float to integer
00887 **       FLOAT            TEXT            ASCII rendering of the float
00888 **       FLOAT            BLOB            Same as FLOAT->TEXT
00889 **       TEXT             INTEGER         Use atoi()
00890 **       TEXT             FLOAT           Use atof()
00891 **       TEXT             BLOB            No change
00892 **       BLOB             INTEGER         Convert to TEXT then use atoi()
00893 **       BLOB             FLOAT           Convert to TEXT then use atof()
00894 **       BLOB             TEXT            Add a \000 terminator if needed
00895 **
00896 ** The following access routines are provided:
00897 **
00898 ** _type()     Return the datatype of the result.  This is one of
00899 **             SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB,
00900 **             or SQLITE_NULL.
00901 ** _blob()     Return the value of a BLOB.
00902 ** _bytes()    Return the number of bytes in a BLOB value or the number
00903 **             of bytes in a TEXT value represented as UTF-8.  The \000
00904 **             terminator is included in the byte count for TEXT values.
00905 ** _bytes16()  Return the number of bytes in a BLOB value or the number
00906 **             of bytes in a TEXT value represented as UTF-16.  The \u0000
00907 **             terminator is included in the byte count for TEXT values.
00908 ** _double()   Return a FLOAT value.
00909 ** _int()      Return an INTEGER value in the host computer's native
00910 **             integer representation.  This might be either a 32- or 64-bit
00911 **             integer depending on the host.
00912 ** _int64()    Return an INTEGER value as a 64-bit signed integer.
00913 ** _text()     Return the value as UTF-8 text.
00914 ** _text16()   Return the value as UTF-16 text.
00915 */
00916 const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
00917 int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
00918 int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
00919 double sqlite3_column_double(sqlite3_stmt*, int iCol);
00920 int sqlite3_column_int(sqlite3_stmt*, int iCol);
00921 sqlite_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
00922 const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
00923 const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
00924 int sqlite3_column_type(sqlite3_stmt*, int iCol);
00925 int sqlite3_column_numeric_type(sqlite3_stmt*, int iCol);
00926 
00927 /*
00928 ** The sqlite3_finalize() function is called to delete a compiled
00929 ** SQL statement obtained by a previous call to sqlite3_prepare()
00930 ** or sqlite3_prepare16(). If the statement was executed successfully, or
00931 ** not executed at all, then SQLITE_OK is returned. If execution of the
00932 ** statement failed then an error code is returned. 
00933 **
00934 ** This routine can be called at any point during the execution of the
00935 ** virtual machine.  If the virtual machine has not completed execution
00936 ** when this routine is called, that is like encountering an error or
00937 ** an interrupt.  (See sqlite3_interrupt().)  Incomplete updates may be
00938 ** rolled back and transactions cancelled,  depending on the circumstances,
00939 ** and the result code returned will be SQLITE_ABORT.
00940 */
00941 int sqlite3_finalize(sqlite3_stmt *pStmt);
00942 
00943 /*
00944 ** The sqlite3_reset() function is called to reset a compiled SQL
00945 ** statement obtained by a previous call to sqlite3_prepare() or
00946 ** sqlite3_prepare16() back to it's initial state, ready to be re-executed.
00947 ** Any SQL statement variables that had values bound to them using
00948 ** the sqlite3_bind_*() API retain their values.
00949 */
00950 int sqlite3_reset(sqlite3_stmt *pStmt);
00951 
00952 /*
00953 ** The following two functions are used to add user functions or aggregates
00954 ** implemented in C to the SQL langauge interpreted by SQLite. The
00955 ** difference only between the two is that the second parameter, the
00956 ** name of the (scalar) function or aggregate, is encoded in UTF-8 for
00957 ** sqlite3_create_function() and UTF-16 for sqlite3_create_function16().
00958 **
00959 ** The first argument is the database handle that the new function or
00960 ** aggregate is to be added to. If a single program uses more than one
00961 ** database handle internally, then user functions or aggregates must 
00962 ** be added individually to each database handle with which they will be
00963 ** used.
00964 **
00965 ** The third parameter is the number of arguments that the function or
00966 ** aggregate takes. If this parameter is negative, then the function or
00967 ** aggregate may take any number of arguments.
00968 **
00969 ** The fourth parameter is one of SQLITE_UTF* values defined below,
00970 ** indicating the encoding that the function is most likely to handle
00971 ** values in.  This does not change the behaviour of the programming
00972 ** interface. However, if two versions of the same function are registered
00973 ** with different encoding values, SQLite invokes the version likely to
00974 ** minimize conversions between text encodings.
00975 **
00976 ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
00977 ** pointers to user implemented C functions that implement the user
00978 ** function or aggregate. A scalar function requires an implementation of
00979 ** the xFunc callback only, NULL pointers should be passed as the xStep
00980 ** and xFinal parameters. An aggregate function requires an implementation
00981 ** of xStep and xFinal, but NULL should be passed for xFunc. To delete an
00982 ** existing user function or aggregate, pass NULL for all three function
00983 ** callback. Specifying an inconstent set of callback values, such as an
00984 ** xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is
00985 ** returned.
00986 */
00987 int sqlite3_create_function(
00988   sqlite3 *,
00989   const char *zFunctionName,
00990   int nArg,
00991   int eTextRep,
00992   void*,
00993   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
00994   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
00995   void (*xFinal)(sqlite3_context*)
00996 );
00997 int sqlite3_create_function16(
00998   sqlite3*,
00999   const void *zFunctionName,
01000   int nArg,
01001   int eTextRep,
01002   void*,
01003   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
01004   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
01005   void (*xFinal)(sqlite3_context*)
01006 );
01007 
01008 /*
01009 ** This function is deprecated.  Do not use it.  It continues to exist
01010 ** so as not to break legacy code.  But new code should avoid using it.
01011 */
01012 int sqlite3_aggregate_count(sqlite3_context*);
01013 
01014 /*
01015 ** The next group of routines returns information about parameters to
01016 ** a user-defined function.  Function implementations use these routines
01017 ** to access their parameters.  These routines are the same as the
01018 ** sqlite3_column_* routines except that these routines take a single
01019 ** sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
01020 ** column number.
01021 */
01022 const void *sqlite3_value_blob(sqlite3_value*);
01023 int sqlite3_value_bytes(sqlite3_value*);
01024 int sqlite3_value_bytes16(sqlite3_value*);
01025 double sqlite3_value_double(sqlite3_value*);
01026 int sqlite3_value_int(sqlite3_value*);
01027 sqlite_int64 sqlite3_value_int64(sqlite3_value*);
01028 const unsigned char *sqlite3_value_text(sqlite3_value*);
01029 const void *sqlite3_value_text16(sqlite3_value*);
01030 const void *sqlite3_value_text16le(sqlite3_value*);
01031 const void *sqlite3_value_text16be(sqlite3_value*);
01032 int sqlite3_value_type(sqlite3_value*);
01033 int sqlite3_value_numeric_type(sqlite3_value*);
01034 
01035 /*
01036 ** Aggregate functions use the following routine to allocate
01037 ** a structure for storing their state.  The first time this routine
01038 ** is called for a particular aggregate, a new structure of size nBytes
01039 ** is allocated, zeroed, and returned.  On subsequent calls (for the
01040 ** same aggregate instance) the same buffer is returned.  The implementation
01041 ** of the aggregate can use the returned buffer to accumulate data.
01042 **
01043 ** The buffer allocated is freed automatically by SQLite.
01044 */
01045 void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
01046 
01047 /*
01048 ** The pUserData parameter to the sqlite3_create_function()
01049 ** routine used to register user functions is available to
01050 ** the implementation of the function using this call.
01051 */
01052 void *sqlite3_user_data(sqlite3_context*);
01053 
01054 /*
01055 ** The following two functions may be used by scalar user functions to
01056 ** associate meta-data with argument values. If the same value is passed to
01057 ** multiple invocations of the user-function during query execution, under
01058 ** some circumstances the associated meta-data may be preserved. This may
01059 ** be used, for example, to add a regular-expression matching scalar
01060 ** function. The compiled version of the regular expression is stored as
01061 ** meta-data associated with the SQL value passed as the regular expression
01062 ** pattern.
01063 **
01064 ** Calling sqlite3_get_auxdata() returns a pointer to the meta data
01065 ** associated with the Nth argument value to the current user function
01066 ** call, where N is the second parameter. If no meta-data has been set for
01067 ** that value, then a NULL pointer is returned.
01068 **
01069 ** The sqlite3_set_auxdata() is used to associate meta data with a user
01070 ** function argument. The third parameter is a pointer to the meta data
01071 ** to be associated with the Nth user function argument value. The fourth
01072 ** parameter specifies a 'delete function' that will be called on the meta
01073 ** data pointer to release it when it is no longer required. If the delete
01074 ** function pointer is NULL, it is not invoked.
01075 **
01076 ** In practice, meta-data is preserved between function calls for
01077 ** expressions that are constant at compile time. This includes literal
01078 ** values and SQL variables.
01079 */
01080 void *sqlite3_get_auxdata(sqlite3_context*, int);
01081 void sqlite3_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));
01082 
01083 
01084 /*
01085 ** These are special value for the destructor that is passed in as the
01086 ** final argument to routines like sqlite3_result_blob().  If the destructor
01087 ** argument is SQLITE_STATIC, it means that the content pointer is constant
01088 ** and will never change.  It does not need to be destroyed.  The 
01089 ** SQLITE_TRANSIENT value means that the content will likely change in
01090 ** the near future and that SQLite should make its own private copy of
01091 ** the content before returning.
01092 */
01093 #define SQLITE_STATIC      ((void(*)(void *))0)
01094 #define SQLITE_TRANSIENT   ((void(*)(void *))-1)
01095 
01096 /*
01097 ** User-defined functions invoke the following routines in order to
01098 ** set their return value.
01099 */
01100 void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
01101 void sqlite3_result_double(sqlite3_context*, double);
01102 void sqlite3_result_error(sqlite3_context*, const char*, int);
01103 void sqlite3_result_error16(sqlite3_context*, const void*, int);
01104 void sqlite3_result_int(sqlite3_context*, int);
01105 void sqlite3_result_int64(sqlite3_context*, sqlite_int64);
01106 void sqlite3_result_null(sqlite3_context*);
01107 void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
01108 void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
01109 void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
01110 void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
01111 void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
01112 
01113 /*
01114 ** These are the allowed values for the eTextRep argument to
01115 ** sqlite3_create_collation and sqlite3_create_function.
01116 */
01117 #define SQLITE_UTF8    1
01118 #define SQLITE_UTF16LE 2
01119 #define SQLITE_UTF16BE 3
01120 #define SQLITE_UTF16   4    /* Use native byte order */
01121 #define SQLITE_ANY     5    /* sqlite3_create_function only */
01122 
01123 /*
01124 ** These two functions are used to add new collation sequences to the
01125 ** sqlite3 handle specified as the first argument. 
01126 **
01127 ** The name of the new collation sequence is specified as a UTF-8 string
01128 ** for sqlite3_create_collation() and a UTF-16 string for
01129 ** sqlite3_create_collation16(). In both cases the name is passed as the
01130 ** second function argument.
01131 **
01132 ** The third argument must be one of the constants SQLITE_UTF8,
01133 ** SQLITE_UTF16LE or SQLITE_UTF16BE, indicating that the user-supplied
01134 ** routine expects to be passed pointers to strings encoded using UTF-8,
01135 ** UTF-16 little-endian or UTF-16 big-endian respectively.
01136 **
01137 ** A pointer to the user supplied routine must be passed as the fifth
01138 ** argument. If it is NULL, this is the same as deleting the collation
01139 ** sequence (so that SQLite cannot call it anymore). Each time the user
01140 ** supplied function is invoked, it is passed a copy of the void* passed as
01141 ** the fourth argument to sqlite3_create_collation() or
01142 ** sqlite3_create_collation16() as its first parameter.
01143 **
01144 ** The remaining arguments to the user-supplied routine are two strings,
01145 ** each represented by a [length, data] pair and encoded in the encoding
01146 ** that was passed as the third argument when the collation sequence was
01147 ** registered. The user routine should return negative, zero or positive if
01148 ** the first string is less than, equal to, or greater than the second
01149 ** string. i.e. (STRING1 - STRING2).
01150 */
01151 int sqlite3_create_collation(
01152   sqlite3*, 
01153   const char *zName, 
01154   int eTextRep, 
01155   void*,
01156   int(*xCompare)(void*,int,const void*,int,const void*)
01157 );
01158 int sqlite3_create_collation16(
01159   sqlite3*, 
01160   const char *zName, 
01161   int eTextRep, 
01162   void*,
01163   int(*xCompare)(void*,int,const void*,int,const void*)
01164 );
01165 
01166 /*
01167 ** To avoid having to register all collation sequences before a database
01168 ** can be used, a single callback function may be registered with the
01169 ** database handle to be called whenever an undefined collation sequence is
01170 ** required.
01171 **
01172 ** If the function is registered using the sqlite3_collation_needed() API,
01173 ** then it is passed the names of undefined collation sequences as strings
01174 ** encoded in UTF-8. If sqlite3_collation_needed16() is used, the names
01175 ** are passed as UTF-16 in machine native byte order. A call to either
01176 ** function replaces any existing callback.
01177 **
01178 ** When the user-function is invoked, the first argument passed is a copy
01179 ** of the second argument to sqlite3_collation_needed() or
01180 ** sqlite3_collation_needed16(). The second argument is the database
01181 ** handle. The third argument is one of SQLITE_UTF8, SQLITE_UTF16BE or
01182 ** SQLITE_UTF16LE, indicating the most desirable form of the collation
01183 ** sequence function required. The fourth parameter is the name of the
01184 ** required collation sequence.
01185 **
01186 ** The collation sequence is returned to SQLite by a collation-needed
01187 ** callback using the sqlite3_create_collation() or
01188 ** sqlite3_create_collation16() APIs, described above.
01189 */
01190 int sqlite3_collation_needed(
01191   sqlite3*, 
01192   void*, 
01193   void(*)(void*,sqlite3*,int eTextRep,const char*)
01194 );
01195 int sqlite3_collation_needed16(
01196   sqlite3*, 
01197   void*,
01198   void(*)(void*,sqlite3*,int eTextRep,const void*)
01199 );
01200 
01201 /*
01202 ** Specify the key for an encrypted database.  This routine should be
01203 ** called right after sqlite3_open().
01204 **
01205 ** The code to implement this API is not available in the public release
01206 ** of SQLite.
01207 */
01208 int sqlite3_key(
01209   sqlite3 *db,                   /* Database to be rekeyed */
01210   const void *pKey, int nKey     /* The key */
01211 );
01212 
01213 /*
01214 ** Change the key on an open database.  If the current database is not
01215 ** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
01216 ** database is decrypted.
01217 **
01218 ** The code to implement this API is not available in the public release
01219 ** of SQLite.
01220 */
01221 int sqlite3_rekey(
01222   sqlite3 *db,                   /* Database to be rekeyed */
01223   const void *pKey, int nKey     /* The new key */
01224 );
01225 
01226 /*
01227 ** Sleep for a little while. The second parameter is the number of
01228 ** miliseconds to sleep for. 
01229 **
01230 ** If the operating system does not support sleep requests with 
01231 ** milisecond time resolution, then the time will be rounded up to 
01232 ** the nearest second. The number of miliseconds of sleep actually 
01233 ** requested from the operating system is returned.
01234 */
01235 int sqlite3_sleep(int);
01236 
01237 /*
01238 ** Return TRUE (non-zero) if the statement supplied as an argument needs
01239 ** to be recompiled.  A statement needs to be recompiled whenever the
01240 ** execution environment changes in a way that would alter the program
01241 ** that sqlite3_prepare() generates.  For example, if new functions or
01242 ** collating sequences are registered or if an authorizer function is
01243 ** added or changed.
01244 **
01245 */
01246 int sqlite3_expired(sqlite3_stmt*);
01247 
01248 /*
01249 ** Move all bindings from the first prepared statement over to the second.
01250 ** This routine is useful, for example, if the first prepared statement
01251 ** fails with an SQLITE_SCHEMA error.  The same SQL can be prepared into
01252 ** the second prepared statement then all of the bindings transfered over
01253 ** to the second statement before the first statement is finalized.
01254 */
01255 int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
01256 
01257 /*
01258 ** If the following global variable is made to point to a
01259 ** string which is the name of a directory, then all temporary files
01260 ** created by SQLite will be placed in that directory.  If this variable
01261 ** is NULL pointer, then SQLite does a search for an appropriate temporary
01262 ** file directory.
01263 **
01264 ** Once sqlite3_open() has been called, changing this variable will invalidate
01265 ** the current temporary database, if any.
01266 */
01267 extern char *sqlite3_temp_directory;
01268 
01269 /*
01270 ** This function is called to recover from a malloc() failure that occured
01271 ** within the SQLite library. Normally, after a single malloc() fails the 
01272 ** library refuses to function (all major calls return SQLITE_NOMEM).
01273 ** This function restores the library state so that it can be used again.
01274 **
01275 ** All existing statements (sqlite3_stmt pointers) must be finalized or
01276 ** reset before this call is made. Otherwise, SQLITE_BUSY is returned.
01277 ** If any in-memory databases are in use, either as a main or TEMP
01278 ** database, SQLITE_ERROR is returned. In either of these cases, the 
01279 ** library is not reset and remains unusable.
01280 **
01281 ** This function is *not* threadsafe. Calling this from within a threaded
01282 ** application when threads other than the caller have used SQLite is
01283 ** dangerous and will almost certainly result in malfunctions.
01284 **
01285 ** This functionality can be omitted from a build by defining the 
01286 ** SQLITE_OMIT_GLOBALRECOVER at compile time.
01287 */
01288 int sqlite3_global_recover(void);
01289 
01290 /*
01291 ** Test to see whether or not the database connection is in autocommit
01292 ** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
01293 ** by default.  Autocommit is disabled by a BEGIN statement and reenabled
01294 ** by the next COMMIT or ROLLBACK.
01295 */
01296 int sqlite3_get_autocommit(sqlite3*);
01297 
01298 /*
01299 ** Return the sqlite3* database handle to which the prepared statement given
01300 ** in the argument belongs.  This is the same database handle that was
01301 ** the first argument to the sqlite3_prepare() that was used to create
01302 ** the statement in the first place.
01303 */
01304 sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
01305 
01306 /*
01307 ** Register a callback function with the database connection identified by the 
01308 ** first argument to be invoked whenever a row is updated, inserted or deleted.
01309 ** Any callback set by a previous call to this function for the same 
01310 ** database connection is overridden.
01311 **
01312 ** The second argument is a pointer to the function to invoke when a 
01313 ** row is updated, inserted or deleted. The first argument to the callback is
01314 ** a copy of the third argument to sqlite3_update_hook. The second callback 
01315 ** argument is one of SQLITE_INSERT, SQLITE_DELETE or SQLITE_UPDATE, depending
01316 ** on the operation that caused the callback to be invoked. The third and 
01317 ** fourth arguments to the callback contain pointers to the database and 
01318 ** table name containing the affected row. The final callback parameter is 
01319 ** the rowid of the row. In the case of an update, this is the rowid after 
01320 ** the update takes place.
01321 **
01322 ** The update hook is not invoked when internal system tables are
01323 ** modified (i.e. sqlite_master and sqlite_sequence).
01324 **
01325 ** If another function was previously registered, its pArg value is returned.
01326 ** Otherwise NULL is returned.
01327 */
01328 void *sqlite3_update_hook(
01329   sqlite3*, 
01330   void(*)(void *,int ,char const *,char const *,sqlite_int64),
01331   void*
01332 );
01333 
01334 /*
01335 ** Register a callback to be invoked whenever a transaction is rolled
01336 ** back. 
01337 **
01338 ** The new callback function overrides any existing rollback-hook
01339 ** callback. If there was an existing callback, then it's pArg value 
01340 ** (the third argument to sqlite3_rollback_hook() when it was registered) 
01341 ** is returned. Otherwise, NULL is returned.
01342 **
01343 ** For the purposes of this API, a transaction is said to have been 
01344 ** rolled back if an explicit "ROLLBACK" statement is executed, or
01345 ** an error or constraint causes an implicit rollback to occur. The 
01346 ** callback is not invoked if a transaction is automatically rolled
01347 ** back because the database connection is closed.
01348 */
01349 void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
01350 
01351 /*
01352 ** This function is only available if the library is compiled without
01353 ** the SQLITE_OMIT_SHARED_CACHE macro defined. It is used to enable or
01354 ** disable (if the argument is true or false, respectively) the 
01355 ** "shared pager" feature.
01356 */
01357 int sqlite3_enable_shared_cache(int);
01358 
01359 /*
01360 ** Attempt to free N bytes of heap memory by deallocating non-essential
01361 ** memory allocations held by the database library (example: memory 
01362 ** used to cache database pages to improve performance).
01363 **
01364 ** This function is not a part of standard builds.  It is only created
01365 ** if SQLite is compiled with the SQLITE_ENABLE_MEMORY_MANAGEMENT macro.
01366 */
01367 int sqlite3_release_memory(int);
01368 
01369 /*
01370 ** Place a "soft" limit on the amount of heap memory that may be allocated by
01371 ** SQLite within the current thread. If an internal allocation is requested 
01372 ** that would exceed the specified limit, sqlite3_release_memory() is invoked
01373 ** one or more times to free up some space before the allocation is made.
01374 **
01375 ** The limit is called "soft", because if sqlite3_release_memory() cannot free
01376 ** sufficient memory to prevent the limit from being exceeded, the memory is
01377 ** allocated anyway and the current operation proceeds.
01378 **
01379 ** This function is only available if the library was compiled with the 
01380 ** SQLITE_ENABLE_MEMORY_MANAGEMENT option set.
01381 ** memory-management has been enabled.
01382 */
01383 void sqlite3_soft_heap_limit(int);
01384 
01385 /*
01386 ** This routine makes sure that all thread-local storage has been
01387 ** deallocated for the current thread.
01388 **
01389 ** This routine is not technically necessary.  All thread-local storage
01390 ** will be automatically deallocated once memory-management and
01391 ** shared-cache are disabled and the soft heap limit has been set
01392 ** to zero.  This routine is provided as a convenience for users who
01393 ** want to make absolutely sure they have not forgotten something
01394 ** prior to killing off a thread.
01395 */
01396 void sqlite3_thread_cleanup(void);
01397 
01398 /*
01399 ** Return meta information about a specific column of a specific database
01400 ** table accessible using the connection handle passed as the first function 
01401 ** argument.
01402 **
01403 ** The column is identified by the second, third and fourth parameters to 
01404 ** this function. The second parameter is either the name of the database
01405 ** (i.e. "main", "temp" or an attached database) containing the specified
01406 ** table or NULL. If it is NULL, then all attached databases are searched
01407 ** for the table using the same algorithm as the database engine uses to 
01408 ** resolve unqualified table references.
01409 **
01410 ** The third and fourth parameters to this function are the table and column 
01411 ** name of the desired column, respectively. Neither of these parameters 
01412 ** may be NULL.
01413 **
01414 ** Meta information is returned by writing to the memory locations passed as
01415 ** the 5th and subsequent parameters to this function. Any of these 
01416 ** arguments may be NULL, in which case the corresponding element of meta 
01417 ** information is ommitted.
01418 **
01419 ** Parameter     Output Type      Description
01420 ** -----------------------------------
01421 **
01422 **   5th         const char*      Data type
01423 **   6th         const char*      Name of the default collation sequence 
01424 **   7th         int              True if the column has a NOT NULL constraint
01425 **   8th         int              True if the column is part of the PRIMARY KEY
01426 **   9th         int              True if the column is AUTOINCREMENT
01427 **
01428 **
01429 ** The memory pointed to by the character pointers returned for the 
01430 ** declaration type and collation sequence is valid only until the next 
01431 ** call to any sqlite API function.
01432 **
01433 ** If the specified table is actually a view, then an error is returned.
01434 **
01435 ** If the specified column is "rowid", "oid" or "_rowid_" and an 
01436 ** INTEGER PRIMARY KEY column has been explicitly declared, then the output 
01437 ** parameters are set for the explicitly declared column. If there is no
01438 ** explicitly declared IPK column, then the output parameters are set as 
01439 ** follows:
01440 **
01441 **     data type: "INTEGER"
01442 **     collation sequence: "BINARY"
01443 **     not null: 0
01444 **     primary key: 1
01445 **     auto increment: 0
01446 **
01447 ** This function may load one or more schemas from database files. If an
01448 ** error occurs during this process, or if the requested table or column
01449 ** cannot be found, an SQLITE error code is returned and an error message
01450 ** left in the database handle (to be retrieved using sqlite3_errmsg()).
01451 **
01452 ** This API is only available if the library was compiled with the
01453 ** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
01454 */
01455 int sqlite3_table_column_metadata(
01456   sqlite3 *db,                /* Connection handle */
01457   const char *zDbName,        /* Database name or NULL */
01458   const char *zTableName,     /* Table name */
01459   const char *zColumnName,    /* Column name */
01460   char const **pzDataType,    /* OUTPUT: Declared data type */
01461   char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
01462   int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
01463   int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
01464   int *pAutoinc               /* OUTPUT: True if colums is auto-increment */
01465 );
01466 
01467 /*
01468 ** Undo the hack that converts floating point types to integer for
01469 ** builds on processors without floating point support.
01470 */
01471 #ifdef SQLITE_OMIT_FLOATING_POINT
01472 # undef double
01473 #endif
01474 
01475 #ifdef __cplusplus
01476 }  /* End of the 'extern "C"' block */
01477 #endif
01478 #endif

Generated on Mon May 29 01:10:33 2006 for Papagan by  doxygen 1.4.6-NO