xref: /PHP-7.3/ext/odbc/tests/bug44618.phpt (revision c21e901b)
1--TEST--
2Bug #44618 (Fetching may rely on uninitialized data)
3--SKIPIF--
4<?php include 'skipif.inc'; ?>
5--FILE--
6<?php
7include __DIR__ . "/config.inc";
8$conn = odbc_connect($dsn, $user, $pass, SQL_CUR_USE_ODBC);
9
10odbc_exec($conn, "CREATE TABLE bug44618(ID INT, real1 REAL, text1 TEXT)");
11odbc_exec($conn, "INSERT INTO bug44618 VALUES (1, 10.0199995, 'testing 1,2,3')");
12
13$result = odbc_exec($conn, "SELECT * FROM bug44618");
14var_dump(odbc_fetch_array($result));
15$result = null;
16
17$result = odbc_exec($conn, "SELECT * FROM bug44618");
18odbc_fetch_into($result, $array);
19var_dump($array);
20$result = null;
21
22$result = odbc_exec($conn, "SELECT * FROM bug44618");
23odbc_fetch_row($result);
24var_dump(odbc_result($result, "text1"));
25$result = null;
26
27$result = odbc_exec($conn, "SELECT * FROM bug44618");
28odbc_result_all($result);
29$result = null;
30?>
31--CLEAN--
32<?php
33include __DIR__ . "/config.inc";
34$conn = odbc_connect($dsn, $user, $pass);
35odbc_exec($conn, "DROP TABLE bug44618");
36?>
37--EXPECTF--
38Warning: odbc_fetch_array(): Cannot get data of column #3 (retcode 100) in %s on line %d
39array(3) {
40  ["ID"]=>
41  string(1) "1"
42  ["real1"]=>
43  string(5) "10.02"
44  ["text1"]=>
45  bool(false)
46}
47
48Warning: odbc_fetch_into(): Cannot get data of column #3 (retcode 100) in %s on line %d
49array(3) {
50  [0]=>
51  string(1) "1"
52  [1]=>
53  string(5) "10.02"
54  [2]=>
55  bool(false)
56}
57
58Warning: odbc_result(): Cannot get data of column #3 (retcode 100) in %s on line %d
59bool(false)
60<table><tr><th>ID</th><th>real1</th><th>text1</th></tr>
61<tr><td>1</td><td>10.02</td><td></td></tr></table>
62Warning: odbc_result_all(): Cannot get data of column #3 (retcode 100) in %s on line %d
63