[MDEV-8270] create temporary table ... select ... from innodb_table doesn't work on read-only instances Created: 2015-06-05  Updated: 2015-06-05  Resolved: 2015-06-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.0.12
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Crystal Lemire Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Attachments: File innodb_bug.opt     File innodb_bug.test    
Issue Links:
Duplicate
duplicates MDEV-6581 Writing to TEMPORARY TABLE not possib... Closed
duplicates MDEV-8065 create temporary table ... select ...... Closed

 Description   

When mysqld has read_only=1 and innodb is used as the default storage engine, execution of "CREATE TEMPORARY TABLE temp_table SELECT * FROM permanent_table LIMIT 10" fails with error "The MySQL server is running with the --read-only option so it cannot execute this statement". Despite this error, the temporary table tt is created, although it is not populated with data.

The statement works fine if table permanent_table's storage engine is MYISAM. Also, the statement "CREATE TEMPORARY TABLE temp_table LIKE permanent_table; INSERT INTO temp_table SELECT * FROM permanent_table LIMIT 10;" works fine.

Tracing through the 10.0 branch, when ha_commit_trans is called (sql/handler.cc:1338), ha_check_and_coalesce_trx_read_only returns 1 for rw_ha_count. In ha_check_and_coalesce_trx_read_only (sql/handler.cc:1201), the innodb handler info object has the transaction marked as read_write. When I set a watchpoint on the internal ha_info m_flags to see when they are modified from read-only to read-write, I see that handler::ha_create_partitioning_metadata (sql/handler.cc:4302) is called (presumably for creation of the temporary table), which in turn calls mark_trx_read_write(). In this invocation of mark_trx_read_write (handler.cc:3904), the table_share variable is not yet populated, so the function cannot detect that the newly created table is a temporary table and exempt this transaction from being marked as read-write.



 Comments   
Comment by Elena Stepanova [ 2015-06-05 ]

Thanks for the report.

It looks like a duplicate of MDEV-8065 which, in turn, is another variation of MDEV-6581 – similar story, table gets created but not populated. An interesting specifics here is that with CREATE .. AS SELECT it happens even without binary logging. I have added a note about it to MDEV-6581 and link to this bug, which is now being closed as a duplicate. You can track further work on the issue in scope of MDEV-6581.

Generated at Thu Feb 08 07:25:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.