Feature Requests: Browse | Submit New | Admin

[#28001] DBD-Pg: DBI::DatabaseHandle#do should support multiple queries.

Date:
2010-03-24 13:57
Priority:
3
Submitted By:
Chaker Nakhli (nakhli)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
DBD-Pg: DBI::DatabaseHandle#do should support multiple queries.

Detailed description
==== SUMMARY ====

DBI::DatabaseHandle#do should be able to run multiple queries for DBD-Pg as it is supported in the native Pg driver.
Currently, it fails with the following error:
ERROR: cannot insert multiple commands into a prepared

==== DETAILS ====

DBI::DatabaseHandle#do should *not* prepare queries and should allow executing multiple queries. The documentation states:
"(DatabaseHandle#do) goes straight to the DBD‘s implementation, and does *not* work like execute and
prepare.".

Pg sql, on which DBD-pg is based, supports multiple queries.

Code snippet:

require 'pg'
require 'dbd/pg'
require 'dbi'

# Pg Succeeds
PGconn.new({:host=>host,:user=>user,:password=>password,
:dbname=>dbname})
do |conn|
  conn.exec("select 1; select 1;")
end

# DBD-Pg Fails with: ERROR: cannot insert multiple commands into a prepared statement
DBI::connect("dbi:pg:database=#{dbname};host=#{host};",
user, password) do |dbh|
  dbh.do("select 1; select 1;")
end

Other Postgres connectors like Npgsql for .NET and PyGreSQL
for python also support multiple queries.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item