php_pdo_dblib_int.h 4.6 KB

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