List:Commits« Previous MessageNext Message »
From:Marc Alff Date:November 4 2008 4:13pm
Subject:bzr push into mysql-6.0-perf branch (marc.alff:2725 to 2726)
View as plain text  
 2726 Marc Alff	2008-11-04
      Reworked table implementation
removed:
  storage/perfschema/pse_metadata.cc
  storage/perfschema/pse_metadata.h
added:
  storage/perfschema/psm_table.cc
  storage/perfschema/psm_table.h
  storage/perfschema/table_setup_actors.cc
  storage/perfschema/table_setup_actors.h
  storage/perfschema/table_setup_consumers.cc
  storage/perfschema/table_setup_consumers.h
modified:
  mysql-test/suite/perfschema/r/information_schema.result
  mysql-test/suite/perfschema/r/schema.result
  storage/perfschema/Makefile.am
  storage/perfschema/ha_perfschema.cc
  storage/perfschema/ha_perfschema.h
  storage/perfschema/psm_bootstrap.cc
  storage/perfschema/psm_column_types.h
  storage/perfschema/table_performance_timers.cc
  storage/perfschema/table_performance_timers.h
  storage/perfschema/table_setup_instruments.cc
  storage/perfschema/table_setup_instruments.h
  storage/perfschema/table_setup_timers.cc
  storage/perfschema/table_setup_timers.h

 2725 Marc Alff	2008-11-03 [merge]
      Merge mysql-6.0 -> mysql-6.0-perf
added:
  mysql-test/suite/falcon/r/falcon_bug_39342.result
  mysql-test/suite/falcon/r/falcon_year_4digit.result
  mysql-test/suite/falcon/t/falcon_bug_39342.test
  mysql-test/suite/falcon/t/falcon_year_4digit.test
  mysql-test/suite/ndb/r/ndb_dd_is_talbespaces.result
  mysql-test/suite/ndb/t/ndb_dd_is_talbespaces.test
modified:
  .bzrignore
  BUILD/compile-dist
  configure.in
  include/waiting_threads.h
  mysql-test/lib/mtr_report.pl
  mysql-test/r/group_by.result
  mysql-test/r/information_schema-big.result
  mysql-test/r/innodb_mrr.result
  mysql-test/r/myisam_mrr.result
  mysql-test/r/ps_ddl.result
  mysql-test/r/subselect3.result
  mysql-test/r/sum_distinct.result
  mysql-test/suite/backup/r/backup_commit_restore.result
  mysql-test/suite/backup/r/backup_logs.result
  mysql-test/suite/backup/r/backup_tablespace.result
  mysql-test/suite/backup/r/backup_triggers_and_events.result
  mysql-test/suite/backup/t/backup_commit_restore.test
  mysql-test/suite/backup/t/backup_ddl_blocker.test
  mysql-test/suite/backup/t/backup_fkey.test
  mysql-test/suite/backup/t/backup_logs.test
  mysql-test/suite/backup/t/backup_security.test
  mysql-test/suite/backup/t/backup_triggers_and_events.test
  mysql-test/suite/falcon/t/falcon_bug_34164.test
  mysql-test/suite/falcon/t/falcon_bugs2.test
  mysql-test/suite/funcs_1/r/is_columns_mysql.result
  mysql-test/t/group_by.test
  mysql-test/t/innodb_mrr.test
  mysql-test/t/myisam_mrr.test
  mysql-test/t/ps_ddl.test
  mysql-test/t/subselect3.test
  mysql-test/t/sum_distinct.test
  scripts/mysql_system_tables.sql
  scripts/mysql_system_tables_fix.sql
  sql/backup/backup_aux.h
  sql/backup/backup_info.cc
  sql/backup/backup_info.h
  sql/backup/backup_kernel.h
  sql/backup/data_backup.cc
  sql/backup/image_info.cc
  sql/backup/image_info.h
  sql/backup/kernel.cc
  sql/backup/logger.cc
  sql/backup/logger.h
  sql/backup/stream.cc
  sql/backup/stream.h
  sql/ha_ndbcluster.cc
  sql/hostname.cc
  sql/item_sum.cc
  sql/item_sum.h
  sql/log.cc
  sql/log.h
  sql/mdl.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  sql/rpl_handler.cc
  sql/share/errmsg.txt
  sql/si_logs.cc
  sql/si_logs.h
  sql/si_objects.cc
  sql/si_objects.h
  sql/sql_select.cc
  sql/sql_select.h
  storage/falcon/Bitmap.cpp
  storage/falcon/Bitmap.h
  storage/falcon/Cache.cpp
  storage/falcon/Configuration.cpp
  storage/falcon/Connection.h
  storage/falcon/Database.cpp
  storage/falcon/Database.h
  storage/falcon/Dbb.cpp
  storage/falcon/DeferredIndex.cpp
  storage/falcon/DeferredIndex.h
  storage/falcon/DeferredIndexWalker.cpp
  storage/falcon/Index.cpp
  storage/falcon/Record.cpp
  storage/falcon/Record.h
  storage/falcon/RecordGroup.cpp
  storage/falcon/RecordGroup.h
  storage/falcon/RecordLeaf.cpp
  storage/falcon/RecordLeaf.h
  storage/falcon/RecordScavenge.cpp
  storage/falcon/RecordSection.h
  storage/falcon/RecordVersion.cpp
  storage/falcon/RecordVersion.h
  storage/falcon/SQLException.h
  storage/falcon/SRLUpdateIndex.cpp
  storage/falcon/SRLUpdateRecords.cpp
  storage/falcon/Scavenger.cpp
  storage/falcon/Scavenger.h
  storage/falcon/SerialLog.cpp
  storage/falcon/SerialLog.h
  storage/falcon/SerialLogFile.cpp
  storage/falcon/SerialLogWindow.cpp
  storage/falcon/StorageConnection.cpp
  storage/falcon/StorageConnection.h
  storage/falcon/StorageDatabase.cpp
  storage/falcon/StorageDatabase.h
  storage/falcon/StorageParameters.h
  storage/falcon/StorageTable.cpp
  storage/falcon/StorageTable.h
  storage/falcon/StorageTableShare.cpp
  storage/falcon/StorageTableShare.h
  storage/falcon/StorageVersion.h
  storage/falcon/SyncHandler.cpp
  storage/falcon/SyncHandler.h
  storage/falcon/SyncObject.cpp
  storage/falcon/Table.cpp
  storage/falcon/Table.h
  storage/falcon/Transaction.cpp
  storage/falcon/TransactionManager.cpp
  storage/falcon/WalkDeferred.cpp
  storage/falcon/ha_falcon.cpp
  storage/falcon/ha_falcon.h
  storage/myisam/ha_myisam.cc
  unittest/mysys/Makefile.am
  zlib/gzio.c

