pg_get_result() hangs for query length > 65535

From: john_ramsden(at)sagitta-ps(dot)com (John Ramsden)
To: pgsql-general(at)postgresql(dot)org
Subject: pg_get_result() hangs for query length > 65535
Date: 2004-08-13 08:41:28
Message-ID: d27434e.0408130041.19b11d9f@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a script running on PHP v4.3.6 (cgi) that hangs forever
in a call to the Postgres pg_get_result() function when and only
when the query length is 65536 or more bytes.

The query is a simple INSERT, of a single ASCII value into a
'text' type field, and works fine for shorter queries.

(As the code first calls pg_escape_string() on the value to be
inserted, I'm sure the problem doesn't relate to bad characters
in the data.)

Anyone have any ideas? My impression is that few PHP coders use
pg_send_query() and pg_get_result(), despite this being the only
way (AFAIK) of getting specific error codes/text when something
goes wrong (in which event pg_query() just returns false).

The following is an extract from the offending code:

if ($db_type == 'mysql')
{
$qry_id = @mysql_query ($x_qry, $x_db_conn);

$g_db_err_no = mysql_errno ();
$g_db_err_str = mysql_error ();
}

else if ($db_type == 'postgres')
{
# Because pg_query() returns FALSE if the query fails, one must must
# use pg_send_query() and pg_get_result() to get the result handle.
#
# $qry_id = @pg_query ($x_db_conn, $x_qry);
#
if (! pg_send_query ($x_db_conn, $x_qry))
{
die ("pg_send_query");
}

!!!!!!!! QUERY OF LENGTH 64K OR MORE HANGS IN FOLLOWING pg_get_result() CALL

if (! ($qry_id = pg_get_result ($x_db_conn)))
{
die ("pg_get_result");
}

# jr.debug
error_log (" past pg_get_result()!\n", 3, '/tmp/hack.log');

# pg_result_error(), available from PHP v4.2.0+, like pg_result_status(),
# returns a better result then pg_last_error(), as the latter may be set
# by all kinds of internal calls and thus not reflect the app-level error.
#
$g_db_err_no = pg_result_status ($qry_id);
$g_db_err_str = pg_result_error ($qry_id);
}

else if ($db_type == 'mssql')
{

:::

Cheers

John R Ramsden (john_ramsden(at)sagitta-ps(dot)cam) <-- com not cam

Browse pgsql-general by date

  From Date Subject
Next Message val 2004-08-13 09:56:00 ODBC Driver Standards
Previous Message Ulrich Wisser 2004-08-13 07:22:58 heap errors - should I be worried?