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 | Frank M. Kromann <frank@kromann.info> | 15 +----------------------------------------------------------------------+ 16 */ 17 18 /* internal header; not supposed to be installed */ 19 20 #ifndef PHP_PDO_DBLIB_INT_H 21 #define PHP_PDO_DBLIB_INT_H 22 23 #ifndef PDO_DBLIB_FLAVOUR 24 # define PDO_DBLIB_FLAVOUR "Generic DB-lib" 25 #endif 26 27 #ifdef PHP_DBLIB_IS_MSSQL 28 # include <sqlfront.h> 29 # include <sqldb.h> 30 31 # define DBERRHANDLE(a, b) dbprocerrhandle(a, b) 32 # define DBMSGHANDLE(a, b) dbprocmsghandle(a, b) 33 # define EHANDLEFUNC DBERRHANDLE_PROC 34 # define MHANDLEFUNC DBMSGHANDLE_PROC 35 # define DBSETOPT(a, b, c) dbsetopt(a, b, c) 36 # define SYBESMSG SQLESMSG 37 # define SYBESEOF SQLESEOF 38 # define SYBEFCON SQLECONN /* SQLEFCON does not exist in MS SQL Server. */ 39 # define SYBEMEM SQLEMEM 40 # define SYBEPWD SQLEPWD 41 42 #else 43 # include <sybfront.h> 44 # include <sybdb.h> 45 # include <syberror.h> 46 47 /* alias some types */ 48 # define SQLTEXT SYBTEXT 49 # define SQLCHAR SYBCHAR 50 # define SQLVARCHAR SYBVARCHAR 51 # define SQLINT1 SYBINT1 52 # define SQLINT2 SYBINT2 53 # define SQLINT4 SYBINT4 54 # define SQLINT8 SYBINT8 55 # define SQLINTN SYBINTN 56 # define SQLBIT SYBBIT 57 # define SQLFLT4 SYBREAL 58 # define SQLFLT8 SYBFLT8 59 # define SQLFLTN SYBFLTN 60 # define SQLDECIMAL SYBDECIMAL 61 # define SQLNUMERIC SYBNUMERIC 62 # define SQLDATETIME SYBDATETIME 63 # define SQLDATETIM4 SYBDATETIME4 64 # define SQLDATETIMN SYBDATETIMN 65 # ifdef SYBMSDATETIME2 66 # define SQLMSDATETIME2 SYBMSDATETIME2 67 # endif 68 # define SQLMONEY SYBMONEY 69 # define SQLMONEY4 SYBMONEY4 70 # define SQLMONEYN SYBMONEYN 71 # define SQLIMAGE SYBIMAGE 72 # define SQLBINARY SYBBINARY 73 # define SQLVARBINARY SYBVARBINARY 74 # ifdef SYBUNIQUE 75 # define SQLUNIQUE SYBUNIQUE 76 #else 77 # define SQLUNIQUE 36 /* FreeTDS Hack */ 78 # endif 79 80 # define DBERRHANDLE(a, b) dberrhandle(b) 81 # define DBMSGHANDLE(a, b) dbmsghandle(b) 82 # define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1) 83 # define NO_MORE_RPC_RESULTS 3 84 # define dbfreelogin dbloginfree 85 # define dbrpcexec dbrpcsend 86 87 typedef short TDS_SHORT; 88 # ifndef PHP_WIN32 89 typedef unsigned char *LPBYTE; 90 # endif 91 typedef float DBFLT4; 92 #endif 93 94 /* hardcoded string length from FreeTDS 95 * src/tds/convert.c:tds_convert_datetimeall() 96 */ 97 # define DATETIME_MAX_LEN 63 98 99 int pdo_dblib_error_handler(DBPROCESS *dbproc, int severity, int dberr, 100 int oserr, char *dberrstr, char *oserrstr); 101 102 int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, 103 int severity, char *msgtext, char *srvname, char *procname, int line); 104 105 extern const pdo_driver_t pdo_dblib_driver; 106 extern const struct pdo_stmt_methods dblib_stmt_methods; 107 108 typedef struct { 109 int severity; 110 int oserr; 111 int dberr; 112 char *oserrstr; 113 char *dberrstr; 114 char *sqlstate; 115 char *lastmsg; 116 } pdo_dblib_err; 117 118 void pdo_dblib_err_dtor(pdo_dblib_err *err); 119 120 typedef struct { 121 LOGINREC *login; 122 DBPROCESS *link; 123 124 pdo_dblib_err err; 125 unsigned assume_national_character_set_strings:1; 126 unsigned stringify_uniqueidentifier:1; 127 unsigned skip_empty_rowsets:1; 128 unsigned datetime_convert:1; 129 } pdo_dblib_db_handle; 130 131 typedef struct { 132 pdo_dblib_db_handle *H; 133 pdo_dblib_err err; 134 unsigned int computed_column_name_count; 135 } pdo_dblib_stmt; 136 137 typedef struct { 138 const char* key; 139 int value; 140 } pdo_dblib_keyval; 141 142 143 ZEND_BEGIN_MODULE_GLOBALS(dblib) 144 pdo_dblib_err err; 145 char sqlstate[6]; 146 ZEND_END_MODULE_GLOBALS(dblib) 147 148 #if defined(ZTS) && (defined(COMPILE_DL_PDO_DBLIB) || defined(COMPILE_DL_PDO_MSSQL)) 149 ZEND_TSRMLS_CACHE_EXTERN() 150 #endif 151 152 ZEND_EXTERN_MODULE_GLOBALS(dblib) 153 #define DBLIB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(dblib, v) 154 155 ZEND_EXTERN_MODULE_GLOBALS(dblib) 156 157 enum { 158 PDO_DBLIB_ATTR_CONNECTION_TIMEOUT = PDO_ATTR_DRIVER_SPECIFIC, 159 PDO_DBLIB_ATTR_QUERY_TIMEOUT, 160 PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER, 161 PDO_DBLIB_ATTR_VERSION, 162 PDO_DBLIB_ATTR_TDS_VERSION, 163 PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS, 164 PDO_DBLIB_ATTR_DATETIME_CONVERT, 165 }; 166 167 #endif 168