=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result	2008-11-03 16:45:45 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result	2008-11-04 16:11:21 +0000
@@ -30,8 +30,8 @@ from information_schema.tables
 where TABLE_SCHEMA='performance_schema';
 TABLE_NAME	TABLE_ROWS	AVG_ROW_LENGTH
 performance_timers	5	0
-setup_actors	0	0
-setup_consumers	0	0
+setup_actors	99	0
+setup_consumers	3	0
 setup_instruments	99	0
 setup_timers	1	0
 select TABLE_NAME, DATA_LENGTH, MAX_DATA_LENGTH

=== modified file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result	2008-11-03 16:45:45 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result	2008-11-04 16:11:21 +0000
@@ -16,7 +16,7 @@ show create table performance_schema.set
 Table	Create Table
 setup_actors	CREATE TABLE `setup_actors` (
   `TYPE` enum('ALL','BACKGROUND','CONNECTION','EVENT','USER') NOT NULL,
-  `SCHEMA` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+  `ACTOR_SCHEMA` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
   `NAME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table performance_schema.setup_instruments;

=== modified file 'storage/perfschema/Makefile.am'
--- a/storage/perfschema/Makefile.am	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/Makefile.am	2008-11-04 16:11:21 +0000
@@ -32,17 +32,19 @@ DEFS =                  -DMYSQL_SERVER @
 
 SUBDIRS =               . unittest
 
-noinst_HEADERS = ha_perfschema.h pse_metadata.h psm.h psm_server.h \
+noinst_HEADERS = ha_perfschema.h psm_table.h psm.h psm_server.h \
 		psm_global.h psm_sync_info.h psm_sync.h psm_bootstrap.h \
                 psm_column_types.h psm_column_values.h \
                 table_setup_instruments.h table_performance_timers.h \
-                table_setup_timers.h
+                table_setup_timers.h table_setup_actors.h \
+                table_setup_consumers.h
 
-PSE_SOURCES = ha_perfschema.cc pse_metadata.cc psm.cc psm_server.cc \
+PSE_SOURCES = ha_perfschema.cc psm_table.cc psm.cc psm_server.cc \
 		psm_global.cc psm_sync_info.cc psm_sync.cc \
                 psm_bootstrap.cc psm_column_values.cc \
                 table_setup_instruments.cc table_performance_timers.cc \
-                table_setup_timers.cc
+                table_setup_timers.cc table_setup_actors.cc \
+                table_setup_consumers.cc
 
 EXTRA_LIBRARIES = libperfschema.a
 noinst_LIBRARIES = @plugin_perfschema_static_target@

=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/ha_perfschema.cc	2008-11-04 16:11:21 +0000
@@ -15,13 +15,16 @@
 
 #include "mysql_priv.h"
 #include "ha_perfschema.h"
-#include "pse_metadata.h"
 #include "mysql/plugin.h"
+#include "psm_table.h"
 
 PSE_SHARE pse_share;
 
 handlerton *pse_hton= NULL;
 
+LEX_STRING PERFORMANCE_SCHEMA_str=
+{ C_STRING_WITH_LEN("performance_schema") };
+
 static handler* pse_create_handler(handlerton *hton,
                                    TABLE_SHARE *table,
                                    MEM_ROOT *mem_root)
@@ -29,10 +32,10 @@ static handler* pse_create_handler(handl
   return new (mem_root) ha_perfschema(hton, table);
 }
 
-static const pse_table_metadata*
-find_metadata(const char *db, const char *name)
+static const psm_table_info*
+find_table_info(const char *db, const char *name)
 {
-  DBUG_ENTER("find_metadata");
+  DBUG_ENTER("find_table_info");
 
   if ((strlen(db) != PERFORMANCE_SCHEMA_str.length) ||
       (strncmp(db,
@@ -40,16 +43,9 @@ find_metadata(const char *db, const char
               PERFORMANCE_SCHEMA_str.length) != 0))
     DBUG_RETURN(NULL);
 
-  const pse_table_metadata *current= & pse_all_tables[0];
-
-  while (current->m_name != NULL)
-  {
-    if (strcmp(name, current->m_name) == 0)
-      DBUG_RETURN(current);
-
-    current++;
-  }
-  DBUG_RETURN(NULL);
+  const psm_table_info* result;
+  result= psm_table::find_table_info(name);
+  DBUG_RETURN(result);
 }
 
 static int pse_discover(handlerton *hton, THD* thd, const char *db,
@@ -76,13 +72,14 @@ static int pse_table_exists_in_engine(ha
 {
   DBUG_ENTER("pse_table_exists_in_engine");
   /*
-    In bootstrap mode (the server starting), we pretend the tables
-    in performance schema don't exist, so that the creation script
-    can proceed and create them.
+    In bootstrap mode, we pretend the native tables
+    in performance_schema don't exist, so that the creation script
+    can proceed and 'create' them.
+    This is needed to generate a .frm file for each native table.
   */
   if (! thd->bootstrap)
   {
-    if (find_metadata(db, name))
+    if (find_table_info(db, name))
       DBUG_RETURN(HA_ERR_TABLE_EXIST);
   }
   DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
@@ -139,8 +136,8 @@ mysql_declare_plugin_end;
 
 ha_perfschema::ha_perfschema(handlerton *hton, TABLE_SHARE *share)
   : handler(hton, share),
-  m_metadata(NULL),
-  m_scan(NULL)
+  m_table_info(NULL),
+  m_table(NULL)
 {}
 
 ha_perfschema::~ha_perfschema()
@@ -160,8 +157,9 @@ int ha_perfschema::open(const char *name
   DBUG_ENTER("ha_perfschema::open");
   thr_lock_data_init(& pse_share.lock, & lock, NULL);
 
-  m_metadata= find_metadata(table_share->db.str, table_share->table_name.str);
-  if (! m_metadata)
+  m_table_info= find_table_info(table_share->db.str,
+                                table_share->table_name.str);
+  if (! m_table_info)
     DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 
   DBUG_RETURN(0);
@@ -170,7 +168,9 @@ int ha_perfschema::open(const char *name
 int ha_perfschema::close(void)
 {
   DBUG_ENTER("ha_perfschema::close");
-  m_metadata= NULL;
+  m_table_info= NULL;
+  if (m_table)
+    delete m_table;
   DBUG_RETURN(0);
 }
 
@@ -181,15 +181,12 @@ int ha_perfschema::write_row(uchar *buf)
   DBUG_ENTER("ha_perfschema::write_row");
 
   ha_statistic_increment(&SSV::ha_write_count);
+  DBUG_ASSERT(m_table_info);
 
-  DBUG_ASSERT(m_metadata);
-
-  if (! m_metadata->m_write_row)
-  {
-    DBUG_RETURN(HA_ERR_WRONG_COMMAND);
-  }
-
-  result= (* m_metadata->m_write_row)(table, buf, table->field);
+  if (m_table_info->m_write_row)
+    result= m_table_info->m_write_row(table, buf, table->field);
+  else
+    result= HA_ERR_WRONG_COMMAND;
 
   DBUG_RETURN(result);
 }
@@ -197,7 +194,8 @@ int ha_perfschema::write_row(uchar *buf)
 int ha_perfschema::update_row(const uchar *old_data, uchar *new_data)
 {
   DBUG_ENTER("ha_perfschema::update_row");
-  DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+  // DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+  DBUG_RETURN(0);
 }
 
 int ha_perfschema::delete_row(const uchar *buf)
@@ -240,27 +238,31 @@ int ha_perfschema::index_last(uchar *buf
 
 int ha_perfschema::rnd_init(bool scan)
 {
+  int result;
   DBUG_ENTER("ha_perfschema::rnd_init");
 
-  DBUG_ASSERT(m_scan == NULL);
-  DBUG_ASSERT(m_metadata);
+  DBUG_ASSERT(m_table_info);
+  DBUG_ASSERT(m_table_info->m_open_table != NULL);
+  DBUG_ASSERT(m_table == NULL);
 
-  if (! m_metadata->m_open_scan)
+  m_table= (* m_table_info->m_open_table)();
+  if (m_table)
   {
-    DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+    result= 0;
   }
+  else
+    result= HA_ERR_OUT_OF_MEM;
 
-  m_scan= (* m_metadata->m_open_scan)();
-  DBUG_RETURN(0);
+  DBUG_RETURN(result);
 }
 
 int ha_perfschema::rnd_end()
 {
   DBUG_ENTER("ha_perfschema::rnd_end");
-  if (m_scan)
+  if (m_table)
   {
-    delete m_scan;
-    m_scan= NULL;
+    delete m_table;
+    m_table= NULL;
   }
   DBUG_RETURN(0);
 }
@@ -270,14 +272,10 @@ int ha_perfschema::rnd_next(uchar *buf)
   int result;
   DBUG_ENTER("ha_perfschema::rnd_next");
 
-  if (m_scan)
-  {
-    result= m_scan->read_row(table, buf, table->field);
-  }
-  else
-  {
-    result= HA_ERR_END_OF_FILE;
-  }
+  DBUG_ASSERT(m_table);
+  result= m_table->rnd_next();
+  if (result == 0)
+    result= m_table->read_row(table, buf, table->field);
   DBUG_RETURN(result);
 }
 
@@ -289,27 +287,29 @@ void ha_perfschema::position(const uchar
 
 int ha_perfschema::rnd_pos(uchar *buf, uchar *pos)
 {
+  int result;
   DBUG_ENTER("ha_perfschema::rnd_pos");
-  DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+
+  DBUG_ASSERT(m_table);
+  result= m_table->rnd_pos(pos);
+  if (result == 0)
+    result= m_table->read_row(table, buf, table->field);
+  DBUG_RETURN(result);
 }
 
 int ha_perfschema::info(uint flag)
 {
   DBUG_ENTER("ha_perfschema::info");
-  DBUG_ASSERT(m_metadata);
-  // TODO: DBUG_ASSERT(m_metadata->m_info);
-  pse_table_info *info= m_metadata->m_info;
-  if (info == NULL)
-    DBUG_RETURN(0);
+  DBUG_ASSERT(m_table_info);
   if (flag & HA_STATUS_VARIABLE)
   {
-    stats.records=           info->m_records;
-    stats.deleted=           info->m_deleted;
-    stats.data_file_length=  0;
+    stats.records= m_table_info->m_records;
+    stats.deleted= m_table_info->m_deleted;
+    stats.data_file_length= 0;
     stats.index_file_length= 0;
-    stats.delete_length=     0;
-    stats.check_time=        0;
-    stats.mean_rec_length=   0;
+    stats.delete_length= 0;
+    stats.check_time= 0;
+    stats.mean_rec_length= 0;
   }
   if (flag & HA_STATUS_CONST)
   {
@@ -317,7 +317,7 @@ int ha_perfschema::info(uint flag)
     stats.max_index_file_length= 0;
     stats.create_time= 0;
     stats.block_size= 0;
-    ref_length= info->m_ref_length;
+    ref_length= m_table_info->m_ref_length;
   }
   DBUG_RETURN(0);
 }

=== modified file 'storage/perfschema/ha_perfschema.h'
--- a/storage/perfschema/ha_perfschema.h	2008-10-10 20:34:55 +0000
+++ b/storage/perfschema/ha_perfschema.h	2008-11-04 16:11:21 +0000
@@ -18,8 +18,8 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
-class pse_table_metadata;
-class pse_scan;
+struct psm_table_info;
+class psm_table;
 
 /** @brief
   EXAMPLE_SHARE is a structure that will be shared among all open handlers.
@@ -236,7 +236,6 @@ public:
 
 private:
   THR_LOCK_DATA lock;      /* MySQL lock */
-  const pse_table_metadata *m_metadata;
-
-  pse_scan *m_scan;
+  const psm_table_info *m_table_info;
+  psm_table *m_table;
 };

=== removed file 'storage/perfschema/pse_metadata.cc'
--- a/storage/perfschema/pse_metadata.cc	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/pse_metadata.cc	1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#include "mysql_priv.h"
-#include "pse_metadata.h"
-
-#include "table_setup_timers.h"
-#include "table_setup_instruments.h"
-#include "table_performance_timers.h"
-
-LEX_STRING PERFORMANCE_SCHEMA_str=
-{ C_STRING_WITH_LEN("performance_schema") };
-
-LEX_STRING SETUP_ACTORS_str=
-{ C_STRING_WITH_LEN("setup_actors") };
-
-LEX_STRING SETUP_INSTRUMENTS_str=
-{ C_STRING_WITH_LEN("setup_instruments") };
-
-LEX_STRING SETUP_CONSUMERS_str=
-{ C_STRING_WITH_LEN("setup_consumers") };
-
-LEX_STRING SETUP_TIMERS_str=
-{ C_STRING_WITH_LEN("setup_timers") };
-
-LEX_STRING PERFORMANCE_TIMERS_str=
-{ C_STRING_WITH_LEN("performance_timers") };
-
-LEX_STRING SESSION_WAITS_str=
-{ C_STRING_WITH_LEN("session_waits") };
-
-LEX_STRING SESSION_WAIT_HISTORIES_str=
-{ C_STRING_WITH_LEN("session_wait_histories") };
-
-LEX_STRING SESSION_WAIT_LONG_HISTORIES_str=
-{ C_STRING_WITH_LEN("session_wait_long_histories") };
-
-pse_table_metadata pse_all_tables[]=
-{
-  {
-    SETUP_ACTORS_str.str,
-    NULL,
-    NULL,
-    HA_POS_ERROR,
-    0
-  },
-  {
-    SETUP_INSTRUMENTS_str.str,
-    NULL,
-    pse_scan_setup_instruments::create,
-    HA_POS_ERROR,
-    & pse_scan_setup_instruments::m_info
-  },
-  {
-    SETUP_CONSUMERS_str.str,
-    NULL,
-    NULL,
-    HA_POS_ERROR,
-    0
-  },
-  {
-    SETUP_TIMERS_str.str,
-    NULL,
-    pse_scan_setup_timers::create,
-    HA_POS_ERROR,
-    & pse_scan_setup_timers::m_info
-  },
-  {
-    PERFORMANCE_TIMERS_str.str,
-    NULL,
-    pse_scan_performance_timers::create,
-    HA_POS_ERROR,
-    & pse_scan_performance_timers::m_info
-  },
-  {
-    NULL,
-    NULL,
-    NULL,
-    0,
-    0
-  }
-};
-

=== removed file 'storage/perfschema/pse_metadata.h'
--- a/storage/perfschema/pse_metadata.h	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/pse_metadata.h	1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef PSE_METADATA_H
-#define PSE_METADATA_H
-
-class Field;
-struct TABLE;
-
-class pse_scan
-{
-public:
-  virtual int read_row(TABLE * table, unsigned char *buf, Field **fields) = 0;
-
-protected:
-  pse_scan()
-  {}
-
-public:
-  virtual ~pse_scan()
-  {}
-};
-
-typedef pse_scan* (*pse_open_scan_t)();
-
-typedef int (*pse_write_row_t)(TABLE * table,
-                               unsigned char *buf,
-                               Field **fields);
-
-struct pse_table_info
-{
-  ha_rows m_records;
-  ha_rows m_deleted;
-  ulong m_reclength;
-  uint m_options;
-  uint m_ref_length;
-};
-
-struct pse_table_metadata
-{
-  const char* m_name;
-  pse_write_row_t m_write_row;
-  pse_open_scan_t m_open_scan;
-  ha_rows m_estimate_rows_upper_bound;
-  pse_table_info *m_info;
-};
-
-extern pse_table_metadata pse_all_tables[];
-
-extern LEX_STRING PERFORMANCE_SCHEMA_str;
-
-extern LEX_STRING SETUP_ACTORS_str;
-extern LEX_STRING SETUP_INSTRUMENTS_str;
-extern LEX_STRING SETUP_CONSUMERS_str;
-extern LEX_STRING SETUP_TIMERS_str;
-extern LEX_STRING PERFORMANCE_TIMERS_str;
-extern LEX_STRING SESSION_WAITS_str;
-extern LEX_STRING SESSION_WAIT_HISTORIES_str;
-extern LEX_STRING SESSION_WAIT_LONG_HISTORIES_str;
-
-#endif

=== modified file 'storage/perfschema/psm_bootstrap.cc'
--- a/storage/perfschema/psm_bootstrap.cc	2008-11-01 01:05:08 +0000
+++ b/storage/perfschema/psm_bootstrap.cc	2008-11-04 16:11:21 +0000
@@ -23,7 +23,7 @@ const char* psm_bootstrap_queries[]=
   "CREATE TABLE performance_schema.setup_actors("
     "TYPE ENUM ('ALL', 'BACKGROUND', 'CONNECTION', "
                "'EVENT', 'USER') not null, "
-    "`SCHEMA` VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
+    "ACTOR_SCHEMA VARCHAR(64) character set utf8 collate utf8_unicode_ci, "
     "NAME VARCHAR(64) character set utf8 collate utf8_unicode_ci"
   ") ENGINE=PERFORMANCE_SCHEMA;"
   ,

=== modified file 'storage/perfschema/psm_column_types.h'
--- a/storage/perfschema/psm_column_types.h	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/psm_column_types.h	2008-11-04 16:11:21 +0000
@@ -55,12 +55,15 @@ enum enum_yes_no
 */
 enum enum_actor_type
 {
-  ACTOR_TYPE_ALL= 0,
-  ACTOR_TYPE_BACKGROUND= 1,
-  ACTOR_TYPE_CONNECTION= 2,
-  ACTOR_TYPE_EVENT= 3,
-  ACTOR_TYPE_USER= 4,
-  LAST_ACTOR_TYPE= ACTOR_TYPE_USER
+  ACTOR_TYPE_ALL= 1,
+  ACTOR_TYPE_BACKGROUND= 2,
+  ACTOR_TYPE_CONNECTION= 3,
+  ACTOR_TYPE_EVENT= 4,
+  ACTOR_TYPE_USER= 5
 };
+#define FIRST_ACTOR_TYPE ((int) ACTOR_TYPE_ALL)
+#define LAST_ACTOR_TYPE ((int) ACTOR_TYPE_USER)
+#define COUNT_ACTOR_TYPE (LAST_ACTOR_TYPE - FIRST_ACTOR_TYPE + 1)
+
 #endif
 

=== added file 'storage/perfschema/psm_table.cc'
--- a/storage/perfschema/psm_table.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/psm_table.cc	2008-11-04 16:11:21 +0000
@@ -0,0 +1,68 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "mysql_priv.h"
+#include "psm_table.h"
+
+#include "table_setup_actors.h"
+#include "table_setup_consumers.h"
+#include "table_setup_instruments.h"
+#include "table_setup_timers.h"
+#include "table_performance_timers.h"
+
+static psm_table_info *psm_all_tables[]=
+{
+  & table_setup_actors::m_info,
+  & table_setup_consumers::m_info,
+  & table_setup_instruments::m_info,
+  & table_setup_timers::m_info,
+  & table_performance_timers::m_info,
+  NULL
+};
+
+const psm_table_info*
+psm_table::find_table_info(const char* name)
+{
+  DBUG_ENTER("psm_table::find_table_info");
+
+  psm_table_info **current= & psm_all_tables[0];
+  uint name_len= strlen(name);
+
+  while ((*current) != NULL)
+  {
+    if ((name_len == (*current)->m_name.length) &&
+        (strcmp(name, (*current)->m_name.str) == 0))
+      DBUG_RETURN(*current);
+
+    current++;
+  }
+  DBUG_RETURN(NULL);
+}
+
+int psm_table::read_row(TABLE *table,
+                        unsigned char *buf,
+                        Field **fields)
+{
+  int result;
+  my_bitmap_map *org_bitmap;
+
+  // TODO: find why is this necessary ?
+  org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
+  result= read_row_values(table, buf, fields);
+  dbug_tmp_restore_column_map(table->write_set, org_bitmap);
+
+  return result;
+}
+

=== added file 'storage/perfschema/psm_table.h'
--- a/storage/perfschema/psm_table.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/psm_table.h	2008-11-04 16:11:21 +0000
@@ -0,0 +1,61 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef PSM_TABLE_H
+#define PSM_TABLE_H
+
+class Field;
+struct TABLE;
+struct psm_table_info;
+
+class psm_table
+{
+public:
+  static const psm_table_info* find_table_info(const char* name);
+
+  int read_row(TABLE *table, unsigned char *buf, Field **fields);
+  virtual int rnd_next() = 0;
+  virtual int rnd_pos(unsigned char *pos) = 0;
+
+protected:
+  virtual int read_row_values(TABLE *table, unsigned char *buf,
+                              Field **fields) = 0;
+
+  psm_table()
+  {}
+
+public:
+  virtual ~psm_table()
+  {}
+};
+
+typedef psm_table* (*psm_open_table_t)();
+typedef int (*psm_write_row_t)(TABLE *table,
+                               unsigned char *buf, Field **fields);
+
+struct psm_table_info
+{
+  LEX_STRING m_name;
+  psm_open_table_t m_open_table;
+  psm_write_row_t m_write_row;
+  ha_rows m_records;
+  ha_rows m_deleted;
+  ulong m_reclength;
+  uint m_options;
+  uint m_ref_length;
+  ha_rows m_estimate_rows_upper_bound;
+};
+
+#endif

=== modified file 'storage/perfschema/table_performance_timers.cc'
--- a/storage/perfschema/table_performance_timers.cc	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_performance_timers.cc	2008-11-04 16:11:21 +0000
@@ -14,29 +14,33 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "mysql_priv.h"
-#include "pse_metadata.h"
 #include "table_performance_timers.h"
 
-pse_table_info
-pse_scan_performance_timers::m_info=
+psm_table_info
+table_performance_timers::m_info=
 {
-  5,
-  0,
-  sizeof(row_performance_timers),
-  0,
-  sizeof(pos_performance_timers)
+  { C_STRING_WITH_LEN("performance_timers") },
+  & table_performance_timers::create,
+  NULL,
+  5, // records
+  0, // deleted
+  sizeof(row_performance_timers), // rec length
+  0, // options
+  sizeof(pos_performance_timers), // ref length
+  5 // estimate rows upper bound
 };
 
-pse_scan* pse_scan_performance_timers::create()
+psm_table* table_performance_timers::create()
 {
-  return new pse_scan_performance_timers();
+  return new table_performance_timers();
 }
 
-pse_scan_performance_timers::pse_scan_performance_timers()
+table_performance_timers::table_performance_timers()
 {
   int index;
 
   m_pos.m_index= 0;
+  m_row= NULL;
 
   index= (int)TIMER_NAME_CYCLE - FIRST_TIMER_NAME;
   m_data[index].m_timer_name= TIMER_NAME_CYCLE;
@@ -69,43 +73,41 @@ pse_scan_performance_timers::pse_scan_pe
   m_data[index].m_timer_overhead= 35;
 }
 
-int pse_scan_performance_timers::read_row(TABLE *table,
-                                         unsigned char *buf,
-                                         Field **fields)
+int table_performance_timers::rnd_next()
 {
   int result;
-  my_bitmap_map *org_bitmap;
-  row_performance_timers *row;
-
-  org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
 
   if (m_pos.m_index < COUNT_TIMER_NAME)
   {
-    row= & m_data[m_pos.m_index];
+    m_row= & m_data[m_pos.m_index];
     m_pos.m_index++;
-    result= read_row_values(table, buf, fields, row);
+    result= 0;
   }
   else
+  {
+    m_row= NULL;
     result= HA_ERR_END_OF_FILE;
-
-  dbug_tmp_restore_column_map(table->write_set, org_bitmap);
+  }
 
   return result;
 }
 
-int pse_scan_performance_timers::read_row_values(TABLE *table,
-                                                unsigned char *buf,
-                                                Field **fields,
-                                                row_performance_timers *row)
+int table_performance_timers::rnd_pos(unsigned char *pos)
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+int table_performance_timers::read_row_values(TABLE *table,
+                                              unsigned char *buf,
+                                              Field **fields)
 {
   Field *f;
   Field_enum *col_timer_name;
   Field_longlong *col_timer_frequency;
   Field_longlong *col_timer_interval;
   Field_longlong *col_timer_overhead;
-  CHARSET_INFO *cs;
 
-  cs= & my_charset_utf8_bin;
+  DBUG_ASSERT(m_row);
 
   /* Set the null bits */
   DBUG_ASSERT(table->s->null_bytes == 1);
@@ -122,22 +124,22 @@ int pse_scan_performance_timers::read_ro
       case 0:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
         col_timer_name= (Field_enum*) f;
-        col_timer_name->store_type(row->m_timer_name);
+        col_timer_name->store_type(m_row->m_timer_name);
         break;
       case 1:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
         col_timer_frequency= (Field_longlong*) f;
-        col_timer_frequency->store(row->m_timer_frequency);
+        col_timer_frequency->store(m_row->m_timer_frequency);
         break;
       case 2:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
         col_timer_interval= (Field_longlong*) f;
-        col_timer_interval->store(row->m_timer_interval);
+        col_timer_interval->store(m_row->m_timer_interval);
         break;
       case 3:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONGLONG);
         col_timer_overhead= (Field_longlong*) f;
-        col_timer_overhead->store(row->m_timer_overhead);
+        col_timer_overhead->store(m_row->m_timer_overhead);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_performance_timers.h'
--- a/storage/perfschema/table_performance_timers.h	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_performance_timers.h	2008-11-04 16:11:21 +0000
@@ -17,6 +17,7 @@
 #define TABLE_PERFORMANCE_TIMERS_H
 
 #include "psm_column_types.h"
+#include "psm_table.h"
 
 struct row_performance_timers
 {
@@ -31,27 +32,28 @@ struct pos_performance_timers
   uint m_index;
 };
 
-class pse_scan_performance_timers : public pse_scan
+class table_performance_timers : public psm_table
 {
 public:
-  static pse_table_info m_info;
-  static pse_scan* create();
+  static psm_table_info m_info;
+  static psm_table* create();
 
-  int read_row(TABLE *table, unsigned char *buf, Field **fields);
+  virtual int rnd_next();
+  virtual int rnd_pos(unsigned char *pos);
 
-private:
-  int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
-                      row_performance_timers *row);
+protected:
+  virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields);
 
 protected:
-  pse_scan_performance_timers();
+  table_performance_timers();
 
 public:
-  ~pse_scan_performance_timers()
+  ~table_performance_timers()
   {}
 
 private:
   pos_performance_timers m_pos;
+  row_performance_timers *m_row;
   row_performance_timers m_data[COUNT_TIMER_NAME];
 };
 

=== added file 'storage/perfschema/table_setup_actors.cc'
--- a/storage/perfschema/table_setup_actors.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_actors.cc	2008-11-04 16:11:21 +0000
@@ -0,0 +1,125 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "mysql_priv.h"
+#include "psm_sync_info.h"
+#include "psm_column_types.h"
+#include "psm_column_values.h"
+#include "table_setup_actors.h"
+
+psm_table_info
+table_setup_actors::m_info=
+{
+  { C_STRING_WITH_LEN("setup_actors") },
+  & table_setup_actors::create,
+  NULL,
+  99,
+  0,
+  sizeof(row_setup_actors),
+  0,
+  sizeof(pos_setup_actors),
+  HA_POS_ERROR
+};
+
+psm_table* table_setup_actors::create()
+{
+  return new table_setup_actors();
+}
+
+table_setup_actors::table_setup_actors()
+{
+  m_pos.m_index= 0;
+  m_row= NULL;
+}
+
+int table_setup_actors::rnd_next()
+{
+  int result;
+
+  if (m_pos.m_index == 0) // TODO
+  {
+    static row_setup_actors dummy;
+    dummy.m_type= ACTOR_TYPE_ALL;
+    strcpy(dummy.m_actor_schema, "TODO");
+    dummy.m_actor_schema_length= 4;
+    strcpy(dummy.m_name, "REALLY");
+    dummy.m_name_length= 6;
+    m_row= & dummy;
+    m_pos.m_index++;
+  }
+  else
+  {
+    m_row= NULL;
+    result= HA_ERR_END_OF_FILE;
+  }
+
+  return result;
+}
+
+int table_setup_actors::rnd_pos(unsigned char *pos)
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+int table_setup_actors::read_row_values(TABLE *table,
+                                        unsigned char *buf,
+                                        Field **fields)
+{
+  Field *f;
+  Field_enum *col_type;
+  Field_varstring *col_actor_schema;
+  Field_varstring *col_name;
+  CHARSET_INFO *cs;
+
+  cs= & my_charset_utf8_bin;
+
+  DBUG_ASSERT(m_row);
+
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; *fields ; fields++)
+  {
+    f= *fields;
+
+    if (bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
+        col_type= (Field_enum*) f;
+        col_type->store_type(m_row->m_type);
+        break;
+      case 1:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+        col_actor_schema= (Field_varstring*) f;
+        col_actor_schema->store(m_row->m_actor_schema,
+                                m_row->m_actor_schema_length, cs);
+        break;
+      case 2:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+        col_name= (Field_varstring*) f;
+        col_name->store(m_row->m_name, m_row->m_name_length, cs);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_setup_actors.h'
--- a/storage/perfschema/table_setup_actors.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_actors.h	2008-11-04 16:11:21 +0000
@@ -0,0 +1,60 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef TABLE_SETUP_ACTORS_H
+#define TABLE_SETUP_ACTORS_H
+
+#include "psm_table.h"
+#include "psm_column_types.h"
+
+struct row_setup_actors
+{
+  enum_actor_type m_type;
+  char m_actor_schema[64];
+  int m_actor_schema_length;
+  char m_name[64];
+  int m_name_length;
+};
+
+struct pos_setup_actors
+{
+  uint m_index;
+};
+
+class table_setup_actors : public psm_table
+{
+public:
+  static psm_table_info m_info;
+  static psm_table* create();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(unsigned char *pos);
+
+protected:
+  virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields);
+
+  table_setup_actors();
+
+public:
+  ~table_setup_actors()
+  {}
+
+private:
+  pos_setup_actors m_pos;
+  row_setup_actors *m_row;
+};
+
+#endif
+

=== added file 'storage/perfschema/table_setup_consumers.cc'
--- a/storage/perfschema/table_setup_consumers.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_consumers.cc	2008-11-04 16:11:21 +0000
@@ -0,0 +1,140 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "mysql_priv.h"
+#include "table_setup_consumers.h"
+
+// TODO: move in session_waits when it's implemented
+bool flag_session_waits= true;
+bool flag_session_wait_histories= true;
+bool flag_session_wait_long_histories= false;
+
+#define COUNT_SETUP_CONSUMERS 3
+static row_setup_consumers all_setup_consumers_data[COUNT_SETUP_CONSUMERS]=
+{
+  {
+    { C_STRING_WITH_LEN("session_waits") },
+    & flag_session_waits
+  },
+  {
+    { C_STRING_WITH_LEN("session_wait_histories") },
+    & flag_session_wait_histories
+  },
+  {
+    { C_STRING_WITH_LEN("session_wait_long_histories") },
+    & flag_session_wait_long_histories
+  }
+};
+
+psm_table_info
+table_setup_consumers::m_info=
+{
+  { C_STRING_WITH_LEN("setup_consumers") },
+  & table_setup_consumers::create,
+  NULL,
+  COUNT_SETUP_CONSUMERS, // records
+  0, // deleted
+  sizeof(row_setup_consumers), // rec length
+  0, // options
+  sizeof(pos_setup_consumers), // ref length
+  COUNT_SETUP_CONSUMERS // estimate rows upper bound
+};
+
+psm_table* table_setup_consumers::create()
+{
+  return new table_setup_consumers();
+}
+
+table_setup_consumers::table_setup_consumers()
+{
+  m_pos.m_index= 0;
+  m_row= NULL;
+}
+
+int table_setup_consumers::rnd_next()
+{
+  int result;
+
+  if (m_pos.m_index < COUNT_SETUP_CONSUMERS)
+  {
+    m_row= & all_setup_consumers_data[m_pos.m_index];
+    m_pos.m_index++;
+    result= 0;
+  }
+  else
+  {
+    m_row= NULL;
+    result= HA_ERR_END_OF_FILE;
+  }
+
+  return result;
+}
+
+int table_setup_consumers::rnd_pos(unsigned char *pos)
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+int table_setup_consumers::read_row_values(TABLE *table,
+                                           unsigned char *buf,
+                                           Field **fields)
+{
+  Field *f;
+  Field_varstring *col_name;
+  Field_enum *col_enabled;
+  Field_long *col_number_of_rows_filled;
+  CHARSET_INFO *cs;
+
+  DBUG_ASSERT(m_row);
+
+  cs= & my_charset_utf8_bin;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; *fields ; fields++)
+  {
+    f= *fields;
+
+    if (bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
+        col_name= (Field_varstring*) f;
+        col_name->store(m_row->m_name.str, m_row->m_name.length, cs);
+        break;
+      case 1:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
+        col_enabled= (Field_enum*) f;
+        col_enabled->store_type((*m_row->m_enabled_ptr) ? ENUM_YES : ENUM_NO);
+        break;
+      case 2:
+        DBUG_ASSERT(f->real_type() == MYSQL_TYPE_LONG);
+        col_number_of_rows_filled= (Field_long*) f;
+        col_number_of_rows_filled->store(0);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+
+

=== added file 'storage/perfschema/table_setup_consumers.h'
--- a/storage/perfschema/table_setup_consumers.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_consumers.h	2008-11-04 16:11:21 +0000
@@ -0,0 +1,56 @@
+/* Copyright (C) 2008 Sun Microsystems, Inc
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef TABLE_SETUP_CONSUMERS_H
+#define TABLE_SETUP_CONSUMERS_H
+
+#include "psm_column_types.h"
+#include "psm_table.h"
+
+struct row_setup_consumers
+{
+  LEX_STRING m_name;
+  bool *m_enabled_ptr;
+};
+
+struct pos_setup_consumers
+{
+  uint m_index;
+};
+
+class table_setup_consumers : public psm_table
+{
+public:
+  static psm_table_info m_info;
+  static psm_table* create();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(unsigned char *pos);
+
+protected:
+  virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields);
+
+  table_setup_consumers();
+
+public:
+  ~table_setup_consumers()
+  {}
+
+private:
+  pos_setup_consumers m_pos;
+  row_setup_consumers *m_row;
+};
+
+#endif

=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_setup_instruments.cc	2008-11-04 16:11:21 +0000
@@ -14,40 +14,43 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "mysql_priv.h"
-#include "pse_metadata.h"
 #include "psm_sync_info.h"
 #include "psm_column_types.h"
 #include "psm_column_values.h"
 #include "table_setup_instruments.h"
 
-pse_table_info
-pse_scan_setup_instruments::m_info=
+psm_table_info
+table_setup_instruments::m_info=
 {
+  { C_STRING_WITH_LEN("setup_instruments") },
+  & table_setup_instruments::create,
+  NULL,
   99,
   0,
   sizeof(row_setup_instruments),
   0,
-  sizeof(pos_setup_instruments)
+  sizeof(pos_setup_instruments),
+  HA_POS_ERROR
 };
 
-pse_scan* pse_scan_setup_instruments::create()
+psm_table* table_setup_instruments::create()
 {
-  return new pse_scan_setup_instruments();
+  return new table_setup_instruments();
 }
 
-int pse_scan_setup_instruments::read_row(TABLE *table,
-                                         unsigned char *buf,
-                                         Field **fields)
+table_setup_instruments::table_setup_instruments()
+{
+  m_pos.m_index= 0;
+  memset(& m_row, 0, sizeof(m_row));
+}
+
+int table_setup_instruments::rnd_next()
 {
   int result;
-  my_bitmap_map *org_bitmap;
-  row_setup_instruments row;
   PSM_sync_info *info;
   char* name_ptr;
   const LEX_STRING *prefix;
 
-  org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
-
   m_pos.m_index++;
   info= find_sync_info(m_pos.m_index);
 
@@ -68,29 +71,31 @@ int pse_scan_setup_instruments::read_row
     }
     DBUG_ASSERT(prefix->length <= MAX_PREFIX_LENGTH);
     /* Instrument name = Prefix + category + name */
-    memcpy(row.m_name, prefix->str, prefix->length);
-    name_ptr= row.m_name + prefix->length;
+    memcpy(m_row.m_name, prefix->str, prefix->length);
+    name_ptr= m_row.m_name + prefix->length;
     memcpy(name_ptr, info->m_category, info->m_category_length);
     name_ptr+= info->m_category_length;
     memcpy(name_ptr, info->m_name, info->m_name_length);
     name_ptr+= info->m_name_length;
-    row.m_name_length= name_ptr - row.m_name;
-    row.m_enabled= false;
-    row.m_timed= true;
-    result= read_row_values(table, buf, fields, & row);
+    m_row.m_name_length= name_ptr - m_row.m_name;
+    m_row.m_enabled= false;
+    m_row.m_timed= true;
+    result= 0;
   }
   else
     result= HA_ERR_END_OF_FILE;
 
-  dbug_tmp_restore_column_map(table->write_set, org_bitmap);
-
   return result;
 }
 
-int pse_scan_setup_instruments::read_row_values(TABLE *table,
-                                                unsigned char *buf,
-                                                Field **fields,
-                                                row_setup_instruments *row)
+int table_setup_instruments::rnd_pos(unsigned char *pos)
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+int table_setup_instruments::read_row_values(TABLE *table,
+                                             unsigned char *buf,
+                                             Field **fields)
 {
   Field *f;
   Field_varstring *col_name;
@@ -113,17 +118,17 @@ int pse_scan_setup_instruments::read_row
       case 0:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
         col_name= (Field_varstring*) f;
-        col_name->store(row->m_name, row->m_name_length, cs);
+        col_name->store(m_row.m_name, m_row.m_name_length, cs);
         break;
       case 1:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
         col_enabled= (Field_enum*) f;
-        col_enabled->store_type(row->m_enabled ? ENUM_YES : ENUM_NO);
+        col_enabled->store_type(m_row.m_enabled ? ENUM_YES : ENUM_NO);
         break;
       case 2:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
         col_timed= (Field_enum*) f;
-        col_timed->store_type(row->m_timed ? ENUM_YES : ENUM_NO);
+        col_timed->store_type(m_row.m_timed ? ENUM_YES : ENUM_NO);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_setup_instruments.h'
--- a/storage/perfschema/table_setup_instruments.h	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_setup_instruments.h	2008-11-04 16:11:21 +0000
@@ -17,6 +17,7 @@
 #define TABLE_SETUP_INSTRUMENTS_H
 
 #include "psm_sync_info.h"
+#include "psm_table.h"
 
 struct row_setup_instruments
 {
@@ -31,30 +32,27 @@ struct pos_setup_instruments
   PSM_sync_key m_index;
 };
 
-class pse_scan_setup_instruments : public pse_scan
+class table_setup_instruments : public psm_table
 {
 public:
-  static pse_table_info m_info;
-  static pse_scan* create();
+  static psm_table_info m_info;
+  static psm_table* create();
 
-  int read_row(TABLE *table, unsigned char *buf, Field **fields);
-
-private:
-  int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
-                      row_setup_instruments *row);
+  virtual int rnd_next();
+  virtual int rnd_pos(unsigned char *pos);
 
 protected:
-  pse_scan_setup_instruments()
-  {
-    m_pos.m_index= 0;
-  }
+  virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields);
+
+  table_setup_instruments();
 
 public:
-  ~pse_scan_setup_instruments()
+  ~table_setup_instruments()
   {}
 
 private:
   pos_setup_instruments m_pos;
+  row_setup_instruments m_row;
 };
 
 #endif

=== modified file 'storage/perfschema/table_setup_timers.cc'
--- a/storage/perfschema/table_setup_timers.cc	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_setup_timers.cc	2008-11-04 16:11:21 +0000
@@ -14,68 +14,73 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "mysql_priv.h"
-#include "pse_metadata.h"
 #include "table_setup_timers.h"
 #include "psm_column_values.h"
 
-pse_table_info
-pse_scan_setup_timers::m_info=
+psm_table_info
+table_setup_timers::m_info=
 {
+  { C_STRING_WITH_LEN("setup_timers") },
+  & table_setup_timers::create,
+  NULL,
   1,
   0,
   sizeof(row_setup_timers),
   0,
-  sizeof(pos_setup_timers)
+  sizeof(pos_setup_timers),
+  HA_POS_ERROR
 };
 
-pse_scan* pse_scan_setup_timers::create()
+psm_table* table_setup_timers::create()
 {
-  return new pse_scan_setup_timers();
+  return new table_setup_timers();
 }
 
-pse_scan_setup_timers::pse_scan_setup_timers()
+table_setup_timers::table_setup_timers()
 {
   m_pos.m_index= 0;
+  m_row= NULL;
 
   m_data[0].m_name= timer_name_wait.str;
   m_data[0].m_name_length= timer_name_wait.length;
   m_data[0].m_timer_name= TIMER_NAME_CYCLE;
 }
 
-int pse_scan_setup_timers::read_row(TABLE *table,
-                                    unsigned char *buf,
-                                    Field **fields)
+int table_setup_timers::rnd_next()
 {
   int result;
-  my_bitmap_map *org_bitmap;
-  row_setup_timers *row;
-
-  org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
 
   if (m_pos.m_index < (sizeof(m_data)/sizeof(m_data[0])))
   {
-    row= & m_data[m_pos.m_index];
+    m_row= & m_data[m_pos.m_index];
     m_pos.m_index++;
-    result= read_row_values(table, buf, fields, row);
+    result= 0;
   }
   else
+  {
+    m_row= NULL;
     result= HA_ERR_END_OF_FILE;
-
-  dbug_tmp_restore_column_map(table->write_set, org_bitmap);
+  }
 
   return result;
 }
 
-int pse_scan_setup_timers::read_row_values(TABLE *table,
-                                           unsigned char *buf,
-                                           Field **fields,
-                                           row_setup_timers *row)
+int table_setup_timers::rnd_pos(unsigned char *pos)
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+int table_setup_timers::read_row_values(TABLE *table,
+                                        unsigned char *buf,
+                                        Field **fields)
 {
   Field *f;
   Field_varstring *col_name;
   Field_enum *col_timer_name;
   CHARSET_INFO *cs;
 
+  DBUG_ASSERT(m_row);
+
   cs= & my_charset_utf8_bin;
 
   /* Set the null bits */
@@ -92,12 +97,12 @@ int pse_scan_setup_timers::read_row_valu
       case 0:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_VARCHAR);
         col_name= (Field_varstring*) f;
-        col_name->store(row->m_name, row->m_name_length, cs);
+        col_name->store(m_row->m_name, m_row->m_name_length, cs);
         break;
       case 1:
         DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
         col_timer_name= (Field_enum*) f;
-        col_timer_name->store_type(row->m_timer_name);
+        col_timer_name->store_type(m_row->m_timer_name);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_setup_timers.h'
--- a/storage/perfschema/table_setup_timers.h	2008-11-03 16:45:45 +0000
+++ b/storage/perfschema/table_setup_timers.h	2008-11-04 16:11:21 +0000
@@ -17,6 +17,7 @@
 #define TABLE_SETUP_TIMERS_H
 
 #include "psm_column_types.h"
+#include "psm_table.h"
 
 struct row_setup_timers
 {
@@ -30,27 +31,27 @@ struct pos_setup_timers
   uint m_index;
 };
 
-class pse_scan_setup_timers : public pse_scan
+class table_setup_timers : public psm_table
 {
 public:
-  static pse_table_info m_info;
-  static pse_scan* create();
+  static psm_table_info m_info;
+  static psm_table* create();
 
-  int read_row(TABLE *table, unsigned char *buf, Field **fields);
-
-private:
-  int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
-                      row_setup_timers *row);
+  virtual int rnd_next();
+  virtual int rnd_pos(unsigned char *pos);
 
 protected:
-  pse_scan_setup_timers();
+  virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields);
+
+  table_setup_timers();
 
 public:
-  ~pse_scan_setup_timers()
+  ~table_setup_timers()
   {}
 
 private:
   pos_setup_timers m_pos;
+  row_setup_timers *m_row;
   row_setup_timers m_data[1];
 };
 

Thread
bzr push into mysql-6.0-perf branch (marc.alff:2725 to 2726) Marc Alff4 Nov