Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ DBISTATE_DECLARE;
#define TRACE_PQCMDSTATUS TRACE_XX "%sPQcmdStatus\n", THEADER_slow)
#define TRACE_PQCMDTUPLES TRACE_XX "%sPQcmdTuples\n", THEADER_slow)
#define TRACE_PQCONNECTDB TRACE_XX "%sPQconnectdb\n", THEADER_slow)
#define TRACE_PQCONNECTSTART TRACE_XX "%sPQconnectStart\n", THEADER_slow)
#define TRACE_PQCONNECTPOLL TRACE_XX "%sPQconnectPoll\n", THEADER_slow)
#define TRACE_PQCONSUMEINPUT TRACE_XX "%sPQconsumeInput\n", THEADER_slow)
#define TRACE_PQDB TRACE_XX "%sPQdb\n", THEADER_slow)
#define TRACE_PQENDCOPY TRACE_XX "%sPQendcopy\n", THEADER_slow)
Expand Down
35 changes: 34 additions & 1 deletion Pg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use 5.008001;

our %EXPORT_TAGS =
(
async => [qw($DBDPG_DEFAULT PG_ASYNC PG_OLDQUERY_CANCEL PG_OLDQUERY_WAIT)],
async => [qw($DBDPG_DEFAULT PG_ASYNC PG_OLDQUERY_CANCEL PG_OLDQUERY_WAIT PG_ASYNC_CONN_READ PG_ASYNC_CONN_WRITE)],
pg_limits => [qw($DBDPG_DEFAULT
PG_MIN_SMALLINT PG_MAX_SMALLINT PG_MIN_INTEGER PG_MAX_INTEGER PG_MAX_BIGINT PG_MIN_BIGINT
PG_MIN_SMALLSERIAL PG_MAX_SMALLSERIAL PG_MIN_SERIAL PG_MAX_SERIAL PG_MIN_BIGSERIAL PG_MAX_BIGSERIAL)],
Expand Down Expand Up @@ -151,6 +151,7 @@ use 5.008001;
# uncoverable branch false
if (!$methods_are_installed) {
DBD::Pg::db->install_method('pg_cancel');
DBD::Pg::db->install_method('pg_continue_connect');
DBD::Pg::db->install_method('pg_endcopy');
DBD::Pg::db->install_method('pg_error_field');
DBD::Pg::db->install_method('pg_getline');
Expand Down Expand Up @@ -3223,6 +3224,25 @@ the L</fetchrow_hashref> method.
Creates a copy of the database handle by connecting with the same parameters as the original
handle, then trying to merge the attributes. See the DBI documentation for complete usage.

=head3 B<pg_continue_connect>

$rc = $dbh->pg_continue_connect();

Continues an asychronous connect operation. See B<Asynchronous
Connect> below. After an asychronous connect was initiated, this
method must be called in a loop for as long as it returns either 1 or
2, indicating a desire to read or write data,
respectively. Afterwards, the next call to pg_continue_connect must
not take place until an indication that data can either be
read or written on the current pg_socket was obtained, eg, via
select.

The method returns -1 if no asynchronous connect was in progress, -2 to
indicate that an asynchronous connect failed and 0 if the connection
was successfully established.

The socket may have changed after each call to the method.

=head2 Database Handle Attributes

=head3 B<AutoCommit> (boolean)
Expand Down Expand Up @@ -4290,6 +4310,19 @@ as you don't need it anymore.
$count = $sth2->fetchall_arrayref()->[0][0];
}

=head3 Asynchronous Connect

Passing a true value for the attribute pg_async_connect to the DBI
connect method, eg,

$dbh = DBI->connect('dbi:Pg:...', $username, $password,
{ pg_async_connect => 1 });

starts an asynchronous connect. The B<pg_continue_connect> method must
be used afterwards to complete the connection establishment process. If
the attribute is present but its value is false, an ordinarty
synchronous connect will be done instead.

=head2 Array support

DBD::Pg allows arrays (as arrayrefs) to be passed in to both
Expand Down
11 changes: 11 additions & 0 deletions Pg.xs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ constant(name=Nullch)
PG_OLDQUERY_CANCEL = 2
PG_OLDQUERY_WAIT = 4

PG_ASYNC_CONN_READ = 1
PG_ASYNC_CONN_WRITE = 2

CODE:
if (0==ix) {
if (!name) {
Expand Down Expand Up @@ -847,6 +850,14 @@ _pg_type_info (type_sv=Nullsv)
ST(0) = sv_2mortal( newSViv( type_num ) );
}

int
pg_continue_connect(dbh)
SV* dbh
CODE:
RETVAL = pg_db_continue_connect(dbh);
OUTPUT:
RETVAL

void
pg_result(dbh)
SV * dbh
Expand Down
Loading