From: Date: October 9 2006 4:03pm Subject: bk commit into 5.1 tree (stewart:1.2305) BUG#20839 List-Archive: http://lists.mysql.com/commits/13334 X-Bug: 20839 Message-Id: <20061009140352.F2668141863D@localhost.localdomain> Below is the list of changes that have just been committed into a local 5.1 repository of stewart. When stewart 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, 2006-10-10 00:03:46+10:00, stewart@willster.(none) +2 -0 BUG#20839 Illegal error code: 155 returned downgrading from 5.1.12-> 5.1.11 Update mysqldump to dump the needed tablespaces to create the tables for either the dbs or tables we're dumping. With --all-tablespaces, we still dump everything. client/mysqldump.c@stripped, 2006-10-10 00:03:40+10:00, stewart@willster.(none) +143 -26 Add --no-tablespaces to force not dumping any tablespace information Change behaviour so that: If dumping all databases, all tablespaces are dumped If dumping with --all-tablespaces, all tablespaces are dumped If dumping a set of databases, dump only tablespaces used by tables in that database If dumping a set of tables, dump only tablespaces used by those tables If --no-tablespaces is specified, no tablespaces are dumped. Default behaviour is to dump a restorable dump - i.e. with the tablespaces. When connecting to old mysqld, --no-tablespaces should be specified. sql/sql_show.cc@stripped, 2006-10-10 00:03:41+10:00, stewart@willster.(none) +16 -5 Use the TABLESPACE_NAME field of the INFORMATION_SCHEMA.PARTITIONS table. NOTE: *CHANGE* in behaviour: if no tablespace, TABLESPACE_NAME will be NULL. This is to support a tablespace called 'default' (which you can happily create). It is likely that the other fields with 'default' should change too. This should also happily continue to work in the future (from a user point of view) when we introduce tablespace per partition. # 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: stewart # Host: willster.(none) # Root: /home/stewart/Documents/MySQL/5.1/bug20839 --- 1.252/client/mysqldump.c 2006-10-10 00:03:52 +10:00 +++ 1.253/client/mysqldump.c 2006-10-10 00:03:52 +10:00 @@ -99,7 +99,7 @@ opt_replace_into= 0, opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1, opt_events= 0, - opt_alltspcs=0; + opt_alltspcs=0, opt_notspcs= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*mysql=0; static my_bool insert_pat_inited=0; @@ -170,6 +170,10 @@ "Dump all the tablespaces.", (gptr*) &opt_alltspcs, (gptr*) &opt_alltspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-tablespaces", 'y', + "Do not dump any tablespace information.", + (gptr*) &opt_notspcs, (gptr*) &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + 0, 0}, {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.", (gptr*) &opt_drop_database, (gptr*) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -446,6 +450,10 @@ static char *primary_key_fields(const char *table_name); static my_bool get_view_structure(char *table, char* db); static my_bool dump_all_views_in_db(char *database); +static int dump_all_tablespaces(); +static int dump_tablespaces_for_tables(char *db, char **table_names, int tables); +static int dump_tablespaces_for_databases(char** databases); +static int dump_tablespaces(char* ts_where); #include @@ -2746,9 +2754,100 @@ static int dump_all_tablespaces() { + return dump_tablespaces(NULL); +} + +static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) +{ + char *where; + int r; + int i; + + size_t sz= 200+tables*(NAME_LEN*2+3); + where= my_malloc(sz, MYF(MY_WME)); + + if (!where) + return 1; + + char name_buff[NAME_LEN*2+3]; + mysql_real_escape_string(mysql, name_buff, db, strlen(db)); + + snprintf(where,sz-1, + " AND TABLESPACE_NAME IN (" + "SELECT DISTINCT TABLESPACE_NAME FROM" + " INFORMATION_SCHEMA.PARTITIONS" + " WHERE" + " TABLE_SCHEMA='%s'" + " AND TABLE_NAME IN (", name_buff); + + for (i=0 ; i 1 && !opt_databases) { /* Only one database and selected table(s) */ + if (!opt_alltspcs && !opt_notspcs) + dump_tablespaces_for_tables(*argv, (argv + 1), (argc -1)); dump_selected_tables(*argv, (argv + 1), (argc - 1)); } else { /* One or more databases, all tables */ + if (!opt_alltspcs && !opt_notspcs) + dump_tablespaces_for_databases(argv); dump_databases(argv); } #ifdef HAVE_SMEM --- 1.362/sql/sql_show.cc 2006-10-10 00:03:52 +10:00 +++ 1.363/sql/sql_show.cc 2006-10-10 00:03:52 +10:00 @@ -3889,6 +3889,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *table, + TABLE *show_table, partition_element *part_elem, handler *file, uint part_id) { @@ -3942,11 +3943,21 @@ table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE); else table->field[23]->store(STRING_WITH_LEN("default"), cs); + + table->field[24]->set_notnull(); if (part_elem->tablespace_name) table->field[24]->store(part_elem->tablespace_name, strlen(part_elem->tablespace_name), cs); else - table->field[24]->store(STRING_WITH_LEN("default"), cs); + { + DBUG_PRINT("info",("FOO")); + char *ts= show_table->file->get_tablespace_name(thd); + if(ts) + table->field[24]->store(ts, strlen(ts), cs); + else + table->field[24]->set_null(); + my_free(ts, MYF(0)); + } } return; } @@ -4129,7 +4140,7 @@ table->field[6]->store((longlong) ++subpart_pos, TRUE); table->field[6]->set_notnull(); - store_schema_partitions_record(thd, table, subpart_elem, + store_schema_partitions_record(thd, table, show_table, subpart_elem, file, part_id); part_id++; if(schema_table_store_record(thd, table)) @@ -4138,7 +4149,7 @@ } else { - store_schema_partitions_record(thd, table, part_elem, + store_schema_partitions_record(thd, table, show_table, part_elem, file, part_id); part_id++; if(schema_table_store_record(thd, table)) @@ -4150,7 +4161,7 @@ else #endif { - store_schema_partitions_record(thd, table, 0, file, 0); + store_schema_partitions_record(thd, table, show_table, 0, file, 0); if(schema_table_store_record(thd, table)) DBUG_RETURN(1); } @@ -5334,7 +5345,7 @@ {"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"PARTITION_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, 0}, {"NODEGROUP", 12 , MYSQL_TYPE_STRING, 0, 0, 0}, - {"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + {"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} };