Hi!

> So, a few questions as to how MySQL does it, and hopefully a discussion on

I can say what I have seen in MySQL 5.1 - most notably sql/sql_show.cc

> how Drizzle should do it:
> 1) Are the information_schema tables views or temporary tables?

As far as I know they are not "views" in the sense of named schema
objects defined by a query expression.
They are temporary tables in the sense that they are transient
in-memory structures that are bound to the thread (the current
connection).
In C they are defined through a special struct in table.h

typedef struct st_schema_table
{
  const char* table_name;
  ST_FIELD_INFO *fields_info;
  /* Create information_schema table */
  TABLE *(*create_table)  (THD *thd, TABLE_LIST *table_list);
  /* Fill table with data */
  int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
  /* Handle fileds for old SHOW */
  int (*old_format) (THD *thd, struct st_schema_table *schema_table);
  int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
                        bool res, LEX_STRING *db_name, LEX_STRING *table_name);
  int idx_field1, idx_field2;
  bool hidden;
  uint i_s_requested_object;  /* the object we need to open(TABLE | VIEW) */
} ST_SCHEMA_TABLE;

I don't think this is the same as a table you create with CREATE TEMP TABLE.

> 2) Where are the definitions stored for the information_schema tables?

If you mean, the column layout that is defined as a list in the C code.
The member

  ST_FIELD_INFO *fields_info;

of ST_SCHEMA_TABLE holds this list.

The specific IS table layouts are hardwired in sql_show.cc

For example, here is the column layout for I_S.processlist:

ST_FIELD_INFO processlist_fields_info[]=
{
  {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
  {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
  {"HOST", LIST_PROCESS_HOST_LEN,  MYSQL_TYPE_STRING, 0, 0, "Host",
   SKIP_OPEN_TABLE},
  {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE},
  {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command", SKIP_OPEN_TABLE},
  {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
  {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
  {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
   SKIP_OPEN_TABLE},
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
};

> 3) How and when do the definitions get loaded?

If you mean by "definition" the column layout, then I think it is
loaded from the start on. The arrays of ST_FIELD_INFO are global
variables.
I am not entirely sure how and when the data is loaded.

> I see these questions (particularly #3) as important particularly for
> plugins, as some plugins will (heck, I'd probably argue that most of the
> major ones *should*) add to the information_schema database.

well, I believe that for information schema plugins, the definition is
loaded at least upon INSTALL plugin, but also on server startup (for
those plugins already installed)

I hope this helps,

Roland
>
> --
> - Sheeri K. Cabral
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~drizzle-discuss
> Post to     : [email protected]
> Unsubscribe : https://launchpad.net/~drizzle-discuss
> More help   : https://help.launchpad.net/ListHelp
>
>



-- 
Roland Bouman
http://rpbouman.blogspot.com/

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to