xref: /PHP-7.2/ext/pdo_dblib/php_pdo_dblib_int.h (revision 7a7ec01a)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2018 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Wez Furlong <wez@php.net>                                    |
16   |         Frank M. Kromann <frank@kromann.info>                        |
17   +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef PHP_PDO_DBLIB_INT_H
23 #define PHP_PDO_DBLIB_INT_H
24 
25 #ifndef PDO_DBLIB_FLAVOUR
26 # define PDO_DBLIB_FLAVOUR "Generic DB-lib"
27 #endif
28 
29 #if PHP_DBLIB_IS_MSSQL
30 # include <sqlfront.h>
31 # include <sqldb.h>
32 
33 # define DBERRHANDLE(a, b)	dbprocerrhandle(a, b)
34 # define DBMSGHANDLE(a, b)	dbprocmsghandle(a, b)
35 # define EHANDLEFUNC		DBERRHANDLE_PROC
36 # define MHANDLEFUNC		DBMSGHANDLE_PROC
37 # define DBSETOPT(a, b, c)	dbsetopt(a, b, c)
38 # define SYBESMSG		SQLESMSG
39 # define SYBESEOF		SQLESEOF
40 # define SYBEFCON		SQLECONN		/* SQLEFCON does not exist in MS SQL Server. */
41 # define SYBEMEM		SQLEMEM
42 # define SYBEPWD		SQLEPWD
43 
44 #else
45 # include <sybfront.h>
46 # include <sybdb.h>
47 # include <syberror.h>
48 
49 /* alias some types */
50 # define SQLTEXT	SYBTEXT
51 # define SQLCHAR	SYBCHAR
52 # define SQLVARCHAR	SYBVARCHAR
53 # define SQLINT1	SYBINT1
54 # define SQLINT2	SYBINT2
55 # define SQLINT4	SYBINT4
56 # define SQLINT8	SYBINT8
57 # define SQLINTN	SYBINTN
58 # define SQLBIT		SYBBIT
59 # define SQLFLT4	SYBREAL
60 # define SQLFLT8	SYBFLT8
61 # define SQLFLTN	SYBFLTN
62 # define SQLDECIMAL	SYBDECIMAL
63 # define SQLNUMERIC	SYBNUMERIC
64 # define SQLDATETIME	SYBDATETIME
65 # define SQLDATETIM4	SYBDATETIME4
66 # define SQLDATETIMN	SYBDATETIMN
67 # define SQLMONEY		SYBMONEY
68 # define SQLMONEY4		SYBMONEY4
69 # define SQLMONEYN		SYBMONEYN
70 # define SQLIMAGE		SYBIMAGE
71 # define SQLBINARY		SYBBINARY
72 # define SQLVARBINARY	SYBVARBINARY
73 # ifdef SYBUNIQUE
74 #  define SQLUNIQUE		SYBUNIQUE
75 #else
76 #  define SQLUNIQUE		36 /* FreeTDS Hack */
77 # endif
78 
79 # define DBERRHANDLE(a, b)	dberrhandle(b)
80 # define DBMSGHANDLE(a, b)	dbmsghandle(b)
81 # define DBSETOPT(a, b, c)	dbsetopt(a, b, c, -1)
82 # define NO_MORE_RPC_RESULTS	3
83 # define dbfreelogin		dbloginfree
84 # define dbrpcexec			dbrpcsend
85 
86 typedef short TDS_SHORT;
87 # ifndef PHP_WIN32
88 typedef unsigned char *LPBYTE;
89 # endif
90 typedef float			DBFLT4;
91 #endif
92 
93 int pdo_dblib_error_handler(DBPROCESS *dbproc, int severity, int dberr,
94 	int oserr, char *dberrstr, char *oserrstr);
95 
96 int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
97 	int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line);
98 
99 extern pdo_driver_t pdo_dblib_driver;
100 extern struct pdo_stmt_methods dblib_stmt_methods;
101 
102 typedef struct {
103 	int severity;
104 	int oserr;
105 	int dberr;
106 	char *oserrstr;
107 	char *dberrstr;
108 	char *sqlstate;
109 	char *lastmsg;
110 } pdo_dblib_err;
111 
112 void pdo_dblib_err_dtor(pdo_dblib_err *err);
113 
114 typedef struct {
115 	LOGINREC	*login;
116 	DBPROCESS	*link;
117 
118 	pdo_dblib_err err;
119 	unsigned assume_national_character_set_strings:1;
120 	unsigned stringify_uniqueidentifier:1;
121 } pdo_dblib_db_handle;
122 
123 typedef struct {
124 	pdo_dblib_db_handle *H;
125 	pdo_dblib_err err;
126 	unsigned int computed_column_name_count;
127 } pdo_dblib_stmt;
128 
129 typedef struct {
130 	const char* key;
131 	int value;
132 } pdo_dblib_keyval;
133 
134 
135 ZEND_BEGIN_MODULE_GLOBALS(dblib)
136 	pdo_dblib_err err;
137 	char sqlstate[6];
138 ZEND_END_MODULE_GLOBALS(dblib)
139 
140 #ifdef ZTS
141 # define DBLIB_G(v) TSRMG(dblib_globals_id, zend_dblib_globals *, v)
142 #else
143 # define DBLIB_G(v) (dblib_globals.v)
144 #endif
145 
146 ZEND_EXTERN_MODULE_GLOBALS(dblib)
147 
148 enum {
149 	PDO_DBLIB_ATTR_CONNECTION_TIMEOUT = PDO_ATTR_DRIVER_SPECIFIC,
150 	PDO_DBLIB_ATTR_QUERY_TIMEOUT,
151 	PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER,
152 	PDO_DBLIB_ATTR_VERSION,
153 };
154 
155 #endif
156