You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.3 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2008 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. /* $Id$ */
  21. #ifndef PHP_PDO_PGSQL_INT_H
  22. #define PHP_PDO_PGSQL_INT_H
  23. #include <libpq-fe.h>
  24. #include <libpq/libpq-fs.h>
  25. #include <php.h>
  26. #define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
  27. typedef struct {
  28. const char *file;
  29. int line;
  30. unsigned int errcode;
  31. char *errmsg;
  32. } pdo_pgsql_error_info;
  33. /* stuff we use in a pgsql database handle */
  34. typedef struct {
  35. PGconn *server;
  36. unsigned attached:1;
  37. unsigned _reserved:31;
  38. pdo_pgsql_error_info einfo;
  39. Oid pgoid;
  40. } pdo_pgsql_db_handle;
  41. typedef struct {
  42. char *def;
  43. Oid pgsql_type;
  44. long intval;
  45. zend_bool boolval;
  46. } pdo_pgsql_column;
  47. typedef struct {
  48. pdo_pgsql_db_handle *H;
  49. PGresult *result;
  50. int current_row;
  51. pdo_pgsql_column *cols;
  52. char *cursor_name;
  53. #if HAVE_PQPREPARE
  54. char *stmt_name;
  55. char *query;
  56. char **param_values;
  57. int *param_lengths;
  58. int *param_formats;
  59. Oid *param_types;
  60. zend_bool is_prepared;
  61. #endif
  62. } pdo_pgsql_stmt;
  63. typedef struct {
  64. Oid oid;
  65. } pdo_pgsql_bound_param;
  66. extern pdo_driver_t pdo_pgsql_driver;
  67. extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *file, int line TSRMLS_DC);
  68. #define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, __FILE__, __LINE__ TSRMLS_CC)
  69. #define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, __FILE__, __LINE__ TSRMLS_CC)
  70. extern struct pdo_stmt_methods pgsql_stmt_methods;
  71. #ifdef HAVE_PQRESULTERRORFIELD
  72. #define pdo_pgsql_sqlstate(r) PQresultErrorField(r, PG_DIAG_SQLSTATE)
  73. #else
  74. #define pdo_pgsql_sqlstate(r) (const char *)NULL
  75. #endif
  76. enum {
  77. PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT = PDO_ATTR_DRIVER_SPECIFIC,
  78. };
  79. struct pdo_pgsql_lob_self {
  80. pdo_dbh_t *dbh;
  81. PGconn *conn;
  82. int lfd;
  83. Oid oid;
  84. };
  85. php_stream *pdo_pgsql_create_lob_stream(pdo_dbh_t *stmt, int lfd, Oid oid TSRMLS_DC);
  86. extern php_stream_ops pdo_pgsql_lob_stream_ops;
  87. #endif /* PHP_PDO_PGSQL_INT_H */
  88. /*
  89. * Local variables:
  90. * tab-width: 4
  91. * c-basic-offset: 4
  92. * End:
  93. * vim600: noet sw=4 ts=4 fdm=marker
  94. * vim<600: noet sw=4 ts=4
  95. */