Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron 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
1.1839 05/05/24 22:26:42 mronstrom@stripped +4 -0
WL 1354: Partitioning
Completed coding of reverse parser for partitioning syntax
sql/table.cc
1.190 05/05/24 22:26:32 mronstrom@stripped +77 -34
Completed coding of reverse parser for partitioning syntax
sql/sql_table.cc
1.228 05/05/24 22:26:32 mronstrom@stripped +12 -0
Completed coding of reverse parser for partitioning syntax
sql/sql_show.cc
1.246 05/05/24 22:26:32 mronstrom@stripped +15 -3
Completed coding of reverse parser for partitioning syntax
sql/mysql_priv.h
1.266 05/05/24 22:26:32 mronstrom@stripped +2 -0
Completed coding of reverse parser for partitioning syntax
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mronstrom
# Host: c-f10be253.1238-1-64736c10.cust.bredbandsbolaget.se
# Root: /Users/mikron/wl1354
--- 1.265/sql/mysql_priv.h Fri May 13 15:22:57 2005
+++ 1.266/sql/mysql_priv.h Tue May 24 22:26:32 2005
@@ -611,6 +611,8 @@
uint *start_part, uint *end_part, bool *use_bit_array);
bool check_partition_info(partition_info *part_info,enum db_type eng_type,
handler *file, ulonglong max_rows);
+char *generate_partition_syntax(partition_info *part_info,
+ uint *buf_length, bool use_sql_alloc);
uint get_tot_partitions(partition_info *part_info);
bool is_sub_partitioned(partition_info *part_info);
--- 1.245/sql/sql_show.cc Tue May 24 14:39:30 2005
+++ 1.246/sql/sql_show.cc Tue May 24 22:26:32 2005
@@ -1024,9 +1024,21 @@
append_directory(thd, packet, "DATA", create_info.data_file_name);
append_directory(thd, packet, "INDEX", create_info.index_file_name);
}
- /*
- TODO RONM: Partitioning Syntax will be added here
- */
+ {
+ /*
+ Partition syntax for CREATE TABLE is at the end of the syntax.
+ */
+ uint part_syntax_len;
+ char *part_syntax;
+ if (table->s->part_info &&
+ (!(part_syntax= generate_partition_syntax(table->s->part_info,
+ &part_syntax_len,
+ FALSE))))
+ {
+ packet->append(part_syntax, part_syntax_len);
+ my_free(part_syntax, MYF(0));
+ }
+ }
DBUG_RETURN(0);
}
--- 1.227/sql/sql_table.cc Thu May 12 16:15:52 2005
+++ 1.228/sql/sql_table.cc Tue May 24 22:26:32 2005
@@ -1505,6 +1505,8 @@
DB_TYPE_DEFAULT or the engine set in the ALTER TABLE command.
*/
enum db_type part_engine_type= create_info->db_type;
+ char *part_syntax_buf;
+ uint syntax_len;
if (part_engine_type == DB_TYPE_PARTITION_DB)
{
/*
@@ -1517,6 +1519,16 @@
if (check_partition_info(part_info, part_engine_type,
file, create_info->max_rows))
DBUG_RETURN(TRUE);
+ /*
+ We reverse the partitioning parser and generate a standard format
+ for syntax stored in frm file.
+ */
+ if (!(part_syntax_buf= generate_partition_syntax(part_info,
+ &syntax_len,
+ TRUE)))
+ DBUG_RETURN(TRUE);
+ part_info->part_info_string= part_syntax_buf;
+ part_info->part_info_len= syntax_len;
if ((!(file->partition_flags() & HA_CAN_PARTITION)) ||
create_info->db_type == DB_TYPE_PARTITION_DB)
{
--- 1.189/sql/table.cc Tue May 24 17:50:08 2005
+++ 1.190/sql/table.cc Tue May 24 22:26:32 2005
@@ -213,6 +213,13 @@
DBUG_RETURN(FALSE);
}
+/*
+ The code below is support routines for the reverse parsing of the
+ partitioning syntax. This feature is very useful to generate syntax for
+ all default values to avoid all default checking when opening the frm
+ file. It is also used when altering the partitioning by use of various
+ ALTER TABLE commands. Finally it is used for SHOW CREATE TABLES.
+*/
int add_write(File fptr, const char *buf, uint len)
{
uint len_written= my_write(fptr, buf, len, MYF(0));
@@ -403,16 +410,44 @@
return err;
}
-int generate_partition_syntax(partition_info *part_info)
+/*
+ Here we will generate the full syntax for the given command where all
+ defaults have been expanded. By so doing the it is also possible to
+ make lots of checks of correctness while at it.
+ This could will also be reused for SHOW CREATE TABLES and also for all
+ type ALTER TABLE commands focusing on changing the PARTITION structure
+ in any fashion.
+
+ The implementation writes the syntax to a temporary file (essentially
+ an abstraction of a dynamic array) and if all writes goes well it
+ allocates a buffer and writes the syntax into this one and returns it.
+
+ SYNOPSIS
+ generate_partition_syntax()
+ part_info The partitioning data structure
+ buf_length A pointer to the returned buffer length
+ use_sql_alloc Allocate buffer from sql_alloc if true
+ otherwise use my_malloc
+
+ RETURN VALUES
+ NULL error
+ buf, buf_length Buffer and its length
+*/
+char *generate_partition_syntax(partition_info *part_info,
+ uint *buf_length,
+ bool use_sql_alloc)
{
uint i,j, no_parts, no_subparts;
partition_element *part_elem;
+ ulonglong buffer_length;
int err;
DBUG_ENTER("generate_partition_syntax");
File fptr;
+ char *buf= NULL; //Return buffer
/* TODO RONM Generate a unique file name */
- if ((fptr= my_open("./part_syntax.tmp",O_CREAT|O_RDWR, MYF(0))))
- DBUG_RETURN(TRUE);
+ const char *file_name= "./part_syntax.tmp";
+ if ((fptr= my_open(file_name,O_CREAT|O_RDWR, MYF(MY_WME))))
+ DBUG_RETURN(NULL);
err= add_partition_by(fptr);
switch (part_info->part_type)
{
@@ -430,7 +465,9 @@
break;
default:
DBUG_ASSERT(0);
- DBUG_RETURN(TRUE);
+ /* We really shouldn't get here, no use in continuing from here */
+ exit(1);
+ DBUG_RETURN(NULL);
}
if (part_info->part_expr)
err+= add_string_len(fptr, part_info->part_func_string,
@@ -439,18 +476,11 @@
if (is_sub_partitioned(part_info))
{
err+= add_subpartition_by(fptr);
- switch (part_info->subpart_type)
- {
- case HASH_PARTITION:
- if (part_info->list_of_subpart_fields)
- err+= add_key_partition(fptr, part_info->subpart_field_list);
- else
- err+= add_hash(fptr);
- break;
- default:
- DBUG_ASSERT(0);
- DBUG_RETURN(TRUE);
- }
+ /* Must be hash partitioning for subpartitioning */
+ if (part_info->list_of_subpart_fields)
+ err+= add_key_partition(fptr, part_info->subpart_field_list);
+ else
+ err+= add_hash(fptr);
if (part_info->subpart_expr)
err+= add_string_len(fptr, part_info->subpart_func_string,
part_info->subpart_func_len);
@@ -490,10 +520,37 @@
else
err+= add_end_parenthesis(fptr);
}
- DBUG_RETURN(TRUE);
-error:
- DBUG_ASSERT(0);
- DBUG_RETURN(TRUE);
+ if (err)
+ goto close_file;
+ buffer_length= my_seek(fptr, 0L,MY_SEEK_END,MYF(0));
+ if ((buffer_length) == MY_FILEPOS_ERROR)
+ goto close_file;
+ if (my_seek(fptr, 0L, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)
+ goto close_file;
+ *buf_length= (uint)buffer_length;
+ if (use_sql_alloc)
+ buf= sql_alloc(*buf_length);
+ else
+ buf= my_malloc(*buf_length, MYF(MY_WME));
+ if (!buf)
+ goto close_file;
+
+ if (my_read(fptr, buf, *buf_length, MYF(MY_FNABP)) == MY_FILE_ERROR)
+ if (!use_sql_alloc)
+ my_free(buf, MYF(0));
+ else
+ buf= NULL;
+
+close_file:
+ /*
+ Delete the file before closing to ensure the file doesn't get synched
+ to disk unnecessary. We only used the file system as a dynamic array
+ implementation so we are not really interested in getting the file
+ present on disk.
+ */
+ my_delete(file_name, MYF(0));
+ my_close(fptr, MYF(0));
+ DBUG_RETURN(buf);
}
bool check_partition_info(partition_info *part_info,enum db_type eng_type,
@@ -557,20 +614,6 @@
return_value= TRUE;
}
my_free((char*)engine_array,MYF(0));
- /*
- Here we will generate the full syntax for the given command where all
- defaults have been expanded. By so doing the it is also possible to
- make lots of checks of correctness while at it.
- This could will also be reused for SHOW CREATE TABLES and also for all
- type ALTER TABLE commands focusing on changing the PARTITION structure
- in any fashion.
- TODO RONM:
- */
- if (!return_value)
- {
- /* TODO RONM Fix surrounding code */
- generate_partition_syntax(part_info);
- }
DBUG_RETURN(return_value);
}
| Thread |
|---|
| • bk commit into 5.1 tree (mronstrom:1.1839) | mikael | 25 May |