diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 27 | ||||
-rwxr-xr-x | scripts/fill_func_tables.sh | 234 | ||||
-rw-r--r-- | scripts/fill_help_tables.sh | 571 | ||||
-rw-r--r-- | scripts/make_binary_distribution.sh | 20 | ||||
-rwxr-xr-x | scripts/make_win_src_distribution.sh | 23 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 310 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sh | 402 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 43 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 290 | ||||
-rw-r--r-- | scripts/mysql_prepare_privilege_tables_for_5.sql | 53 | ||||
-rw-r--r-- | scripts/mysql_zap.sh | 6 | ||||
-rw-r--r-- | scripts/mysqlaccess.sh | 3 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 39 |
13 files changed, 1534 insertions, 487 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index c464c271a55..d4da77d0387 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -20,7 +20,7 @@ bin_SCRIPTS = @server_scripts@ \ msql2mysql \ mysql_config \ mysql_fix_privilege_tables \ - mysql_fix_extensions \ + mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ mysql_zap \ @@ -34,7 +34,8 @@ bin_SCRIPTS = @server_scripts@ \ mysql_tableinfo \ mysqld_multi \ make_win_src_distribution \ - make_win_binary_distribution + make_win_binary_distribution \ + mysql_create_system_tables EXTRA_SCRIPTS = make_binary_distribution.sh \ make_sharedlib_distribution.sh \ @@ -43,7 +44,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ msql2mysql.sh \ mysql_config.sh \ mysql_fix_privilege_tables.sh \ - mysql_fix_extensions.sh \ + mysql_fix_extensions.sh \ mysql_install_db.sh \ mysql_setpermission.sh \ mysql_secure_installation.sh \ @@ -53,17 +54,19 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ mysql_convert_table_format.sh \ mysql_find_rows.sh \ mysqlhotcopy.sh \ - mysqldumpslow.sh \ + mysqldumpslow.sh \ mysql_explain_log.sh \ mysqld_multi.sh \ mysql_tableinfo.sh \ - mysqld_safe.sh + mysqld_safe.sh \ + fill_help_tables.sh \ + mysql_create_system_tables.sh EXTRA_DIST = $(EXTRA_SCRIPTS) \ mysqlaccess.conf \ mysqlbug -pkgdata_DATA = make_binary_distribution make_sharedlib_distribution +dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql # mysqlbug should be distributed built so that people can report build # failures with it. @@ -73,7 +76,7 @@ CLEANFILES = @server_scripts@ \ msql2mysql \ mysql_config \ mysql_fix_privilege_tables \ - mysql_fix_extensions \ + mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ mysql_zap \ @@ -83,7 +86,9 @@ CLEANFILES = @server_scripts@ \ mysqlhotcopy \ mysqldumpslow \ mysqld_multi \ - make_win_src_distribution + make_win_src_distribution \ + fill_help_tables \ + mysql_create_system_tables SUPERCLEANFILES = mysqlbug @@ -104,6 +109,7 @@ SUFFIXES = .sh -e 's!@''libexecdir''@!$(libexecdir)!g' \ -e 's!@''pkglibdir''@!$(pkglibdir)!g' \ -e 's!@''pkgincludedir''@!$(pkgincludedir)!g' \ + -e 's!@''pkgdatadir''@!$(pkgdatadir)!g' \ -e 's!@''CC''@!@CC@!'\ -e 's!@''CXX''@!@CXX@!'\ -e 's!@''GXX''@!@GXX@!'\ @@ -139,3 +145,8 @@ SUFFIXES = .sh # Don't update the files from bitkeeper %::SCCS/s.% + +all: fill_help_tables.sql make_win_src_distribution make_binary_distribution make_sharedlib_distribution + +fill_help_tables.sql: fill_help_tables ../Docs/manual.texi + ./fill_help_tables < ../Docs/manual.texi > fill_help_tables.sql diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh new file mode 100755 index 00000000000..459afee2fe1 --- /dev/null +++ b/scripts/fill_func_tables.sh @@ -0,0 +1,234 @@ +#!/usr/bin/perl +# fill_func_tables - parse ../Docs/manual.texi + +# Original version by vva + +my $cat_name= ""; +my $func_name= ""; +my $text= ""; +my $example= ""; + +local $mode= ""; + +sub prepare_name +{ + my ($a)= @_; + + $a =~ s/(\@itemize \@bullet)/ /g; + $a =~ s/(\@end itemize)/ /g; + $a =~ s/(\@end multitable)/ /g; + $a =~ s/(\@end table)/ /g; + $a =~ s/(\@cindex(.*?)\n)/ /g; + $a =~ s/(\@multitable \@columnfractions(.*?)\n)/ /g; + $a =~ s/(\@node(.*?)\n)/ /g; + $a =~ s/(\@tab)/\t/g; + $a =~ s/\@item/ /g; + $a =~ s/\@code\{((.|\n)+?)\}/$1/go; + $a =~ s/\@strong\{(.+?)\}/$1/go; + $a =~ s/\@samp\{(.+?)\}/$1/go; + $a =~ s/\@emph\{((.|\n)+?)\}/\/$1\//go; + $a =~ s/\@xref\{((.|\n)+?)\}/See also : [$1]/go; + $a =~ s/\@ref\{((.|\n)+?)\}/[$1]/go; + $a =~ s/\'/\'\'/g; + $a =~ s/\\/\\\\/g; + $a =~ s/\`/\`\`/g; + + $a =~ s/\@table \@code/ /g; + + $a =~ s/\(\)//g; + + $a =~ s/((\w|\s)+)\(([\+-=><\/%*!<>\s]+)\)/$3/gxs; #$a =~ s/((\w|\s)+)\(([\+-=><\/%*!<>\s]+)\)/$3 $1/gxs; + $a =~ s/([\+-=><\/%*!<>\s]+)\(((\w|\s)+)\)/$1/gxs;#$a =~ s/([\+-=><\/%*!<>\s]+)\(((\w|\s)+)\)/$1 $2/gxs; + $a =~ s/((\w|\s)+)\((.+)\)/$1/gxs; + + return $a; +} + +sub prepare_text +{ + my ($a)= @_; + + $a =~ s/(\@itemize \@bullet)/ /g; + $a =~ s/(\@end itemize)/ /g; + $a =~ s/(\@end multitable)/ /g; + $a =~ s/(\@end table)/ /g; + $a =~ s/(\@cindex(.*?)\n)/ /g; + $a =~ s/(\@multitable \@columnfractions(.*?)\n)/ /g; + $a =~ s/(\@node(.*?)\n)/ /g; + $a =~ s/(\@tab)/\t/g; + $a =~ s/\@itemx/ /g; + $a =~ s/\@item/ /g; + $a =~ s/\@code\{((.|\n)+?)\}/$1/go; + $a =~ s/\@strong\{(.+?)\}/$1/go; + $a =~ s/\@samp\{(.+?)\}/$1/go; + $a =~ s/\@emph\{((.|\n)+?)\}/\/$1\//go; + $a =~ s/\@xref\{((.|\n)+?)\}/See also : [$1]/go; + $a =~ s/\@ref\{((.|\n)+?)\}/[$1]/go; + $a =~ s/\'/\'\'/g; + $a =~ s/\\/\\\\/g; + $a =~ s/\`/\`\`/g; + $a =~ s/(\n*?)$//g; + $a =~ s/\n/\\n/g; + + $a =~ s/\@table \@code/ /g; + + return $a; +} + +sub prepare_example +{ + my ($a)= @_; + + $a =~ s/\'/\'\'/g; + $a =~ s/\\/\\\\/g; + $a =~ s/\`/\`\`/g; + $a =~ s/(\n*?)$//g; + $a =~ s/\n/\\n/g; + + return $a; +} + +sub flush_all +{ + my ($mode) = @_; + + if ($mode eq ""){return;} + + $func_name= prepare_name($func_name); + $text= prepare_text($text); + $example= prepare_example($example); + + if ($func_name ne "" && $text ne "" && !($func_name =~ /[abcdefghikjlmnopqrstuvwxyz]/)){ + print "INSERT INTO function (name,description,example) VALUES ("; + print "'$func_name',"; + print "'$text',"; + print "'$example'"; + print ");\n"; + print "INSERT INTO function_category (cat_id,func_id) VALUES (\@cur_category,LAST_INSERT_ID());\n"; + } + + $func_name= ""; + $text= ""; + $example= ""; + $mode= ""; +} + +sub new_category +{ + my ($category)= @_; + + $category= prepare_text($category); + + print "INSERT INTO function_category_name (name) VALUES (\'$category\');\n"; + print "SELECT \@cur_category:=LAST_INSERT_ID();\n"; +} + +print "INSERT INTO db (Host,DB,User,Select_priv) VALUES ('%','mysql_help','','Y');\n"; +print "CREATE DATABASE mysql_help;\n"; + +print "USE mysql_help;\n"; + +print "DROP TABLE IF EXISTS function;\n"; +print "CREATE TABLE function ("; +print " func_id int unsigned not null auto_increment,"; +print " name varchar(64) not null,"; +print " url varchar(128) not null,"; +print " description text not null,"; +print " example text not null,"; +print " min_args tinyint not null,"; +print " max_args tinyint,"; +print " date_created datetime not null,"; +print " last_modified timestamp not null,"; +print " primary key (func_id)"; +print ") type=myisam;\n\n"; + +print "DROP TABLE IF EXISTS function_category_name;\n"; +print "CREATE TABLE function_category_name ("; +print " cat_id smallint unsigned not null auto_increment,"; +print " name varchar(64) not null,"; +print " url varchar(128) not null,"; +print " date_created datetime not null,"; +print " last_modified timestamp not null,"; +print " primary key (cat_id)"; +print ") type=myisam;\n\n"; + +print "DROP TABLE IF EXISTS function_category;\n"; +print "CREATE TABLE function_category ("; +print " cat_id smallint unsigned not null references function_category_name,"; +print " func_id int unsigned not null references function,"; +print " primary key (cat_id, func_id)"; +print ") type=myisam;\n\n"; + +print "DELETE FROM function_category_name;\n"; +print "DELETE FROM function_category;\n"; +print "DELETE FROM function;\n"; +print "SELECT \@cur_category:=null;\n\n"; + +my $in_section_6_3= 0; + +for(<>) +{ + if ($_=~/\@section Functions for Use in \@code{SELECT} and \@code{WHERE} Clauses/ && + !$in_section_6_3){ + $in_section_6_3= 1; + next; + } + + if ($_=~/\@section/ && $in_section_6_3){ + $in_section_6_3= 0; + next; + } + + if (!$in_section_6_3) { next; } + + my $c_name= ""; + + ($c_name)=m|\@c for_mysql_help,(.+?)$|; + if (!($c_name eq "") && ! ($c_name =~ m/$cat_name/i)){ + ($cat_name)= $c_name; + new_category($cat_name); + next; + } + + ($c_name)=m|\@subsubsection (.+?)$|; + if (!($c_name eq "") && ! ($c_name =~ m/$cat_name/i)){ + ($cat_name)= $c_name; + new_category($cat_name); + next; + } + + ($c_name)=m|\@subsection (.+?)$|; + if (!($c_name eq "") && ! ($c_name =~ m/$cat_name/i)){ + ($cat_name)= $c_name; + new_category($cat_name); + next; + } + + ($f_name)=m|\@findex (.+?)$|; + if (!($f_name eq "")){ + flush_all($mode); + ($func_name)= ($f_name); + $mode= "text"; + next; + } + + if ($_=~/\@example/ && ($mode eq "text")){ + $mode= "example"; + next; + } + + if ($_=~/\@end example/ && ($mode eq "example")){ + flush_all($mode); + next; + } + + if ($mode eq "text") { $text .= $_; } + if ($mode eq "example") { $example .= $_; } +} + + +print "DELETE function_category_name "; +print "FROM function_category_name "; +print "LEFT JOIN function_category ON function_category.cat_id=function_category_name.cat_id "; +print "WHERE function_category.cat_id is null;" + diff --git a/scripts/fill_help_tables.sh b/scripts/fill_help_tables.sh new file mode 100644 index 00000000000..cb5437f7178 --- /dev/null +++ b/scripts/fill_help_tables.sh @@ -0,0 +1,571 @@ +#!@PERL@ +# +# Copyright (C) 2003 MySQL AB +# For a more info consult the file COPYRIGHT distributed with this file. +# +# This script generates the SQL statements required by mysql_install_db to +# fill up the tables for the server-side online function help, which can be +# invoked with "help <function>" from the MySQL client. +# +# Usage: +# fill_help_tables OPTIONS < manual.texi > fill_help_tables.sql +# +# --help display this helpscreen and exit +# --verbose print information about help completeness to STDERR +# --lexems=path path to file with lexems. it is used with verbose option. +# default value is ../sql/lex.h +# Examples: +# ./fill_help_tables --help +# ./fill_help_tables --verbose < manual.texi > fill_help_tables.sql +# ./fill_help_tables < manual.texi > fill_help_tables.sql +# +# Please note, that you first need to update Docs/manual.texi with the +# manual file from the separate "mysqldoc" BitKeeper-Tree! The manual.texi +# included in the source tree is just an empty stub file - the full manual +# is now maintained in a separate tree. +# +# extra tags in manual.texi: +# +# @c help_category <category_name>[@<parent_category_name>] +# +# @c description_for_help_topic <topic_name> <keyword1> <keyword2> +# .... +# @c end_description_for_help_topic +# +# @c example_for_help_topic <topic_name> +# @example +# .... +# @end example +# +# +# Original version by Victor Vagin <vva@mysql.com> +# + +use strict; +use Getopt::Long; + +my $insert_portion_size= 15; +my $error_prefix= "---- help parsing errors :"; + +my $path_to_lex_file= "../sql/lex.h"; +my $verbose_option= 0; +my $help_option= 0; + +my $cur_line= 0; +my $count_errors= 0; + +GetOptions( + "help",\$help_option, + "verbose",\$verbose_option, + "lexems=s",\$path_to_lex_file +); + +if ($help_option ne 0) +{ + print <<_HELP; + +This script generates the SQL statements required by mysql_install_db to +fill up the tables for the server-side online function help, which can be +invoked with "help <function>" from the MySQL client. + +Usage: + fill_help_tables OPTIONS < manual.texi > fill_help_tables.sql + + --help display this helpscreen and exit + --verbose print information about help completeness to STDERR + --lexems=path path to file with lexems. it is used with verbose option. + default value is ../sql/lex.h + +Examples: + ./fill_help_tables --help + ./fill_help_tables --verbose < manual.texi > fill_help_tables.sql + ./fill_help_tables < manual.texi > fill_help_tables.sql + +_HELP + exit; +} + +my $current_category= ""; +my $current_parent_category= ""; +my $next_example_for_topic= ""; + +my %topics; +my %categories; +my %keywords; + +$categories{Contents}->{__parent_category__}= ""; + +sub print_error +{ + my ($text)= @_; + if ($count_errors==0) + { + print STDERR "$error_prefix\n"; + } + print STDERR "line $cur_line : $text"; + $count_errors++; +} + +sub add_topic_to_category +{ + my ($topic_name)= @_; + + $categories{$current_category}->{$topic_name}= $topics{$topic_name}; + my $category= $categories{$current_category}; + $category->{__name__}= $current_category; + + if (exists($category->{__parent_category__})) + { + my $old_parent= $category->{__parent_category__}; + if ($old_parent ne $current_parent_category) + { + print_error "wrong parent for $current_category\n"; + } + } + + if ($current_parent_category ne "") + { + $category->{__parent_category__}= $current_parent_category; + } + + if (exists($topics{$topic_name}->{category})) + { + my $old_category= $topics{$topic_name}->{category}; + if ($old_category ne $category) + { + print_error "wrong category for $topic_name (first one's \"$old_category->{__name__}\" second one's \"$current_category\")\n"; + } + } + + $topics{$topic_name}->{category}= $category; +} + +sub add_example +{ + my ($topic_name,$example)= @_; + + $topic_name=~ tr/a-z/A-Z/; + + if (exists($topics{$topic_name}->{example})) + { + print_error "double example for $topic_name\n"; + } + + $topics{$topic_name}->{example}= $example; + add_topic_to_category($topic_name); +} + +sub add_description +{ + my ($topic_name,$description)= @_; + + $topic_name=~ tr/a-z/A-Z/; + + if (exists($topics{$topic_name}->{description})) + { + print_error "double description for $topic_name\n"; + } + $topics{$topic_name}->{description}= $description; + add_topic_to_category($topic_name); +} + +sub add_keyword +{ + my ($topic_name,$keyword)= @_; + + $topic_name=~ tr/a-z/A-Z/; + $keyword=~ tr/a-z/A-Z/; + + push(@{$topics{$topic_name}->{keywords}},$keyword); + if (exists($keywords{$keyword}->{$topic_name})) + { + print_error "double keyword $keyword for $topic_name\n"; + } + $keywords{$keyword}->{$topic_name}= $topics{$topic_name}; +} + +sub prepare_name +{ + my ($a)= @_; + + $a =~ s/(\@itemize \@bullet)/ /g; + $a =~ s/(\@end itemize)/ /g; + $a =~ s/(\@end multitable)/ /g; + $a =~ s/(\@end table)/ /g; + $a =~ s/(\@cindex(.*?)\n)/ /g; + $a =~ s/(\@multitable \@columnfractions(.*?)\n)/ /g; + $a =~ s/(\@node(.*?)\n)/ /g; + $a =~ s/(\@tab)/\t/g; + $a =~ s/\@item/ /g; + $a =~ s/\@code\{((.|\n)+?)\}/$1/go; + $a =~ s/\@strong\{(.+?)\}/$1/go; + $a =~ s/\@samp\{(.+?)\}/$1/go; + $a =~ s/\@emph\{((.|\n)+?)\}/\/$1\//go; + $a =~ s/\@xref\{((.|\n)+?)\}/See also : [$1]/go; + $a =~ s/\@ref\{((.|\n)+?)\}/[$1]/go; + $a =~ s/\'/\'\'/g; + $a =~ s/\\/\\\\/g; + $a =~ s/\`/\`\`/g; + + $a =~ s/\@table \@code/ /g; + $a =~ s/\(\)//g; + $a =~ s/\"/\\\"/g; + + $a =~ s/((\w|\s)+)\(([\+-=><\/%*!<>\s]+)\)/$3/gxs; + $a =~ s/([\+-=><\/%*!<>\s]+)\(((\w|\s)+)\)/$1/gxs; + $a =~ s/((\w|\s)+)\((.+)\)/$1/gxs; + + $a =~ s/((\s)+)$//g; + + return $a; +} + +sub prepare_description +{ + my ($a)= @_; + + $a =~ s/(\@itemize \@bullet\n)//g; + $a =~ s/(\@c help_keyword (.*?)\n)//g; + $a =~ s/(\@end itemize\n)//g; + $a =~ s/(\@end example\n)//g; + $a =~ s/(\@example\n)//g; + $a =~ s/(\@{)/{/g; + $a =~ s/(\@})/}/g; + $a =~ s/(\@end multitable)/ /g; + $a =~ s/(\@end table)/ /g; + $a =~ s/(\@cindex(.*?)\n)//g; + $a =~ s/(\@findex(.*?)\n)//g; + $a =~ s/(\@table(.*?)\n)//g; + $a =~ s/(\@multitable \@columnfractions(.*?)\n)/ /g; + $a =~ s/(\@node(.*?)\n)/ /g; + $a =~ s/(\@tab)/\t/g; + $a =~ s/\@itemx/ /g; + $a =~ s/(\@item\n(\s*?))(\S)/ --- $3/g; + $a =~ s/(\@item)/ /g; + $a =~ s/(\@tindex\s(.*?)\n)//g; + $a =~ s/(\@c\s(.*?)\n)//g; + $a =~ s/\@code\{((.|\n)+?)\}/$1/go; + $a =~ s/\@strong\{(.+?)\}/$1/go; + $a =~ s/\@samp\{(.+?)\}/$1/go; + $a =~ s/\@emph\{((.|\n)+?)\}/\/$1\//go; + $a =~ s/\@xref\{((.|\n)+?)\}/See also : [$1]/go; + $a =~ s/\@ref\{((.|\n)+?)\}/[$1]/go; + $a =~ s/\@w\{((.|\n)+?)\}/$1/go; + $a =~ s/\@strong\{((.|\n)+?)\}/\n!!!!\n$1\n!!!!\n/go; + $a =~ s/\@file\{((.|\n)+?)\}/\*$1/go; + $a =~ s/\\/\\\\/g; + $a =~ s/\n\n$/\n/g; + $a =~ s/\n\n$/\n/g; + $a =~ s/\n\n$/\n/g; + $a =~ s/\n\n$/\n/g; + $a =~ s/\n\n$/\n/g; + $a =~ s/\n/\\n/g; + $a =~ s/\"/\\\"/g; + + $a =~ s/\@table \@code/ /g; + + return $a; +} + +sub prepare_example +{ + my ($a)= @_; + + $a =~ s/(^\@c for_help_topic(.*?)\n)//g; + + $a =~ s/\\/\\\\/g; + $a =~ s/(\@{)/{/g; + $a =~ s/(\@})/}/g; + $a =~ s/(\@\@)/\@/g; + $a =~ s/(\n*?)$//g; + $a =~ s/\n/\\n/g; + $a =~ s/\"/\\\"/g; + + return $a; +} + +sub parse_example +{ + return if (!($_=~/\@example/)); + return if ($next_example_for_topic eq ""); + + my $topic_name= $next_example_for_topic; + $next_example_for_topic= ""; + my $text= ""; + + while (<>) + { + $cur_line++; + last if ($_=~/\@end example/); + $text .= $_; + } + + $text= prepare_example($text); + $topic_name= prepare_name($topic_name); + add_example($topic_name,$text) if ($topic_name ne ""); +} + +sub parse_example_for_topic +{ + my ($for_topic)= m|\@c example_for_help_topic (.+?)$|; + return if ($for_topic eq ""); + + $next_example_for_topic= $for_topic; +} + +sub parse_description +{ + my ($topic_description)= m|\@c description_for_help_topic (.+?)$|; + return if ($topic_description eq ""); + + my ($topic_name,$topic_keywords)= split(/ /,$topic_description); + + if ($topic_name eq "" || $topic_keywords eq "") + { + $topic_name= $topic_description; + } + else + { + my $keyword; + foreach $keyword (split(/ /,$topic_keywords)) + { + add_keyword($topic_name,$keyword) if ($keyword ne ""); + } + } + + my $text= ""; + + while (<>) + { + $cur_line++; + last if ($_=~/\@c end_description_for_help_topic/); + $text .= $_; + } + + $text= prepare_description($text); + $topic_name= prepare_name($topic_name); + add_description($topic_name,$text); +} + +sub parse_category +{ + my ($c_name,$pc_name)= m|\@c help_category (.+?)\@(.+?)$|; + + if ($pc_name ne "") + { + $current_category= prepare_name($c_name); + $current_parent_category= prepare_name($pc_name); + } + else + { + my ($c_name)=m|\@c help_category (.+?)$|; + return if ($c_name eq ""); + + $current_category= prepare_name($c_name); + $current_parent_category= "Contents" + } +} + +# parse manual: + +while (<>) +{ + parse_example_for_topic (); + parse_example (); + parse_description (); + parse_category (); + $cur_line++; +} + +# test results of parsing: + +sub print_bad_names +{ + my($names,$prompt)= @_; + if (scalar(@{$names})) + { + print STDERR "\n-------------- $prompt : \n\n"; + my $name; + foreach $name (@{$names}) + { + print STDERR "$name\n"; + } + print STDERR "\n"; + } +} + +sub print_verbose_errors +{ + my($name_of_log_file)= @_; + + my @without_help; + my @description_with_at; + my @example_with_at; + my @without_description; + my @without_example; + + print STDERR "\n-------------- parameters of help completeness : \n\n"; + + my $count_lex= 0; + if (!open (TLEX,"<$path_to_lex_file")) + { + print STDERR "Error opening lex file \"$path_to_lex_file\" $!\n"; + } + else + { + for (<TLEX>) + { + my ($a,$lex,$b)=m|(.+?)\"(.+?)\"(.+?)$|; + next if ($lex eq ""); + $count_lex++; + next if (exists($topics{$lex}) || exists($keywords{$lex})); + push(@without_help,$lex); + } + close(TLEX); + print STDERR "number of lexems in \"$path_to_lex_file\" - $count_lex\n"; + } + + my $name; + my @topic_names= keys(%topics); + foreach $name (@topic_names) + { + my $topic= $topics{$name}; + push(@description_with_at,$name) if ($topic->{description}=~/\@/); + push(@example_with_at,$name) if ($topic->{example}=~/\@/); + push(@without_description,$name) if (!exists($topic->{description})); + push(@without_example,$name) if (!exists($topic->{example})); + } + + my $count_categories= scalar(keys(%categories)); + print STDERR "number of help categories - ",$count_categories,"\n"; + my $count_topics= scalar(@topic_names); + print STDERR "number of help topics - ",$count_topics,"\n"; + my $count_keywords= scalar(keys(%keywords)); + print STDERR "number of help keywords - ",$count_keywords,"\n"; + + my $count_without_help= scalar(@without_help); + print_bad_names(\@without_help,"lexems without help (". + $count_without_help." ~ ". + (int (($count_without_help/$count_lex)*100)). + "%)"); + print_bad_names(\@description_with_at, + " topics below have symbol \'@\' in their descriptions.\n". + "it's probably the litter from 'texi' tags (script needs fixing)"); + print_bad_names(\@example_with_at, + " topics below have symbol \'@\' in their examples.\n". + "it's probably the litter from 'texi' tags (script needs fixing)"); + print_bad_names(\@without_description,"topics without description"); + + my $count_without_example= scalar(@without_example); + print_bad_names(\@without_example,"topics without example (". + $count_without_example." ~ ". + (int (($count_without_example/$count_topics)*100)). + "%)"); +} + +print_verbose_errors if ($verbose_option ne 0); + +# output result + +sub print_insert_header +{ + my($count,$header)= @_; + + if ($count % $insert_portion_size ne 0) { + print ","; + } else { + print ";\n" if ($count ne 0); + print "$header"; + } +} + +print "delete from help_topic;\n"; +print "delete from help_category;\n"; +print "delete from help_keyword;\n"; +print "delete from help_relation;\n\n"; + +my @category_names= keys(%categories); +if (scalar(@category_names)) +{ + my $cat_name; + my $count= 0; + foreach $cat_name (@category_names) + { + $categories{$cat_name}->{__id__}= $count; + $count++; + } + + my $header= "insert into help_category ". + "(help_category_id,name,parent_category_id) values "; + $count= 0; + foreach $cat_name (@category_names) + { + print_insert_header($count,$header); + my $parent_cat_name= $categories{$cat_name}->{__parent_category__}; + my $parent_cat_id= $parent_cat_name eq "" + ? "-1" : $categories{$parent_cat_name}->{__id__}; + print "($count,\"$cat_name\",$parent_cat_id)"; + $count++; + } + printf ";\n\n"; +} + +my @topic_names= keys(%topics); +if (scalar(@topic_names)) +{ + my $header= "insert into help_topic ". + "(help_topic_id,help_category_id,name,description,example) values "; + my $topic_name; + my $count= 0; + foreach $topic_name (@topic_names) + { + print_insert_header($count,$header); + my $topic= $topics{$topic_name}; + print "($count,"; + print "$topic->{category}->{__id__},"; + print "\"$topic_name\","; + print "\"$topic->{description}\","; + print "\"$topic->{example}\")"; + $topics{$topic_name}->{__id__}= $count; + $count++; + } + printf ";\n\n"; +} + +my @keywords_names= keys(%keywords); +if (scalar(@keywords_names)) +{ + my $header= "insert into help_keyword (help_keyword_id,name) values "; + my $keyword_name; + my $count= 0; + foreach $keyword_name (@keywords_names) + { + print_insert_header($count,$header); + print "($count,\"$keyword_name\")"; + $count++; + } + printf ";\n\n"; + + $header= "insert into help_relation ". + "(help_topic_id,help_keyword_id) values "; + $count= 0; + my $count_keyword= 0; + foreach $keyword_name (@keywords_names) + { + my $topic_name; + foreach $topic_name (keys(%{$keywords{$keyword_name}})) + { + print_insert_header($count,$header); + print "($topics{$topic_name}->{__id__},$count_keyword)"; + $count++; + } + $count_keyword++; + } + printf ";\n\n"; +} + +if ($count_errors) +{ + print STDERR "$count_errors errors !!!\n"; + exit 1; +} diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index c7945e31eda..3261ec309d4 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -17,6 +17,7 @@ DEBUG=0 SILENT=0 TMP=/tmp SUFFIX="" +NDBCLUSTER= parse_arguments() { for arg do @@ -26,6 +27,7 @@ parse_arguments() { --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; --no-strip) STRIP=0 ;; --silent) SILENT=1 ;; + --with-ndbcluster) NDBCLUSTER=1 ;; *) echo "Unknown argument '$arg'" exit 1 @@ -192,6 +194,7 @@ if [ $BASE_SYSTEM != "netware" ] ; then fi $CP support-files/* $BASE/support-files +$CP scripts/*.sql $BASE/share if [ $BASE_SYSTEM = "netware" ] ; then rm -f $BASE/support-files/magic \ @@ -215,20 +218,21 @@ do done $CP mysql-test/include/*.inc $BASE/mysql-test/include -$CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data +$CP mysql-test/std_data/*.dat mysql-test/std_data/*.*001 $BASE/mysql-test/std_data $CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data $CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t $CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r if [ $BASE_SYSTEM != "netware" ] ; then $CP scripts/* $BASE/bin - $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db + $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ \@pkgdatadir\@ ./support-files < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe mv $BASE/support-files/binary-configure $BASE/configure chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure $CP -r sql-bench/* $BASE/sql-bench rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la + rm -f $BASE/bin/*.sql fi rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution $BASE/bin/setsomevars $BASE/support-files/Makefile* $BASE/support-files/*.sh @@ -243,6 +247,18 @@ if [ -d $BASE/sql-bench/SCCS ] ; then find $BASE/sql-bench -name SCCS -print | xargs rm -r -f fi +# NDB Cluster +if [ x$NDBCLUSTER = x1 ]; then + if [ ! -f ndb/BinDist.sh ]; then + echo "Missing ndb/BinDist.sh"; exit 1 + fi + mkdir $BASE/ndb || exit 1 + # assume we have cpio.. + if (cd ndb && sh BinDist.sh | cpio -pdm $BASE/ndb); then :; else + echo "Copy failed - missing files in ndb/BinDist.sh ?"; exit 1 + fi +fi + # Change the distribution to a long descriptive name NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$system-$machine$SUFFIX BASE2=$TMP/$NEW_NAME diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 3556b00cbc7..57612ac8edc 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -178,18 +178,8 @@ rm -r -f "$BASE/share/Makefile" rm -r -f "$BASE/share/Makefile.in" rm -r -f "$BASE/share/Makefile.am" -# -# Clean up if we did this from a bk tree -# - -if [ -d $BASE/SCCS ] -then - find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f -fi - mkdir $BASE/Docs $BASE/extra $BASE/include - # # Copy directory files # @@ -252,7 +242,7 @@ copy_dir_dirs() { for i in client dbug extra heap include isam \ libmysql libmysqld merge myisam \ - myisammrg mysys regex sql strings \ + myisammrg mysys regex sql strings sql-common \ tools vio zlib do copy_dir_files $i @@ -287,7 +277,7 @@ for i in COPYING ChangeLog README \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ Docs/manual.txt Docs/mysqld_error.txt \ - Docs/INSTALL-BINARY + Docs/INSTALL-BINARY Docs/internals.texi do print_debug "Copying file '$i'" @@ -321,6 +311,15 @@ unix_to_dos $BASE/README mv $BASE/README $BASE/README.txt # +# Clean up if we did this from a bk tree +# + +if [ -d $BASE/SSL/SCCS ] +then + find $BASE -type d -name SCCS | xargs rm -r -f +fi + +# # Initialize the initial data directory # diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh new file mode 100644 index 00000000000..5129c028238 --- /dev/null +++ b/scripts/mysql_create_system_tables.sh @@ -0,0 +1,310 @@ +#!/bin/sh +# Copyright (C) 1997-2003 MySQL AB +# For a more info consult the file COPYRIGHT distributed with this file + +# This script writes on stdout SQL commands to generate all not +# existing MySQL system tables. It also replaces the help tables with +# new context from the manual (from fill_help_tables.sql). + +# $1 - "test" or "real" or "verbose" variant of database +# $2 - path to mysql-database directory +# $3 - hostname +# $4 - windows option + +if test "$1" = "" +then + echo " +This script writes on stdout SQL commands to generate all not +existing MySQL system tables. It also replaces the help tables with +new context from the manual (from fill_help_tables.sql). + +Usage: + mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option> +" + exit +fi + +mdata=$2 +hostname=$3 +windows=$4 + +# Initialize variables +c_d="" i_d="" +c_h="" i_h="" +c_u="" i_u="" +c_f="" i_f="" +c_t="" c_c="" +c_ht="" +c_hc="" +c_hr="" +c_hk="" +i_ht="" + +# Check for old tables +if test ! -f $mdata/db.frm +then + if test "$1" = "verbose" ; then + echo "Preparing db table" 1>&2; + fi + + # mysqld --bootstrap wants one command/line + c_d="$c_d CREATE TABLE db (" + c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL," + c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL," + c_d="$c_d User char(16) binary DEFAULT '' NOT NULL," + c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_d="$c_d PRIMARY KEY Host (Host,Db,User)," + c_d="$c_d KEY User (User)" + c_d="$c_d )" + c_d="$c_d comment='Database privileges';" + + i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); + INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');" +fi + +if test ! -f $mdata/host.frm +then + if test "$1" = "verbose" ; then + echo "Preparing host table" 1>&2; + fi + + c_h="$c_h CREATE TABLE host (" + c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL," + c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL," + c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_h="$c_h PRIMARY KEY Host (Host,Db)" + c_h="$c_h )" + c_h="$c_h comment='Host privileges; Merged with database privileges';" +fi + +if test ! -f $mdata/user.frm +then + if test "$1" = "verbose" ; then + echo "Preparing user table" 1>&2; + fi + + c_u="$c_u CREATE TABLE user (" + c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL," + c_u="$c_u User char(16) binary DEFAULT '' NOT NULL," + c_u="$c_u Password char(41) binary DEFAULT '' NOT NULL," + c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL," + c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL," + c_u="$c_u ssl_cipher BLOB NOT NULL," + c_u="$c_u x509_issuer BLOB NOT NULL," + c_u="$c_u x509_subject BLOB NOT NULL," + c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL," + c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL," + c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL," + c_u="$c_u PRIMARY KEY Host (Host,User)" + c_u="$c_u )" + c_u="$c_u comment='Users and global privileges';" + + if test "$1" = "test" + then + i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); + INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); + REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); + INSERT INTO user (host,user) values ('localhost',''); + INSERT INTO user (host,user) values ('$hostname','');" + else + i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);" + if test "$windows" = "0" + then + i_u="$i_u + INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); + INSERT INTO user (host,user) values ('$hostname',''); + INSERT INTO user (host,user) values ('localhost','');" + else + i_u="INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);" + fi + fi +fi + +if test ! -f $mdata/func.frm +then + if test "$1" = "verbose" ; then + echo "Preparing func table" 1>&2; + fi + + c_f="$c_f CREATE TABLE func (" + c_f="$c_f name char(64) binary DEFAULT '' NOT NULL," + c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL," + c_f="$c_f dl char(128) DEFAULT '' NOT NULL," + c_f="$c_f type enum ('function','aggregate') NOT NULL," + c_f="$c_f PRIMARY KEY (name)" + c_f="$c_f )" + c_f="$c_f comment='User defined functions';" +fi + +if test ! -f $mdata/tables_priv.frm +then + if test "$1" = "verbose" ; then + echo "Preparing tables_priv table" 1>&2; + fi + + c_t="$c_t CREATE TABLE tables_priv (" + c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL," + c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL," + c_t="$c_t User char(16) binary DEFAULT '' NOT NULL," + c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL," + c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL," + c_t="$c_t Timestamp timestamp(14)," + c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL," + c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL," + c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name)," + c_t="$c_t KEY Grantor (Grantor)" + c_t="$c_t )" + c_t="$c_t comment='Table privileges';" +fi + +if test ! -f $mdata/columns_priv.frm +then + if test "$1" = "verbose" ; then + echo "Preparing columns_priv table" 1>&2; + fi + + c_c="$c_c CREATE TABLE columns_priv (" + c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL," + c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL," + c_c="$c_c User char(16) binary DEFAULT '' NOT NULL," + c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL," + c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL," + c_c="$c_c Timestamp timestamp(14)," + c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL," + c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)" + c_c="$c_c )" + c_c="$c_c comment='Column privileges';" +fi + +if test ! -f $mdata/help_topic.frm +then + if test "$1" = "verbose" ; then + echo "Preparing help_topic table" 1>&2; + fi + + c_ht="$c_ht CREATE TABLE help_topic (" + c_ht="$c_ht help_topic_id int unsigned not null," + c_ht="$c_ht name varchar(64) not null," + c_ht="$c_ht help_category_id smallint unsigned not null," + c_ht="$c_ht description text not null," + c_ht="$c_ht example text not null," + c_ht="$c_ht url varchar(128) not null," + c_ht="$c_ht primary key (help_topic_id)," + c_ht="$c_ht unique index (name)" + c_ht="$c_ht )" + c_ht="$c_ht comment='help topics';" +fi + +old_categories="yes" + +if test ! -f $mdata/help_category.frm +then + if test "$1" = "verbose" ; then + echo "Preparing help_category table" 1>&2; + fi + + c_hc="$c_hc CREATE TABLE help_category (" + c_hc="$c_hc help_category_id smallint unsigned not null," + c_hc="$c_hc name varchar(64) not null," + c_hc="$c_hc parent_category_id smallint unsigned null," + c_hc="$c_hc url varchar(128) not null," + c_hc="$c_hc primary key (help_category_id)," + c_hc="$c_hc unique index (name)" + c_hc="$c_hc )" + c_hc="$c_hc comment='help categories';" +fi + +if test ! -f $mdata/help_keyword.frm +then + if test "$1" = "verbose" ; then + echo "Preparing help_keyword table" 1>&2; + fi + + c_hk="$c_hk CREATE TABLE help_keyword (" + c_hk="$c_hk help_keyword_id int unsigned not null," + c_hk="$c_hk name varchar(64) not null," + c_hk="$c_hk primary key (help_keyword_id)," + c_hk="$c_hk unique index (name)" + c_hk="$c_hk )" + c_hk="$c_hk comment='help keywords';" +fi + +if test ! -f $mdata/help_relation.frm +then + if test "$1" = "verbose" ; then + echo "Preparing help_relation table" 1>&2; + fi + + c_hr="$c_hr CREATE TABLE help_relation (" + c_hr="$c_hr help_topic_id int unsigned not null references help_topic," + c_hr="$c_hr help_keyword_id int unsigned not null references help_keyword," + c_hr="$c_hr primary key (help_keyword_id, help_topic_id)" + c_hr="$c_hr )" + c_hr="$c_hr comment='keyword-topic relation';" +fi + +cat << END_OF_DATA +use mysql; +$c_d +$i_d + +$c_h +$i_h + +$c_u +$i_u + +$c_f +$i_f + +$c_t +$c_c + +$c_ht +$c_hc +$c_hr +$c_hk +END_OF_DATA + diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 2fbcd76c318..69bf2bebaa8 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -1,292 +1,184 @@ #!/bin/sh +# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql +# through the mysql client program to the mysqld server -# -# Copyright (C) 2004 MySQL AB -# For a more info consult the file COPYRIGHT distributed with this file. -# -# This script converts any old privilege tables to privilege tables suitable -# for MySQL 4.0. -# -# You can safely ignore all 'Duplicate column' and 'Unknown column' errors" -# as this just means that your tables where already up to date. -# This script is safe to run even if your tables are already up to date! -# -# On windows you should do 'mysql --force < mysql_fix_privilege_tables.sql' -# instead of this script -# -# Usage: -# mysql_fix_privilege_tables -# - fix tables for host "localhost" as "root" with no password -# mysql_fix_privilege_tables <password> -# - fix tables for host "localhost" as "root" with <password> -# mysql_fix_privilege_tables --sql-only -# - output sql-script to file /usr/share/mysql/echo_stderr -# mysql_fix_privilege_tables OPTIONS -# - fix tables on connection with OPTIONS -# -# where OPTIONS are -# --host=<host> -# --port=<port> -# --socket=<socket> -# --user=<user> -# --password=<password> -# --database=<database> - -root_password="" +# Default values (Can be changed in my.cnf) +password="" host="localhost" user="root" +sql_only=0 +basedir="" +verbose=0 +args="" port="" socket="" -comment="" database="mysql" -bindir="@bindir@" +bindir="" -# Old format where there is only one argument and it's the password -if test "$#" = 1 -then - case "$1" in - --*) ;; - *) root_password="$1" ; shift ;; - esac -fi +file=mysql_fix_privilege_tables.sql + +# The following code is almost identical to the code in mysql_install_db.sh + +parse_arguments() { + # We only need to pass arguments through to the server if we don't + # handle them here. So, we collect unrecognized options (passed on + # the command line) into the args variable. + pick_args= + if test "$1" = PICK-ARGS-FROM-ARGV + then + pick_args=1 + shift + fi -# read all the options -parse_arguments() -{ for arg do case "$arg" in - --sql-only) cmd="/usr/share/mysql/echo_stderr" ;; + --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --sql|--sql-only) sql_only=1;; + --verbose) verbose=1 ;; --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;; - --user=*) user=`echo "$arg" | sed -e "s;--user=;;"` ;; - --host=*) host=`echo "$arg" | sed -e "s;--host=;;"` ;; --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; - --password=*) root_password=`echo "$arg" | sed -e "s;--password=;;"` ;; --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;; --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"` ;; *) - echo "Unknown argument '$arg'" - exit 1 - ;; + if test -n "$pick_args" + then + # This sed command makes sure that any special chars are quoted, + # so the arg gets passed exactly to the server. + args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'` + fi + ;; esac done } - -parse_arguments "$@" -if test -z "$cmd"; then - cmd="$bindir/mysql -f --user=$user --host=$host" - if test ! -z "$root_password"; then - cmd="$cmd --password=$root_password" +# 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 +do + if test -x $dir/my_print_defaults + then + print_defaults="$dir/my_print_defaults" + break + fi +done + +parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` +parse_arguments PICK-ARGS-FROM-ARGV "$@" + +if test -z "$basedir" +then + basedir=@prefix@ + if test -z "$bindir" + then + bindir=@bindir@ fi - if test ! -z "$port"; then - cmd="$cmd --port=$port" + execdir=@libexecdir@ + pkgdatadir=@pkgdatadir@ +else + if test -z "$bindir" + then + bindir="$basedir/bin" fi - if test ! -z "$socket"; then - cmd="$cmd --socket=$socket" + if test -x "$basedir/libexec/mysqld" + then + execdir="$basedir/libexec" + elif test -x "@libexecdir@/mysqld" + then + execdir="@libexecdir@" + else + execdir="$basedir/bin" fi - cmd="$cmd $database" fi -echo "This scripts updates the mysql.user, mysql.db, mysql.host and the" -echo "mysql.func tables to MySQL 3.22.14 and above." -echo "" -echo "This is needed if you want to use the new GRANT functions," -echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 3.23" -echo "" -echo "If you get 'Access denied' errors, you should run this script again" -echo "and give the MySQL root user password as an argument!" - -echo "Converting all privilege tables to MyISAM format" -$cmd <<END_OF_DATA -ALTER TABLE user type=MyISAM; -ALTER TABLE db type=MyISAM; -ALTER TABLE host type=MyISAM; -ALTER TABLE func type=MyISAM; -ALTER TABLE columns_priv type=MyISAM; -ALTER TABLE tables_priv type=MyISAM; -END_OF_DATA - - -# Fix old password format, add File_priv and func table -echo "" -echo "If your tables are already up to date or partially up to date you will" -echo "get some warnings about 'Duplicated column name'. You can safely ignore these!" - -$cmd <<END_OF_DATA -alter table user change password password char(16) NOT NULL; -alter table user add File_priv enum('N','Y') NOT NULL; -CREATE TABLE if not exists func ( - name char(64) binary DEFAULT '' NOT NULL, - ret tinyint(1) DEFAULT '0' NOT NULL, - dl char(128) DEFAULT '' NOT NULL, - type enum ('function','aggregate') NOT NULL, - PRIMARY KEY (name) -); -END_OF_DATA -echo "" - -# Add the new grant colums - -echo "Creating Grant Alter and Index privileges if they don't exists" -echo "You can ignore any Duplicate column errors" -$cmd <<END_OF_DATA -alter table user add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; -alter table host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; -alter table db add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL; -END_OF_DATA -res=$? -echo "" - -# If the new grant columns didn't exists, copy File -> Grant -# and Create -> Alter, Index, References - -if test $res = 0 +# The following test is to make this script compatible with the 4.0 where +# the first argument was the password +if test -z "$password" then - echo "Setting default privileges for the new grant, index and alter privileges" - $cmd <<END_OF_DATA - UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; - UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; - UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv; -END_OF_DATA - echo "" + password=`echo $args | sed -e 's/ *//g'` fi -# -# The second alter changes ssl_type to new 4.0.2 format - -echo "Adding columns needed by GRANT .. REQUIRE (openssl)" -echo "You can ignore any Duplicate column errors" -$cmd <<END_OF_DATA -ALTER TABLE user -ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL, -ADD ssl_cipher BLOB NOT NULL, -ADD x509_issuer BLOB NOT NULL, -ADD x509_subject BLOB NOT NULL; -ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; -END_OF_DATA -echo "" - -# -# Create tables_priv and columns_priv if they don't exists -# - -echo "Creating the new table and column privilege tables" - -$cmd <<END_OF_DATA -CREATE TABLE IF NOT EXISTS tables_priv ( - Host char(60) DEFAULT '' NOT NULL, - Db char(60) DEFAULT '' NOT NULL, - User char(16) DEFAULT '' NOT NULL, - Table_name char(60) DEFAULT '' NOT NULL, - Grantor char(77) DEFAULT '' NOT NULL, - Timestamp timestamp(14), - Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL, - Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Table_name) -); -CREATE TABLE IF NOT EXISTS columns_priv ( - Host char(60) DEFAULT '' NOT NULL, - Db char(60) DEFAULT '' NOT NULL, - User char(16) DEFAULT '' NOT NULL, - Table_name char(60) DEFAULT '' NOT NULL, - Column_name char(59) DEFAULT '' NOT NULL, - Timestamp timestamp(14), - Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Table_name,Column_name) -); -END_OF_DATA - -# -# Name change of Type -> Column_priv from MySQL 3.22.12 -# - -echo "Changing name of columns_priv.Type -> columns_priv.Column_priv" -echo "You can ignore any Unknown column errors from this" - -$cmd <<END_OF_DATA -ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL; -END_OF_DATA -echo "" - -# -# Add the new 'type' column to the func table. -# - -echo "Fixing the func table" -echo "You can ignore any Duplicate column errors" - -$cmd <<EOF -alter table func add type enum ('function','aggregate') NOT NULL; -EOF -echo "" - -# -# Change the user,db and host tables to MySQL 4.0 format -# +cmd="$bindir/mysql -f --user=$user --host=$host" +if test -z "$password" ; then + cmd="$cmd --password=$password" +fi +if test ! -z "$port"; then + cmd="$cmd --port=$port" +fi +if test ! -z "$socket"; then + cmd="$cmd --socket=$socket" +fi +cmd="$cmd --database=$database" -echo "Adding new fields used by MySQL 4.0.2 to the privilege tables" -echo "You can ignore any Duplicate column errors" +if test $sql_only = 1 +then + cmd="cat" +fi -$cmd <<END_OF_DATA -alter table user -add Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER alter_priv, -add Super_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Show_db_priv, -add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Super_priv, -add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv, -add Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv, -add Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv, -add Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; -END_OF_DATA +# Find where mysql_fix_privilege_tables.sql is located +for i in $basedir/support-files $basedir/share $basedir/share/mysql \ + $basedir/scripts @pkgdatadir@ . ./scripts +do + if test -f $i/$file + then + pkgdatadir=$i + fi +done -if test $? -eq "0" +sql_file="$pkgdatadir/$file" +if test ! -f $sql_file then - # Convert privileges so that users have similar privileges as before - echo "" - echo "Updating new privileges in MySQL 4.0.2 from old ones" - $cmd <<END_OF_DATA - update user set show_db_priv= select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>""; -END_OF_DATA - echo "" + echo "Could not find file '$file'." + echo "Please use --basedir to specify the directory where MySQL is installed" + exit 1 fi -# Add fields that can be used to limit number of questions and connections -# for some users. - -$cmd <<END_OF_DATA -alter table user -add max_questions int(11) NOT NULL AFTER x509_subject, -add max_updates int(11) unsigned NOT NULL AFTER max_questions, -add max_connections int(11) unsigned NOT NULL AFTER max_updates; -END_OF_DATA +s_echo() +{ + if test $sql_only = 0 + then + echo $1 + fi +} -# -# Add Create_tmp_table_priv and Lock_tables_priv to db and host -# +s_echo "This scripts updates all the mysql privilege tables to be usable by" +s_echo "MySQL 4.0 and above." +s_echo "" +s_echo "This is needed if you want to use the new GRANT functions," +s_echo "CREATE AGGREGATE FUNCTION or want to use the more secure passwords in 4.1" +s_echo "" -$cmd <<END_OF_DATA -alter table db -add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, -add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; -alter table host -add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, -add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; -END_OF_DATA +if test $verbose = 1 +then + s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors" + s_echo "as this just means that your tables where already up to date." + s_echo "This script is safe to run even if your tables are already up to date!" + s_echo "" +fi -# -# Fix the new bugs discovered by new tests (for Bug #2874 Grant table bugs ) -# -$cmd <<END_OF_DATA -alter table db change Db Db char(64) binary DEFAULT '' NOT NULL; -alter table host change Db Db char(64) binary DEFAULT '' NOT NULL; -alter table user change password Password char(16) binary NOT NULL, change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; -alter table tables_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL; -alter table tables_priv add KEY Grantor (Grantor); -alter table columns_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL, change Column_name Column_name char(64) binary DEFAULT '' NOT NULL; - -alter table db comment='Database privileges'; -alter table host comment='Host privileges; Merged with database privileges'; -alter table user comment='Users and global privileges'; -alter table func comment='User defined functions'; -alter table tables_priv comment='Table privileges'; -alter table columns_priv comment='Column privileges'; -END_OF_DATA +if test $verbose = 0 +then + cat $sql_file | $cmd > /dev/null 2>&1 +else + cat $sql_file | $cmd > /dev/null +fi +if test $? = 0 +then + s_echo "done" +else + s_echo "Got a failure from command:" + s_echo "$cmd" + s_echo "Please check the above output and try again." + if test $verbose = 0 + then + s_echo "" + s_echo "Running the script with the --verbose option may give you some information" + s_echo "of what went wrong." + fi + s_echo "" + s_echo "If you get an 'Access denied' error, you should run this script again and" + s_echo "give the MySQL root user password as an argument with the --password= option" +fi diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index bfff05151e5..dabc653bcbb 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -9,14 +9,13 @@ -- this sql script. -- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' -USE mysql; ALTER TABLE user type=MyISAM; ALTER TABLE db type=MyISAM; ALTER TABLE host type=MyISAM; ALTER TABLE func type=MyISAM; ALTER TABLE columns_priv type=MyISAM; ALTER TABLE tables_priv type=MyISAM; -ALTER TABLE user change Password Password char(41) not null; +ALTER TABLE user change Password Password char(41) binary not null; ALTER TABLE user add File_priv enum('N','Y') NOT NULL; CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, @@ -39,7 +38,6 @@ UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Crea UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; - -- -- The second alter changes ssl_type to new 4.0.2 format -- Adding columns needed by GRANT .. REQUIRE (openssl)" @@ -85,7 +83,6 @@ CREATE TABLE IF NOT EXISTS columns_priv ( ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL; - -- -- Add the new 'type' column to the func table. -- @@ -109,7 +106,6 @@ ADD Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv, ADD Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv, ADD Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; - -- Convert privileges so that users have similar privileges as before UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv, Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv where user<>"" AND @hadShowDbPriv = 0; @@ -137,7 +133,7 @@ ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; alter table db change Db Db char(64) binary DEFAULT '' NOT NULL; alter table host change Db Db char(64) binary DEFAULT '' NOT NULL; -alter table user change password Password char(16) binary NOT NULL, change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; +alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; alter table tables_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL; alter table tables_priv add KEY Grantor (Grantor); alter table columns_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL, change Column_name Column_name char(64) binary DEFAULT '' NOT NULL; @@ -148,3 +144,38 @@ alter table user comment='Users and global privileges'; alter table func comment='User defined functions'; alter table tables_priv comment='Table privileges'; alter table columns_priv comment='Column privileges'; + +# +# Create some possible missing tables +# +CREATE TABLE IF NOT EXISTS help_topic ( +help_topic_id int unsigned not null, +name varchar(64) not null, +help_category_id smallint unsigned not null, +description text not null, +example text not null, +url varchar(128) not null, +primary key (help_topic_id), unique index (name) +) comment='help topics'; + +CREATE TABLE IF NOT EXISTS help_category ( +help_category_id smallint unsigned not null, +name varchar(64) not null, +parent_category_id smallint unsigned null, +url varchar(128) not null, +primary key (help_category_id), +unique index (name) +) comment='help categories'; + +CREATE TABLE IF NOT EXISTS help_relation ( +help_topic_id int unsigned not null references help_topic, +help_keyword_id int unsigned not null references help_keyword, +primary key (help_keyword_id, help_topic_id) +) comment='keyword-topic relation'; + +CREATE TABLE IF NOT EXISTS help_keyword ( +help_keyword_id int unsigned not null, +name varchar(64) not null, +primary key (help_keyword_id), +unique index (name) +) comment='help keywords'; diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 012725265a1..61d173aac05 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2002 MySQL AB +# Copyright (C) 2002-2003 MySQL AB # For a more info consult the file COPYRIGHT distributed with this file. # This scripts creates the privilege tables db, host, user, tables_priv, @@ -7,13 +7,9 @@ # # All unrecognized arguments to this script are passed to mysqld. -IN_RPM=0 -case "$1" in - -IN-RPM) - IN_RPM="1"; shift - ;; -esac -defaults= +in_rpm=0 +windows=0 +defaults="" case "$1" in --no-defaults|--defaults-file=*|--defaults-extra-file=*) defaults="$1"; shift @@ -38,6 +34,9 @@ parse_arguments() { --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --skip-name-resolve) ip_only=1 ;; + --verbose) verbose=1 ;; + --rpm) in_rpm=1 ;; + --windows) windows=1 ;; *) if test -n "$pick_args" then @@ -55,6 +54,9 @@ parse_arguments() { if test -x ./bin/my_print_defaults then print_defaults="./bin/my_print_defaults" +elif test -x ./extra/my_print_defaults +then + print_defaults="./extra/my_print_defaults" elif test -x @bindir@/my_print_defaults then print_defaults="@bindir@/my_print_defaults" @@ -71,6 +73,9 @@ execdir= bindir= basedir= force=0 +verbose=0 +fill_help_tables="" + parse_arguments `$print_defaults $defaults mysqld mysql_install_db` parse_arguments PICK-ARGS-FROM-ARGV "$@" @@ -79,30 +84,58 @@ if test -z "$basedir" then basedir=@prefix@ bindir=@bindir@ - execdir=@libexecdir@ + execdir=@libexecdir@ + pkgdatadir=@pkgdatadir@ else bindir="$basedir/bin" -if test -x "$basedir/libexec/mysqld" -then - execdir="$basedir/libexec" -elif test -x "@libexecdir@/mysqld" + if test -x "$basedir/libexec/mysqld" + then + execdir="$basedir/libexec" + elif test -x "@libexecdir@/mysqld" + then + execdir="@libexecdir@" + else + execdir="$basedir/bin" + fi +fi + +# find fill_help_tables.sh +for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ +do + if test -f $i/fill_help_tables.sql + then + pkgdatadir=$i + fi +done + +if test -f $pkgdatadir/fill_help_tables.sql then - execdir="@libexecdir@" + fill_help_tables=$pkgdatadir/fill_help_tables.sql else - execdir="$basedir/bin" -fi + echo "Could not find help file 'fill_help_tables.sql' in @pkgdatadir@ or inside $basedir". + exit 1; fi mdata=$ldata/mysql +mysqld=$execdir/mysqld +mysqld_opt="" +scriptdir=$bindir -if test ! -x $execdir/mysqld +if test "$windows" = 1 then - if test "$IN_RPM" = "1" + mysqld="./sql/mysqld" + mysqld_opt="--language=./sql/share/english" + scriptdir="./scripts" +fi + +if test ! -x $mysqld +then + if test "$in_rpm" = 1 then - echo "FATAL ERROR $execdir/mysqld not found!" + echo "FATAL ERROR $mysqld not found!" exit 1 else - echo "Didn't find $execdir/mysqld" + echo "Didn't find $mysqld" echo "You should do a 'make install' before executing this script" exit 1 fi @@ -112,7 +145,7 @@ fi hostname=`@HOSTNAME@` # Check if hostname is valid -if test "$IN_RPM" = "0" -a $force = "0" +if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0 then resolved=`$bindir/resolveip $hostname 2>&1` if [ $? -ne 0 ] @@ -143,6 +176,7 @@ then fi # Create database directories mysql & test + if test ! -d $ldata; then mkdir $ldata; chmod 700 $ldata ; fi if test ! -d $ldata/mysql; then mkdir $ldata/mysql; chmod 700 $ldata/mysql ; fi if test ! -d $ldata/test; then mkdir $ldata/test; chmod 700 $ldata/test ; fi @@ -150,195 +184,53 @@ fi chown $user $ldata $ldata/mysql $ldata/test; fi -# Initialize variables -c_d="" i_d="" -c_h="" i_h="" -c_u="" i_u="" -c_f="" i_f="" -c_t="" c_c="" - -# Check for old tables if test ! -f $mdata/db.frm then - echo "Preparing db table" - - # mysqld --bootstrap wants one command/line - c_d="$c_d CREATE TABLE db (" - c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL," - c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL," - c_d="$c_d User char(16) binary DEFAULT '' NOT NULL," - c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_d="$c_d PRIMARY KEY Host (Host,Db,User)," - c_d="$c_d KEY User (User)" - c_d="$c_d )" - c_d="$c_d comment='Database privileges';" - - i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); - INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');" -fi - -if test ! -f $mdata/host.frm -then - echo "Preparing host table" - - c_h="$c_h CREATE TABLE host (" - c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL," - c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL," - c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_h="$c_h PRIMARY KEY Host (Host,Db)" - c_h="$c_h )" - c_h="$c_h comment='Host privileges; Merged with database privileges';" + c_d="yes" fi -if test ! -f $mdata/user.frm +if test $verbose = 1 then - echo "Preparing user table" - - c_u="$c_u CREATE TABLE user (" - c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL," - c_u="$c_u User char(16) binary DEFAULT '' NOT NULL," - c_u="$c_u Password char(16) binary DEFAULT '' NOT NULL," - c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL," - c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL," - c_u="$c_u ssl_cipher BLOB NOT NULL," - c_u="$c_u x509_issuer BLOB NOT NULL," - c_u="$c_u x509_subject BLOB NOT NULL," - c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL," - c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL," - c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL," - c_u="$c_u PRIMARY KEY Host (Host,User)" - c_u="$c_u )" - c_u="$c_u comment='Users and global privileges';" - - i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - - REPLACE INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - REPLACE INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - - INSERT INTO user (host,user) values ('localhost',''); - INSERT INTO user (host,user) values ('$hostname','');" + create_option="verbose" +else + create_option="real" fi -if test ! -f $mdata/func.frm +if test "$in_rpm" -eq 0 -a "$windows" -eq 0 then - echo "Preparing func table" - - c_f="$c_f CREATE TABLE func (" - c_f="$c_f name char(64) binary DEFAULT '' NOT NULL," - c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL," - c_f="$c_f dl char(128) DEFAULT '' NOT NULL," - c_f="$c_f type enum ('function','aggregate') NOT NULL," - c_f="$c_f PRIMARY KEY (name)" - c_f="$c_f )" - c_f="$c_f comment='User defined functions';" + echo "Installing all prepared tables" fi - -if test ! -f $mdata/tables_priv.frm +mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \ +--skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \ +--skip-bdb $args" +if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \ + | eval "$mysqld_install_cmd_line" then - echo "Preparing tables_priv table" - - c_t="$c_t CREATE TABLE tables_priv (" - c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL," - c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL," - c_t="$c_t User char(16) binary DEFAULT '' NOT NULL," - c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL," - c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL," - c_t="$c_t Timestamp timestamp(14)," - c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL," - c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL," - c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name)," - c_t="$c_t KEY Grantor (Grantor)" - c_t="$c_t )" - c_t="$c_t comment='Table privileges';" -fi - -if test ! -f $mdata/columns_priv.frm -then - echo "Preparing columns_priv table" - - c_c="$c_c CREATE TABLE columns_priv (" - c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL," - c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL," - c_c="$c_c User char(16) binary DEFAULT '' NOT NULL," - c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL," - c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL," - c_c="$c_c Timestamp timestamp(14)," - c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL," - c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)" - c_c="$c_c )" - c_c="$c_c comment='Column privileges';" -fi - -echo "Installing all prepared tables" -if eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \ - --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $args" << END_OF_DATA -use mysql; -$c_d -$i_d - -$c_h -$i_h - -$c_u -$i_u - -$c_f -$i_f - -$c_t -$c_c -END_OF_DATA -then - echo "" - if test "$IN_RPM" = "0" + if test -n "$fill_help_tables" + then + if test "$in_rpm" -eq 0 -a "$windows" -eq 0 + then + echo "Fill help tables" + fi + if ! (echo "use mysql; + " + cat $fill_help_tables) | eval "$mysqld_install_cmd_line" + then + echo "" + echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!" + echo "The \"HELP\" command might not work properly" + echo "" + fi + fi + if test "$in_rpm" = 0 -a "$windows" = 0 then + echo "" echo "To start mysqld at boot time you have to copy support-files/mysql.server" echo "to the right place for your system" echo fi + if test "$windows" -eq 0 + then echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !" echo "To do so, start the server, then issue the following commands:" echo "$bindir/mysqladmin -u root password 'new-password'" @@ -354,7 +246,7 @@ then echo "able to use the new GRANT command!" fi echo - if test "$IN_RPM" = "0" + if test "$in_rpm" = "0" then echo "You can start the MySQL daemon with:" echo "cd @prefix@ ; $bindir/mysqld_safe &" @@ -368,14 +260,14 @@ then echo "The latest information about MySQL is available on the web at" echo "http://www.mysql.com" echo "Support MySQL by buying support/licenses at https://order.mysql.com" - echo + fi exit 0 else - echo "Installation of grant tables failed!" + echo "Installation of system tables failed!" echo echo "Examine the logs in $ldata for more information." echo "You can also try to start the mysqld daemon with:" - echo "$execdir/mysqld --skip-grant &" + echo "$mysqld --skip-grant &" echo "You can use the command line tool" echo "$bindir/mysql to connect to the mysql" echo "database and look at the grant tables:" diff --git a/scripts/mysql_prepare_privilege_tables_for_5.sql b/scripts/mysql_prepare_privilege_tables_for_5.sql new file mode 100644 index 00000000000..a9b6d43aee0 --- /dev/null +++ b/scripts/mysql_prepare_privilege_tables_for_5.sql @@ -0,0 +1,53 @@ + +use mysql; + +-- +-- merging `host` table and `db` +-- + +UPDATE IGNORE host SET Host='%' WHERE Host=''; +DELETE FROM host WHERE Host=''; + +INSERT IGNORE INTO db (User, Host, Select_priv, Insert_priv, Update_priv, + Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, + Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv) + SELECT d.User, h.Host, + (d.Select_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Insert_priv = 'Y' || h.Select_priv = 'Y') + 1, + (d.Update_priv = 'Y' || h.Update_priv = 'Y') + 1, + (d.Delete_priv = 'Y' || h.Delete_priv = 'Y') + 1, + (d.Create_priv = 'Y' || h.Create_priv = 'Y') + 1, + (d.Drop_priv = 'Y' || h.Drop_priv = 'Y') + 1, + (d.Grant_priv = 'Y' || h.Grant_priv = 'Y') + 1, + (d.References_priv = 'Y' || h.References_priv = 'Y') + 1, + (d.Index_priv = 'Y' || h.Index_priv = 'Y') + 1, + (d.Alter_priv = 'Y' || h.Alter_priv = 'Y') + 1, + (d.Create_tmp_table_priv = 'Y' || h.Create_tmp_table_priv = 'Y') + 1, + (d.Lock_tables_priv = 'Y' || h.Lock_tables_priv = 'Y') + 1 + FROM db d, host h WHERE d.Host = ''; + +UPDATE IGNORE db SET Host='%' WHERE Host = ''; +DELETE FROM db WHERE Host=''; + +TRUNCATE TABLE host; + +-- +-- Adding missing users to `user` table +-- +-- note that invalid password causes the user to be skipped during the +-- load of grand tables (at mysqld startup) thus three following inserts +-- do not affect anything + +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM db; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM tables_priv; +INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM columns_priv; + +SELECT DISTINCT +"There are user accounts with the username 'PUBLIC'. In the SQL-1999 +(or later) standard this name is reserved for PUBLIC role and can +not be used as a valid user name. Consider renaming these accounts before +upgrading to MySQL-5.0. +These accounts are:" x +FROM user WHERE user='PUBLIC'; +SELECT CONCAT(user,'@',host) FROM user WHERE user='PUBLIC'; + diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index f485d164282..89823c1373b 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -111,10 +111,10 @@ Usage: $0 [-signal] [-?Ift] [--help] pattern Options: -I or -? "info" -f "force" -t "test". Version 1.0 -Kill processes with matches pattern. +Kill processes that match the pattern. If -f isn't given, ask user for confirmation for each process to kill. -If signal isn't given, try first with signal 15 and after that with signal 9. -If -t is given the processes is only shown on stdout. +If signal isn't given, try first with signal 15, then with signal 9. +If -t is given, the processes are only shown on stdout. EOF exit(1); } diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 75ef63ecdd0..9fd1f63f67a 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -414,7 +414,6 @@ _HOWTO use Getopt::Long; use Sys::Hostname; use IPC::Open3; -#use CGI; #moved to use of CGI by monty # **************************** @@ -527,7 +526,7 @@ if ($MySQLaccess::CMD) { #command-line version } } if ($MySQLaccess::CGI) { #CGI-version - use CGI; + require CGI; $Q = new CGI; $Param{'help'} = $Q->param('help') ; $Param{'host'} = $Q->param('host') || $Q->param('h') || $Param{'host'}; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index b75aa1a7c31..9767976460c 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -180,6 +180,45 @@ sub init_log } #### +#### Init log file. Check for appropriate place for log file, in the following +#### order my_print_defaults mysqld datadir, @datadir@, /var/log, /tmp +#### + +sub init_log +{ + if ($my_print_defaults_exists) + { + @mysqld_opts= `my_print_defaults mysqld`; + chomp @mysqld_opts; + foreach my $opt (@mysqld_opts) + { + if ($opt =~ m/^\-\-datadir[=](.*)/) + { + if (-d "$1" && -w "$1") + { + $logdir= $1; + } + } + } + } + if (!defined($logdir)) + { + $logdir= "@datadir@" if (-d "@datadir@" && -w "@datadir@"); + } + if (!defined($logdir)) + { + # Log file was not specified and we could not log to a standard place, + # so log file be disabled for now. + print "WARNING: Log file disabled. Maybe directory/file isn't writable?\n"; + $opt_no_log= 1; + } + else + { + $opt_log= "$logdir/mysqld_multi.log"; + } +} + +#### #### Report living and not running MySQL servers #### |