Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12668

SRID is not preserved in UNION, VIEW, MIN, MAX

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 11.5.1
    • Data types, GIS
    • None

    Description

      SRID is not preserved in UNION:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a POINT REF_SYSTEM_ID=10);
      DROP TABLE IF EXISTS t2;
      CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT a FROM t1;
      SELECT G_TABLE_NAME,G_GEOMETRY_COLUMN,SRID FROM INFORMATION_SCHEMA.GEOMETRY_COLUMNS;
      

      +--------------+-------------------+------+
      | G_TABLE_NAME | G_GEOMETRY_COLUMN | SRID |
      +--------------+-------------------+------+
      | t1           | a                 |   10 |
      | t2           | a                 |    0 |
      +--------------+-------------------+------+
      

      The expected SRID value is 10 for both columns.

      The exact geometry type and SRID are not preserved when creating a table using UNION and VIEW:

      DROP TABLE IF EXISTS t1;
      DROP VIEW IF EXISTS v1;
      DROP TABLE IF EXISTS t2;
       
      CREATE TABLE t1 (p POINT REF_SYSTEM_ID=10);
      CREATE VIEW v1 AS SELECT p FROM t1;
      CREATE TABLE t2 AS SELECT MIN(p) AS p FROM t1 UNION SELECT p FROM v1;
      SHOW CREATE TABLE t2;
      SELECT G_TABLE_NAME,G_GEOMETRY_COLUMN,SRID FROM INFORMATION_SCHEMA.GEOMETRY_COLUMNS;
      

      +-------+----------------------------------------------------------------------------------------+
      | Table | Create Table                                                                           |
      +-------+----------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `p` geometry DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+----------------------------------------------------------------------------------------+
      

      +--------------+-------------------+------+
      | G_TABLE_NAME | G_GEOMETRY_COLUMN | SRID |
      +--------------+-------------------+------+
      | t1           | p                 |   10 |
      | t2           | p                 |    0 |
      | v1           | p                 |   10 |
      +--------------+-------------------+------+
      

      The expected column type for t2.p would be POINT.
      The expected SRID value would be 10 for all three columns.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - Hi holyfoot , Can you please review a patch: https://github.com/MariaDB/server/commit/047dc42ccf586ded6017f628973e147932e6ec44 ? Thanks.

            ok to push.

            holyfoot Alexey Botchkov added a comment - ok to push.

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.