Skip to content

Commit

Permalink
Adopt changed !enter-exectute + minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
salortiz committed Mar 25, 2016
1 parent 5dea4e4 commit 81de0cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
6 changes: 1 addition & 5 deletions lib/DBDish/SQLite/StatementHandle.pm6
Expand Up @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions lib/DBDish/mysql/Connection.pm6
Expand Up @@ -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() {
Expand Down
9 changes: 2 additions & 7 deletions lib/DBDish/mysql/StatementHandle.pm6
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 81de0cb

Please sign in to comment.