WL#8543: Mutator ST_SRID

Affects: Server-8.0   —   Status: Complete

Add a mutator ST_SRID function that changes the SRID of a geometric
object without changing/transforming the contents, according to
ISO/IEC 13249-3:2011 Sect. 5.1.5.

This function is especially valuable when we introduce geography
support and users want to tell which SRS their data is in:

UPDATE t1 SET geometry_column=ST_SRID(geometry_column, 4326);

PostGIS has implemented this with a non-standard name:
http://postgis.net/docs/ST_SetSRID.html

MySQL already has an ST_SRID observer function.


Unless otherwise specified, the term "ST_SRID" in this section refers
to the two parameter mutator function, not the observer function.

Functional requirements:

F-1: ST_SRID MUST return NULL if either argument is NULL.

F-2: ST_SRID MUST NOT return NULL if neither argument is NULL.

F-3: If the geometry argument is not a syntactically well-formed geometry, ST_SRID 
     MUST raise ER_GIS_INVALID_DATA during function evaluation.

F-4: If the SRID argument is not within the range of an unsigned 32 bit integer, 
     ST_SRID MUST raise ER_DATA_OUT_OF_RANGE during function evaluation.

F-5: If the SRID doesn't refer to a spatial reference system, ST_SRID MUST raise 
     ER_SRS_NOT_FOUND (see definition below) during function evaluation.

F-6: If the geometry argument is a valid geometry and the SRID is within range, 
     ST_SRID MUST return an object of the same type as the input geometry.

Non-functional requirements:

NF-1: The function MUST be non-nullable if both arguments are non-nullable.


I-1: No new files.

I-2: Interface SQL02 is extended with a new two-parameter form of ST_SRID: 
     <geometry> = ST_SRID(<geometry>, <srid>).

I-3: No new commands.

I-4: No new tools.

I-5: No impact on existing functionality.

I-6: Interface ERR01 is extended with a new error message: ER_SRS_NOT_FOUND, 
     SQLSTATE SR001, "There's no spatial reference system with SRID %u."

I-7: No new warnings.


Create a new Item_func_set_srid, subclass of Item_geometry_func, that
sets the SRID value.

Parse the geometry string to verify that it is well-formed. Return
ER_GIS_INVALID_DATA if it isn't.

Validate the SRID using validate_srid_arg() and check that the SRID
exists in the data dictionary. Return ER_SRS_NOT_FOUND if it's not
defined.

Rename Item_func_srid to Item_func_get_srid and modify
Create_func_srid to accept both 1 and 2 argument forms of ST_SRID()
and create the corresponding item.