New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support my sql5.5 #52
base: master
Are you sure you want to change the base?
Conversation
---- MySQL 5.7: ST_AsBinary(), ST_AsWKB(), AsBinary(), and AsWKB() are synonyms. MySQL 5.5: ST_AsWKB does not exist 5.5 only supports AsBinary(g), AsWKB(g)
…oc/refman/5.7/en/spatial-datatypes.html There for should map to the geometry of postgres
@@ -164,7 +164,7 @@ private function __construct() | |||
|
|||
'point' => [ | |||
'increased_size' => '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
While geometry
is capable to hold point value, the
point
simply restrict a value to a specific type...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what I know: when I use this script, it fails on all of my point data types ( contain latitude and longitude). This change allows my data to import.
Here is what I have learned:
postgresql point storage size is only 16 byte
postgis geometry point storage size is 29 byte
Here is what I am guessing:
the postgresql point is simply an xy coordinate
the postgis geometry point is an xy coordinate plus Spatial Reference System attached to it.
As this post points out - you can not convert from one to the other.
http://dba.stackexchange.com/questions/156947/how-do-i-go-from-a-postgresql-native-point-type-to-a-postgis-point/156948
I don't claim to be a PostgreSQL expert. If there is another way to make this import work I would like to know. I can provide a MySQL test case if that would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test-case would be appreciated...
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL test case:
create table testGeoPoint (
ID
bigint(20) NOT NULL,
GEOPOINT
point DEFAULT NULL,
LATITUDE
decimal(19,10) DEFAULT NULL,
LONGITUDE
decimal(19,10) DEFAULT NULL
) ENGINE=InnoDB;
insert into testGeoPoint values ( 1, GeomFromText('POINT(-74.0445000000 40.6892000000 )' ), 40.6892000000, -74.0445000000 );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error output I see is:
--Following MySQL query will return a data set, rejected by PostgreSQL:
SELECT ID
,HEX(AsWKB(GEOPOINT
)),LATITUDE
,LONGITUDE
FROM testGeoPoint
LIMIT 0, 1;
-- FromMySqlToPostgreSql::populateTableWorker
-- PDOException code: 22P02
-- File: /home/mores/wip/MySQL2PSQL/php/migration/FromMySqlToPostgreSql/FromMySqlToPostgreSql.php
-- Line: 674
-- Message: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type point: "0101000000022B8716D98252C09C33A2B437584440"
CONTEXT: COPY testGeoPoint, line 1, column GEOPOINT: "0101000000022B8716D98252C09C33A2B437584440"
-- SQL: SELECT ID
,HEX(AsWKB(GEOPOINT
)),LATITUDE
,LONGITUDE
FROM testGeoPoint
LIMIT 0, 1;
COPY "test"."testGeoPoint" FROM '/home/mores/wip/MySQL2PSQL/php/temporary_directory/testGeoPoint0.csv' DELIMITER ',' CSV;
-------------------------------------------------------
@@ -712,7 +712,12 @@ private function arrangeColumnsData(array $arrColumns) | |||
|| stripos($arrColumn['Type'], 'linestring') !== false | |||
|| stripos($arrColumn['Type'], 'polygon') !== false | |||
) { | |||
$strRetVal .= 'HEX(ST_AsWKB(`' . $arrColumn['Field'] . '`)),'; | |||
if ( strcmp( '5.5', substr( $this->mysqlVersion, 0, 3 ) ) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this code deal with MySQL version < 5.5 , or version > 5.5 ?
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AsBinary() and AsWKB() are deprecated as of MySQL 5.7.6 and will be removed in a future MySQL release.
As far as I know ST_AsWKB will only work for 5.6 and above.
Would you prefer to see:
if( mysql <= 5.5 )
{
AsWKB
}
else
{
ST_AsWKB
}
I will modify the PR how ever you see fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, that if( mysql <= 5.5 )
is much better option.
Could you modify the P.R. a little bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do.
Great idea! |
Is there agreement to merge this pull request now? |
MySQL 5.7: ST_AsBinary(), ST_AsWKB(), AsBinary(), and AsWKB() are synonyms.
MySQL 5.5: ST_AsWKB does not exist
5.5 supports AsBinary(g), AsWKB(g)
I am still unable to transfer my point(s) from MySQL to PostgreSql, but atleast this patch gets it closer to working.