xref: /PHP-7.4/ext/pdo_pgsql/pdo_pgsql.c (revision 67f9b0b7)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 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: Edin Kadribasic <edink@emini.dk>                             |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22 
23 #include "php.h"
24 #include "php_ini.h"
25 #include "ext/standard/info.h"
26 #include "pdo/php_pdo.h"
27 #include "pdo/php_pdo_driver.h"
28 #include "php_pdo_pgsql.h"
29 #include "php_pdo_pgsql_int.h"
30 
31 #ifdef HAVE_PG_CONFIG_H
32 #undef SIZEOF_OFF_T
33 #include <pg_config.h>
34 #endif
35 
36 /* {{{ pdo_pgsql_functions[] */
37 static const zend_function_entry pdo_pgsql_functions[] = {
38 	PHP_FE_END
39 };
40 /* }}} */
41 
42 /* {{{ pdo_sqlite_deps
43  */
44 static const zend_module_dep pdo_pgsql_deps[] = {
45 	ZEND_MOD_REQUIRED("pdo")
46 	ZEND_MOD_END
47 };
48 /* }}} */
49 
50 /* {{{ pdo_pgsql_module_entry */
51 zend_module_entry pdo_pgsql_module_entry = {
52 	STANDARD_MODULE_HEADER_EX, NULL,
53 	pdo_pgsql_deps,
54 	"pdo_pgsql",
55 	pdo_pgsql_functions,
56 	PHP_MINIT(pdo_pgsql),
57 	PHP_MSHUTDOWN(pdo_pgsql),
58 	NULL,
59 	NULL,
60 	PHP_MINFO(pdo_pgsql),
61 	PHP_PDO_PGSQL_VERSION,
62 	STANDARD_MODULE_PROPERTIES
63 };
64 /* }}} */
65 
66 #ifdef COMPILE_DL_PDO_PGSQL
67 ZEND_GET_MODULE(pdo_pgsql)
68 #endif
69 
70 /* true global environment */
71 
72 /* {{{ PHP_MINIT_FUNCTION
73  */
PHP_MINIT_FUNCTION(pdo_pgsql)74 PHP_MINIT_FUNCTION(pdo_pgsql)
75 {
76 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES);
77 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE);
78 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE);
79 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
80 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
81 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
82 
83 	php_pdo_register_driver(&pdo_pgsql_driver);
84 	return SUCCESS;
85 }
86 /* }}} */
87 
88 /* {{{ PHP_MSHUTDOWN_FUNCTION
89  */
PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)90 PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)
91 {
92 	php_pdo_unregister_driver(&pdo_pgsql_driver);
93 	return SUCCESS;
94 }
95 /* }}} */
96 
97 /* {{{ PHP_MINFO_FUNCTION
98  */
PHP_MINFO_FUNCTION(pdo_pgsql)99 PHP_MINFO_FUNCTION(pdo_pgsql)
100 {
101 	php_info_print_table_start();
102 	php_info_print_table_row(2, "PDO Driver for PostgreSQL", "enabled");
103 #ifdef HAVE_PG_CONFIG_H
104 	php_info_print_table_row(2, "PostgreSQL(libpq) Version", PG_VERSION);
105 #endif
106 	php_info_print_table_end();
107 }
108 /* }}} */
109