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