1
1
--TEST--
2
- Bug GH-15432 (Heap corruption when querying a vector)
2
+ Bug GH-15432 (Heap corruption when querying a vector/PHP crashes when processing a MySQL DB query with a new Vector format introduced in MySQL 9.0 )
3
3
--EXTENSIONS--
4
4
mysqli
5
5
--SKIPIF--
@@ -16,9 +16,49 @@ if ($link->server_version < 90000 || $link->server_version >= 10_00_00) {
16
16
--FILE--
17
17
<?php
18
18
require 'connect.inc ' ;
19
+
20
+ mysqli_report (MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT );
21
+
19
22
$ link = my_mysqli_connect ($ host , $ user , $ passwd , $ db , $ port , $ socket );
20
- var_dump ($ link ->query ('SELECT STRING_TO_VECTOR("[1.05, -17.8, 32]") ' ));
23
+
24
+ $ expected = '00000040000040400000a040 ' ;
25
+
26
+ mysqli_query ($ link , "DROP TABLE IF EXISTS test " );
27
+ mysqli_query ($ link , "CREATE TABLE test(vectorfield VECTOR) " );
28
+ mysqli_query ($ link , 'INSERT INTO test VALUES (TO_VECTOR("[2, 3, 5]")) ' );
29
+
30
+ // Textual protocol
31
+ $ result = mysqli_query ($ link , "SELECT vectorfield FROM test " )->fetch_column ();
32
+ $ value = bin2hex ($ result );
33
+ if ($ value !== $ expected ) {
34
+ printf ("[001] Expecting %s/%s, got %s/%s \n" ,
35
+ gettype ($ expected ), $ expected ,
36
+ gettype ($ value ), $ value );
37
+ }
38
+
39
+ // Binary protocol
40
+ $ result = $ link ->execute_query ("SELECT vectorfield FROM test " )->fetch_column ();
41
+ $ value = bin2hex ($ result );
42
+ if ($ value !== $ expected ) {
43
+ printf ("[002] Expecting %s/%s, got %s/%s \n" ,
44
+ gettype ($ expected ), $ expected ,
45
+ gettype ($ value ), $ value );
46
+ }
47
+
48
+ // Testing inverse to make sure the value hasn't been changed
49
+ $ expected = '[2.00000e+00,3.00000e+00,5.00000e+00] ' ;
50
+ $ result = $ link ->execute_query ("SELECT VECTOR_TO_STRING(0x " . $ value .") " )->fetch_column ();
51
+ if ($ result !== $ expected ) {
52
+ printf ("[002] Expecting %s/%s, got %s/%s \n" ,
53
+ gettype ($ expected ), $ expected ,
54
+ gettype ($ result ), $ result );
55
+ }
56
+
57
+ echo "OK " ;
58
+ ?>
59
+ --CLEAN--
60
+ <?php
61
+ require_once 'clean_table.inc ' ;
21
62
?>
22
- --EXPECTF--
23
- Warning: mysqli::query(): Unknown type 242 sent by the server. Please send a report to the developers in %s on line %d
24
- bool(false)
63
+ --EXPECT--
64
+ OK
0 commit comments