xref: /PHP-8.2/ext/odbc/tests/bug73448.phpt (revision b5a14e6c)
1--TEST--
2Bug #73448 odbc_errormsg returns trash, always 513 bytes
3--EXTENSIONS--
4odbc
5--SKIPIF--
6<?php include 'skipif.inc'; ?>
7--FILE--
8<?php
9
10include 'config.inc';
11
12$conn = odbc_connect($dsn, $user, $pass);
13
14$sqlCommandList = array(
15    "/* empty batch is without error */",
16    "/* non existent procedure xy */ execute xy",
17    "/* empty batch,error message is not empty */",
18    "/* valid select with result */ select * from sys.sysobjects",
19    "/* another erroneous query */ SELECT * FROM zwiebelfleisch",
20    "/* valid select with result */ select * from sys.sysobjects",
21);
22
23foreach ($sqlCommandList as $exampleNumber => $sql) {
24    $r = @odbc_exec($conn, $sql);
25
26    if (false === $r) {
27        $e = odbc_errormsg($conn);
28        $n = odbc_error($conn);
29
30        var_dump($sql, $n, $e);
31        echo "\n";
32    }
33
34    if ($r) {
35        odbc_free_result($r);
36    }
37
38}
39
40odbc_close($conn);
41?>
42--EXPECTF--
43string(42) "/* non existent procedure xy */ execute xy"
44string(5) "37000"
45string(%d) "[Microsoft][%s][SQL Server]Could not find stored procedure 'xy'."
46
47string(58) "/* another erroneous query */ SELECT * FROM zwiebelfleisch"
48string(5) "S0002"
49string(%d) "[Microsoft][%s][SQL Server]Invalid object name 'zwiebelfleisch'."
50
51