Commit d0e83062 authored by jani@hynda.mysql.fi's avatar jani@hynda.mysql.fi
Browse files

Added xml patch to mysqldump.

Made innodb to compile more cleanly with debugging options
enabled. Fixed a few bugs and found a few possible bugs, which
I hope Heikki will check. Comments needs to be fixed too. Some
while() functions should be changed to do ... until for documenting
purposes, because some of them must and will be processed at least
once, or a variable would be used uninitialized.

Regards,
Jani
parent 8e2bfcb8
Loading
Loading
Loading
Loading
+79 −30
Original line number Diff line number Diff line
@@ -31,7 +31,9 @@
** SSL by
** Andrei Errapart <andreie@no.spam.ee>
** Tnu Samuel  <tonu@please.do.not.remove.this.spam.ee>
**/
** XML by Gary Huntress <ghuntress@mediaone.net> 10/10/01, cleaned up
** and adapted to mysqldump 05/11/01 by Jani Tolonen
*/

#define DUMP_VERSION "8.18"

@@ -70,7 +72,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
		lock_tables=0,ignore_errors=0,flush_logs=0,replace=0,
		ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0,
                opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
	        opt_alldbs=0,opt_create_db=0,opt_first_slave=0, opt_autocommit=0, opt_master_data;
	        opt_alldbs=0,opt_create_db=0,opt_first_slave=0, 
                opt_autocommit=0, opt_master_data, opt_xml=0;
static MYSQL  mysql_connection,*sock=0;
static char  insert_pat[12 * 1024],*opt_password=0,*current_user=0,
             *current_host=0,*path=0,*fields_terminated=0,
@@ -135,6 +138,7 @@ static struct option long_options[] =
  {"verbose",    	no_argument,		0, 'v'},
  {"version",    	no_argument,    	0, 'V'},
  {"where",		required_argument, 	0, 'w'},
  {"xml", 		no_argument, 		0, 'X'},
  {0, 0, 0, 0}
};

@@ -248,6 +252,7 @@ puts("\
  -v, --verbose		Print info about the various stages.\n\
  -V, --version		Output version information and exit.\n\
  -w, --where=		dump only selected records; QUOTES mandatory!\n\
  -X, --xml             dump a database as well formed XML\n\
  -x, --first-slave     Locks all tables across all databases.\n\
  EXAMPLES: \"--where=user=\'jimf\'\" \"-wuserid>1\" \"-wuserid<1\"\n\
  Use -T (--tab=...) with --fields-...\n\
@@ -273,6 +278,10 @@ puts("\


static void write_heder(FILE *sql_file, char *db_name)
{
  if (opt_xml)
    fprintf(sql_file,"<?xml version=\"1.0\"?>\n");
  else
  {
    fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
    fprintf(sql_file, "-- Host: %s    Database: %s\n",
@@ -281,6 +290,7 @@ static void write_heder(FILE *sql_file, char *db_name)
	  sql_file);
    fprintf(sql_file, "-- Server version\t%s\n",
	    mysql_get_server_info(&mysql_connection));
  }
  return;
} /* write_heder */

@@ -294,7 +304,7 @@ static int get_options(int *argc,char ***argv)
  load_defaults("my",load_default_groups,argc,argv);
  set_all_changeable_vars(md_changeable_vars);
  while ((c=getopt_long(*argc,*argv,
			"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix",
			"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?IxX",
			long_options, &option_index)) != EOF)
  {
    switch(c) {
@@ -397,6 +407,7 @@ static int get_options(int *argc,char ***argv)
    case 'w':
      where=optarg;
      break;
    case 'X': opt_xml = 1; break;
    case 'x':
      opt_first_slave=1;
      break;
@@ -649,12 +660,15 @@ static uint getTableStructure(char *table, char* db)
        }
        write_heder(sql_file, db);
      }
      fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table);
      if (!opt_xml)
	fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",
		table);
      if (opt_drop)
        fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);

      tableRes=mysql_store_result(sock);
      row=mysql_fetch_row(tableRes);
      if (!opt_xml)
	fprintf(sql_file, "%s;\n", row[1]);
      mysql_free_result(tableRes);
    }
