Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 23rd, 2005, 01:38 AM
John Ramsden
Guest
 
Posts: n/a
Default pg_get_result() hangs for query length > 65535

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@sagitta-ps.cam) <-- com not cam
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles