diff options
| author | Derick Rethans <derick@php.net> | 2001-01-18 22:17:05 +0000 |
|---|---|---|
| committer | Derick Rethans <derick@php.net> | 2001-01-18 22:17:05 +0000 |
| commit | 82d58bdc4a3cd58ee78eb017c0a3b2dc37922391 (patch) | |
| tree | 62134a11ee9728701b4d6626ee54b04ee50a3625 /ext/pgsql/pgsql.c | |
| parent | 9a3cb4559f54f11b5806eb029790b111625de986 (diff) | |
| download | php-git-82d58bdc4a3cd58ee78eb017c0a3b2dc37922391.tar.gz | |
- Added the pg_lolseek function, which allows for arbitrary seeking within
a large object, and the pg_lotell call, which can be used to find the
current file offset for a large object (Submitted by: Adam Haberlach
<adam@newsnipple.com>).
@- Added the pg_lolseek and pg_lotell functions (Derick)
Diffstat (limited to 'ext/pgsql/pgsql.c')
| -rw-r--r-- | ext/pgsql/pgsql.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 4962ca92bc..da6b87bdb4 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -75,6 +75,8 @@ function_entry pgsql_functions[] = { PHP_FE(pg_loreadall, NULL) PHP_FE(pg_loimport, NULL) PHP_FE(pg_loexport, NULL) + PHP_FE(pg_lolseek, NULL) + PHP_FE(pg_lotell, NULL) PHP_FE(pg_put_line, NULL) PHP_FE(pg_end_copy, NULL) #if HAVE_PQCLIENTENCODING @@ -1736,6 +1738,59 @@ PHP_FUNCTION(pg_loexport) } /* }}} */ +/* {{{ proto int pg_lolseek(int objoid, int offset, int whence) + Seek into a postgres large object*/ +PHP_FUNCTION(pg_lolseek) { + val **pgsql_lofp, **seek_offset, **seek_whence; + gLofp *pgsql; + + switch(ZEND_NUM_ARGS()) { + case 3: + if (zend_get_parameters_ex(3, &pgsql_lofp, &seek_offset, &seek_whence)==FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(seek_offset); + convert_to_long_ex(seek_whence); + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp); + if (lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, Z_STRVAL_PP(seek_offset), Z_STRVAL_PP(seek_whence))) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto int pg_tell(int objoid) + return current offset into large object */ +PHP_FUNCTION(pg_lotell) { + long int offset; + zval **pgsql_lofp; + pgLofp *pgsql; + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &pgsql_lofp)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + END_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp); + + ffset = lo_tell((PGconn *)pgsql->conn, pgsql->lofd); + ETURN_LONG (offset); +} +/* }}} */ + #if HAVE_PQCLIENTENCODING /* {{{ proto int pg_set_client_encoding([int connection,] string encoding) |
