xref: /PHP-8.2/ext/pdo_firebird/tests/gh10908.phpt (revision fa751c7d)
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  MYSMALLINT SMALLINT,
26  MYINT INT,
27  MYCHAR CHAR(10),
28  MYBOOL BOOLEAN
29);
30EOT;
31$dbh->exec($sql);
32$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', 32767, 200000, 'azertyuiop', false);");
33
34function query_and_dump($dbh, $sql) {
35    foreach ($dbh->query($sql) as $row) {
36        print_r($row);
37        print("\n");
38    }
39}
40
41query_and_dump($dbh, "SELECT CODE   FROM gh10908"); // works fine
42query_and_dump($dbh, "SELECT ID     FROM gh10908"); // Used to "bus error"
43query_and_dump($dbh, "SELECT NUM    FROM gh10908"); // Used to "bus error"
44query_and_dump($dbh, "SELECT DBL    FROM gh10908"); // Used to "bus error"
45query_and_dump($dbh, "SELECT TS     FROM gh10908"); // Used to "bus error"
46query_and_dump($dbh, "SELECT MYBLOB FROM gh10908"); // Used to "bus error"
47query_and_dump($dbh, "SELECT *      FROM gh10908"); // Used to "bus error"
48
49query_and_dump($dbh, "SELECT CAST(NUM AS NUMERIC(9, 3)) FROM gh10908"); // works fine
50query_and_dump($dbh, "SELECT CAST(ID AS INTEGER)        FROM gh10908"); // works fine
51query_and_dump($dbh, "SELECT CAST(ID AS BIGINT)         FROM gh10908"); // Used to "bus error"
52
53echo "Did not crash\n";
54
55?>
56--CLEAN--
57<?php
58require 'testdb.inc';
59$dbh->exec("DROP TABLE gh10908");
60?>
61--EXPECT--
62Array
63(
64    [CODE] => ABC
65    [0] => ABC
66)
67
68Array
69(
70    [ID] => 1
71    [0] => 1
72)
73
74Array
75(
76    [NUM] => 12.340
77    [0] => 12.340
78)
79
80Array
81(
82    [DBL] => 1
83    [0] => 1
84)
85
86Array
87(
88    [TS] => 2023-03-24 17:39:00
89    [0] => 2023-03-24 17:39:00
90)
91
92Array
93(
94    [MYBLOB] => abcdefg
95    [0] => abcdefg
96)
97
98Array
99(
100    [ID] => 1
101    [0] => 1
102    [CODE] => ABC
103    [1] => ABC
104    [NUM] => 12.340
105    [2] => 12.340
106    [DBL] => 1
107    [3] => 1
108    [FLT] => 2
109    [4] => 2
110    [TS] => 2023-03-24 17:39:00
111    [5] => 2023-03-24 17:39:00
112    [MYDATE] => 2023-03-24
113    [6] => 2023-03-24
114    [MYTIME] => 17:39:00
115    [7] => 17:39:00
116    [MYBLOB] => abcdefg
117    [8] => abcdefg
118    [MYSMALLINT] => 32767
119    [9] => 32767
120    [MYINT] => 200000
121    [10] => 200000
122    [MYCHAR] => azertyuiop
123    [11] => azertyuiop
124    [MYBOOL] =>
125    [12] =>
126)
127
128Array
129(
130    [CAST] => 12.340
131    [0] => 12.340
132)
133
134Array
135(
136    [CAST] => 1
137    [0] => 1
138)
139
140Array
141(
142    [CAST] => 1
143    [0] => 1
144)
145
146Did not crash
147