[Commits] Rev 2880: Added support for NO_RECORD record format (don't store any row data) for Aria. in http://bazaar.launchpad.net/~maria-captains/maria/5.3/

serg at askmonty.org serg at askmonty.org
Thu Jan 13 17:12:09 EET 2011


At http://bazaar.launchpad.net/~maria-captains/maria/5.3/

------------------------------------------------------------
revno: 2880
revision-id: sergii at pisem.net-20110113151111-0r0c36ezqmv2w8jp
parent: sergii at pisem.net-20110113150109-12i1o1e5m3flj91m
committer: Sergei Golubchik <sergii at pisem.net>
branch nick: 5.3-monty
timestamp: Thu 2011-01-13 16:11:11 +0100
message:
  Added support for NO_RECORD record format (don't store any row data) for Aria.
  This makes the keys smaller (no row pointer) and gives us proper errors if we
  use the table wrongly.
  
  Use this record format for internal temporary tables, if possible.
-------------- next part --------------
=== modified file 'include/my_base.h'
--- a/include/my_base.h	2010-11-04 14:53:10 +0000
+++ b/include/my_base.h	2011-01-13 15:11:11 +0000
@@ -519,7 +519,7 @@ enum en_fieldtype {
 };
 
 enum data_file_type {
-  STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD
+  STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD, NO_RECORD
 };
 
 /* For key ranges */

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-01-13 15:01:09 +0000
+++ b/sql/sql_select.cc	2011-01-13 15:11:11 +0000
@@ -12474,9 +12474,10 @@ bool create_internal_tmp_table(TABLE *ta
     create_info.data_file_length= ~(ulonglong) 0;
 
   if ((error= maria_create(share->table_name.str,
-                           share->reclength < 64 &&
-                           !share->blob_fields ? STATIC_RECORD :
-                           BLOCK_RECORD,
+                           table->no_rows ? NO_RECORD :
+                           (share->reclength < 64 &&
+                            !share->blob_fields ? STATIC_RECORD :
+                            BLOCK_RECORD),
                            share->keys, &keydef,
                            (uint) (*recinfo-start_recinfo),
                            start_recinfo,

=== modified file 'storage/maria/Makefile.am'
--- a/storage/maria/Makefile.am	2010-11-30 21:11:03 +0000
+++ b/storage/maria/Makefile.am	2011-01-13 15:11:11 +0000
@@ -124,7 +124,7 @@ libaria_la_SOURCES =	ma_init.c ma_open.c
                         ma_search.c ma_page.c ma_key_recover.c ma_key.c \
                         ma_locking.c ma_state.c \
                         ma_rrnd.c ma_scan.c ma_cache.c \
-                        ma_statrec.c ma_packrec.c ma_dynrec.c \
+                        ma_statrec.c ma_packrec.c ma_dynrec.c ma_norec.c \
                         ma_blockrec.c ma_bitmap.c \
                         ma_update.c ma_write.c ma_unique.c \
                         ma_delete.c \

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2010-12-13 13:51:47 +0000
+++ b/storage/maria/ma_check.c	2011-01-13 15:11:11 +0000
@@ -993,10 +993,12 @@ static int chk_index(HA_CHECK *param, MA
       /* fall through */
     }
     if ((share->data_file_type != BLOCK_RECORD &&
+         share->data_file_type != NO_RECORD &&
          record >= share->state.state.data_file_length) ||
         (share->data_file_type == BLOCK_RECORD &&
          ma_recordpos_to_page(record) * share->base.min_block_length >=
-         share->state.state.data_file_length))
+         share->state.state.data_file_length) ||
+        (share->data_file_type == NO_RECORD && record != 0))
     {
 #ifndef DBUG_OFF
       char llbuff2[22], llbuff3[22];
@@ -2047,6 +2049,12 @@ int maria_chk_data_link(HA_CHECK *param,
   case COMPRESSED_RECORD:
     error= check_compressed_record(param, info, extend, record);
     break;
+  case NO_RECORD:
+    param->records= share->state.state.records;
+    param->record_checksum= 0;
+    extend= 1;                                  /* No row checksums */
+    /* no data, nothing to do */
+    break;
   } /* switch */
 
   if (error)
@@ -2277,7 +2285,14 @@ static int initialize_variables_for_repa
 {
   MARIA_SHARE *share= info->s;
 
-  /* Ro allow us to restore state and check how state changed */
+  if (share->data_file_type == NO_RECORD)
+  {
+    _ma_check_print_error(param,
+                          "Can't repair tables with record type NO_DATA");
+    return 1;
+  }
+
+  /* Allow us to restore state and check how state changed */
   memcpy(org_share, share, sizeof(*share));
 
   /* Repair code relies on share->state.state so we have to update it here */
@@ -5184,8 +5199,10 @@ static int sort_get_next_record(MARIA_SO
       }
       DBUG_RETURN(0);
     }
+  case NO_RECORD:
+    DBUG_RETURN(1);                             /* Impossible */
   }
-  DBUG_RETURN(1);               /* Impossible */
+  DBUG_RETURN(1);                               /* Impossible */
 }
 
 
@@ -5305,6 +5322,8 @@ int _ma_sort_write_record(MARIA_SORT_PAR
       sort_param->filepos+=reclength+length;
       share->state.split++;
       break;
+    case NO_RECORD:
+      DBUG_RETURN(1);                           /* Impossible */
     }
   }
   if (sort_param->master)

=== modified file 'storage/maria/ma_create.c'
--- a/storage/maria/ma_create.c	2010-09-12 16:40:01 +0000
+++ b/storage/maria/ma_create.c	2011-01-13 15:11:11 +0000
@@ -250,10 +250,16 @@ int maria_create(const char *name, enum 
     datafile_type= BLOCK_RECORD;
   }
 
+  if (datafile_type == NO_RECORD && uniques)
+  {
+    /* Can't do unique without data, revert to block records */
+    datafile_type= BLOCK_RECORD;
+  }
+
   if (datafile_type == DYNAMIC_RECORD)
     options|= HA_OPTION_PACK_RECORD;    /* Must use packed records */
 
-  if (datafile_type == STATIC_RECORD)
+  if (datafile_type == STATIC_RECORD || datafile_type == NO_RECORD)
   {
     /* We can't use checksum with static length rows */
     flags&= ~HA_CREATE_CHECKSUM;
@@ -366,7 +372,9 @@ int maria_create(const char *name, enum 
                                       }
   else
   {
-    if (datafile_type != STATIC_RECORD)
+    if (datafile_type == NO_RECORD)
+      pointer= 0;
+    else if (datafile_type != STATIC_RECORD)
       pointer= maria_get_pointer_length(ci->data_file_length,
                                         maria_data_pointer_size);
     else

=== added file 'storage/maria/ma_norec.c'
--- a/storage/maria/ma_norec.c	1970-01-01 00:00:00 +0000
+++ b/storage/maria/ma_norec.c	2011-01-13 15:11:11 +0000
@@ -0,0 +1,66 @@
+/* Copyright (C) 2010 Monty Program Ab
+
+   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 */
+
+/*
+  Functions to handle tables with no row data (only index)
+  This is useful when you just want to do key reads or want to use
+  the index to check against duplicates.
+*/
+
+#include "maria_def.h"
+
+my_bool _ma_write_no_record(MARIA_HA *info __attribute__((unused)),
+                            const uchar *record __attribute__((unused)))
+{
+  return 0;
+}
+
+my_bool _ma_update_no_record(MARIA_HA *info __attribute__((unused)),
+                             MARIA_RECORD_POS pos __attribute__((unused)),
+                             const uchar *oldrec __attribute__((unused)),
+                             const uchar *record __attribute__((unused)))
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+
+my_bool _ma_delete_no_record(MARIA_HA *info __attribute__((unused)),
+                             const uchar *record __attribute__((unused)))
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+
+int _ma_read_no_record(MARIA_HA *info  __attribute__((unused)),
+                       uchar *record  __attribute__((unused)),
+                       MARIA_RECORD_POS pos __attribute__((unused)))
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+
+int _ma_read_rnd_no_record(MARIA_HA *info __attribute__((unused)),
+                           uchar *buf  __attribute__((unused)),
+                           MARIA_RECORD_POS filepos __attribute__((unused)),
+                           my_bool skip_deleted_blocks __attribute__((unused)))
+{
+  return HA_ERR_WRONG_COMMAND;
+}
+
+my_off_t _ma_no_keypos_to_recpos(MARIA_SHARE *share __attribute__ ((unused)),
+                                 my_off_t pos __attribute__ ((unused)))
+{
+  return 0;
+}

=== modified file 'storage/maria/ma_open.c'
--- a/storage/maria/ma_open.c	2011-01-13 15:01:09 +0000
+++ b/storage/maria/ma_open.c	2011-01-13 15:11:11 +0000
@@ -1078,6 +1078,20 @@ void _ma_setup_functions(register MARIA_
     else
       share->calc_checksum= _ma_checksum;
     break;
+  case NO_RECORD:
+    share->read_record=      _ma_read_no_record;
+    share->scan=             _ma_read_rnd_no_record;
+    share->delete_record=    _ma_delete_no_record;
+    share->update_record=    _ma_update_no_record;
+    share->write_record=     _ma_write_no_record;
+    share->recpos_to_keypos= _ma_no_keypos_to_recpos;
+    share->keypos_to_recpos= _ma_no_keypos_to_recpos;
+
+    /* Abort if following functions are called */
+    share->compare_record=   0;
+    share->compare_unique=   0;
+    share->calc_checksum= 0;
+    break;
   case BLOCK_RECORD:
     share->once_init= _ma_once_init_block_record;
     share->once_end=  _ma_once_end_block_record;

=== modified file 'storage/maria/ma_search.c'
--- a/storage/maria/ma_search.c	2010-10-14 22:46:20 +0000
+++ b/storage/maria/ma_search.c	2011-01-13 15:11:11 +0000
@@ -785,6 +785,7 @@ MARIA_RECORD_POS _ma_row_pos_from_key(co
   case 4:  pos= (my_off_t) mi_uint4korr(after_key);  break;
   case 3:  pos= (my_off_t) mi_uint3korr(after_key);  break;
   case 2:  pos= (my_off_t) mi_uint2korr(after_key);  break;
+  case 0:                                       /* NO_RECORD */
   default:
     pos=0L;                                     /* Shut compiler up */
   }
@@ -894,6 +895,7 @@ void _ma_dpointer(MARIA_SHARE *share, uc
   case 4: mi_int4store(buff,pos); break;
   case 3: mi_int3store(buff,pos); break;
   case 2: mi_int2store(buff,(uint) pos); break;
+  case 0: break;                                /* For NO_RECORD */
   default: abort();                             /* Impossible */
   }
 } /* _ma_dpointer */

=== modified file 'storage/maria/ma_test1.c'
--- a/storage/maria/ma_test1.c	2008-12-02 22:02:52 +0000
+++ b/storage/maria/ma_test1.c	2011-01-13 15:11:11 +0000
@@ -409,6 +409,10 @@ static int run_test(const char *filename
   if (!silent)
     printf("- Reading rows with key\n");
   record[1]= 0;                                 /* For nicer printf */
+
+  if (record_type == NO_RECORD)
+    maria_extra(file, HA_EXTRA_KEYREAD, 0);
+
   for (i=0 ; i <= 25 ; i++)
   {
     create_key(key,i);
@@ -422,6 +426,11 @@ static int run_test(const char *filename
              (int) key_length,key+offset_to_key,error,my_errno,record+1);
     }
   }
+  if (record_type == NO_RECORD)
+  {
+    maria_extra(file, HA_EXTRA_NO_KEYREAD, 0);
+    goto end;
+  }
 
   if (!silent)
     printf("- Reading rows with position\n");
@@ -757,6 +766,8 @@ static struct my_option my_long_options[
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"rows-in-block", 'M', "Store rows in block format",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"rows-no-data", 'n', "Don't store any data, only keys",
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"row-pointer-size", 'R', "Undocumented", (uchar**) &rec_pointer_size,
    (uchar**) &rec_pointer_size, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"silent", 's', "Undocumented",
@@ -816,6 +827,9 @@ get_one_option(int optid, const struct m
   case 'M':
     record_type= BLOCK_RECORD;
     break;
+  case 'n':
+    record_type= NO_RECORD;
+    break;
   case 'S':
     if (key_field == FIELD_VARCHAR)
     {
@@ -887,6 +901,10 @@ static void get_options(int argc, char *
     exit(ho_error);
   if (transactional)
     record_type= BLOCK_RECORD;
+  if (record_type == NO_RECORD)
+    skip_update= skip_delete= 1;
+
+
   return;
 } /* get options */
 

=== modified file 'storage/maria/maria_chk.c'
--- a/storage/maria/maria_chk.c	2010-12-05 13:10:12 +0000
+++ b/storage/maria/maria_chk.c	2011-01-13 15:11:11 +0000
@@ -68,7 +68,7 @@ static const char *field_pack[]=
 
 static const char *record_formats[]=
 {
-  "Fixed length", "Packed", "Compressed", "Block", "?"
+  "Fixed length", "Packed", "Compressed", "Block", "No data", "?", "?"
 };
 
 static const char *bitmap_description[]=

=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h	2011-01-13 15:01:09 +0000
+++ b/storage/maria/maria_def.h	2011-01-13 15:11:11 +0000
@@ -872,6 +872,18 @@ extern my_bool _ma_update_static_record(
                                         const uchar *, const uchar *);
 extern my_bool _ma_delete_static_record(MARIA_HA *info, const uchar *record);
 extern my_bool _ma_cmp_static_record(MARIA_HA *info, const uchar *record);
+
+extern my_bool _ma_write_no_record(MARIA_HA *info, const uchar *record);
+extern my_bool _ma_update_no_record(MARIA_HA *info, MARIA_RECORD_POS pos,
+                                    const uchar *oldrec, const uchar *record);
+extern my_bool _ma_delete_no_record(MARIA_HA *info, const uchar *record);
+extern int _ma_read_no_record(MARIA_HA *info, uchar *record,
+                              MARIA_RECORD_POS pos);
+extern int _ma_read_rnd_no_record(MARIA_HA *info, uchar *buf,
+                                  MARIA_RECORD_POS filepos,
+                                  my_bool skip_deleted_blocks);
+my_off_t _ma_no_keypos_to_recpos(MARIA_SHARE *share, my_off_t pos);
+
 extern my_bool _ma_ck_write(MARIA_HA *info, MARIA_KEY *key);
 extern my_bool _ma_enlarge_root(MARIA_HA *info, MARIA_KEY *key,
                                 MARIA_RECORD_POS *root);

=== modified file 'storage/maria/unittest/ma_test_all-t'
--- a/storage/maria/unittest/ma_test_all-t	2010-09-12 16:40:01 +0000
+++ b/storage/maria/unittest/ma_test_all-t	2011-01-13 15:11:11 +0000
@@ -250,6 +250,7 @@ sub run_check_tests
                       ["-p -B --key_length=480","-sm"],
                       ["--checksum --unique","-se"],
                       ["--unique","-se"],
+                      ["--rows-no-data", "-s"],
                       ["--key_multiple -N -S","-sm"],
                       ["--key_multiple -a -p --key_length=480","-sm"],
                       ["--key_multiple -a -B --key_length=480","-sm"],

=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c	2010-11-19 21:33:47 +0000
+++ b/storage/myisam/mi_check.c	2011-01-13 15:11:11 +0000
@@ -993,9 +993,6 @@ int chk_data_link(HA_CHECK *param, MI_IN
     if (killed_ptr(param))
       goto err2;
     switch (info->s->data_file_type) {
-    case BLOCK_RECORD:
-      DBUG_ASSERT(0);                           /* Impossible */
-      break;
     case STATIC_RECORD:
       if (my_b_read(&param->read_cache,(uchar*) record,
                     info->s->base.pack_reclength))
@@ -1213,6 +1210,9 @@ int chk_data_link(HA_CHECK *param, MI_IN
       link_used+= (block_info.filepos - start_recpos);
       used+= (pos-start_recpos);
       break;
+    default:
+      DBUG_ASSERT(0);                           /* Impossible */
+      break;
     } /* switch */
     if (! got_error)
     {
@@ -3270,9 +3270,6 @@ static int sort_get_next_record(MI_SORT_
     DBUG_RETURN(1);
 
   switch (share->data_file_type) {
-  case BLOCK_RECORD:
-    DBUG_ASSERT(0);                           /* Impossible */
-    break;
   case STATIC_RECORD:
     for (;;)
     {
@@ -3666,6 +3663,9 @@ static int sort_get_next_record(MI_SORT_
                                                            record));
       DBUG_RETURN(0);
     }
+  default:
+    DBUG_ASSERT(0);                           /* Impossible */
+    break;
   }
   DBUG_RETURN(1);                               /* Impossible */
 }
@@ -3702,9 +3702,6 @@ int sort_write_record(MI_SORT_PARAM *sor
   if (sort_param->fix_datafile)
   {
     switch (sort_info->new_data_file_type) {
-    case BLOCK_RECORD:
-      DBUG_ASSERT(0);                           /* Impossible */
-      break;
     case STATIC_RECORD:
       if (my_b_write(&info->rec_cache,sort_param->record,
                      share->base.pack_reclength))
@@ -3778,6 +3775,9 @@ int sort_write_record(MI_SORT_PARAM *sor
       sort_param->filepos+=reclength+length;
       info->s->state.split++;
       break;
+    default:
+      DBUG_ASSERT(0);                           /* Impossible */
+      break;
     }
   }
   if (sort_param->master)



More information about the commits mailing list