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.

171 lines
5.0 KiB

24 years ago
24 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 4 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2002 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.02 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_02.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: Zeev Suraski <zeev@zend.com> |
  16. | Jouni Ahto <jouni.ahto@exdec.fi> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #ifndef PHP_PGSQL_H
  21. #define PHP_PGSQL_H
  22. #if HAVE_PGSQL
  23. extern zend_module_entry pgsql_module_entry;
  24. #define pgsql_module_ptr &pgsql_module_entry
  25. #ifdef PHP_PGSQL_PRIVATE
  26. #undef SOCKET_SIZE_TYPE
  27. #include <libpq-fe.h>
  28. #ifdef PHP_WIN32
  29. #define INV_WRITE 0x00020000
  30. #define INV_READ 0x00040000
  31. #else
  32. #include <libpq/libpq-fs.h>
  33. #endif
  34. #ifdef HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT
  35. const char * pg_encoding_to_char(int encoding);
  36. #endif
  37. PHP_MINIT_FUNCTION(pgsql);
  38. PHP_MSHUTDOWN_FUNCTION(pgsql);
  39. PHP_RINIT_FUNCTION(pgsql);
  40. PHP_RSHUTDOWN_FUNCTION(pgsql);
  41. PHP_MINFO_FUNCTION(pgsql);
  42. /* connection functions */
  43. PHP_FUNCTION(pg_connect);
  44. PHP_FUNCTION(pg_pconnect);
  45. PHP_FUNCTION(pg_close);
  46. PHP_FUNCTION(pg_connection_reset);
  47. PHP_FUNCTION(pg_connection_status);
  48. PHP_FUNCTION(pg_connection_busy);
  49. PHP_FUNCTION(pg_host);
  50. PHP_FUNCTION(pg_dbname);
  51. PHP_FUNCTION(pg_port);
  52. PHP_FUNCTION(pg_tty);
  53. PHP_FUNCTION(pg_options);
  54. /* query functions */
  55. PHP_FUNCTION(pg_query);
  56. PHP_FUNCTION(pg_send_query);
  57. PHP_FUNCTION(pg_cancel_query);
  58. /* result functions */
  59. PHP_FUNCTION(pg_fetch_array);
  60. PHP_FUNCTION(pg_fetch_object);
  61. PHP_FUNCTION(pg_fetch_result);
  62. PHP_FUNCTION(pg_fetch_row);
  63. PHP_FUNCTION(pg_affected_rows);
  64. PHP_FUNCTION(pg_get_result);
  65. PHP_FUNCTION(pg_result_status);
  66. PHP_FUNCTION(pg_free_result);
  67. PHP_FUNCTION(pg_last_oid);
  68. PHP_FUNCTION(pg_num_rows);
  69. PHP_FUNCTION(pg_num_fields);
  70. PHP_FUNCTION(pg_field_name);
  71. PHP_FUNCTION(pg_field_num);
  72. PHP_FUNCTION(pg_field_size);
  73. PHP_FUNCTION(pg_field_type);
  74. PHP_FUNCTION(pg_field_prtlen);
  75. PHP_FUNCTION(pg_field_is_null);
  76. /* error message functions */
  77. PHP_FUNCTION(pg_result_error);
  78. PHP_FUNCTION(pg_last_error);
  79. PHP_FUNCTION(pg_last_notice);
  80. /* copy functions */
  81. PHP_FUNCTION(pg_put_line);
  82. PHP_FUNCTION(pg_end_copy);
  83. PHP_FUNCTION(pg_copy_to);
  84. PHP_FUNCTION(pg_copy_from);
  85. /* large object functions */
  86. PHP_FUNCTION(pg_lo_create);
  87. PHP_FUNCTION(pg_lo_unlink);
  88. PHP_FUNCTION(pg_lo_open);
  89. PHP_FUNCTION(pg_lo_close);
  90. PHP_FUNCTION(pg_lo_read);
  91. PHP_FUNCTION(pg_lo_write);
  92. PHP_FUNCTION(pg_lo_read_all);
  93. PHP_FUNCTION(pg_lo_import);
  94. PHP_FUNCTION(pg_lo_export);
  95. PHP_FUNCTION(pg_lo_seek);
  96. PHP_FUNCTION(pg_lo_tell);
  97. /* debugging functions */
  98. PHP_FUNCTION(pg_trace);
  99. PHP_FUNCTION(pg_untrace);
  100. /* utility functions */
  101. #if HAVE_PQCLIENTENCODING
  102. PHP_FUNCTION(pg_client_encoding);
  103. PHP_FUNCTION(pg_set_client_encoding);
  104. #endif
  105. #if HAVE_PQESCAPE
  106. PHP_FUNCTION(pg_escape_string);
  107. PHP_FUNCTION(pg_escape_bytea);
  108. #endif
  109. static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent);
  110. /* static int php_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS); */
  111. static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
  112. static void php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
  113. static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list TSRMLS_DC);
  114. static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
  115. static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
  116. static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS,int entry_type);
  117. typedef struct pgLofp {
  118. PGconn *conn;
  119. int lofd;
  120. } pgLofp;
  121. typedef struct _php_pgsql_result_handle {
  122. PGconn *conn;
  123. PGresult *result;
  124. int row;
  125. } pgsql_result_handle;
  126. typedef struct {
  127. long default_link;
  128. long num_links,num_persistent;
  129. long max_links,max_persistent;
  130. long allow_persistent;
  131. long auto_reset_persistent;
  132. int le_lofp,le_string;
  133. int ignore_notices;
  134. char *last_notice;
  135. uint last_notice_len;
  136. } php_pgsql_globals;
  137. #ifdef ZTS
  138. # define PGG(v) TSRMG(pgsql_globals_id, php_pgsql_globals *, v)
  139. extern int pgsql_globals_id;
  140. #else
  141. # define PGG(v) (pgsql_globals.v)
  142. extern php_pgsql_globals pgsql_globals;
  143. #endif
  144. #endif
  145. #else
  146. #define pgsql_module_ptr NULL
  147. #endif
  148. #define phpext_pgsql_ptr pgsql_module_ptr
  149. #endif /* PHP_PGSQL_H */