Feature Requests: Browse | Submit New | Admin

[#23142] Get last SQL?

Date:
2008-12-08 16:19
Priority:
2
Submitted By:
Pistos (pistos)
Assigned To:
Mike Pomraning (pilcrow)
Category:
None
State:
Open
Summary:
Get last SQL?

Detailed description
Sorry if there's already a way to do this, but if not, it would be great to be able to get the last SQL sent to a handle,
specifically the one that causes an error condition.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-10-26 04:03
Sender: Mike Pomraning

Attached patch implements and tests.
Date: 2009-10-25 03:14
Sender: Mike Pomraning

dbi-0.4.2 (2009-07-11) introduced DBI::DatabaseHandle#last_statement,
which is the SQL most recently #prepare()d, #execute()d or #do()ne
on the handle.

However, it seems to me that the intent of this request is best
served by additionally having any sth.execute() update the
last_statement attribute of its parent dbh.  E.g.,

  class DBI::StatementHandle
    def execute(*bindvars)
      self.dbh.instance_variable_set(:@last_statement, @query)
      ...
    end
  end

Note that StatementHandles right now (0.4.3) do not record the
queries they are asked to execute.

Reactions?

Attached Files:

Name Description Download
dbi-0.4.3-last_statement-rf-23142.patch sth.execute now sets parent dbh.last_statement Download

Changes:

Field Old Value Date By
File Added4783: dbi-0.4.3-last_statement-rf-23142.patch2009-10-26 04:03pilcrow
priority32009-10-25 03:14pilcrow
assigned_tonone2009-10-25 03:14pilcrow
assigned_toerikh2008-12-15 21:23erikh
category_id0.4.12008-12-15 21:23erikh
artifact_group_idDBI2008-12-15 21:23erikh
category_id0.4.02008-12-15 21:22erikh