@@ -721,7 +735,9 @@ static uint getTableStructure(char *table, char* db)
        }
        write_heder(sql_file, db);
      }
      fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table);
      if (!opt_xml)
	fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",
		table);
      if (opt_drop)
        fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
      fprintf(sql_file, "CREATE TABLE %s (\n", table_name);
@@ -977,13 +993,17 @@ static void dumpTable(uint numFields, char *table)
  }
  else
  {
    fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", table);
    if (!opt_xml)
      fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n",
	      table);
    sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
    if (where)
    {
      if (!opt_xml)
	fprintf(md_result_file,"-- WHERE:  %s\n",where);
      strxmov(strend(query), " WHERE ",where,NullS);
    }
    if (!opt_xml)
      fputs("\n\n", md_result_file);
    if (mysql_query(sock, query))
    {
@@ -1017,6 +1037,8 @@ static void dumpTable(uint numFields, char *table)
    row_break=0;
    rownr=0;
    init_length=(uint) strlen(insert_pat)+4;
    if (opt_xml)
      fprintf(md_result_file, "\t<%s>\n", table);

    if (opt_autocommit)
      fprintf(md_result_file, "set autocommit=0;\n");
@@ -1026,7 +1048,7 @@ static void dumpTable(uint numFields, char *table)
      uint i;
      ulong *lengths=mysql_fetch_lengths(res);
      rownr++;
      if (!extended_insert)
      if (!extended_insert && !opt_xml)
	fputs(insert_pat,md_result_file);
      mysql_field_seek(res,0);

@@ -1085,21 +1107,35 @@ static void dumpTable(uint numFields, char *table)
	}
	else
	{
	  if (i)
	  if (i && !opt_xml)
	    fputc(',', md_result_file);
	  if (row[i])
	  {
	    if (!IS_NUM_FIELD(field))
	    {   
		if (opt_xml)
		  fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
			  field->name, row[i], field->name);
		else
		   unescape(md_result_file, row[i], lengths[i]);
	    }
	    else
	    {
	      /* change any strings ("inf","nan",..) into NULL */
	      char *ptr = row[i];
		if (opt_xml)
		  fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
			  field->name,!isalpha(*ptr) ?ptr: "NULL",field->name);
		else
	          fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file);
	    }
	  }
	  else
	  {
	    if (opt_xml)
	      fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
		      field->name, "NULL", field->name);
	    else
	      fputs("NULL", md_result_file);
	  }
	}
@@ -1118,18 +1154,26 @@ static void dumpTable(uint numFields, char *table)
	}
        else
        {
	  if (row_break)
	  if (row_break && !opt_xml)
	    fputs(";\n", md_result_file);
	  row_break=1;				/* This is first row */
	  
	  if (!opt_xml)
	  {
	    fputs(insert_pat,md_result_file);
	    fputs(extended_row.str,md_result_file);
	  }
	  total_length = row_length+init_length;
        }
      }
      else
      else if (!opt_xml)
	fputs(");\n", md_result_file);
    }
    if (extended_insert && row_break)
    
    //XML - close table tag and supress regular output
    if (opt_xml)
	fprintf(md_result_file, "\t</%s>\n", table); 
    else if (extended_insert && row_break)
      fputs(";\n", md_result_file);		/* If not empty table */
    fflush(md_result_file);
    if (mysql_errno(sock))
