summaryrefslogtreecommitdiffstats
path: root/src/pl/plperl/sql/plperl_end.sql
blob: 90f49dc6f97249445cfd52e092bbf425806c141c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- test END block handling

-- Not included in the normal testing
-- because it's beyond the scope of the test harness.
-- Available here for manual developer testing.

DO $do$
	my $testlog = "/tmp/pgplperl_test.log";

	warn "Run test, then examine contents of $testlog (which must already exist)\n";
	return unless -f $testlog;

    use IO::Handle; # for autoflush
	open my $fh, '>', $testlog
		or die "Can't write to $testlog: $!";
    $fh->autoflush(1);

    print $fh "# you should see just 3 'Warn: ...' lines: PRE, END and SPI ...\n";
    $SIG{__WARN__} = sub { print $fh "Warn: @_" };
    $SIG{__DIE__}  = sub { print $fh "Die: @_" unless $^S; die @_ };

	END {
		warn "END\n";
		eval { spi_exec_query("select 1") };
		warn $@;
	}
    warn "PRE\n";

$do$ language plperlu;