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