--- pgsql.c Wed Oct 3 19:31:58 2007 +++ pgsql.c Thu Dec 6 23:16:34 2007 @@ -63,4 +63,5 @@ #define PGSQL_MAX_LENGTH_OF_DOUBLE 60 +#if UINT_MAX > LONG_MAX #define PGSQL_RETURN_OID(oid) do { \ if (oid > LONG_MAX) { \ @@ -72,5 +73,7 @@ RETURN_LONG((long)oid); \ } while(0) - +#else +#define PGSQL_RETURN_OID(oid) RETURN_LONG((long)oid) +#endif #if HAVE_PQSETNONBLOCKING @@ -273,5 +276,5 @@ /* {{{ _php_pgsql_trim_message */ -static char * _php_pgsql_trim_message(const char *message, int *len) +static char * _php_pgsql_trim_message(const char *message, size_t *len) { register int i = strlen(message)-1; @@ -364,5 +367,5 @@ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message); } - zend_hash_index_update(&PGG(notices), (int)resource_id, (void **)¬ice, sizeof(php_pgsql_notice *), NULL); + zend_hash_index_update(&PGG(notices), (ulong)resource_id, (void **)¬ice, sizeof(php_pgsql_notice *), NULL); } } @@ -762,5 +765,6 @@ if (!(connect_type & PGSQL_CONNECT_FORCE_NEW) && zend_hash_find(&EG(regular_list),str.c,str.len+1,(void **) &index_ptr)==SUCCESS) { - int type,link; + int type; + ulong link; void *ptr; @@ -768,5 +772,5 @@ RETURN_FALSE; } - link = (int) index_ptr->ptr; + link = (uintptr_t /* ulong is as wide or wider than pointer */) index_ptr->ptr; ptr = zend_list_find(link,&type); /* check if the link is still there */ if (ptr && (type==le_link || type==le_plink)) { @@ -1749,4 +1753,5 @@ if (return_oid) { +#if UINT_MAX > LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */ if (oid > LONG_MAX) { smart_str oidstr = {0}; @@ -1754,5 +1759,7 @@ smart_str_0(&oidstr); RETURN_STRINGL(oidstr.c, oidstr.len, 0); - } else { + } else +#endif + { RETURN_LONG((long)oid); } @@ -1855,4 +1862,5 @@ oid = PQftype(pgsql_result, Z_LVAL_PP(field)); +#if UINT_MAX > LONG_MAX if (oid > LONG_MAX) { smart_str s = {0}; @@ -1864,4 +1872,5 @@ } else +#endif { Z_LVAL_P(return_value) = (long)oid; @@ -5742,6 +5751,6 @@ zval *row; char *field_name, *element, *data; - size_t num_fields, element_len, data_len; - int pg_numrows, pg_row; + size_t num_fields, element_len; + int pg_numrows, pg_row, data_len; uint i; assert(Z_TYPE_P(ret_array) == IS_ARRAY);