@@ -1205,8 +1249,13 @@ static int dump_databases(char **db_names)
  int result=0;
  for ( ; *db_names ; db_names++)
  { 
    //XML edit - add database element
    if (opt_xml)
      fprintf(md_result_file, "<%s>\n", *db_names);
    if (dump_all_tables_in_db(*db_names))
      result=1;
    if (opt_xml)
      fprintf(md_result_file, "</%s>\n", *db_names);
  }
  return result;
} /* dump_databases */
+4 −4
Original line number Diff line number Diff line
@@ -837,7 +837,7 @@ btr_parse_page_reorganize(
/*======================*/
			/* out: end of log record or NULL */
	byte*	ptr,	/* in: buffer */
	byte*	end_ptr,/* in: buffer end */
	byte*	end_ptr __attribute__((unused)), /* in: buffer end */
	page_t*	page,	/* in: page or NULL */
	mtr_t*	mtr)	/* in: mtr or NULL */
{
@@ -1438,7 +1438,7 @@ btr_page_split_and_insert(
	page_t*		insert_page;
	page_cur_t*	page_cursor;
	rec_t*		first_rec;
	byte*		buf;
	byte*		buf = 0; /* remove warning */
	rec_t*		move_limit;
	ibool		insert_will_fit;
	ulint		n_iterations = 0;
@@ -1616,7 +1616,7 @@ static
void
btr_level_list_remove(
/*==================*/
	dict_tree_t*	tree,	/* in: index tree */
	dict_tree_t*	tree __attribute__((unused)), /* in: index tree */
	page_t*		page,	/* in: page to remove */
	mtr_t*		mtr)	/* in: mtr */
{	
@@ -2338,7 +2338,7 @@ btr_validate_level(
{
	ulint		space;
	page_t*		page;
	page_t*		right_page;
	page_t*		right_page = 0; /* remove warning */
	page_t*		father_page;
	page_t*		right_father_page;
	rec_t*		node_ptr;
+9 −8
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ static
void
btr_cur_latch_leaves(
/*=================*/
	dict_tree_t*	tree,		/* in: index tree */
	dict_tree_t*	tree __attribute__((unused)),	/* in: index tree */
	page_t*		page,		/* in: leaf page where the search
					converged */
	ulint		space,		/* in: space id */
@@ -219,7 +219,7 @@ btr_cur_search_to_nth_level(
	ulint		insert_planned;
	ulint		buf_mode;
	ulint		estimate;
	ulint		root_height;
	ulint		root_height = 0; /* remove warning */
#ifdef BTR_CUR_ADAPT
	btr_search_t*	info;
#endif
@@ -488,7 +488,7 @@ btr_cur_open_at_index_side(
	ulint		page_no;
	ulint		space;
	ulint		height;
	ulint		root_height;
	ulint		root_height = 0; /* remove warning */
	rec_t*		node_ptr;
	ulint		estimate;

@@ -2907,8 +2907,9 @@ btr_store_big_rec_extern_fields(
	rec_t*		rec,		/* in: record */
	big_rec_t*	big_rec_vec,	/* in: vector containing fields
					to be stored externally */
	mtr_t*		local_mtr)	/* in: mtr containing the latch to
					rec and to the tree */
	mtr_t*		local_mtr __attribute__((unused))) /* in: mtr
                                        containing the latch to rec and to the
                                        tree */
{
	byte*	data;
	ulint	local_len;
@@ -3069,9 +3070,9 @@ btr_free_externally_stored_field(
	ibool		do_not_free_inherited,/* in: TRUE if called in a
					rollback and we do not want to free
					inherited fields */
	mtr_t*		local_mtr)	/* in: mtr containing the latch to
					data an an X-latch to the index
					tree */
	mtr_t*		local_mtr __attribute__((unused))) /* in: mtr 
                                        containing the latch to data an an 
                                        X-latch to the index tree */
{
	page_t*	page;
	page_t*	rec_page;
+1 −1
Original line number Diff line number Diff line
@@ -1245,7 +1245,7 @@ btr_search_update_hash_on_insert(
	dulint		tree_id;
	ulint		fold;
	ulint		ins_fold;
	ulint		next_fold;
	ulint		next_fold = 0; /* remove warning (??? bug ???) */
	ulint		n_fields;
	ulint		n_bytes;
	ulint		side;
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ buf_page_print(
	ut_sprintf_buf(buf, read_buf, UNIV_PAGE_SIZE);

	fprintf(stderr,
	"InnoDB: Page dump in ascii and hex (%lu bytes):\n%s",
	"InnoDB: Page dump in ascii and hex (%u bytes):\n%s",
					UNIV_PAGE_SIZE, buf);
	fprintf(stderr, "InnoDB: End of page dump\n");

Loading