php_pdo_pgsql_int.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. | Authors: Edin Kadribasic <edink@emini.dk> |
  16. | Ilia Alshanestsky <ilia@prohost.org> |
  17. | Wez Furlong <wez@php.net> |
  18. +----------------------------------------------------------------------+
  19. */
  20. #ifndef PHP_PDO_PGSQL_INT_H
  21. #define PHP_PDO_PGSQL_INT_H
  22. #include <libpq-fe.h>
  23. #include <libpq/libpq-fs.h>
  24. #include <php.h>
  25. #define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
  26. typedef struct {
  27. const char *file;
  28. int line;
  29. unsigned int errcode;
  30. char *errmsg;
  31. } pdo_pgsql_error_info;
  32. /* stuff we use in a pgsql database handle */
  33. typedef struct {
  34. PGconn *server;
  35. unsigned attached:1;
  36. unsigned _reserved:31;
  37. pdo_pgsql_error_info einfo;
  38. Oid pgoid;
  39. unsigned int stmt_counter;
  40. /* The following two variables have the same purpose. Unfortunately we need
  41. to keep track of two different attributes having the same effect. */
  42. zend_bool emulate_prepares;
  43. zend_bool disable_native_prepares; /* deprecated since 5.6 */
  44. zend_bool disable_prepares;
  45. } pdo_pgsql_db_handle;
  46. typedef struct {
  47. char *def;
  48. zend_long intval;
  49. Oid pgsql_type;
  50. zend_bool boolval;
  51. } pdo_pgsql_column;
  52. typedef struct {
  53. pdo_pgsql_db_handle *H;
  54. PGresult *result;
  55. pdo_pgsql_column *cols;
  56. char *cursor_name;
  57. char *stmt_name;
  58. char *query;
  59. char **param_values;
  60. int *param_lengths;
  61. int *param_formats;
  62. Oid *param_types;
  63. int current_row;
  64. zend_bool is_prepared;
  65. } pdo_pgsql_stmt;
  66. typedef struct {
  67. Oid oid;
  68. } pdo_pgsql_bound_param;
  69. extern const pdo_driver_t pdo_pgsql_driver;
  70. extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *msg, const char *file, int line);
  71. #define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, NULL, __FILE__, __LINE__)
  72. #define pdo_pgsql_error_msg(d,e,m) _pdo_pgsql_error(d, NULL, e, NULL, m, __FILE__, __LINE__)
  73. #define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, NULL, __FILE__, __LINE__)
  74. #define pdo_pgsql_error_stmt_msg(s,e,m) _pdo_pgsql_error(s->dbh, s, e, NULL, m, __FILE__, __LINE__)
  75. extern const struct pdo_stmt_methods pgsql_stmt_methods;
  76. #define pdo_pgsql_sqlstate(r) PQresultErrorField(r, PG_DIAG_SQLSTATE)
  77. enum {
  78. PDO_PGSQL_ATTR_DISABLE_PREPARES = PDO_ATTR_DRIVER_SPECIFIC,
  79. };
  80. struct pdo_pgsql_lob_self {
  81. zval dbh;
  82. PGconn *conn;
  83. int lfd;
  84. Oid oid;
  85. };
  86. enum pdo_pgsql_specific_constants {
  87. PGSQL_TRANSACTION_IDLE = PQTRANS_IDLE,
  88. PGSQL_TRANSACTION_ACTIVE = PQTRANS_ACTIVE,
  89. PGSQL_TRANSACTION_INTRANS = PQTRANS_INTRANS,
  90. PGSQL_TRANSACTION_INERROR = PQTRANS_INERROR,
  91. PGSQL_TRANSACTION_UNKNOWN = PQTRANS_UNKNOWN
  92. };
  93. php_stream *pdo_pgsql_create_lob_stream(zval *pdh, int lfd, Oid oid);
  94. extern const php_stream_ops pdo_pgsql_lob_stream_ops;
  95. #endif /* PHP_PDO_PGSQL_INT_H */
  96. /*
  97. * Local variables:
  98. * tab-width: 4
  99. * c-basic-offset: 4
  100. * End:
  101. * vim600: noet sw=4 ts=4 fdm=marker
  102. * vim<600: noet sw=4 ts=4
  103. */