Re: [HACKERS] SQLSTATE of notice PGresult

2010-09-22 Thread Tom Lane
Robert Haas writes: > On Wed, Sep 22, 2010 at 4:18 AM, Dmitriy Igrishin wrote: >> Okay, as Robert points, "0" code in successful messages seems as waste >> of bytes. But according to the documentation, "All messages emitted by the >> PostgreSQL server are assigned five-character error codes t

Re: [HACKERS] SQLSTATE of notice PGresult

2010-09-22 Thread Kevin Grittner
Robert Haas wrote: > I'm not even sure that it would be correct to say "All error > messages...", unless elog(ERROR, "can't happen") throws something > into that field. If it doesn't, it should. Probably 'XX000' (internal_error). -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hacker

Re: [HACKERS] SQLSTATE of notice PGresult

2010-09-22 Thread Robert Haas
On Wed, Sep 22, 2010 at 4:18 AM, Dmitriy Igrishin wrote: > Okay, as Robert points, "0" code in successful messages seems as waste > of bytes. But according to the documentation, "All messages emitted by the > PostgreSQL server are assigned five-character error codes that follow the > SQL > sta

Re: [HACKERS] SQLSTATE of notice PGresult

2010-09-22 Thread Dmitriy Igrishin
Hey all, Okay, as Robert points, "0" code in successful messages seems as waste of bytes. But according to the documentation, "All messages emitted by the PostgreSQL server are assigned five-character error codes that follow the SQL standard's conventions for "SQLSTATE" codes." - the first sen

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-25 Thread Euler Taveira de Oliveira
Tom Lane escreveu: > You didn't actually read what I said, did you? That patch will have > precisely zero effect on the OP's example. > Oh, I see your point. Didn't pay attention at the OP's example. I was only worried about the successful queries that doesn't return SQLSTATE but as you point out

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Tom Lane
Euler Taveira de Oliveira writes: > What I'm thinking is something like You didn't actually read what I said, did you? That patch will have precisely zero effect on the OP's example. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Euler Taveira de Oliveira
Tom Lane escreveu: > The real issue > here is that there are no SQLSTATEs assigned for any error/warning > conditions generated internally in libpq. > Did you mean successful conditions? Only warning/error conditions produce a SQLSTATE. > As far as this particular example goes, I think it's highl

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Euler Taveira de Oliveira
Robert Haas escreveu: > It appears to me that it already is documented. The very first > sentence of the documentation reads: > > Returns an individual field of an error report. > > And a few sentences later it says: > > NULL is returned if the PGresult is not an error or warning result > I'm

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Tom Lane
Robert Haas writes: > I suppose we could change the function to return 0 always when the > operation is not an error or warning report, rather than NULL, but > certainly we wouldn't want to include those bytes in *every* success > message, so they'd have to be something that the libpq inferred

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Robert Haas
On Tue, Aug 24, 2010 at 9:44 PM, Euler Taveira de Oliveira wrote: > Robert Haas escreveu: >> On Fri, Aug 20, 2010 at 11:05 AM, Euler Taveira de Oliveira >> wrote: >>> Dmitriy Igrishin escreveu:   /* NOT presents - NULL. Why not "0" ? */   const char* sqlstate = Pg::PQresultErrorFiel

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Euler Taveira de Oliveira
Robert Haas escreveu: > On Fri, Aug 20, 2010 at 11:05 AM, Euler Taveira de Oliveira > wrote: >> Dmitriy Igrishin escreveu: >>> /* NOT presents - NULL. Why not "0" ? */ >>> const char* sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE); >>> >> That's because the protocol doesn't set e

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-24 Thread Robert Haas
On Fri, Aug 20, 2010 at 11:05 AM, Euler Taveira de Oliveira wrote: > Dmitriy Igrishin escreveu: >>   /* NOT presents - NULL. Why not "0" ? */ >>   const char* sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE); >> > That's because the protocol doesn't set error field when the command > s

Re: [HACKERS] SQLSTATE of notice PGresult

2010-08-20 Thread Euler Taveira de Oliveira
Dmitriy Igrishin escreveu: > /* NOT presents - NULL. Why not "0" ? */ > const char* sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE); > That's because the protocol doesn't set error field when the command succeeded. IMHO it's an oversight (the documentation is correct but the code