6f8acf80012cff7e7db992c2d08b81ac82a832b5
[freeside.git] / install / 5.005 / DBD-Pg-1.22-fixvercmp / eg / notify_test.patch
1 diff -r --unified DBD-Pg-1.00/test.pl DBD-Pg-1.00.alex/test.pl
2 --- DBD-Pg-1.00/test.pl Sun May 27 10:10:13 2001
3 +++ DBD-Pg-1.00.alex/test.pl    Sun Jun 10 15:38:09 2001
4 @@ -40,7 +40,7 @@
5  my $dsn_main = "dbi:Pg:dbname=$dbmain";
6  my $dsn_test = "dbi:Pg:dbname=$dbtest";
7  
8 -my ($dbh0, $dbh, $sth);
9 +my ($dbh0, $dbh, $dbh1, $sth);
10  
11  #DBI->trace(3); # make your choice
12  
13 @@ -445,16 +445,56 @@
14  # end transaction
15  $dbh->{AutoCommit} = 1;
16  
17 +# compare large objects
18 +
19  ( $dbh->func($lobjId, 'lo_unlink') )
20      and print "\$dbh->func(lo_unlink) ...... ok\n"
21      or  print "\$dbh->func(lo_unlink) ...... not ok\n";
22  
23 -# compare large objects
24 -
25  ( $pgin cmp $buf and $pgin cmp $blob )
26      and print "compare blobs .............. not ok\n"
27      or  print "compare blobs .............. ok\n";
28  
29 +my $fd;
30 +( $fd=$dbh->func( 'getfd') )
31 +    and print "\$dbh->func(getfd) .......... ok\n"
32 +    or  print "\$dbh->func(getfd) .......... not ok\n";
33 +
34 +( $dbh->do( 'LISTEN test ') )
35 +    and print "\$dbh->do('LISTEN test') .... ok\n"
36 +    or  print "\$dbh->do('LISTEN test') .... not ok\n";
37 +
38 +( $dbh1 = DBI->connect("$dsn_test", '', '', { AutoCommit => 1 }) )
39 +    and print "DBI->connect (for notify)... ok\n"
40 +    or  die   "DBI->connect (for notify)... not ok: ", $DBI::errstr;
41 +
42 +# there should be no data for read on $fd , until we send a notify
43 +   
44 +    my $rout;
45 +    my $rin = '';
46 +    vec($rin,$fd,1) = 1;
47 +    my $nfound = select( $rout=$rin, undef, undef, 0);
48 +
49 +( $nfound==0 ) 
50 +    and print "select(\$fd) returns no data. ok\n"
51 +    or  die   "select(\$fd) returns no data. not ok\n";
52 +
53 +( $dbh1->do( 'NOTIFY test ') )
54 +    and print "\$dbh1->do('NOTIFY test') ... ok\n"
55 +    or  print "\$dbh1->do('NOTIFY test') ... not ok\n";
56 +
57 +    my $nfound = select( $rout=$rin, undef, undef, 1);
58 +
59 +( $nfound==1 ) 
60 +    and print "select(\$fd) returns data.... ok\n"
61 +    or  die   "select(\$fd) returns data.... not ok\n";
62 +
63 +my $notify_r;
64 +
65 +( $notify_r = $dbh->func('notifies') ) 
66 +    and print "\$dbh->func('notifies')...... ok\n"
67 +    or  die   "\$dbh->func('notifies')...... not ok\n";
68 +
69  ######################### disconnect and drop test database
70  
71  # disconnect
72 @@ -462,6 +502,10 @@
73  ( $dbh->disconnect )
74      and print "\$dbh->disconnect ........... ok\n"
75      or  die   "\$dbh->disconnect ........... not ok: ", $DBI::errstr;
76 +
77 +( $dbh1->disconnect )
78 +    and print "\$dbh1->disconnect .......... ok\n"
79 +    or  die   "\$dbh1->disconnect .......... not ok: ", $DBI::errstr;
80  
81  $dbh0->do("DROP DATABASE $dbtest");
82  $dbh0->disconnect;