List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:February 11 2009 1:48pm
Subject:re: why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?
View as plain text  
Hi!

>>>>> "MARK" == MARK CALLAGHAN <mdcallag@stripped> writes:

MARK> I would like to know within ha_myisam::open() that the table to be
MARK> opened is a temp table. Code in ha_myisam:open expects the flag
MARK> HA_OPEN_TMP_TABLE to be set in some cases, but it is not set for my
MARK> case. This is true for MySQL 5.0.37 and appears to be true for 5.0.75.
MARK> Why is HA_OPEN_TMP_TABLE not set?

MARK> int ha_myisam::open(const char *name, int mode, uint test_if_locked)

<cut>

MARK> The caller has code to set HA_OPEN_TMP_TABLE:

MARK>     if ((ha_err= (outparam->file->
MARK>                   ha_open(index_file,
MARK>                           (db_stat & HA_READ_ONLY ? O_RDONLY : O_RDWR),
MARK>                           (db_stat & HA_OPEN_TEMPORARY ? HA_OPEN_TMP_TABLE :
MARK>                            ((db_stat & HA_WAIT_IF_LOCKED) ||
MARK>                             (specialflag & SPECIAL_WAIT_IF_LOCKED)) ?
MARK>                            HA_OPEN_WAIT_IF_LOCKED :
MARK>                            (db_stat & (HA_ABORT_IF_LOCKED | HA_GET_INFO)) ?
MARK>                           HA_OPEN_ABORT_IF_LOCKED :
MARK>                            HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))


MARK> The call stack for this is listed. test_if_locked == 2 so the only
MARK> flag set is HA_OPEN_IGNORE_IF_LOCKED.

MARK> When openfrm is called, db_stat == 7, so HA_OPEN_KEYFILE,
MARK> HA_OPEN_RNDFILE and HA_GET_INDEX are set but HA_OPEN_TEMPORARY is not.

MARK> openfrm is called by open_temporary_table and open_temporary_table
MARK> _never_ passes HA_OPEN_TEMPORARY

The reason is that originally HA_OPEN_TEMPORARY was only meant to be
used for internal temporary tables, not explicitely created ones.

In MySQL 5.1 I split the flag to HA_OPEN_TMP_TABLE and
HA_OPEN_INTERNAL_TABLE and now we should change to set
HA_OPEN_TEMPORARY and thus HA_OPEN_TMP_TABLE also for explicit
temporary tables.

I checked the MyISAM code and don't see any obvious reason why we
couldn't do this change in MySQL 5.0 too.

Regards,
Monty
Thread
why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?MARK CALLAGHAN5 Feb
  • Re: why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?Jay Pipes5 Feb
  • Re: why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?Konstantin Osipov5 Feb
  • re: why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?Michael Widenius11 Feb