I spend many hours tracking down a segfault in a perl script that made a DBI connection to a PostgreSQL 7.4 server. I'm posting this just to raise the awareness level of a problem that hasn't been addressed so other people don't have to take the time I did.
Fetching values of some esoteric types causes a null pointer dereference. You can see this yourself by running SELECT conkey FROM pg_constraint if you have some sort of constraint to fetch. The fix is either wait for a new version of DBD::Pg or manually cast the type to something that is handled. SELECT array_to_string(conkey,' ') FROM pg_constraint works.
Here's a list of types from 7.4 that if encountered will break DBD::Pg <= 1.31.
_line, _circle, _money, _bool, _bytea, _char, _name, _int2, _int2vector, _int4, _regproc, _text, _oid, _tid, _xid, _cid, _oidvector, _bpchar, _varchar, _int8, _point, _lseg, _path, _box, _float4, _float8, _abstime, _reltime, _tinterval, _polygon, _aclitem, _macaddr, _inet, _cidr, _timestamp, _date, _time, _timestamptz, _interval, _numeric, _timetz, _bit, _varbit, _refcursor, _regprocedure, _regoper, _regoperator, _regclass, _regtype, anyelement
The following patch also works to fix the null-pointer bug if you felt like doing that as well.
diff -u DBD-Pg-1.31a/dbdimp.c DBD-Pg-1.31b/dbdimp.c --- DBD-Pg-1.31a/dbdimp.c 2003-10-27 13:57:02.000000000 -0600 +++ DBD-Pg-1.31b/dbdimp.c 2004-01-02 20:43:51.000000000 -0600 @@ -1028,7 +1028,9 @@ pg_type = PQftype(imp_sth->result, i); type_info = pg_type_data(pg_type); - + if (dbis->debug >= 2) + PerlIO_printf(DBILOGFP, "pg_type %d ty +pe_info %d\n", pg_type, type_info == NULL); + if (type_info) type_info->dequote(value, &value_len); + /* dequote in place */ else @@ -1036,7 +1038,7 @@ sv_setpvn(sv, value, value_len); - if ((type_info->type_id == BPCHAROID) && chopb +lanks) { + if (type_info && (type_info->type_id == BPCHAR +OID) && chopblanks) { p = SvEND(sv); len = SvCUR(sv); while(len && *--p == ' ')
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Null pointer dereference in DBD::Pg 1.31 with PostgreSQL 7.4
by DapperDan (Pilgrim) on Jan 03, 2004 at 16:33 UTC | |
|
Re: Null pointer dereference in DBD::Pg 1.31 with PostgreSQL 7.4
by Courage (Parson) on Jan 03, 2004 at 14:18 UTC |