Re: Errors/Warnings missing line numbers
Joel Richard <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.dbdpg |
|---|---|
| Message-ID | <[email protected]> |
Hi Greg,
I'm capable of understanding only some C source for DBD::Pg, so for
me to debug this further would be fruitless. But I've been reading
over it (several times) and what I remember from my college days is
sort of coming back to me...
First, not to sound like a broken record, I still don't see the line
number appearing on the error. I tried doing this on/around line 238:
if (err[strlen(err)] == '\n')
err[strlen(err)] = 'X';
And, no X was appearing in the output. So here's some trace output
(level 4), if that helps. It seems to indicate that there's still a
'\n' at the end of "error_msg" (and presumably at the end of "err")
and it's not getting removed. I think you'll see it just before
the !! (about 20 lines down). Read on for my theory of what's going
on...
# perl ~/test.pl
DBI::db=HASH(0x185452c) trace level set to 0x0/4 (DBI @ 0x0/0)
in DBI 1.50-nothread (pid 9778)
Note: perl is running without the recommended perl -w option
-> selectall_arrayref for DBD::Pg::db (DBI::db=HASH(0x1831b6c)
~0x185452c 'select foo from bar')
1 -> prepare for DBD::Pg::db (DBI::db=HASH(0x185452c)~INNER 'select
foo from bar' undef)
dbih_setup_handle(DBI::st=HASH(0x1854664)=>DBI::st=HASH
(0x18547c0), DBD::Pg::st, 1854670, Null!)
dbih_make_com(DBI::db=HASH(0x185452c), 518b70, DBD::Pg::st, 172,
0) thr#0
dbdpg: dbd_st_prepare (select foo from bar)
dbdpg: dbd_st_split_statement
1 <- prepare= DBI::st=HASH(0x1854664) at test.pl line 6
dbdpg: dbd_st_execute
dbdpg: _sqlstate
dbdpg: pg_error (ERROR: relation "bar" does not exist
) number=7
dbdpg: ERROR: relation "bar" does not exist
error 7 recorded: ERROR: relation "bar" does not exist
!! ERROR: 7 'ERROR: relation "bar" does not exist
' (err#0)
<- selectall_arrayref= undef at test.pl line 6
DBD::Pg::db selectall_arrayref failed: ERROR: relation "bar" does
not exist
-> DESTROY for DBD::Pg::st (DBI::st=HASH(0x18547c0)~INNER)
dbdpg: dbd_st_destroy
ERROR: 7 'ERROR: relation "bar" does not exist
' (err#0)
<- DESTROY= undef
! -> DESTROY for DBD::Pg::db (DBI::db=HASH(0x185452c)~INNER)
dbdpg: dbd_db_disconnect
dbdpg: dbd_db_rollback (AutoCommit is 1) (BegunWork is 0)
dbdpg: dbd_db_destroy
ERROR: 7 'ERROR: relation "bar" does not exist
' (err#0)
! <- DESTROY= undef during global destruction
Although it seems that the line of code -should- be removing the \n,
it's not. The only thing that comes to mind is that the error_msg
string is padded with some \0s and the last character is already a
null and the replacement you are doing is in fact doing nothing.
(That's my best guess. :)
What do you think?
--Joel
On Jun 7, 2006, at 10:50 PM, Greg Sabino Mullane wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>> I installed DBD::Pg 1.49 but I am still not seeing line numbers
>> reported with errors or warnings from DBD::Pg... Is it really
>> DBD::Pg or do I need a later version of something else?
>
> You need a version of DBD::Pg that does what I *meant* to do, not
> what I *actually* did in the last version. :) Specifically, search
> for the sring "final newline" in dbdimp.c and change the next
> two lines to this:
>
> if (err[strlen(err)-1] == '\n')
> err[strlen(err)-1] = '\0';
>
> Very sorry about that. Serves me right for not making a proper
> test for it in the test suite. Thank you for following up on this.
>
> - --
> Greg Sabino Mullane greg-738XdyZ4GzZWk0Htik3J/[email protected]
> PGP Key: 0x14964AC8 200606072246
> http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
>
> -----BEGIN PGP SIGNATURE-----
>
> iD8DBQFEh4/KvJuQZxSWSsgRAt9rAJ99AgA3FCEW4yGEk14yyvkErSTiFwCg2C0u
> 2IBy/DBkHqtm1943eJK66cY=
> =tPCt
> -----END PGP SIGNATURE-----
>
>