From 81de0cb317e9e0a465eeb69ae43bd083a9c4f809 Mon Sep 17 00:00:00 2001 From: Salvador Ortiz Date: Fri, 25 Mar 2016 02:36:31 -0600 Subject: [PATCH] Adopt changed !enter-exectute + minor cleanup --- lib/DBDish/SQLite/StatementHandle.pm6 | 6 +----- lib/DBDish/mysql/Connection.pm6 | 6 ++---- lib/DBDish/mysql/StatementHandle.pm6 | 9 ++------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/DBDish/SQLite/StatementHandle.pm6 b/lib/DBDish/SQLite/StatementHandle.pm6 index 9eff5813..71d21d13 100644 --- a/lib/DBDish/SQLite/StatementHandle.pm6 +++ b/lib/DBDish/SQLite/StatementHandle.pm6 @@ -25,11 +25,7 @@ submethod BUILD(:$!conn!, :$!parent!, ) { } method execute(*@params) { - self!set-err( -1, - "Wrong number of arguments to method execute: got @params.elems(), expected $!param-count" - ) if @params != $!param-count; - - self!enter-execute; + self!enter-execute(@params.elems, $!param-count); for @params.kv -> $idx, $v { self!handle-error(sqlite3_bind($!statement_handle, $idx + 1, $v)); diff --git a/lib/DBDish/mysql/Connection.pm6 b/lib/DBDish/mysql/Connection.pm6 index b8b3bd20..000548a7 100644 --- a/lib/DBDish/mysql/Connection.pm6 +++ b/lib/DBDish/mysql/Connection.pm6 @@ -37,11 +37,9 @@ method prepare(Str $statement, *%args) { } method execute(Str $statement, *%args) { - my $sth = DBDish::mysql::StatementHandle.new( + DBDish::mysql::StatementHandle.new( :$!mysql_client, :parent(self), :$statement, :$!RaiseError, |%args - ); - LEAVE { $sth.finish if $sth }; - $sth.execute; + ).execute; } method mysql_insertid() { diff --git a/lib/DBDish/mysql/StatementHandle.pm6 b/lib/DBDish/mysql/StatementHandle.pm6 index 81b9a132..abcd3e4f 100644 --- a/lib/DBDish/mysql/StatementHandle.pm6 +++ b/lib/DBDish/mysql/StatementHandle.pm6 @@ -51,11 +51,7 @@ method !get-meta(MYSQL_RES $res) { method execute(*@params) { - self!set-err(-1, - "Wrong number of arguments to method execute: got @params.elems(), expected $!param-count" - ) if @params != $!param-count; - - self!enter-execute; + self!enter-execute(@params.elems, $!param-count); my $rows = 0; my $was-select = True; if $!param-count { my @Bufs; @@ -105,7 +101,6 @@ method execute(*@params) { ?? MYSQL_TYPE_BLOB !! MYSQL_TYPE_STRING; } } - #dd $stmt_buf.typed-pointer; @!out-bufs := @Bufs; $!binds = $stmt_buf; $!retlen = $lengths; @@ -118,7 +113,7 @@ method execute(*@params) { without self!handle-errors { .fail } $rows = $!stmt.mysql_stmt_affected_rows; return self!done-execute($rows, $!field_count > 0); - # Try the old path + # Try the fast unprepared path } elsif my $status = $!mysql_client.mysql_query($!statement) { # 0 means OK self!set-err($status, $!mysql_client.mysql_error).fail; }