List:Internals« Previous MessageNext Message »
From:MARK CALLAGHAN Date:February 5 2009 12:20am
Subject:why isn't HA_OPEN_TMP_TABLE set on a call to ha_myisam::open?
View as plain text  
I would like to know within ha_myisam::open() that the table to be
opened is a temp table. Code in ha_myisam:open expects the flag
HA_OPEN_TMP_TABLE to be set in some cases, but it is not set for my
case. This is true for MySQL 5.0.37 and appears to be true for 5.0.75.
Why is HA_OPEN_TMP_TABLE not set?

int ha_myisam::open(const char *name, int mode, uint test_if_locked)
{
  if (!(file=mi_open(name, mode, test_if_locked)))
    return (my_errno ? my_errno : -1);

  if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
    VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0));
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
  if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
    VOID(mi_extra(file, HA_EXTRA_WAIT_LOCK, 0));
  if (!table->s->db_record_offset)
    int_table_flags|=HA_REC_NOT_IN_SEQ;
  if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
    int_table_flags|=HA_HAS_CHECKSUM;
  return (0);
}

The caller has code to set HA_OPEN_TMP_TABLE:

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


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

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

openfrm is called by open_temporary_table and open_temporary_table
_never_ passes HA_OPEN_TEMPORARY

#7  0x00000000005eb93b in ha_myisam::open (this=0x151d4b0,
    name=0x4007ee60
"/usr/local/google/tmp/mysql-5.0.37-x86_64.build/mysql-5.0.37/BUILD/mysql-5.0.37/mysql-test/var/tmp/#sql3e60_1_0",
    mode=2, test_if_locked=2) at ha_myisam.cc:595
#8  0x00000000005e35dd in handler::ha_open (this=0x151d4b0,
    name=0x4007ee60
"/usr/local/google/tmp/mysql-5.0.37-x86_64.build/mysql-5.0.37/BUILD/mysql-5.0.37/mysql-test/var/tmp/#sql3e60_1_0",
    mode=2, test_if_locked=2) at handler.cc:1439
#9  0x0000000000530555 in openfrm (thd=0x1102800,
    name=0x4007f470
"/usr/local/google/tmp/mysql-5.0.37-x86_64.build/mysql-5.0.37/BUILD/mysql-5.0.37/mysql-test/var/tmp/#sql3e60_1_0.frm",
    alias=0x150e4a8 "tm", db_stat=7, prgflag=44, ha_open_flags=0,
outparam=0x1511c00) at table.cc:951
#10 0x000000000051b1f4 in open_temporary_table (thd=0x1102800,
    path=0x4007f470
"/usr/local/google/tmp/mysql-5.0.37-x86_64.build/mysql-5.0.37/BUILD/mysql-5.0.37/mysql-test/var/tmp/#sql3e60_1_0.frm",
    db=0x150e7a8 "test", table_name=0x150e4a8 "tm", link_in_list=true)
at sql_base.cc:2794
#11 0x0000000000604c23 in mysql_create_table (thd=0x1102800,
db=0x150e7a8 "test", table_name=0x150e4a8 "tm",
create_info=0x4007fa80,
    alter_info=0x40080150, internal_tmp_table=false,
select_field_count=0) at sql_table.cc:1762
#12 0x00000000004e6edf in mysql_execute_command (thd=0x1102800) at
sql_parse.cc:4593
#13 0x00000000004ee410 in mysql_parse (thd=0x1102800, inBuf=0x150e410
"create temporary table tm(i int, c char(255)) engine=myisam",
    length=59) at sql_parse.cc:7876
#14 0x00000000004ef34e in dispatch_command (command=COM_QUERY, thd=0x1102800,
    packet=0x14fc501 "create temporary table tm(i int, c char(255))
engine=myisam", packet_length=60) at sql_parse.cc:3007


-- 
Mark Callaghan
mdcallag@stripped
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