xref: /PHP-8.1/ext/pdo_firebird/tests/gh10908.phpt (revision 21e0305f)
1--TEST--
2GH-10908 (Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland)
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--ENV--
8LSAN_OPTIONS=detect_leaks=0
9--FILE--
10<?php
11
12require("testdb.inc");
13
14$sql = <<<EOT
15CREATE TABLE gh10908(
16  ID BIGINT NOT NULL,
17  CODE VARCHAR(60) NOT NULL,
18  NUM NUMERIC(18, 3),
19  DBL DOUBLE PRECISION,
20  FLT FLOAT,
21  TS TIMESTAMP,
22  MYDATE DATE,
23  MYTIME TIME,
24  MYBLOB BLOB,
25  MYBINARY BINARY(2),
26  MYVARBINARY VARBINARY(2),
27  MYSMALLINT SMALLINT,
28  MYINT INT,
29  MYCHAR CHAR(10),
30  MYVARCHAR VARCHAR(5),
31  MYBOOL BOOLEAN
32);
33EOT;
34$dbh->exec($sql);
35$dbh->exec("INSERT INTO gh10908 VALUES(1, 'ABC', 12.34, 1.0, 2.0, '2023-03-24 17:39', '2023-03-24', '17:39', 'abcdefg', 'ab', 'a', 32767, 200000, 'azertyuiop', 'ab', false);");
36
37function query_and_dump($dbh, $sql) {
38    foreach ($dbh->query($sql) as $row) {
39        print_r($row);
40        print("\n");
41    }
42}
43
44query_and_dump($dbh, "SELECT CODE   FROM gh10908"); // works fine
45query_and_dump($dbh, "SELECT ID     FROM gh10908"); // Used to "bus error"
46query_and_dump($dbh, "SELECT NUM    FROM gh10908"); // Used to "bus error"
47query_and_dump($dbh, "SELECT DBL    FROM gh10908"); // Used to "bus error"
48query_and_dump($dbh, "SELECT TS     FROM gh10908"); // Used to "bus error"
49query_and_dump($dbh, "SELECT MYBLOB FROM gh10908"); // Used to "bus error"
50query_and_dump($dbh, "SELECT *      FROM gh10908"); // Used to "bus error"
51
52query_and_dump($dbh, "SELECT CAST(NUM AS NUMERIC(9, 3)) FROM gh10908"); // works fine
53query_and_dump($dbh, "SELECT CAST(ID AS INTEGER)        FROM gh10908"); // works fine
54query_and_dump($dbh, "SELECT CAST(ID AS BIGINT)         FROM gh10908"); // Used to "bus error"
55
56echo "Did not crash\n";
57
58?>
59--CLEAN--
60<?php
61require 'testdb.inc';
62$dbh->exec("DROP TABLE gh10908");
63?>
64--EXPECT--
65Array
66(
67    [CODE] => ABC
68    [0] => ABC
69)
70
71Array
72(
73    [ID] => 1
74    [0] => 1
75)
76
77Array
78(
79    [NUM] => 12.340
80    [0] => 12.340
81)
82
83Array
84(
85    [DBL] => 1.000000
86    [0] => 1.000000
87)
88
89Array
90(
91    [TS] => 2023-03-24 17:39:00
92    [0] => 2023-03-24 17:39:00
93)
94
95Array
96(
97    [MYBLOB] => abcdefg
98    [0] => abcdefg
99)
100
101Array
102(
103    [ID] => 1
104    [0] => 1
105    [CODE] => ABC
106    [1] => ABC
107    [NUM] => 12.340
108    [2] => 12.340
109    [DBL] => 1.000000
110    [3] => 1.000000
111    [FLT] => 2.000000
112    [4] => 2.000000
113    [TS] => 2023-03-24 17:39:00
114    [5] => 2023-03-24 17:39:00
115    [MYDATE] => 2023-03-24
116    [6] => 2023-03-24
117    [MYTIME] => 17:39:00
118    [7] => 17:39:00
119    [MYBLOB] => abcdefg
120    [8] => abcdefg
121    [MYBINARY] => ab
122    [9] => ab
123    [MYVARBINARY] => a
124    [10] => a
125    [MYSMALLINT] => 32767
126    [11] => 32767
127    [MYINT] => 200000
128    [12] => 200000
129    [MYCHAR] => azertyuiop
130    [13] => azertyuiop
131    [MYVARCHAR] => ab
132    [14] => ab
133    [MYBOOL] =>
134    [15] =>
135)
136
137Array
138(
139    [CAST] => 12.340
140    [0] => 12.340
141)
142
143Array
144(
145    [CAST] => 1
146    [0] => 1
147)
148
149Array
150(
151    [CAST] => 1
152    [0] => 1
153)
154
155Did not crash
156