EV-MariaDB

 view release on metacpan or  search on metacpan

lib/EV/MariaDB.pm  view on Meta::CPAN

callback convention is C<($result, $error)>: on success C<$error> is
C<undef>; on failure C<$result> is C<undef> and C<$error> contains the
error message.

Methods divide into two scheduling classes:

=over 4

=item B<Queueable>

C<query> can be called at any time the object is alive — before connect
completes, while a utility op is running, or while other queries are
already in flight. Calls are pipelined and their callbacks fire in
FIFO order.

=item B<Exclusive>

Every other async method (C<prepare>, C<execute>, C<close_stmt>,
C<stmt_reset>, C<ping>, C<select_db>, C<change_user>,
C<reset_connection>, C<set_charset>, C<commit>, C<rollback>,
C<autocommit>, C<query_stream>, C<close_async>, C<send_long_data>)

lib/EV/MariaDB.pm  view on Meta::CPAN


Resets a prepared statement (clears errors, unbinds parameters)
without closing it. Croaks
C<"statement handle is no longer valid (connection was reset)"> on a
handle invalidated by C<reset>/C<reset_connection>/C<change_user>.

=head2 ping

    $m->ping(sub { my ($ok, $err) = @_ });

Checks if the connection is alive.

=head2 select_db

    $m->select_db($dbname, sub { my ($ok, $err) = @_ });

Changes the default database. The new name is cached so a subsequent
C<reset> reconnects to it; the cache is rolled back if the operation
fails.

=head2 change_user

t/14_new_features.t  view on Meta::CPAN

        fail("fork safety: fork failed: $!");
        EV::break;
        return;
    }
    if ($pid == 0) {
        # child: just exit — DESTROY should skip mysql_close
        exit 0;
    }
    # parent: wait for child, then verify connection still works
    waitpid($pid, 0);
    $m->q("select 'alive'", sub {
        my ($r, $e) = @_;
        ok(!$e && $r->[0][0] eq 'alive', 'fork safety: parent connection survives child exit');
        EV::break;
    });
});

# utf8 option: text query results get UTF-8 flag
with_mariadb(utf8 => 1, charset => 'utf8mb4', cb => sub {
    $m->q("select 'hello', _binary'raw'", sub {
        my ($r, $e, $f) = @_;
        ok(!$e, 'utf8 option: query ok');
        ok(utf8::is_utf8($r->[0][0]), 'utf8 option: text column has UTF-8 flag');



( run in 1.746 second using v1.01-cache-2.11-cpan-99c4e6809bf )