mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
99 stars 46 forks source link

Can't dup: Bad file descriptor (Windows only) #40

Closed bgilly1 closed 7 years ago

bgilly1 commented 7 years ago

Steps to reproduce the behavior

use Mojo::Pg; use Data::Dumper; use feature 'say'; use warnings; use strict;

my $pg = Mojo::Pg->new('postgresql://<user>:<pass>@<host>/<db>'); $pg = $pg->options({AutoCommit => 1, RaiseError => 1});

my $db = $pg->db; my $dbh = $db->dbh; say $dbh->{'pg_socket'}; #returns file no. say $dbh->func('getfd'); #deprecated but still returns the same file no. say Dumper tied %$dbh; my $pubsub = Mojo::Pg::PubSub->new(pg => $pg, dbh => $dbh); $pubsub->listen(foo => sub {});

Expected behavior

Should open $dbh->{'pg_socket'} as a handle in Database.pm

Here's the code it's trying to run in Database.pm

open $self->{handle}, '<&', $dbh->{pg_socket} or die "Can't dup: $!"; #line 148

Actual behavior

Can't dup: Bad file descriptor at C:/Strawberry/perl/site/lib/Mojo/Pg/Database.pm line 148. Use of uninitialized value in delete at C:/Strawberry/perl/site/lib/Mojo/Reactor/Poll.pm line 91.

Works on Linux though.

kraih commented 7 years ago

I've tried to fix this but failed, therefore i'm afraid Windows Perl remains unsupported. https://github.com/kraih/mojo-pg/commit/dd12ad597ff46e352926324b42c3ccea654f8b3d

bgilly1 commented 7 years ago

Thanks for taking a run at it 👍