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