473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 (jo**********@sagitta-ps.cam) <-- com not cam
Jul 17 '05 #1
1 2469
"John Ramsden" wrote:
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 (jo**********@sagitta-ps.cam) <-- com not cam


Have you posted to a postgres newsgroup (if there is one, worth
checking)? Since you have not had a reply I venture a guess, based on
mysql. In mysql, you have a packet size variable that needs to be set
to a large value if the query result are big. There may be a similar
setting in postgres. My guess is that this relates to postgres and
not php.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-pg_get_r...ict138691.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=467219
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jonathan | last post by:
Hi I'm doing a project for school and wrote an applet that makes a socket connection to a server (smae host as webserver) that was setup for this project. In the applet there are 3 buttons and by...
3
by: Bob | last post by:
I'm currently updating one of our web sites and have encountered a strange problem. The page that is giving me the problem is written in ASP and hits a SQL 2K DB. When I click submit I have 4...
0
by: iqbal | last post by:
Hi, I have 2 sql servers (A and B) and have established a link between them using sp_addlinkedserver. I have created a table (test) on sql server A. I have created a view (test) on sql server B...
9
by: Christian Wetzig | last post by:
hi, i have a table with test_field of type "TEXT". when i do: select test_field from test where id=1; the connection (with psql) hangs and no output is received, so i have to kill psql. ...
14
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
0
by: Nathan | last post by:
This is a copy of a message at microsoft.public.dotnet.framework.clr: THE CODE: I'm using an HttpWebResponse object to send an HTTP POST to a Java server I have written and are running on the...
0
by: John Ramsden | last post by:
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...
36
by: James Harris | last post by:
Initial issue: read in an arbitrary-length piece of text. Perceived issue: handle variable-length data The code below is a suggestion for implementing a variable length buffer that could be used...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.