php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49357 MySQLi extension fails to recognize POINT (spatial) colums
Submitted: 2009-08-25 14:55 UTC Modified: 2011-03-24 13:03 UTC
From: phpbug at r-o-b-e-r-t dot de Assigned: abedford (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.2.10 OS: Debian/Ubuntu/Gentoo
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbug at r-o-b-e-r-t dot de
New email:
PHP Version: OS:

 

 [2009-08-25 14:55 UTC] phpbug at r-o-b-e-r-t dot de
Description:
------------
As reported in Bug "#37671 MySQLi extension fails to recognize BIT colums" I have the same problem with a Spatial Column.

The Column coord is a POINT Field.



Reproduce code:
---------------
Here is the Table-Definition:
CREATE TABLE `user` (
 `coord` point default NULL,
) ENGINE=InnoDB

The Test Code:

// $mysqli is an existing db connection

$stmt = $mysqli->prepare("SELECT coord FROM user");
$stmt->execute();
$stmt->bind_result($res);
while ($stmt->fetch() === true ) {
  debug_zval_dump($res);
  var_dump($res);
}
$stmt->close();

Expected result:
----------------
The binary representation of the point

Actual result:
--------------
The Output is the same as the BIT-Field Problem (#37671)

Warning: mysqli_stmt::bind_result(): Server returned unknown type 255. Probably your client library is incompatible with the server version you use! in /home/robert/tmp/test.php on line 11
NULL refcount(1)
NULL
NULL refcount(1)
NULL
NULL refcount(1)
NULL
NULL refcount(1)
NULL
NULL refcount(1)
NULL
NULL refcount(1)
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-25 20:01 UTC] bugs at r-o-b-e-r-t dot de
Sorry for my double-posting of the same bug.


But I got everytime an error, that the headers already was sent. So i tried several times to submit my bug, and did not recognize, that it was already submitted.

SORRY!!


regards

 - Robert
 [2009-08-26 10:34 UTC] uw@php.net
Works with mysqlnd, fails with libmysql. Missing type in mysqli_api.c:

@@ -373,6 +373,9 @@
 #ifdef FIELD_TYPE_NEWDECIMAL
                        case MYSQL_TYPE_NEWDECIMAL:
 #endif
+#ifdef FIELD_TYPE_GEOMETRY
+                       case MYSQL_TYPE_GEOMETRY:
+#endif

 [2009-09-11 13:38 UTC] svn@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&revision=288267
Log: Fix for bug #49357  (MySQLi extension fails to recognize POINT (spatial) colums).

Do yourself a favour and use mysqlnd. mysqlnd has no isuses here.

If you insist on using the MySQL Client Library (libmysql) I strongly recommend to use mysqli_stmt_store_result() when fetching geometry data using prepared statements. When streaming data, which is the default for prepared statements, ext/mysqli will have to make a guess on the size of the result buffer it needs. The guess is based on a length reported by the MySQL CLient Library (libmysql). The MySQL Client Library reports 4GB (!) for a POINT - a conservative and safe guess. Consequently, ext/mysqli will try to allocate 4GB of RAM. The true (maximum) size of the column is not available before buffering the result on the client using mysqli_stmt_store_result(). If you call mysqli_stmt_store_result(), the result buffers will not get bigger than needed. However, store_result()/buffering is usually not what you want when you ask for prepared statements.
 [2009-09-14 16:27 UTC] uw@php.net
This has been fixed in PHP 5_3 and trunk (PHP 6). 

Please note the SVN commit message. In the worst case ext/mysqli used together with the MySQL Client Library will allocate a huge result buffer of 4GB to hold as little as 25 bytes needed to represent a POINT(1, 1) in binary format.
 [2010-12-25 13:43 UTC] kalle@php.net
-Type: Bug +Type: Documentation Problem
 [2011-01-06 15:30 UTC] uw@php.net
-Assigned To: +Assigned To: abedford
 [2011-01-06 15:30 UTC] uw@php.net
Tony, could you document it? Thanks!
 [2011-03-24 13:03 UTC] abedford@php.net
-Status: To be documented +Status: Closed
 [2011-03-24 13:03 UTC] abedford@php.net
Have updated the mysqli docs with a new notes section detailing differences 
between mysqlnd and libmysql when handling GEOMETRY types.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC