Annotation of embedaddon/php/ext/pgsql/php_pgsql.h, revision 1.1.1.4

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | PHP Version 5                                                        |
                      4:    +----------------------------------------------------------------------+
1.1.1.4 ! misho       5:    | Copyright (c) 1997-2014 The PHP Group                                |
1.1       misho       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: Zeev Suraski <zeev@zend.com>                                |
                     16:    |          Jouni Ahto <jouni.ahto@exdec.fi>                            |
                     17:    +----------------------------------------------------------------------+
                     18:  */
1.1.1.4 ! misho      19: 
1.1.1.2   misho      20: /* $Id$ */
1.1       misho      21: 
                     22: #ifndef PHP_PGSQL_H
                     23: #define PHP_PGSQL_H
                     24: 
                     25: #if HAVE_PGSQL
                     26: 
                     27: extern zend_module_entry pgsql_module_entry;
                     28: #define pgsql_module_ptr &pgsql_module_entry
                     29: 
                     30: #ifdef PHP_PGSQL_PRIVATE
                     31: #undef SOCKET_SIZE_TYPE
                     32: #include <libpq-fe.h>
                     33: 
                     34: #ifdef PHP_WIN32
                     35: #define INV_WRITE            0x00020000
                     36: #define INV_READ             0x00040000
                     37: #undef PHP_PGSQL_API
                     38: #ifdef PGSQL_EXPORTS
                     39: #define PHP_PGSQL_API __declspec(dllexport)
                     40: #else
                     41: #define PHP_PGSQL_API __declspec(dllimport)
                     42: #endif
                     43: #else
                     44: #include <libpq/libpq-fs.h>
                     45: # if defined(__GNUC__) && __GNUC__ >= 4
                     46: #  define PHP_PGSQL_API __attribute__ ((visibility("default")))
                     47: # else
                     48: #  define PHP_PGSQL_API
                     49: # endif
                     50: #endif
                     51: 
                     52: #ifdef HAVE_PG_CONFIG_H
                     53: #include <pg_config.h>
                     54: #endif
                     55: 
                     56: #ifdef HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT
                     57: const char * pg_encoding_to_char(int encoding);
                     58: #endif
                     59: 
                     60: PHP_MINIT_FUNCTION(pgsql);
                     61: PHP_MSHUTDOWN_FUNCTION(pgsql);
                     62: PHP_RINIT_FUNCTION(pgsql);
                     63: PHP_RSHUTDOWN_FUNCTION(pgsql);
                     64: PHP_MINFO_FUNCTION(pgsql);
                     65: /* connection functions */
                     66: PHP_FUNCTION(pg_connect);
                     67: PHP_FUNCTION(pg_pconnect);
                     68: PHP_FUNCTION(pg_close);
                     69: PHP_FUNCTION(pg_connection_reset);
                     70: PHP_FUNCTION(pg_connection_status);
                     71: PHP_FUNCTION(pg_connection_busy);
                     72: PHP_FUNCTION(pg_host);
                     73: PHP_FUNCTION(pg_dbname);
                     74: PHP_FUNCTION(pg_port);
                     75: PHP_FUNCTION(pg_tty);
                     76: PHP_FUNCTION(pg_options);
                     77: PHP_FUNCTION(pg_version);
                     78: PHP_FUNCTION(pg_ping);
                     79: #if HAVE_PQPARAMETERSTATUS
                     80: PHP_FUNCTION(pg_parameter_status);
                     81: #endif
                     82: #if HAVE_PGTRANSACTIONSTATUS
                     83: PHP_FUNCTION(pg_transaction_status);
                     84: #endif
                     85: /* query functions */
                     86: PHP_FUNCTION(pg_query);
                     87: #if HAVE_PQEXECPARAMS
                     88: PHP_FUNCTION(pg_query_params);
                     89: #endif
                     90: #if HAVE_PQPREPARE
                     91: PHP_FUNCTION(pg_prepare);
                     92: #endif
                     93: #if HAVE_PQEXECPREPARED
                     94: PHP_FUNCTION(pg_execute);
                     95: #endif
                     96: PHP_FUNCTION(pg_send_query);
                     97: #if HAVE_PQSENDQUERYPARAMS
                     98: PHP_FUNCTION(pg_send_query_params);
                     99: #endif
                    100: #if HAVE_PQSENDPREPARE
                    101: PHP_FUNCTION(pg_send_prepare);
                    102: #endif
                    103: #if HAVE_PQSENDQUERYPREPARED
                    104: PHP_FUNCTION(pg_send_execute);
                    105: #endif
                    106: PHP_FUNCTION(pg_cancel_query);
                    107: /* result functions */
                    108: PHP_FUNCTION(pg_fetch_assoc);
                    109: PHP_FUNCTION(pg_fetch_array);
                    110: PHP_FUNCTION(pg_fetch_object);
                    111: PHP_FUNCTION(pg_fetch_result);
                    112: PHP_FUNCTION(pg_fetch_row);
                    113: PHP_FUNCTION(pg_fetch_all);
                    114: PHP_FUNCTION(pg_fetch_all_columns);
                    115: #if HAVE_PQCMDTUPLES
                    116: PHP_FUNCTION(pg_affected_rows);
                    117: #endif
                    118: PHP_FUNCTION(pg_get_result);
                    119: PHP_FUNCTION(pg_result_seek);
                    120: PHP_FUNCTION(pg_result_status);
                    121: PHP_FUNCTION(pg_free_result);
                    122: PHP_FUNCTION(pg_last_oid);
                    123: PHP_FUNCTION(pg_num_rows);
                    124: PHP_FUNCTION(pg_num_fields);
                    125: PHP_FUNCTION(pg_field_name);
                    126: PHP_FUNCTION(pg_field_num);
                    127: PHP_FUNCTION(pg_field_size);
                    128: PHP_FUNCTION(pg_field_type);
                    129: PHP_FUNCTION(pg_field_type_oid);
                    130: PHP_FUNCTION(pg_field_prtlen);
                    131: PHP_FUNCTION(pg_field_is_null);
                    132: PHP_FUNCTION(pg_field_table);
                    133: /* async message functions */
                    134: PHP_FUNCTION(pg_get_notify);
                    135: PHP_FUNCTION(pg_get_pid);
                    136: /* error message functions */
                    137: PHP_FUNCTION(pg_result_error);
                    138: #if HAVE_PQRESULTERRORFIELD
                    139: PHP_FUNCTION(pg_result_error_field);
                    140: #endif
                    141: PHP_FUNCTION(pg_last_error);
                    142: PHP_FUNCTION(pg_last_notice);
                    143: /* copy functions */
                    144: PHP_FUNCTION(pg_put_line);
                    145: PHP_FUNCTION(pg_end_copy);
                    146: PHP_FUNCTION(pg_copy_to);
                    147: PHP_FUNCTION(pg_copy_from);
                    148: /* large object functions */
                    149: PHP_FUNCTION(pg_lo_create);
                    150: PHP_FUNCTION(pg_lo_unlink);
                    151: PHP_FUNCTION(pg_lo_open);
                    152: PHP_FUNCTION(pg_lo_close);
                    153: PHP_FUNCTION(pg_lo_read);
                    154: PHP_FUNCTION(pg_lo_write);
                    155: PHP_FUNCTION(pg_lo_read_all);
                    156: PHP_FUNCTION(pg_lo_import);
                    157: PHP_FUNCTION(pg_lo_export);
                    158: PHP_FUNCTION(pg_lo_seek);
                    159: PHP_FUNCTION(pg_lo_tell);
                    160: 
                    161: /* debugging functions */
                    162: PHP_FUNCTION(pg_trace);
                    163: PHP_FUNCTION(pg_untrace);
                    164: 
                    165: /* utility functions */
                    166: PHP_FUNCTION(pg_client_encoding);
                    167: PHP_FUNCTION(pg_set_client_encoding);
                    168: #if HAVE_PQSETERRORVERBOSITY
                    169: PHP_FUNCTION(pg_set_error_verbosity);
                    170: #endif
                    171: #if HAVE_PQESCAPE
                    172: PHP_FUNCTION(pg_escape_string);
                    173: PHP_FUNCTION(pg_escape_bytea);
                    174: PHP_FUNCTION(pg_unescape_bytea);
