1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Author: Wez Furlong <wez@php.net> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 #ifndef PHP_PDO_SQLITE_INT_H 18 #define PHP_PDO_SQLITE_INT_H 19 20 #include <sqlite3.h> 21 22 typedef struct { 23 const char *file; 24 int line; 25 unsigned int errcode; 26 char *errmsg; 27 } pdo_sqlite_error_info; 28 29 struct pdo_sqlite_func { 30 struct pdo_sqlite_func *next; 31 32 int argc; 33 const char *funcname; 34 35 /* accelerated callback references */ 36 zend_fcall_info_cache func; 37 zend_fcall_info_cache step; 38 zend_fcall_info_cache fini; 39 }; 40 41 struct pdo_sqlite_collation { 42 struct pdo_sqlite_collation *next; 43 44 const char *name; 45 zend_fcall_info_cache callback; 46 }; 47 48 typedef struct { 49 sqlite3 *db; 50 pdo_sqlite_error_info einfo; 51 struct pdo_sqlite_func *funcs; 52 struct pdo_sqlite_collation *collations; 53 } pdo_sqlite_db_handle; 54 55 typedef struct { 56 pdo_sqlite_db_handle *H; 57 sqlite3_stmt *stmt; 58 unsigned pre_fetched:1; 59 unsigned done:1; 60 } pdo_sqlite_stmt; 61 62 extern const pdo_driver_t pdo_sqlite_driver; 63 64 extern int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line); 65 #define pdo_sqlite_error(s) _pdo_sqlite_error(s, NULL, __FILE__, __LINE__) 66 #define pdo_sqlite_error_stmt(s) _pdo_sqlite_error(stmt->dbh, stmt, __FILE__, __LINE__) 67 68 extern const struct pdo_stmt_methods sqlite_stmt_methods; 69 70 enum { 71 PDO_SQLITE_ATTR_OPEN_FLAGS = PDO_ATTR_DRIVER_SPECIFIC, 72 PDO_SQLITE_ATTR_READONLY_STATEMENT, 73 PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES 74 }; 75 76 typedef int pdo_sqlite_create_collation_callback(void*, int, const void*, int, const void*); 77 78 void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS); 79 void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS); 80 void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqlite_create_collation_callback callback); 81 82 #endif 83