Skip to content

Commit

Permalink
Set our own process environment since %*ENV<Path> is only working on …
Browse files Browse the repository at this point in the history
…child processes
  • Loading branch information
azawawi committed Nov 11, 2015
1 parent 497e727 commit 599e1dd
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions examples/pg.p6
@@ -1,18 +1,20 @@
#!/usr/bin/env perl6

use v6;

use lib 'lib';
use DBIish;

BEGIN {
# Windows support
if $*DISTRO.is-win {
# libpq.dll on windows depends on libeay32.dll which in this path
my constant PG-HOME = 'C:\Program Files\PostgreSQL\9.3';
%*ENV<Path> ~= (PG-HOME).fmt( ';%s\bin' );
%*ENV<DBIISH_PG_LIB> = (PG-HOME).fmt( '%s\lib\libpq.dll' );
}
use NativeCall;

# Windows support
if $*DISTRO.is-win {
# libpq.dll on windows depends on libeay32.dll which in this path
my constant PG-HOME = 'C:\Program Files\PostgreSQL\9.3';
my $path = sprintf( 'Path=%s;%s\bin', %*ENV<Path>, PG-HOME );
%*ENV<DBIISH_PG_LIB> = (PG-HOME).fmt( '%s\lib\libpq.dll' );

# Since %*ENV<Path> = ... does not actually own process environment
# Weird magic but needed atm :)
sub _putenv(Str) is native('msvcrt') { ... }
_putenv( $path);
}

my $dbh = DBIish.connect("Pg", :database<postgres>, :user<postgres>, :password<sa>, :RaiseError);
Expand Down

0 comments on commit 599e1dd

Please sign in to comment.