1.1.1.3   misho     175: PHP_FUNCTION(pg_escape_literal);
                    176: PHP_FUNCTION(pg_escape_identifier);
1.1       misho     177: #endif
                    178: 
                    179: /* misc functions */
                    180: PHP_FUNCTION(pg_meta_data);
                    181: PHP_FUNCTION(pg_convert);
                    182: PHP_FUNCTION(pg_insert);
                    183: PHP_FUNCTION(pg_update);
                    184: PHP_FUNCTION(pg_delete);
                    185: PHP_FUNCTION(pg_select);
                    186: 
                    187: /* connection options - ToDo: Add async connection option */
                    188: #define PGSQL_CONNECT_FORCE_NEW     (1<<1)
                    189: /* php_pgsql_convert options */
                    190: #define PGSQL_CONV_IGNORE_DEFAULT   (1<<1)     /* Do not use DEAFULT value by removing field from returned array */
                    191: #define PGSQL_CONV_FORCE_NULL       (1<<2)     /* Convert to NULL if string is null string */
                    192: #define PGSQL_CONV_IGNORE_NOT_NULL  (1<<3)     /* Ignore NOT NULL constraints */
                    193: #define PGSQL_CONV_OPTS             (PGSQL_CONV_IGNORE_DEFAULT|PGSQL_CONV_FORCE_NULL|PGSQL_CONV_IGNORE_NOT_NULL)
                    194: /* php_pgsql_insert/update/select/delete options */
                    195: #define PGSQL_DML_NO_CONV           (1<<8)     /* Do not call php_pgsql_convert() */
                    196: #define PGSQL_DML_EXEC              (1<<9)     /* Execute query */
                    197: #define PGSQL_DML_ASYNC             (1<<10)    /* Do async query */
                    198: #define PGSQL_DML_STRING            (1<<11)    /* Return query string */
                    199: 
                    200: /* exported functions */
                    201: PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta TSRMLS_DC);
                    202: PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC);
                    203: PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *values, ulong opt, char **sql TSRMLS_DC);
                    204: PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *values, zval *ids, ulong opt , char **sql TSRMLS_DC);
                    205: PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids, ulong opt, char **sql TSRMLS_DC);
                    206: PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids, zval *ret_array, ulong opt, char **sql  TSRMLS_DC);
                    207: PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array TSRMLS_DC);
                    208: 
                    209: /* internal functions */
                    210: static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent);
                    211: static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
                    212: static void php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
                    213: static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list TSRMLS_DC);
                    214: static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
                    215: static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
                    216: static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS,int entry_type);
                    217: 
                    218: typedef enum _php_pgsql_data_type {
                    219:        /* boolean */
                    220:        PG_BOOL,
                    221:        /* number */
                    222:        PG_OID,
                    223:        PG_INT2,
                    224:        PG_INT4,
                    225:        PG_INT8,
                    226:        PG_FLOAT4,
                    227:        PG_FLOAT8,
                    228:        PG_NUMERIC,
                    229:        PG_MONEY,
                    230:        /* character */
                    231:        PG_TEXT,
                    232:        PG_CHAR,
                    233:        PG_VARCHAR,
                    234:        /* time and interval */
                    235:        PG_UNIX_TIME,
                    236:        PG_UNIX_TIME_INTERVAL,
                    237:        PG_DATE,
                    238:        PG_TIME,
                    239:        PG_TIME_WITH_TIMEZONE,
                    240:        PG_TIMESTAMP,
                    241:        PG_TIMESTAMP_WITH_TIMEZONE,
                    242:        PG_INTERVAL,
                    243:        /* binary */
                    244:        PG_BYTEA,
                    245:        /* network */
                    246:        PG_CIDR,
                    247:        PG_INET,
                    248:        PG_MACADDR,
                    249:        /* bit */
                    250:        PG_BIT,
                    251:        PG_VARBIT,
                    252:        /* geometoric */
                    253:        PG_LINE,
                    254:        PG_LSEG,
                    255:        PG_POINT,
                    256:        PG_BOX,
                    257:        PG_PATH,
                    258:        PG_POLYGON,
                    259:        PG_CIRCLE,
1.1.1.4 ! misho     260:        /* unknown and system */
1.1       misho     261:        PG_UNKNOWN
                    262: } php_pgsql_data_type;
                    263: 
                    264: typedef struct pgLofp {
                    265:        PGconn *conn;
                    266:        int lofd;
                    267: } pgLofp;
                    268: 
                    269: typedef struct _php_pgsql_result_handle {
                    270:        PGconn *conn;
                    271:        PGresult *result;
                    272:        int row;
                    273: } pgsql_result_handle;
                    274: 
                    275: typedef struct _php_pgsql_notice {
                    276:        char *message;
                    277:        size_t len;
                    278: } php_pgsql_notice;
                    279: 
                    280: ZEND_BEGIN_MODULE_GLOBALS(pgsql)
                    281:        long default_link; /* default link when connection is omitted */
                    282:        long num_links,num_persistent;
                    283:        long max_links,max_persistent;
                    284:        long allow_persistent;
                    285:        long auto_reset_persistent;
                    286:        int le_lofp,le_string;
                    287:        int ignore_notices,log_notices;
                    288:        HashTable notices;  /* notice message for each connection */
                    289: ZEND_END_MODULE_GLOBALS(pgsql)
                    290: 
                    291: ZEND_EXTERN_MODULE_GLOBALS(pgsql)
                    292: 
                    293: #ifdef ZTS
                    294: # define PGG(v) TSRMG(pgsql_globals_id, zend_pgsql_globals *, v)
                    295: #else
                    296: # define PGG(v) (pgsql_globals.v)
                    297: #endif
                    298: 
                    299: #endif
                    300: 
                    301: #else
                    302: 
                    303: #define pgsql_module_ptr NULL
                    304: 
                    305: #endif
                    306: 
                    307: #define phpext_pgsql_ptr pgsql_module_ptr
                    308: 
                    309: #endif /* PHP_PGSQL_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>