prepare v2.2.3
[m6w6/ext-pq] / tests / cancel001.phpt
1 --TEST--
2 cancel
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN);
12 try {
13 $c->exec("SET lc_messages TO 'C'");
14 } catch (pq\Exception $e) {
15 // no not fail if we are not superuser
16 }
17
18 $x = new pq\Cancel($c);
19
20 $c->execAsync("SELECT pg_sleep(10)");
21
22 $x->cancel();
23
24 var_dump($c === $x->connection);
25 var_dump($c->getResult());
26 printf("%s\n", $c->errorMessage);
27 ?>
28 DONE
29 --EXPECTF--
30 Test
31 bool(true)
32 object(pq\Result)#%d (9) {
33 ["status"]=>
34 int(7)
35 ["statusMessage"]=>
36 string(11) "FATAL_ERROR"
37 ["errorMessage"]=>
38 string(47) "ERROR: canceling statement due to user request"
39 ["diag"]=>
40 array(17) {
41 ["severity"]=>
42 string(5) "ERROR"
43 ["sqlstate"]=>
44 string(5) "57014"
45 ["message_primary"]=>
46 string(39) "canceling statement due to user request"
47 ["message_detail"]=>
48 NULL
49 ["message_hint"]=>
50 NULL
51 ["statement_position"]=>
52 NULL
53 ["internal_position"]=>
54 NULL
55 ["internal_query"]=>
56 NULL
57 ["context"]=>
58 NULL
59 ["schema_name"]=>
60 NULL
61 ["table_name"]=>
62 NULL
63 ["column_name"]=>
64 NULL
65 ["datatype_name"]=>
66 NULL
67 ["constraint_name"]=>
68 NULL
69 ["source_file"]=>
70 string(10) "postgres.c"
71 ["source_line"]=>
72 string(4) "%d"
73 ["source_function"]=>
74 string(17) "ProcessInterrupts"
75 }
76 ["numRows"]=>
77 int(0)
78 ["numCols"]=>
79 int(0)
80 ["affectedRows"]=>
81 int(0)
82 ["fetchType"]=>
83 int(0)
84 ["autoConvert"]=>
85 int(65535)
86 }
87 ERROR: canceling statement due to user request
88 DONE