Commit 5535fa96 authored by unknown's avatar unknown
Browse files

Ensure that we free memory used with --order-by-primary (in mysqldump)

Simple, non critical, fix to mysql_fix_privilege_tables


client/mysqldump.c:
  Ensure that we free memory used with --order-by-primary
mysql-test/t/system_mysql_db_fix.test:
  Remove warnings when compiled with support for ISAM
scripts/mysql_fix_privilege_tables.sh:
  Ensure that 'my_print_defaults' is called correctly
sql/set_var.cc:
  Code style cleanups
sql/sql_db.cc:
  Fixed comments
sql/udf_example.cc:
  Fixed comments
parent 878a155e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1825,8 +1825,6 @@ static void dumpTable(uint numFields, char *table)
err:
  if (query != query_buf)
    my_free(query, MYF(MY_ALLOW_ZERO_PTR));
  if (order_by)
    my_free(order_by, MYF(0));
  safe_exit(error);
  return;
} /* dumpTable */
@@ -1978,6 +1976,8 @@ static int dump_all_tables_in_db(char *database)
    numrows = getTableStructure(table, database);
    if (!dFlag && numrows > 0)
      dumpTable(numrows,table);
    my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
    order_by= 0;
  }
  if (opt_xml)
  {
@@ -2027,6 +2027,8 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
    numrows = getTableStructure(*table_names, db);
    if (!dFlag && numrows > 0)
      dumpTable(numrows, *table_names);
    my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
    order_by= 0;
  }
  if (opt_xml)
  {
+6 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use test;

# create system tables as in mysql-3.20

--disable_warnings
CREATE TABLE db (
  Host char(60) binary DEFAULT '' NOT NULL,
  Db char(32) binary DEFAULT '' NOT NULL,
@@ -23,10 +24,12 @@ CREATE TABLE db (
  KEY User (User)
)
type=ISAM;
--enable-warnings

INSERT INTO db VALUES ('%','test',   '','Y','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y');

--disable_warnings
CREATE TABLE host (
  Host char(60) binary DEFAULT '' NOT NULL,
  Db char(32) binary DEFAULT '' NOT NULL,
@@ -39,7 +42,9 @@ CREATE TABLE host (
  PRIMARY KEY Host (Host,Db)
)
type=ISAM;
--enable-warnings

--disable_warnings
CREATE TABLE user (
  Host char(60) binary DEFAULT '' NOT NULL,
  User char(16) binary DEFAULT '' NOT NULL,
@@ -56,6 +61,7 @@ CREATE TABLE user (
  PRIMARY KEY Host (Host,User)
)
type=ISAM;
--enable-warnings

INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
INSERT INTO user VALUES ('localhost','',    '','N','N','N','N','N','N','N','N','N');
+6 −2
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ port=""
socket=""
database="mysql"
bindir=""
print_defaults_bindir="."

file=mysql_fix_privilege_tables.sql

@@ -57,7 +58,9 @@ parse_arguments() {
      --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;;
      --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;;
      --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;;
      --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"` ;;
      --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"`
                  print_defaults_bindir=$bindir
		  ;;
      *)
        if test -n "$pick_args"
        then
@@ -73,7 +76,8 @@ parse_arguments() {
# Get first arguments from the my.cfg file, groups [mysqld] and
# [mysql_install_db], and then merge with the command line arguments

for dir in ./bin @bindir@ @bindir@ extra $bindir/../bin $bindir/../extra
print_defaults=my_print_defaults
for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
do
  if test -x $dir/my_print_defaults
  then
+5 −9
Original line number Diff line number Diff line
@@ -359,22 +359,18 @@ sys_var_thd_bool sys_innodb_table_locks("innodb_table_locks",
sys_var_long_ptr	sys_innodb_autoextend_increment("innodb_autoextend_increment",
							&srv_auto_extend_increment);
#endif

#ifdef HAVE_NDBCLUSTER_DB
// ndb thread specific variable settings
/* ndb thread specific variable settings */
sys_var_thd_ulong 
sys_ndb_autoincrement_prefetch_sz("ndb_autoincrement_prefetch_sz",
				  &SV::ndb_autoincrement_prefetch_sz);
sys_var_thd_bool
sys_ndb_force_send("ndb_force_send",
		   &SV::ndb_force_send);
sys_ndb_force_send("ndb_force_send", &SV::ndb_force_send);
sys_var_thd_bool
sys_ndb_use_exact_count("ndb_use_exact_count",
			&SV::ndb_use_exact_count);
sys_ndb_use_exact_count("ndb_use_exact_count", &SV::ndb_use_exact_count);
sys_var_thd_bool
sys_ndb_use_transactions("ndb_use_transactions",
			 &SV::ndb_use_transactions);
// ndb server global variable settings
// none
sys_ndb_use_transactions("ndb_use_transactions", &SV::ndb_use_transactions);
#endif

/* Time/date/datetime formats */
+15 −13
Original line number Diff line number Diff line
@@ -390,7 +390,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
  
  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));

  // do not create database if another thread is holding read lock
  /* do not create database if another thread is holding read lock */
  if (wait_if_global_read_lock(thd, 0, 1))
  {
    error= -1;
@@ -514,7 +514,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)

  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));

  // do not alter database if another thread is holding read lock
  /* do not alter database if another thread is holding read lock */
  if ((error=wait_if_global_read_lock(thd,0,1)))
    goto exit2;

@@ -542,9 +542,11 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
    Query_log_event qinfo(thd, thd->query, thd->query_length, 0, 
			  /* suppress_use */ TRUE);

    // Write should use the database being created as the "current
    // database" and not the threads current database, which is the
    // default.
    /*
      Write should use the database being created as the "current
      database" and not the threads current database, which is the
      default.
    */
    qinfo.db     = db;
    qinfo.db_len = strlen(db);

@@ -577,7 +579,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
    -1	Error generated
*/


int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
  long deleted=0;
@@ -589,7 +590,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)

  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));

  // do not drop database if another thread is holding read lock
  /* do not drop database if another thread is holding read lock */
  if (wait_if_global_read_lock(thd, 0, 1))
  {
    error= -1;
@@ -657,10 +658,11 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
    {
      Query_log_event qinfo(thd, query, query_length, 0, 
			    /* suppress_use */ TRUE);

      // Write should use the database being created as the "current
      // database" and not the threads current database, which is the
      // default.
      /*
        Write should use the database being created as the "current
        database" and not the threads current database, which is the
        default.
      */
      qinfo.db     = db;
      qinfo.db_len = strlen(db);

@@ -774,7 +776,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
	found_other_files++;
      continue;
    }
    // just for safety we use files_charset_info
    /* just for safety we use files_charset_info */
    if (db && !my_strcasecmp(files_charset_info,
                             extension, reg_ext))
    {
Loading