note 34111 rejected from function.pg-insert by didou
| From: | didou@php.net | Date: | Thu, 07 Aug 2003 12:46:16 +0000 |
| Subject: | note 34111 rejected from function.pg-insert by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53568@lists.php.net to get a copy of this message | ||
Note Submitter: rorezende@hotmail.com
----
In source code of php 4.3.2 exists an error ext/pgsql/pgsql.c.
In the function pg_convert (php_pgsql_convert) it is not necessary to specify the schema name. But
in the sql statement insert it is. Below is the portion of the source code which needs to be fixed.
line (HERE --> smart_str_appends(&querystr, table);)
Must be something like :
NEW HERE -->
smart_str_appends(&querystr, schema);
smart_str_appends(&querystr, ".");
smart_str_appends(&querystr, table);
the schema name can be obtained from realnamespace collumn (oid) from table pg_class.
The source :
PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, ulong opt, char
**sql TSRMLS_DC)
{
zval **val, *converted = NULL;
char buf[256];
char *fld;
smart_str querystr = {0};
int key_type, ret = FAILURE;
uint fld_len;
ulong num_idx;
HashPosition pos;
assert(pg_link != NULL);
assert(table != NULL);
assert(Z_TYPE_P(var_array) == IS_ARRAY);
if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {
return FAILURE;
}
/* convert input array if needed */
if (!(opt & PGSQL_DML_NO_CONV)) {
MAKE_STD_ZVAL(converted);
array_init(converted);
if (php_pgsql_convert(pg_link, table, var_array, converted, (opt & PGSQL_CONV_OPTS) TSRMLS_CC)
== FAILURE) {
goto cleanup;
}
var_array = converted;
}
smart_str_appends(&querystr, "INSERT INTO ");
HERE --> smart_str_appends(&querystr, table);
smart_str_appends(&querystr, " (");