xref: /PHP-7.1/ext/odbc/tests/bug73448.phpt (revision c2308d5d)
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==DONE==
41--EXPECTF--
42string(42) "/* non existent procedure xy */ execute xy"
43string(5) "37000"
44string(%d) "[Microsoft][%s][SQL Server]Could not find stored procedure 'xy'."
45
46string(58) "/* another erroneous query */ SELECT * FROM zwiebelfleisch"
47string(5) "S0002"
48string(%d) "[Microsoft][%s][SQL Server]Invalid object name 'zwiebelfleisch'."
49
50==DONE==
51