End Point Corporation
Services   |   Our Clients   |   Interchange   |   Ruby on Rails   |   PostgreSQL   |   Hosting   |   About Us   |   Contact
Tech News
End Point Home > Tech News
Tech News

DBD::Pg 1.48 Released
by Greg Sabino Mullane
April 14, 2006

Version 1.48 of DBD::Pg, the Perl DBI/PostgreSQL driver, has been released. The driver (which I maintain) can be found at your nearest CPAN mirror. Recent changes fix a number of bugs, both small and large, and include some important new features. Some of the biggest:

  • Default Execute Values
  • Dollar Quoting
  • Fork and Statement Handles
  • Quote Data Types
  • Overhaul of the do() Method
  • SIGNATURE File

Default Execute Values
An experimental new feature has been added to allow setting of "default" values by the execute() method. Currently, you can emulate sending a NULL by using an undefined value. In a similar way, you can now emulate sending a DEFAULT by using a special variable called $DBDPG_DEFAULT. So doing this:

$sth = $dbh->prepare("INSERT INTO foobar (a,b,c,d) VALUES (?,?,?,?)");
$sth->execute(123, $DBDPG_DEFAULT, undef, 'turtle');

is the equivalent of doing this from psql:

INSERT INTO foobar (a,b,c,d) VALUES (123, DEFAULT, NULL, 'turtle');

Dollar Quoting
PostgreSQL's new "dollar quoting" is now fully supported by DBD::Pg. This allows you to use your own custom delimiters to perform tasks such as defining functions, and releases you from worrying about escaping anything (e.g., quotes) inside of the function body. The entire internal parser of DBD::Pg had to be rewritten to handle the concept of dollar quoting.

Fork and Statement Handles
Explicit support for forking has been provided by ensuring that InactiveDestroy is honored by both $dbh and $sth. The latter was not checked before (but also never caused problems since it did not contain any persistent database information). Now that we are using server-side prepared statements, however, it becomes important to make sure that $sth is not destroyed too early, as it issues a DEALLOCATE on any prepared statements it has created.

Quote Data Types
The quote() function now fully supports passing in the data type for times when the default cannot be guessed by DBD::Pg.

Overhaul of the do() Method
The do() method was completely overhauled to make it smarter and more efficient. Because you have an option to pass parameters to the do method, we were previously scanning the statement for placeholders, preparing it, and executing it every time. Now, if do has no extra arguments, we do a quick and direct pg_exec on the spot. In particular, this greatly speeds up ill-written scripts that use do() inside tight loops instead of using prepare/execute like they should.

SIGNATURE File
This version now has a SIGNATURE file, which is a wonderful enhancement from Module::Signature. This allows you to cryptographically verify your DBD::Pg installation directory on the spot. It's also built into the test suite now so the "All tests passed" message shouldn't be expected unless Module::Signature is installed.

Recent Tech News Features
Recent Tech News Features
DBD::Pg 2.0.0 released
Better Git it in Your Soul
Bucardo: Replication for PostgreSQL
RailsConf 2007 Conference Report
Get Out of Technical Debt Now!
Red Hat Enterprise Linux 4 Security Report
Evangelizing Test-Driven Development
USPS changes the Web Tools Rate Calculator API
New edition of The Book of JavaScript reviewed
Interchange 5.4.2 released
Greg Sabino Mullane's PostgreSQL tips and how-to articles
Hardware Monitoring with Nagios on OpenBSD
YAPC::NA 2006 Conference Report
Practices of an Agile Developer Reviewed
Trouble with MySQL 4.1 under heavy load
Interchange 5.4.1 released
PostgreSQL Supports Two-Phase Commit
DBD::Pg 1.48 Released
Interchange 5.4 Released
PostgreSQL 8.1 Shows Database Progress
Red Hat Enterprise Linux 3 Update 3 Released
© 2008 End Point Corporation. 920 Broadway Suite 701, New York, NY 10010 USA | Tel +1 212-929-6923 or 1-888-351-3239 | Fax +1 212-929-6927