xref: /PHP-5.6/ext/sybase_ct/tests/bug22403.phpt (revision 6218d2d9)
1--TEST--
2Sybase-CT bug #22403 (crash when executing a stored procedure without parameters)
3--SKIPIF--
4<?php require('skipif.inc'); ?>
5--FILE--
6<?php
7/* This file is part of PHP test framework for ext/sybase_ct
8 *
9 * $Id$
10 */
11
12  require('test.inc');
13
14  $db= sybase_connect_ex();
15  sybase_set_message_handler('sybase_msg_handler');
16  error_reporting(error_reporting() & !E_NOTICE);       // Suppress notices
17
18  // Check if stored procedure already exists
19  $sp_name= 'phpt_bug22403';
20  var_dump(sybase_select_db(TEMPDB, $db));
21  if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
22    echo "Stored procedure {$sp_name} not found, creating\n";
23    var_dump(sybase_query('
24      create proc '.$sp_name.' (@param int)
25      as
26      begin
27        select @param
28        select @param + 1
29        return @param
30      end
31    '));
32  } else {
33    echo "Stored procedure {$sp_name} found, using\n";
34    var_dump(TRUE);
35  }
36
37  // These don't work
38  var_dump(sybase_select_ex($db, 'exec '.$sp_name));
39  var_dump(sybase_select_ex($db, 'exec '.$sp_name.' "foo"'));
40  var_dump(sybase_select_ex($db, 'exec does_not_exist'));
41
42  // These do
43  var_dump(sybase_select_ex($db, 'exec '.$sp_name.' NULL'));
44  var_dump(sybase_select_ex($db, 'exec '.$sp_name.' 1'));
45
46  // Clean up after ourselves
47  var_dump(sybase_query('drop proc '.$sp_name));
48
49  sybase_close($db);
50?>
51--EXPECTF--
52bool(true)
53Stored procedure %s
54bool(true)
55>>> Query: exec %s
56*** Caught Sybase Server Message #201 [Severity 16, state 2] at line 0
57    %s
58<<< Return: boolean
59bool(false)
60>>> Query: exec %s "foo"
61*** Caught Sybase Server Message #257 [Severity 16, state 1] at line 0
62    %s
63<<< Return: boolean
64bool(false)
65>>> Query: exec does_not_exist
66*** Caught Sybase Server Message #2812 [Severity 16, state %d] at line 1
67    %s
68<<< Return: boolean
69bool(false)
70>>> Query: exec %s NULL
71<<< Return: resource
72array(1) {
73  [0]=>
74  array(1) {
75    ["computed"]=>
76    NULL
77  }
78}
79>>> Query: exec %s 1
80<<< Return: resource
81array(1) {
82  [0]=>
83  array(1) {
84    ["computed"]=>
85    int(1)
86  }
87}
88bool(true)
89