On Thu, Aug 31, 2023 at 10:32 AM Andrew Dunstan <and...@dunslane.net> wrote: > #!/usr/bin/perl > > use strict; use warnings; > > use FFI::Platypus; > > my $ffi = FFI::Platypus->new(api=>1); > $ffi->lib("inst/lib/libpq.so"); > > > $ffi->type('opaque' => 'PGconn'); > $ffi->attach(PQconnectdb => [ 'string' ] => 'PGconn'); > $ffi->attach(PQfinish => [ 'PGconn' ] => 'void'); > > $ffi->type('opaque' => 'PGresult'); > $ffi->attach(PQexec => [ 'PGconn', 'string' ] => 'PGresult'); > $ffi->attach(PQgetvalue => [ 'PGresult', 'int', 'int' ] => 'string'); > > my $pgconn = PQconnectdb("dbname=postgres host=/tmp"); > my $res = PQexec($pgconn, "select count(*) from pg_class"); > my $count = PQgetvalue( $res, 0, 0); > > print "count: $count\n"; > > PQfinish($pgconn);
It looks very promising so far. How hard would it be for us to add this dependency? Mostly pinging build farm owners? I'm still on the fence, but the more I know about IPC::Run, the better the various let's-connect-directly-from-Perl options sound...