List:Commits« Previous MessageNext Message »
From:bmiezejewski Date:September 27 2007 8:23pm
Subject:bk commit into 5.1 tree (bmiezejewski:1.2567)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of brianm. When brianm does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-09-27 15:23:26-05:00, bmiezejewski@lcane.(none) +4 -0
  Temp table perf fix.

  sql/mysql_priv.h@stripped, 2007-09-27 15:23:17-05:00, bmiezejewski@lcane.(none) +19 -0
    Temp table perf fix.

  sql/sql_acl.cc@stripped, 2007-09-27 15:23:17-05:00, bmiezejewski@lcane.(none) +21 -0
    Temp table perf fix.

  sql/sql_select.cc@stripped, 2007-09-27 15:23:17-05:00, bmiezejewski@lcane.(none) +179 -0
    Temp table perf fix.

  sql/sql_table.cc@stripped, 2007-09-27 15:23:18-05:00, bmiezejewski@lcane.(none) +11 -0
    Temp table perf fix.

diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h	2007-09-27 15:16:01 -05:00
+++ b/sql/mysql_priv.h	2007-09-27 15:23:17 -05:00
@@ -1020,6 +1020,24 @@ int reassign_keycache_tables(THD* thd, K
                              KEY_CACHE *dst_cache);
 TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
 
+int create_pse_tmp_table(THD *thd, HA_CREATE_INFO *create_info,
+                         Alter_info *alter_info, char* db_name, 
+                         char* table_name, bool already_created);
+
+bool mysql_prepare_create_pse_table(THD *thd, HA_CREATE_INFO *create_info,
+                            Alter_info *alter_info, 
+                            bool tmp_table, uint *db_options,
+                            handler *file, KEY **key_info_buffer,
+                            uint *key_count, int select_field_count);
+
+my_bool pse_grant_privilege(const char *host, const char *db,
+                            const char *user, const char *table_name, 
+                            ulong table_privilege, ulong column_privilege);
+
+my_bool pse_drop_privilege(const char *host, const char *ip, const char *db,
+                           const char *user, const char *table_name);
+
+
 bool mysql_xa_recover(THD *thd);
 
 bool check_simple_select();
@@ -1880,6 +1898,7 @@ extern TYPELIB log_output_typelib;
 extern handlerton *partition_hton;
 extern handlerton *myisam_hton;
 extern handlerton *heap_hton;
+extern handlerton *nitro_hton;
 
 extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen;
 extern SHOW_COMP_OPTION have_query_cache;
diff -Nrup a/sql/sql_acl.cc b/sql/sql_acl.cc
--- a/sql/sql_acl.cc	2007-08-13 08:11:13 -05:00
+++ b/sql/sql_acl.cc	2007-09-27 15:23:17 -05:00
@@ -6136,6 +6136,27 @@ int fill_schema_user_privileges(THD *thd
 }
 
 
+my_bool pse_grant_privilege(const char *host, const char *db,
+                            const char *user, const char *table_name, 
+                            ulong table_privilege, ulong column_privilege)
+{
+    GRANT_TABLE* grant_table = new GRANT_TABLE (host, db,
+           user, table_name,table_privilege,column_privilege);
+    return my_hash_insert(&column_priv_hash, (uchar*) grant_table);
+}
+
+my_bool pse_drop_privilege(const char *host, const char *ip, const char *db,
+                           const char *user, const char *table_name)
+{
+  GRANT_TABLE *grant= (GRANT_TABLE*) name_hash_search(&column_priv_hash, 
+    host, ip, db,user, table_name, FALSE);
+  if(grant){
+    return hash_delete(&column_priv_hash,(uchar*) grant);
+    delete grant;
+  }
+  return false;
+}
+
 int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond)
 {
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc	2007-08-13 14:39:25 -05:00
+++ b/sql/sql_select.cc	2007-09-27 15:23:17 -05:00
@@ -10191,6 +10191,185 @@ error:
   return 0;
 }
 
