php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
pdo_pgsql.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Edin Kadribasic <edink@emini.dk> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include "php.h"
22#include "php_ini.h"
23#include "ext/standard/info.h"
24#include "ext/pdo/php_pdo.h"
27#include "php_pdo_pgsql.h"
28#include "php_pdo_pgsql_int.h"
29#include "pdo_pgsql_arginfo.h"
30
31static zend_class_entry *PdoPgsql_ce;
32
33/* {{{ pdo_pgsql_deps */
34static const zend_module_dep pdo_pgsql_deps[] = {
37};
38/* }}} */
39
40/* {{{ pdo_pgsql_module_entry */
43 pdo_pgsql_deps,
44 "pdo_pgsql",
45 NULL,
46 PHP_MINIT(pdo_pgsql),
47 PHP_MSHUTDOWN(pdo_pgsql),
48 NULL,
49 NULL,
50 PHP_MINFO(pdo_pgsql),
53};
54/* }}} */
55
56#ifdef COMPILE_DL_PDO_PGSQL
57ZEND_GET_MODULE(pdo_pgsql)
58#endif
59
60/* Escape an identifier for insertion into a text field */
61PHP_METHOD(Pdo_Pgsql, escapeIdentifier)
62{
63 zend_string *from = NULL;
64 char *tmp;
65 pdo_dbh_t *dbh;
67
68 if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &from) == FAILURE) {
70 }
71
75
76 /* Obtain db Handle */
78 if (H->server == NULL) {
79 zend_throw_error(NULL, "PostgreSQL connection has already been closed");
81 }
82
83 tmp = PQescapeIdentifier(H->server, ZSTR_VAL(from), ZSTR_LEN(from));
84 if (!tmp) {
85 pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
88 }
89
90 RETVAL_STRING(tmp);
91 PQfreemem(tmp);
92}
93
94/* Returns true if the copy worked fine or false if error */
99
100/* Returns true if the copy worked fine or false if error */
105
106/* Returns true if the copy worked fine or false if error */
111
112/* Returns true if the copy worked fine or false if error */
117
118/* Creates a new large object, returning its identifier. Must be called inside a transaction. */
123
124/* Opens an existing large object stream. Must be called inside a transaction. */
129
130/* Deletes the large object identified by oid. Must be called inside a transaction. */
135
136/* Get asynchronous notification */
141
142/* Get backend(server) pid */
147
148/* Sets a callback to receive DB notices (after client_min_messages has been set */
149PHP_METHOD(Pdo_Pgsql, setNoticeCallback)
150{
153 if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "F!", &fci, &fcc)) {
155 }
156
159
161
163
164 if (ZEND_FCC_INITIALIZED(fcc)) {
165 H->notice_callback = emalloc(sizeof(zend_fcall_info_cache));
166 zend_fcc_dup(H->notice_callback, &fcc);
167 }
168
169 return;
170
171cleanup:
174}
175
176/* true global environment */
177
178/* {{{ PHP_MINIT_FUNCTION */
180{
187
188 PdoPgsql_ce = register_class_Pdo_Pgsql(pdo_dbh_ce);
189 PdoPgsql_ce->create_object = pdo_dbh_new;
190
192 return FAILURE;
193 }
194
196}
197/* }}} */
198
199/* {{{ PHP_MSHUTDOWN_FUNCTION */
205/* }}} */
206
207/* {{{ PHP_MINFO_FUNCTION */
209{
210 char buf[16];
211
213 php_info_print_table_row(2, "PDO Driver for PostgreSQL", "enabled");
214 pdo_libpq_version(buf, sizeof(buf));
215 php_info_print_table_row(2, "PostgreSQL(libpq) Version", buf);
217}
218/* }}} */
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
#define H(x, y, z)
Definition md5.c:146
PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver)
Definition pdo.c:129
PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver)
Definition pdo.c:113
PDO_API zend_result php_pdo_register_driver_specific_ce(const pdo_driver_t *driver, zend_class_entry *ce)
Definition pdo.c:140
zend_class_entry * pdo_dbh_ce
Definition pdo.c:34
zend_object * pdo_dbh_new(zend_class_entry *ce)
Definition pdo_dbh.c:1533
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
zend_module_entry pdo_pgsql_module_entry
Definition pdo_pgsql.c:41
void pgsqlLOBUnlink_internal(INTERNAL_FUNCTION_PARAMETERS)
void pgsqlCopyFromArray_internal(INTERNAL_FUNCTION_PARAMETERS)
void pgsqlCopyToArray_internal(INTERNAL_FUNCTION_PARAMETERS)
void pdo_pgsql_cleanup_notice_callback(pdo_pgsql_db_handle *H)
void pgsqlCopyFromFile_internal(INTERNAL_FUNCTION_PARAMETERS)
const pdo_driver_t pdo_pgsql_driver
void pgsqlLOBCreate_internal(INTERNAL_FUNCTION_PARAMETERS)
void pgsqlGetPid_internal(INTERNAL_FUNCTION_PARAMETERS)
void pgsqlGetNotify_internal(INTERNAL_FUNCTION_PARAMETERS)
void pgsqlCopyToFile_internal(INTERNAL_FUNCTION_PARAMETERS)
void pdo_libpq_version(char *buf, size_t len)
void pgsqlLOBOpen_internal(INTERNAL_FUNCTION_PARAMETERS)
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_MINIT
Definition php.h:392
#define PHP_METHOD
Definition php.h:365
#define PDO_CONSTRUCT_CHECK_WITH_CLEANUP(cleanup)
Definition php_pdo.h:71
#define PDO_CONSTRUCT_CHECK
Definition php_pdo.h:64
#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value)
Definition php_pdo.h:53
struct _pdo_dbh_t pdo_dbh_t
#define Z_PDO_DBH_P(zv)
#define PDO_HANDLE_DBH_ERR()
#define PDO_DBH_CLEAR_ERR()
#define PHP_PDO_PGSQL_VERSION
@ PDO_PGSQL_ATTR_DISABLE_PREPARES
#define pdo_pgsql_error(d, e, z)
@ PGSQL_TRANSACTION_INTRANS
@ PGSQL_TRANSACTION_UNKNOWN
@ PGSQL_TRANSACTION_IDLE
@ PGSQL_TRANSACTION_ACTIVE
@ PGSQL_TRANSACTION_INERROR
void * driver_data
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
Definition zend.h:50
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc)
Definition zend_API.c:3845
ZEND_API const zend_fcall_info empty_fcall_info
ZEND_API const zend_fcall_info_cache empty_fcall_info_cache
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
struct _zend_fcall_info_cache zend_fcall_info_cache
#define RETVAL_STRING(s)
Definition zend_API.h:1017
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
struct _zend_fcall_info zend_fcall_info
#define RETURN_THROWS()
Definition zend_API.h:1060
#define ZEND_THIS
Definition zend_API.h:523
#define ZEND_FCC_INITIALIZED(fcc)
Definition zend_API.h:341
#define emalloc(size)
Definition zend_alloc.h:151
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
#define ZEND_MOD_END
struct _zend_module_dep zend_module_dep
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES
#define ZEND_MOD_REQUIRED(name)
#define STANDARD_MODULE_HEADER_EX
struct _zend_class_entry zend_class_entry
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
@ FAILURE
Definition zend_types.h:61