473,395 Members | 1,377 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,395 software developers and data experts.

Why would query return PGRES_NONFATAL_ERROR?

I'm using 7.3.2, invoke a small stored procedure via PQexec, and
PQresultStatus returns PGRES_NONFATAL_ERROR. I can find nothing in the docs
to help me understand what could cause this, and PQresultErrorMessage is
blank.

This is pretty rare; most of the time by far the stored procedure executes
and I get the correct result back. I have almost no clue about what's
different when the failure occurs. I did notice this last time that there
was a backend stuck in a state with a transaction open forever. Could that
be it? A write lock conflict?

I've gone into postgresql.conf and upped the logging info. Any clues as to
what I should be looking for?

The stored procedure in question returns a longint, and when getting any
kind of error indication I don't examine its results. Should I be going
ahead and using PQgetvalue after getting a non-fatal error???

I guess next I should look putting some debug code into the stored procedure
to log its progress...
--
Scott Ribe
sc********@killerbytes.com
http://www.killerbytes.com/
(303) 665-7007 voice
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
3 1834
I said:
Hmm ... PGRES_NONFATAL_ERROR is only used for reporting NOTICE messages
coming from the backend, and AFAICS such a result should never be
returned out of PQexec; it's only passed to the notice-message receiver.


Wait, forget that; it's based on looking at CVS tip code :-(

In 7.3 there is only one use of PGRES_NONFATAL_ERROR, and it's this:

ExecStatusType
PQresultStatus(const PGresult *res)
{
if (!res)
return PGRES_NONFATAL_ERROR;
return res->resultStatus;
}

So what you're seeing is a NULL PGresult pointer. (7.4 uses
PGRES_FATAL_ERROR for this case, which I think is saner.)

The most likely causes for a NULL result from PQexec would be
out-of-memory or failure to send the query due to communication
failure. Although PQresultErrorMessage can tell you nothing
(since there is no result), you should find something informative
in the connection's error status (PQerrorMessage).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
Scott Ribe <sc********@killerbytes.com> writes:
I'm using 7.3.2, invoke a small stored procedure via PQexec, and
PQresultStatus returns PGRES_NONFATAL_ERROR. I can find nothing in the docs
to help me understand what could cause this, and PQresultErrorMessage is
blank.
Hmm ... PGRES_NONFATAL_ERROR is only used for reporting NOTICE messages
coming from the backend, and AFAICS such a result should never be
returned out of PQexec; it's only passed to the notice-message receiver.
You say you're getting it back from PQexec? You *sure* your libpq is
7.3 vintage?
I've gone into postgresql.conf and upped the logging info. Any clues as to
what I should be looking for?


A NOTICE or WARNING sent to that client ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
> In 7.3 there is only one use of PGRES_NONFATAL_ERROR, and it's this:

ExecStatusType
PQresultStatus(const PGresult *res)
{
if (!res)
return PGRES_NONFATAL_ERROR;
return res->resultStatus;
}

So what you're seeing is a NULL PGresult pointer. (7.4 uses
PGRES_FATAL_ERROR for this case, which I think is saner.)
That gives me the start of an idea...
The most likely causes for a NULL result from PQexec would be
out-of-memory or failure to send the query due to communication
failure. Although PQresultErrorMessage can tell you nothing
(since there is no result), you should find something informative
in the connection's error status (PQerrorMessage).


I don't think there's any communication failure, since the app and server
are running on the same machine. But I'm using a pool of connections, so
perhaps some prior thread abused a connection and left it in a
non-functioning state. I'll have to take a close look at some of the error
handling, at least make sure that everything is logged by my app, and of
course get the connection's error status when I see PGRES_NONFATAL_ERROR.

Thanks.
--
Scott Ribe
sc********@killerbytes.com
http://www.killerbytes.com/
(303) 665-7007 voice
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4

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

Similar topics

0
by: Phil Powell | last post by:
I have a very simple mySqlQuery object that takes two parameters: 1) the string query 2) the db connection resource I tested and was certain everything is passing correctly (the string query...
0
by: Ryan Booz | last post by:
All... I'm having problems figuring out what pg_query() really returns when there is an error. The documentation says it returns "FALSE", however, when I specifically make a bad query (either...
8
by: Adrian Parker | last post by:
Hi. I would like to query a database, given several where clauses to refine my search, and return the value of one single field in the database. eg: I have a table that lists teachers. Their...
5
by: ~greg | last post by:
I have links on an index page like this: <a href="link" onclick="DoOnClick('link')"> page title </a> -where the DoOnClick("link") just adds a query part to the url before executing: ...
4
by: Bob Bedford | last post by:
We have no access to a mysql NG on my provider's server, so we ask here: We have a long query (long in text) with a UNION between 2 select. We have been informed that some times the query...
6
by: Steven D.Arnold | last post by:
I have a query which does not use column indexes that it should use. I have discovered some interesting behaviors of Postgres which may indicate a bug in the database's query planning. Take a...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
2
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.