+int create_pse_tmp_table(THD *thd, HA_CREATE_INFO *create_info,
+                         Alter_info *alter_info, char* db_name, 
+                         char* table_name, bool already_created)
+{
+  MEM_ROOT own_root;
+  uint field_count= alter_info->create_list.elements;
+  uint blob_count= 0;
+  Field **field;
+  Create_field *cdef;                           /* column definition */
+  uint record_length= 0;
+  uint null_count= 0;                 /* number of columns which may be null */
+  uint null_pack_length;              /* NULL representation array length */
+  uint *blob_field;
+  uchar *bitmaps;
+  TABLE *table;
+  TABLE_SHARE *share;
+  char  *tmp_table_path;
+
+  DBUG_ENTER("create_pse_tmp_table");
+
+  init_sql_alloc(&own_root, TABLE_ALLOC_BLOCK_SIZE, 0);
+
+  if (!multi_alloc_root(&own_root,
+                        &table, sizeof(*table),
+                        &share, sizeof(*share),
+                        &field, (field_count + 1) * sizeof(Field*),
+                        &blob_field, (field_count+1) *sizeof(uint),
+                        &bitmaps, bitmap_buffer_size(field_count)*2,
+                        &tmp_table_path, FN_REFLEN+1,
+                        NullS))
+    return 0;
+
+  build_table_filename(tmp_table_path, FN_REFLEN+1, db_name, table_name, "", 0);
+
+  bzero(table, sizeof(*table));
+  table->mem_root= own_root;
+  table->field= field;
+  table->s= share;
+  table->alias= strmake_root(&table->mem_root, table_name, strlen(table_name));
+
+  //same as create_table_def_key()
+  char* db= strmake_root(&table->mem_root, db_name, strlen(db_name));
+  char* key= (char*)alloc_root(&table->mem_root, MAX_DBKEY_LENGTH);
+  uint key_length= (uint) (strmov(strmov(key, db)+1,
+                                  table->alias)-key)+1;
+  int4store(key + key_length, thd->server_id);
+  int4store(key + key_length + 4, thd->variables.pseudo_thread_id);
+  key_length+= TMP_TABLE_KEY_EXTRA;
+
+  init_tmp_table_share(share, key, key_length,tmp_table_path,tmp_table_path);
+  share->db_plugin= ha_lock_engine(0, create_info->db_type);
+  table->file= get_new_handler(share, &table->mem_root,share->db_type());
+
+  uint db_options= (uint)create_info->table_options;
+  uint key_count=0;
+  KEY    *key_info_buffer;
+  mysql_prepare_create_pse_table(thd, create_info,
+                          alter_info,1,
+                          &db_options,table->file, &key_info_buffer,
+                          &key_count, 0);
+
+  share->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
+  share->table_charset= create_info->table_charset;
+  share->field= field;
+  share->blob_field= blob_field;
+  share->fields= field_count;
+  share->blob_ptr_size= mi_portable_sizeof_char_ptr;
+  setup_tmp_table_column_bitmaps(table, bitmaps);
+
+  /* Create all fields and calculate the total length of record */
+  List_iterator_fast<Create_field> it(alter_info->create_list);
+  while ((cdef= it++))
+  {
+    TYPELIB *interval= NULL;
+    char *field_name= NULL;
+
+    if(cdef->interval)
+    {
+      interval= (TYPELIB *) alloc_root(&table->mem_root, sizeof(*interval));
+      memcpy(interval, cdef->interval, sizeof(*interval));
+    }
+    if(cdef->field_name)
+    {
+      field_name= (char*) alloc_root(&table->mem_root, (uint) strlen(cdef->field_name)+1);
+      strncpy(field_name, cdef->field_name, (uint)strlen(cdef->field_name)+1);
+    }
+
+      *field= make_field(share, 0, cdef->length,
+                       (uchar*) (f_maybe_null(cdef->pack_flag) ? "" : 0),
+                       f_maybe_null(cdef->pack_flag) ? 1 : 0,
+                       cdef->pack_flag, cdef->sql_type, cdef->charset,
+                       cdef->geom_type, cdef->unireg_check,
+                       interval, field_name);
+
+    if (!*field)
+      goto error;
+    (*field)->init(table);
+    record_length+= (*field)->pack_length();
+    if (! ((*field)->flags & NOT_NULL_FLAG))
+      null_count++;
+
+    if ((*field)->flags & BLOB_FLAG)
+      share->blob_field[blob_count++]= (uint) (field - table->field);
+
+    field++;
+  }
+
+  *field= NULL;                             /* mark the end of the list */
+  share->blob_field[blob_count]= 0;            /* mark the end of the list */
+  share->blob_fields= blob_count;
+
+  null_pack_length= (null_count + 7)/8;
+  share->reclength= record_length + null_pack_length;
+  share->rec_buff_length= ALIGN_SIZE(share->reclength + 1);
+  table->record[0]= (uchar*) thd->alloc(share->rec_buff_length*3); //needs to be changed
+  if (!table->record[0])
+    goto error;
+  table->record[1]= table->record[0]+share->reclength;
+  share->default_values= table->record[1]+share->reclength;
+
+  if (null_pack_length)
+  {
+    table->null_flags= (uchar*) table->record[0];
+    share->null_fields= null_count;
+    share->null_bytes= null_pack_length;
+  }
+
+  table->in_use= thd;           /* field->reset() may access table->in_use */
+  {
+    /* Set up field pointers */
+    uchar *null_pos= table->record[0];
+    uchar *field_pos= null_pos + share->null_bytes;
+    uint null_bit= 1;
+
+    for (field= table->field; *field; ++field)
+    {
+      Field *cur_field= *field;
+      if ((cur_field->flags & NOT_NULL_FLAG))
+        cur_field->move_field((uchar*) field_pos);
+      else
+      {
+        cur_field->move_field((uchar*) field_pos, (uchar*) null_pos, null_bit);
+        null_bit<<= 1;
+        if (null_bit == (1 << 8))
+        {
+          ++null_pos;
+          null_bit= 1;
+        }
+      }
+      cur_field->reset();
+
+      field_pos+= cur_field->pack_length();
+    }
+  }
+
+  if(!already_created && table->file->create(tmp_table_path, table, create_info))
+  goto error;
+
+  if (open_tmp_table(table))
+    goto error;
+
+  table->prev=table;
+  table->next= thd->temporary_tables;
+    if (table->next)
+      table->next->prev= table;
+    thd->temporary_tables= table;
+    thd->temporary_tables->prev= 0;
+
+    DBUG_RETURN(0);
+
+error:
+  for (field= table->field; *field; ++field)
+    delete *field;                         /* just invokes field destructor */
+    DBUG_RETURN(1);
+}
+
+
+
+
 
 static bool open_tmp_table(TABLE *table)
 {
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc	2007-09-27 15:16:01 -05:00
+++ b/sql/sql_table.cc	2007-09-27 15:23:18 -05:00
@@ -7129,3 +7129,14 @@ static bool check_engine(THD *thd, const
   }
   return FALSE;
 }
+
+
+bool mysql_prepare_create_pse_table(THD *thd, HA_CREATE_INFO *create_info,
+                            Alter_info *alter_info,
+                            bool tmp_table, uint *db_options,
+                            handler *file, KEY **key_info_buffer,
+                            uint *key_count, int select_field_count)
+{
+  return mysql_prepare_create_table(thd,create_info,alter_info,tmp_table, db_options, 
+	                         file,key_info_buffer,key_count,select_field_count);
+}
Thread
bk commit into 5.1 tree (bmiezejewski:1.2567)bmiezejewski27 Sep