DBD::Pg errstr method doesn't return full error messages
От | Vivek Khera |
---|---|
Тема | DBD::Pg errstr method doesn't return full error messages |
Дата | |
Msg-id | 15089.45167.298471.377749@onceler.kciLink.com обсуждение исходный текст |
Список | pgsql-general |
Hi, I'm using DBD::Pg version 0.98 with Postgres 7.1. I'm noticing that quite often on an error, the $dbh->errstr method doesn't return the full error. For example, if I have a table with a unique key constraint: CREATE TABLE urls ( url_id SERIAL PRIMARY KEY, msg_id integer NOT NULL REFERENCES msg_info(msg_id), url_link varchar(255) NOT NULL default '' ); and I do this insert: INSERT INTO urls (msg_id,url_link) VALUES (9,'http://www.kcilink.com/'); the second time I insert it, I get this on the psql command line: ERROR: Cannot insert a duplicate key into unique index urls_id_link However, if I use a perl module to do it, like this: my $sth = $dbh->prepare('INSERT INTO urls (msg_id,url_link) VALUES (?,?)'); if ($sth and $sth->execute($msgid,$url)) { ($urlid) = $dbh->selectrow_array("SELECT currval('urls_url_id_seq')"); } else { print $dbh->errstr(),"\n"; } where $msgid and $url are the same values above, I get this output: ERROR: Cannot i This makes it a bit difficult to distinguish between a hard error and simply a duplicate insert error, which I can handle in this app. Also, at other times, I get just "7" as the error message rather than the full message, making error reporting just a bit confusing. ;-) Do you know of any issues with $dbh->errstr that could be causing this? Any workarounds I might try?
В списке pgsql-general по дате отправления: