From: Ulf Wendel Date: Wed, 9 Sep 2009 17:10:29 +0000 (+0000) Subject: Tests for http://bugs.php.net/bug.php?id=49357 (libmysql only) . The simple fix sugge... X-Git-Tag: php-5.4.0alpha1~191^2~2677 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86481c0ac00021c2907927a9c17c437c0631d772;p=php Tests for http://bugs.php.net/bug.php?id=49357 (libmysql only) . The simple fix suggested in the bug system is not good enough, therefore no fix yet. --- diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt new file mode 100644 index 0000000000..7d7ef79f30 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt @@ -0,0 +1,141 @@ +--TEST-- +mysqli_stmt_fetch - geometry / spatial types +--SKIPIF-- + +--FILE-- +type != MYSQLI_TYPE_GEOMETRY) { + printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); + } + + $num = 0; + $rows = array(); + while (true === mysqli_stmt_fetch($stmt)) { + $rows[] = array('id' => $id, 'label' => $bind_res); + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 17, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + return false; + } + mysqli_stmt_close($stmt); + + foreach ($rows as $row) { + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $new_id = $row['id'] + 10; + if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) { + printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + mysqli_stmt_close($stmt); + + if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", + $new_id))) { + printf("[%04d] [%d] %s\n", $offset + 14, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row_normal = mysqli_fetch_assoc($res_normal)) { + printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($row_normal['label'] != $row['label']) { + printf("[%04d] PS and non-PS return different data.\n", $offset + 16); + return false; + } + mysqli_free_result($res_normal); + } + + return true; + } + + func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20); + func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40); + func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60); + func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); + func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); + + mysqli_close($link); + print "done!"; +?> +--CLEAN-- + +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt new file mode 100644 index 0000000000..8a40e833a0 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt @@ -0,0 +1,143 @@ +--TEST-- +mysqli_stmt_get_result - geometry / spatial types +--SKIPIF-- + +--FILE-- +type != MYSQLI_TYPE_GEOMETRY) { + printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); + } + + $num = 0; + while ($row = mysqli_fetch_assoc($res)) { + $bind_res = &$row['label']; + + if (!$stmt2 = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + + $id = $row['id'] + 10; + if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) { + printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + + if (!mysqli_stmt_execute($stmt2)) { + printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + mysqli_stmt_close($stmt2); + + if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", + $row['id'] + 10))) { + printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row_normal = mysqli_fetch_assoc($res_normal)) { + printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($row_normal['label'] != $bind_res) { + printf("[%04d] PS and non-PS return different data.\n", $offset + 17); + return false; + } + mysqli_free_result($res_normal); + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + mysqli_free_result($res); + mysqli_stmt_close($stmt); + return false; + } + mysqli_free_result($res); + mysqli_stmt_close($stmt); + + return true; + } + + func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20); + func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40); + func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60); + func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); + func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); + + mysqli_close($link); + print "done!"; +?> +--CLEAN-- + +--EXPECTF-- +done! \ No newline at end of file