Bug #30309 mysql_truncate() does not inform engine that the recreated table is temporary

Submitted: 8 Aug 2007 14:39
Reporter: Guilhem Bichot Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version: OS:Linux
Assigned to: CPU Architecture:Any

[8 Aug 2007 14:39] Guilhem Bichot
Description:
When a table is first created, with CREATE TEMPORARY TABLE, the engine is
passed the flag HA_LEX_CREATE_TMP_TABLE.
If this table is later truncated with TRUNCATE TABLE, the engine is not passed this flag (this flag is not filled by update_create_info_from_table(), which would have a hard time filling it as ha_create_table() passes to this function a TABLE_SHARE which is built with init_tmp_table_share() and thus has
INTERNAL_TMP_TABLE in TABLE_SHARE::tmp_table).
So, the engine's create() is not passed HA_LEX_CREATE_TMP_TABLE when in TRUNCATE. This is a potential issue, as we can see that ha_innodb::create() and ha_myisam::create() test this flag.
No visible issue has been identified so far, though.

How to repeat:
no testcase.
[8 Aug 2007 14:49] Guilhem Bichot
note that when this is fixed, mi_create() will have to be fixed too, as it does
  if (flags & HA_CREATE_TMP_TABLE)
  {
    options|= HA_OPTION_TMP_TABLE;
    create_mode|= O_EXCL | O_NOFOLLOW;
  }
and thus assumes that TRUNCATE cannot pass HA_CREATE_TMP_TABLE.
We might need a flag "this is TRUNCATE, not CREATE" in HA_CREATE_INFO to solve this cleanly
[12 Oct 2007 17:19] Konstantin Osipov
Guilhem, what do you suggest is done for this bug report?
I welcome you to submit the patch.
[15 Oct 2007 9:14] Guilhem Bichot
Hi Konstantin. I don't think you need to work on this now, as no concrete issue with some engine has been identified. Maybe "to be fixed later"?
[27 Oct 2009 17:32] Valeriy Kravchuk
I think Bug #48350 can be related.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.055 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.