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

Creating CONNECT table with SRCDEF in a stored procedure

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 10.0.12
    • Fix Version/s: N/A
    • Labels:
      None

      Description

      I found this while trying to workaround MDEV-6488.

      DROP PROCEDURE IF EXISTS `_`.`materialize_sql`;
      DELIMITER ||
      CREATE PROCEDURE `_`.`materialize_sql`(IN p_name VARCHAR(56), IN p_sql TEXT)
      	MODIFIES SQL DATA
      BEGIN
      	# SET p_name := CONCAT('`', REPLACE(p_name, '`', '``'), '`');
      	
      	-- create table
      	SET @v_materialized_sql := CONCAT_WS('',
      		  'CREATE OR REPLACE TEMPORARY TABLE `_`.', p_name
      		, ' ENGINE = CONNECT'
      		, ' TABLE_TYPE = MYSQL'
      		, ' SRCDEF = ''', REPLACE(p_sql, '''', ''''''), ''''
      		, ' CONNECTION = ''_'''
      		);
      	PREPARE stmt_materialized_sql FROM @v_materialized_sql;
      	EXECUTE stmt_materialized_sql;
      END ||
      DELIMITER ;
      CALL materialize_sql('x', 'SHOW MASTER STATUS');
      DESC x;
      SELECT * FROM x;
      

      There are 3 things to note:

      1) The table structure (DESC x) is correct, but SELECT x returns only empty fields, without a good reason.

      2) If you remove the TEMPORARY keyword, the output will be different: we get 0 rows without a good readon.

      3) If you remove TEMPORARY and uncomment the SET statement, the behaviour is correct (no bug). But "x" is not a special char...

      I still couldn't find any way to create a temporary CONNECT table with a procedure.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            f_razzoli Federico Razzoli added a comment -

            For misteryous reasons the workaround at 3) yesterday worked, and today doesn't. I have no idea about what changed (or if something really changed...). I have to give up, so I hope that this bugs will be fixed.

            Show
            f_razzoli Federico Razzoli added a comment - For misteryous reasons the workaround at 3) yesterday worked, and today doesn't. I have no idea about what changed (or if something really changed...). I have to give up, so I hope that this bugs will be fixed.
            Hide
            f_razzoli Federico Razzoli added a comment - - edited

            Part of this is not really a bug: I didn't know CONNECT tables cannot be temporary. (but then, why I was able to create it? see MDEV-6523)

            However, commenting/uncommenting the SET statement should not affect the shown example.

            Show
            f_razzoli Federico Razzoli added a comment - - edited Part of this is not really a bug: I didn't know CONNECT tables cannot be temporary. (but then, why I was able to create it? see MDEV-6523 ) However, commenting/uncommenting the SET statement should not affect the shown example.
            Hide
            serg Sergei Golubchik added a comment -

            I cannot really repeat it. After I fixed MDEV-6523, one cannot create a TEMPORARY CONNECT table, and with non-temporary tables, your test case seems to work, with or without SET statement.

            Show
            serg Sergei Golubchik added a comment - I cannot really repeat it. After I fixed MDEV-6523 , one cannot create a TEMPORARY CONNECT table, and with non-temporary tables, your test case seems to work, with or without SET statement.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: