Add stubs for PDO PGSql extension methods

This commit is contained in:
Nikita Popov 2020-07-21 12:47:49 +02:00
parent 1afcced1f0
commit 4dd8fec073
4 changed files with 116 additions and 25 deletions

View file

@ -33,6 +33,7 @@
#include "php_pdo_pgsql.h" #include "php_pdo_pgsql.h"
#include "php_pdo_pgsql_int.h" #include "php_pdo_pgsql_int.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"
#include "pgsql_driver_arginfo.h"
static char * _pdo_pgsql_trim_message(const char *message, int persistent) static char * _pdo_pgsql_trim_message(const char *message, int persistent)
{ {
@ -545,7 +546,7 @@ static int pgsql_handle_rollback(pdo_dbh_t *dbh)
} }
/* {{{ Returns true if the copy worked fine or false if error */ /* {{{ Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyFromArray) PHP_METHOD(PDO_PGSql_Ext, pgsqlCopyFromArray)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -658,7 +659,7 @@ static PHP_METHOD(PDO, pgsqlCopyFromArray)
/* }}} */ /* }}} */
/* {{{ Returns true if the copy worked fine or false if error */ /* {{{ Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyFromFile) PHP_METHOD(PDO_PGSql_Ext, pgsqlCopyFromFile)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -756,7 +757,7 @@ static PHP_METHOD(PDO, pgsqlCopyFromFile)
/* {{{ Returns true if the copy worked fine or false if error */ /* {{{ Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyToFile) PHP_METHOD(PDO_PGSql_Ext, pgsqlCopyToFile)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -850,7 +851,7 @@ static PHP_METHOD(PDO, pgsqlCopyToFile)
/* }}} */ /* }}} */
/* {{{ Returns true if the copy worked fine or false if error */ /* {{{ Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyToArray) PHP_METHOD(PDO_PGSql_Ext, pgsqlCopyToArray)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -926,7 +927,7 @@ static PHP_METHOD(PDO, pgsqlCopyToArray)
/* {{{ Creates a new large object, returning its identifier. Must be called inside a transaction. */ /* {{{ Creates a new large object, returning its identifier. Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBCreate) PHP_METHOD(PDO_PGSql_Ext, pgsqlLOBCreate)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -954,7 +955,7 @@ static PHP_METHOD(PDO, pgsqlLOBCreate)
/* }}} */ /* }}} */
/* {{{ Opens an existing large object stream. Must be called inside a transaction. */ /* {{{ Opens an existing large object stream. Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBOpen) PHP_METHOD(PDO_PGSql_Ext, pgsqlLOBOpen)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -1005,7 +1006,7 @@ static PHP_METHOD(PDO, pgsqlLOBOpen)
/* }}} */ /* }}} */
/* {{{ Deletes the large object identified by oid. Must be called inside a transaction. */ /* {{{ Deletes the large object identified by oid. Must be called inside a transaction. */
static PHP_METHOD(PDO, pgsqlLOBUnlink) PHP_METHOD(PDO_PGSql_Ext, pgsqlLOBUnlink)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -1040,7 +1041,7 @@ static PHP_METHOD(PDO, pgsqlLOBUnlink)
/* }}} */ /* }}} */
/* {{{ Get asynchronous notification */ /* {{{ Get asynchronous notification */
static PHP_METHOD(PDO, pgsqlGetNotify) PHP_METHOD(PDO_PGSql_Ext, pgsqlGetNotify)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -1120,7 +1121,7 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
/* }}} */ /* }}} */
/* {{{ Get backend(server) pid */ /* {{{ Get backend(server) pid */
static PHP_METHOD(PDO, pgsqlGetPid) PHP_METHOD(PDO_PGSql_Ext, pgsqlGetPid)
{ {
pdo_dbh_t *dbh; pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H; pdo_pgsql_db_handle *H;
@ -1136,25 +1137,11 @@ static PHP_METHOD(PDO, pgsqlGetPid)
} }
/* }}} */ /* }}} */
static const zend_function_entry dbh_methods[] = {
PHP_ME(PDO, pgsqlLOBCreate, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlLOBOpen, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlLOBUnlink, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlCopyFromArray, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlCopyFromFile, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlCopyToArray, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlCopyToFile, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlGetNotify, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, pgsqlGetPid, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, int kind) static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, int kind)
{ {
switch (kind) { switch (kind) {
case PDO_DBH_DRIVER_METHOD_KIND_DBH: case PDO_DBH_DRIVER_METHOD_KIND_DBH:
return dbh_methods; return class_PDO_PGSql_Ext_methods;
default: default:
return NULL; return NULL;
} }

View file

@ -0,0 +1,33 @@
<?php
/** @generate-function-entries */
// These are extension methods for PDO. This is not a real class.
class PDO_PGSql_Ext {
/** @return bool */
public function pgsqlCopyFromArray(string $table_name, array $rows, string $delimiter = "\t", string $null_as = "\\\\N", string $fields = UNKNOWN) {}
/** @return bool */
public function pgsqlCopyFromFile(string $table_name, string $filename, string $delimiter = "\t", string $null_as = "\\\\N", string $fields = UNKNOWN) {}
/** @return array|false */
public function pgsqlCopyToArray(string $table_name, string $delimiter = "\t", string $null_as = "\\\\N", string $fields = UNKNOWN) {}
/** @return bool */
public function pgsqlCopyToFile(string $table_name, string $filename, string $delimiter = "\t", string $null_as = "\\\\N", string $fields = UNKNOWN) {}
/** @return string|false */
public function pgsqlLOBCreate() {}
/** @return resource|false */
public function pgsqlLOBOpen(string $oid, string $mode = "rb") {}
/** @return bool */
public function pgsqlLOBUnlink(string $oid) {}
/** @return array|false */
public function pgsqlGetNotify(int $result_type = PDO::FETCH_USE_DEFAULT, int $ms_timeout = 0) {}
/** @return int */
public function pgsqlGetPid() {}
}

View file

@ -0,0 +1,71 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 80c3e9c95db8c68ff3a2c2753aa5e9485af9fe4c */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlCopyFromArray, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, table_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, rows, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, delimiter, IS_STRING, 0, "\"\\t\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, null_as, IS_STRING, 0, "\"\\\\\\\\N\"")
ZEND_ARG_TYPE_INFO(0, fields, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlCopyFromFile, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, table_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, delimiter, IS_STRING, 0, "\"\\t\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, null_as, IS_STRING, 0, "\"\\\\\\\\N\"")
ZEND_ARG_TYPE_INFO(0, fields, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlCopyToArray, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, table_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, delimiter, IS_STRING, 0, "\"\\t\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, null_as, IS_STRING, 0, "\"\\\\\\\\N\"")
ZEND_ARG_TYPE_INFO(0, fields, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_PDO_PGSql_Ext_pgsqlCopyToFile arginfo_class_PDO_PGSql_Ext_pgsqlCopyFromFile
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlLOBCreate, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlLOBOpen, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, oid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_STRING, 0, "\"rb\"")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlLOBUnlink, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, oid, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_PGSql_Ext_pgsqlGetNotify, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, result_type, IS_LONG, 0, "PDO::FETCH_USE_DEFAULT")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ms_timeout, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
#define arginfo_class_PDO_PGSql_Ext_pgsqlGetPid arginfo_class_PDO_PGSql_Ext_pgsqlLOBCreate
ZEND_METHOD(PDO_PGSql_Ext, pgsqlCopyFromArray);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlCopyFromFile);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlCopyToArray);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlCopyToFile);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlLOBCreate);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlLOBOpen);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlLOBUnlink);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlGetNotify);
ZEND_METHOD(PDO_PGSql_Ext, pgsqlGetPid);
static const zend_function_entry class_PDO_PGSql_Ext_methods[] = {
ZEND_ME(PDO_PGSql_Ext, pgsqlCopyFromArray, arginfo_class_PDO_PGSql_Ext_pgsqlCopyFromArray, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlCopyFromFile, arginfo_class_PDO_PGSql_Ext_pgsqlCopyFromFile, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlCopyToArray, arginfo_class_PDO_PGSql_Ext_pgsqlCopyToArray, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlCopyToFile, arginfo_class_PDO_PGSql_Ext_pgsqlCopyToFile, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlLOBCreate, arginfo_class_PDO_PGSql_Ext_pgsqlLOBCreate, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlLOBOpen, arginfo_class_PDO_PGSql_Ext_pgsqlLOBOpen, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlLOBUnlink, arginfo_class_PDO_PGSql_Ext_pgsqlLOBUnlink, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlGetNotify, arginfo_class_PDO_PGSql_Ext_pgsqlGetNotify, ZEND_ACC_PUBLIC)
ZEND_ME(PDO_PGSql_Ext, pgsqlGetPid, arginfo_class_PDO_PGSql_Ext_pgsqlGetPid, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead. /* This is a generated file, edit the .stub.php file instead.
* Stub hash: 5134a0b80848f852557b1c22ec102573d79ed9a4 */ * Stub hash: e367675f85371fb06484e39dd6ccb3433766ffb8 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, 0, 0, 2) ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)