… | |
… | |
599 | |
599 | |
600 | Last not least, while the abovew case studies show some difficult |
600 | Last not least, while the abovew case studies show some difficult |
601 | examples, let's look at a more typical easy case, L<DBD::SQLite>. |
601 | examples, let's look at a more typical easy case, L<DBD::SQLite>. |
602 | |
602 | |
603 | Practically all work is done by calling C<_sqlite_exec> in F<dbdimp.c>, so |
603 | Practically all work is done by calling C<_sqlite_exec> in F<dbdimp.c>, so |
604 | other than providing the file and adding |
604 | other than copying F<perlmulticore.h> into the source tree and adding |
605 | |
605 | |
606 | #include "perlmulticore.h" |
606 | #include "perlmulticore.h" |
607 | |
607 | |
608 | To that file, you only need to change the call to C<sqlite3_exec> in |
608 | to that file, you only need to change the call to C<sqlite3_exec> in |
609 | that function by sandwiching it between C<perlinterp_release> and |
609 | that function by sandwiching it between C<perlinterp_release> and |
610 | C<perlinterp_acquire>: |
610 | C<perlinterp_acquire>: |
611 | |
611 | |
|
|
612 | int |
|
|
613 | _sqlite_exec(pTHX_ SV *h, sqlite3 *db, const char *sql) |
|
|
614 | { |
|
|
615 | int rc; |
|
|
616 | char *errmsg; |
|
|
617 | |
612 | perlinterp_release (); // added |
618 | + perlinterp_release (); |
613 | rc = sqlite3_exec(db, sql, NULL, NULL, &errmsg); |
619 | rc = sqlite3_exec(db, sql, NULL, NULL, &errmsg); |
614 | perlinterp_acquire (); // added |
620 | + perlinterp_acquire (); |
|
|
621 | ... |
615 | |
622 | |
616 | To also catch the database opening phase, the same needs to be done for |
623 | To also catch the database opening phase, the same needs to be done for |
617 | C<_sqlite_open>: |
624 | C<_sqlite_open>: |
618 | |
625 | |
619 | _sqlite_open(pTHX_ SV *dbh, const char *dbname, sqlite3 **db, int flags, int extended) |
626 | _sqlite_open(pTHX_ SV *dbh, const char *dbname, sqlite3 **db, int flags, int extended) |
620 | { |
627 | { |
621 | int rc; |
628 | int rc; |
622 | perlinterp_release (); // added |
629 | + perlinterp_release (); |
623 | if (flags) { |
630 | if (flags) { |
624 | rc = sqlite3_open_v2(dbname, db, flags, NULL); |
631 | rc = sqlite3_open_v2(dbname, db, flags, NULL); |
625 | } else { |
632 | } else { |
626 | rc = sqlite3_open(dbname, db); |
633 | rc = sqlite3_open(dbname, db); |
627 | } |
634 | } |
628 | perlinterp_acquire (); // added |
635 | + perlinterp_acquire (); |
629 | if ( rc != SQLITE_OK ) { |
636 | if ( rc != SQLITE_OK ) { |
630 | |
637 | |
631 | And that is it. |
638 | And that is it. |
632 | |
639 | |
633 | =head1 SEE ALSO |
640 | =head1 SEE ALSO |
634 | |
641 | |