Commit 19d37eca authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0

into serg.mysql.com:/usr/home/serg/Abk/mysql-4.0


Docs/manual.texi:
  Auto merged
sql/sql_select.cc:
  Auto merged
parents 43a1ef6c e4e8b31c
This diff is collapsed.
#!/usr/bin/perl -w
#
# Script to rewrite colspecs from relative values to absolute values
#
use strict;
my $table_width = 12.75; # cm
my $gutter_width = 0.09; # cm
my $str = join '', <>;
$str =~ s{([\t ]*(<colspec colwidth=\".+?\" />\s*)+)}
{&rel2abs($1)}ges;
print STDOUT $str;
exit;
#
# Definitions for helper sub-routines
#
sub msg {
print STDERR shift, "\n";
}
sub rel2abs {
my $str = shift;
my @widths = ();
my $total = 0;
my $output = '';
$str =~ /^(\s+)/;
my $ws = $1;
while ($str =~ m/<colspec colwidth="(\d+)\*" \/>/g) {
$total += $1;
push @widths, $1;
}
my $unit = ($table_width - ($#widths * $gutter_width)) / ($total);
foreach (@widths) {
$output .= $ws . '<colspec colwidth="'. sprintf ("%0.2f", $_ * $unit) .'" />' . "\n";
}
return $output . "\n$ws";
}
#!/usr/bin/perl -w #!/usr/bin/perl -w
# 2002-02-15 zak@mysql.com
# Use -w to make perl print useful warnings about the script being run
sub fix_underscore { # Fix the output of `makeinfo --docbook` version 4.0c
$str = shift; # Convert the broken docbook output to well-formed XML that conforms to the O'Reilly idiom
$str =~ tr/_/-/; # See code for detailed comments
return $str; # Authors: Arjen Lentz and Zak Greant
};
sub strip_emph { use strict;
$str = shift;
$str =~ s{<emphasis>(.+?)</emphasis>}
{$1}gs;
return $str;
};
print STDERR "\n--Post-processing makeinfo output--\n"; my $data = '';
my @apx = ();
my $apx = '';
my @nodes = ();
my $nodes = '';
# 2002-02-15 zak@mysql.com msg ("\n-- Post-processing `makeinfo --docbook` output --");
print STDERR "Discard DTD - ORA can add the appropriate DTD for their flavour of DocBook\n"; msg ("** Written to work with makeinfo version 4.0c **\n");
<STDIN>;
print STDERR "Slurp! In comes the rest of the file. :)\n"; msg ("Discarding DTD - not required by subsequent scripts");
$data = join "", <STDIN>; # <> is a magic filehandle - either reading lines from stdin or from file(s) specified on the command line
<>;
# 2002-02-15 zak@mysql.com msg ("Create an XML PI with ISO-8859-1 character encoding");
print STDERR "Add an XML processing instruction with the right character encoding\n"; $data = "<?xml version='1.0' encoding='ISO-8859-1'?>";
$data = "<?xml version='1.0' encoding='ISO-8859-1'?>" . $data;
# 2002-02-15 zak@mysql.com msg ("Get the rest of the data");
# Less than optimal - should be fixed in makeinfo $data = $data . join "", <>;
print STDERR "Put in missing <bookinfo> and <abstract>\n";
$data =~ s/<book lang="en">/<book lang="en"><bookinfo><abstract>/gs;
# 2002-02-15 zak@mysql.com msg ("Add missing <bookinfo> and <abstract> opening tags");
print STDERR "Convert existing ampersands to escape sequences \n"; # Note the absence of the g (global) pattern modified. This situation can only happen once.
$data =~ s/&(?!\w+;)/&amp;/gs; # ...as soon as we find the first instance, we can stop looking.
$data =~ s/<book lang="en">/<book lang="en"><bookinfo><abstract>/;
# 2002-02-15 zak@mysql.com msg ("Removing mailto: from email addresses...");
# Need to talk to Arjen about what the <n> bits are for $data =~ s/mailto://g;
print STDERR "Rework references of the notation '<n>'\n";
$data =~ s/<(\d)>/[$1]/gs;
# 2002-02-15 zak@mysql.com msg ("Removing INFORMALFIGURE...");
# We might need to encode the high-bit characters to ensure proper representation $data =~ s{<informalfigure>.+?</informalfigure>}
# print STDERR "Converting high-bit characters to entities\n"; {}gs;
# $data =~ s/([\200-\400])/&get_entity($1)>/gs;
# There is no get_entity function yet - no point writing it til we need it :)
print STDERR "Changing @@ to @...\n"; msg ("Convert ampersands to XML escape sequences ");
$data =~ s/@@/@/gs; $data =~ s/&(?!\w+;)/&amp;/g;
print STDERR "Changing '_' to '-' in references...\n"; msg ("Changing @@ to @...");
$data =~ s{id=\"(.+?)\"} $data =~ s/@@/@/g;
{"id=\"".&fix_underscore($1)."\""}gsex;
$data =~ s{linkend=\"(.+?)\"}
{"linkend=\"".&fix_underscore($1)."\""}gsex;
print STDERR "Changing ULINK to SYSTEMITEM...\n"; msg ("Rework references of the notation '<n>'");
$data =~ s{<ulink url=\"(.+?)\"></ulink>} # Need to talk to Arjen about what the <n> bits are for
{<systemitem role=\"url\">$1</systemitem>}gs; $data =~ s/<(\d)>/[$1]/g;
print STDERR "Removing INFORMALFIGURE...\n"; msg ("Changing '_' to '-' in references...");
$data =~ s{<informalfigure>(.+?)</informalfigure>} $data =~ s{((?:id|linkend)=\".+?\")}
{}gs; {&underscore2hyphen($1)}gex;
print STDERR "Adding PARA inside ENTRY...\n"; msg ("Changing ULINK to SYSTEMITEM...");
$data =~ s{<ulink url=\"(.+?)\">\s*</ulink>}
{<systemitem role=\"url\">$1</systemitem>}gs;
msg ("Adding PARA inside ENTRY...");
$data =~ s{<entry>(.*?)</entry>} $data =~ s{<entry>(.*?)</entry>}
{<entry><para>$1</para></entry>}gs; {<entry><para>$1</para></entry>}gs;
print STDERR "Removing mailto: from email addresses...\n"; msg ("Fixing spacing problem with titles...");
$data =~ s{mailto:} $data =~ s{(</\w+>)(\w{2,})}
{}gs; {$1 $2}gs;
print STDERR "Fixing spacing problem with titles...\n"; msg ("Adding closing / to XREF and COLSPEC tags...");
$data =~ s{</(\w+)>(\w{2,})} $data =~ s{<(xref|colspec) (.+?)>}
{</$1> $2}gs; {<$1 $2 />}gs;
# 2002-02-15 arjen@mysql.com # Probably need to strip these
print STDERR "Adding closing / to XREF...\n"; msg ('Adding "See " to XREFs that used to be @xref...');
$data =~ s{<xref (.+?)>} $data =~ s{([.'!)])\s*<xref }
{<xref $1 />}gs;
# 2002-02-22 arjen@mysql.com
print STDERR "Adding \"See \" to XREFs that used to be \@xref...\n";
$data =~ s{([\.\'\!\)])[\n ]*<xref }
{$1 See <xref }gs; {$1 See <xref }gs;
# 2002-02-22 arjen@mysql.com msg ('Adding "see " to (XREFs) that used to be (@pxref)...');
print STDERR "Adding \"see \" to (XREFs) that used to be (\@pxref)...\n"; $data =~ s{([([,;])(\s*)<xref }
$data =~ s{(\(|[[,;])([\n]*[ ]*)<xref }
{$1$2see <xref }gs; {$1$2see <xref }gs;
# 2002-01-30 arjen@mysql.com msg ("Making first row in table THEAD...");
print STDERR "Removing COLSPEC...\n"; $data =~ s{( *)<tbody>(\s*<row>.+?</row>)}
$data =~ s{\n *<colspec colwidth=\"[0-9]+\*\">} {$1<thead>$2\n$1</thead>\n$1<tbody>}gs;
{}gs;
# 2002-01-31 arjen@mysql.com
print STDERR "Making first row in table THEAD...\n";
$data =~ s{([ ]*)<tbody>\n([ ]*<row>(.+?)</row>)}
{$1<thead>\n$2\n$1</thead>\n$1<tbody>}gs;
# 2002-01-31 arjen@mysql.com msg ("Removing EMPHASIS inside THEAD...");
print STDERR "Removing EMPHASIS inside THEAD...\n";
$data =~ s{<thead>(.+?)</thead>} $data =~ s{<thead>(.+?)</thead>}
{"<thead>".&strip_emph($1)."</thead>"}gsex; {"<thead>".&strip_tag($1, 'emphasis')."</thead>"}gsex;
# 2002-01-31 arjen@mysql.com
print STDERR "Removing lf before /PARA in ENTRY...\n";
$data =~ s{(<entry><para>(.+?))\n(</para></entry>)}
{$1$3}gs;
# 2002-01-31 arjen@mysql.com (2002-02-15 added \n stuff) msg ("Removing empty PARA...");
print STDERR "Removing whitespace before /PARA if not on separate line...\n"; $data =~ s{<para>\s*</para>}
$data =~ s{([^\n ])[ ]+</para>} {}gs;
{$1</para>}gs;
# 2002-01-31 arjen@mysql.com msg ("Removing lf before /PARA in ENTRY...");
print STDERR "Removing empty PARA in ENTRY...\n"; $data =~ s{\n(</para></entry>)}
$data =~ s{<entry><para></para></entry>} {$1}gs;
{<entry></entry>}gs;
# 2002-01-31 arjen@mysql.com msg ("Removing whitespace before /PARA if not on separate line...");
print STDERR "Removing PARA around INDEXENTRY if no text in PARA...\n"; $data =~ s{(\S+)[\t ]+</para>}
$data =~ s{<para>((<indexterm role=\"(cp|fn)\">(<(primary|secondary)>[^<]+?</(primary|secondary)>)+?</indexterm>)+?)[\n]*</para>[\n]*} {$1</para>}g;
{$1\n}gs;
# ----- msg ("Removing PARA around INDEXTERM if no text in PARA...");
$data =~ s{<para>((?:<indexterm role=\"(?:cp|fn)\">(?:<(primary|secondary)>[^>]+</\2>)+?</indexterm>)+?)\s*</para>}
{$1}gs;
@apx = ("Users", "MySQL Testimonials", "News", @apx = ("Users", "MySQL Testimonials", "News", "GPL-license", "LGPL-license");
"GPL-license", "LGPL-license");
foreach $apx (@apx) { foreach $apx (@apx) {
print STDERR "Removing appendix $apx...\n"; msg ("Removing appendix $apx...");
$data =~ s{<appendix id=\"$apx\">(.+?)</appendix>} $data =~ s{<appendix id=\"$apx\">(.+?)</appendix>}
{}gs; {}gs;
print STDERR " ... Building list of removed nodes ...\n"; # Skip to next appendix regex if the regex did not match anything
foreach(split "\n", $&) { next unless (defined $&);
push @nodes, $2 if(/<(\w+) id=\"(.+?)\">/)
}; msg ("...Building list of removed nodes...");
};
# Split the last bracketed regex match into an array
# Extract the node names from the tags and push them into an array
foreach (split "\n", $&) {
push @nodes, $1 if /<\w+ id=\"(.+?)\">/
}
}
# 2002-02-22 arjen@mysql.com (added fix " /" to end of regex, to make it match) # 2002-02-22 arjen@mysql.com (added fix " /" to end of regex, to make it match)
print STDERR "Fixing references to removed nodes...\n"; msg ("Fixing references to removed nodes...");
foreach $node (@nodes) { # Merge the list of node names into a set of regex alternations
$web = $node; $nodes = join "|", @nodes;
$web =~ s/[ ]/_/;
$web = "http://www.mysql.com/doc/" . # Find all references to removed nodes and convert them to absolute URLs
(join "/", (split //, $web)[0..1])."/$web.html"; $data =~ s{<\w+ linkend="($nodes)" />}
print STDERR "$node -> $web\n"; {&xref2link($1)}ges;
$data =~ s{<(\w+) linkend=\"$node\" />}
{$web}gs;
};
print STDOUT $data; print STDOUT $data;
exit;
#
# Definitions for helper sub-routines
#
sub msg {
print STDERR shift, "\n";
}
sub strip_tag($$) {
(my $str, my $tag) = @_;
$str =~ s{<$tag>(.+?)</$tag>}{$1}gs;
return $str;
}
sub underscore2hyphen($) {
my $str = shift;
$str =~ tr/_/-/;
return $str;
}
sub xref2link {
my $ref = shift;
$ref =~ tr/ /_/;
$ref =~ s{^((.)(.).+)$}{$2/$3/$1.html};
return "http://www.mysql.com/doc/" . $ref;
}
# We might need to encode the high-bit characters to ensure proper representation
# msg ("Converting high-bit characters to entities");
# $data =~ s/([\200-\400])/&get_entity($1)>/gs;
# There is no get_entity function yet - no point writing it til we need it :)
#! /usr/local/bin/perl #! /usr/bin/perl -w
# O'Reilly's Perl script to chop mysql.xml into separate ch/apps/index files. # O'Reilly's Perl script to chop mysql.xml into separate ch/apps/index files.
# The indexes are actually not used, they're created straight from the xrefs. # The indexes are actually not used, they're created straight from the xrefs.
use strict;
# Breaks the MySQL reference manual into chapters, appendices, and indexes. # Breaks the MySQL reference manual into chapters, appendices, and indexes.
my $input_file; use strict;
my $directory;
my $chap_num;
my $app_letter;
my $start_text;
my $line;
my $input_file;
my $output_name;
$input_file = "mysql.xml";
$directory="chaps_apps_index";
$chap_num=1; # Start chapter numbers at one (there is no preface)
$app_letter="a"; # Start appendix letters at "a"
$start_text="";
$line="";
open (INPUT_FILE, '<' . $input_file) or die "Cannot open $input_file";
if (-d $directory) {
my $unlinked = unlink <$directory/*>;
printf(Removed "%d files\n", $unlinked);
}
else {
mkdir $directory or die "Cannot make $directory subdirectory";
}
while (1) { my $app_letter = "a"; # Start appendix letters at "a"
my $chap_num = 1; # Start chapter numbers at one (there is no preface)
my $directory = "mysql_refman_" . time;
my $ext = ".xml";
my $line = "";
my $output_name = "";
my $start_text = "";
# Terminating statement for loop. mkdir $directory unless -d $directory;
exit if not defined $line;
if ($line =~ /(?:.*)(<chapter.*)/i ) { while (defined $line) {
if ($line =~ /(<chapter.+)/i ) {
$start_text = $1; $start_text = $1;
$output_name = &make_chapter_name($chap_num); $output_name = sprintf("ch%02d%s", $chap_num, $ext);
$chap_num++; ++$chap_num;
&process_file("chapter"); &process_file("chapter");
} }
elsif ($line =~ /(?:.*)(<appendix.*)/i ) { elsif ($line =~ /(<appendix.+)/i ) {
$start_text = $1 ; $start_text = $1 ;
$output_name = &make_appendix_name($app_letter); $output_name = "app$app_letter$ext";
$app_letter++; ++$app_letter;
&process_file("appendix"); &process_file("appendix");
} }
elsif ($line =~ /(?:.*)(<index\s+id=")(.*?)(">.*)/i ) { elsif ($line =~ /(<index\s+id=")(.*?)(">.*)/i ) {
$start_text = $1 . $2 . $3; $start_text = $1 . $2 . $3;
$output_name = lc($2) . ".xml"; $output_name = lc($2) . $ext;
&process_file("index"); &process_file("index");
} }
else { else {
# Automatically skips junk in between chapters, appendices, # Skip junk in between chapters, appendices and indexes.
# and indexes. $line = <>;
$line = <INPUT_FILE>;
} }
} }
sub make_chapter_name { sub process_file {
my $num = shift; my $marker = shift;
my $name = "ch" . sprintf("%02d", $num) . ".xml"; my $path = "$directory/$output_name";
return $name;
}
sub make_appendix_name { open (OUTPUT_FILE, ">$path") or die "Cannot open $path";
my $letter = shift;
my $name = "app" . sprintf("%s", $letter) . ".xml"; print STDERR "Creating $path\n";
return $name;
} # Print out XML PI
print OUTPUT_FILE "<?xml version='1.0' encoding='ISO-8859-1'?>\n";
sub process_file {
my $marker=shift;
open (OUTPUT_FILE, '>' . $directory . "/" . $output_name) or
die "Cannot open $output_name";
# Print whatever happened to appear at the end of the previous chapter. # Print whatever happened to appear at the end of the previous chapter.
print OUTPUT_FILE $start_text . "\n" if $start_text; print OUTPUT_FILE "$start_text\n" if $start_text;
while (1) {
$line = <INPUT_FILE>; while (defined $line) {
exit if not defined $line; $line = <>;
# Note: Anything after the terminating marker is lost, just like # Note: Anything after the terminating marker is lost, just like
# lines in between chapters. # lines in between chapters.
if ($line =~ /(.*<\/\s*$marker\s*>)/i ) { if ($line =~ /(.*<\/\s*$marker\s*>)/i ) {
print OUTPUT_FILE $1 . "\n" if $1; print OUTPUT_FILE "$1\n" if $1;
close OUTPUT_FILE; close OUTPUT_FILE;
return; return;
} }
......
...@@ -18,3 +18,7 @@ ...@@ -18,3 +18,7 @@
# See if the XML output is well-formed # See if the XML output is well-formed
xmlwf mysql.xml xmlwf mysql.xml
# If all is well, keep processing
cat mysql.xml | Support/colspec-fix.pl | Support/docbook-split;
...@@ -757,10 +757,9 @@ Large server clusters using replication are in production use, with ...@@ -757,10 +757,9 @@ Large server clusters using replication are in production use, with
good results. Work on enhanced replication features is continuing good results. Work on enhanced replication features is continuing
in @code{MySQL} 4.0. in @code{MySQL} 4.0.
@item @code{InnoDB} tables -- Stable (in 3.23 from 3.23.47) @item @code{InnoDB} tables -- Stable (in 3.23 from 3.23.49)
The @code{InnoDB} transactional table handler has now been declared The @code{InnoDB} transactional table handler has now been declared
stable in the @code{MySQL} 3.23 development tree, starting from stable in the @code{MySQL} 3.23 tree, starting from version 3.23.49.
version 3.23.47.
@code{InnoDB} is being used in large, heavy load production systems. @code{InnoDB} is being used in large, heavy load production systems.
@item @code{BDB} tables -- Gamma @item @code{BDB} tables -- Gamma
...@@ -291,6 +291,11 @@ WWW (@uref{http://mysql.tecnoera.com/}) ...@@ -291,6 +291,11 @@ WWW (@uref{http://mysql.tecnoera.com/})
@image{Flags/chile} Chile [Vision] @@ @image{Flags/chile} Chile [Vision] @@
WWW (@uref{http://mysql.vision.cl/}) WWW (@uref{http://mysql.vision.cl/})
@item
@image{Flags/costarica} Costa Rica [Ogmios Communications] @@
WWW (@uref{http://mysql.ogmios.co.cr/})
FTP (@uref{ftp://mysql.ogmios.co.cr/pub/mysql/})
@end itemize @end itemize
@strong{Asia:} @strong{Asia:}
......
...@@ -737,7 +737,7 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -737,7 +737,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
*end=0; /* Remove '=' */ *end=0; /* Remove '=' */
} }
/* Change all '_' in variable name to '-' */ /* Change all '_' in variable name to '-' */
for (end= *option ; (end= strcend(end,'_')) ; ) for (end= *option ; (end= strcend(end,'_')) && *end ; )
*end= '-'; *end= '-';
switch (find_type(*option+2,&option_types,2)) { switch (find_type(*option+2,&option_types,2)) {
case 1: /* port */ case 1: /* port */
......
...@@ -86,6 +86,21 @@ explain select a,b from t1 union all select a,b from t2; ...@@ -86,6 +86,21 @@ explain select a,b from t1 union all select a,b from t2;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4 t1 ALL NULL NULL NULL NULL 4
t2 ALL NULL NULL NULL NULL 4 t2 ALL NULL NULL NULL NULL 4
explain select xx from t1 union select 1;
Unknown column 'xx' in 'field list'
explain select a,b from t1 union select 1;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4
0 0 No tables used
explain select 1 union select a,b from t1 union select 1;
table type possible_keys key key_len ref rows Extra
0 0 No tables used
t1 ALL NULL NULL NULL NULL 4
0 0 No tables used
explain select a,b from t1 union select 1 limit 0;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4
0 0 Impossible WHERE
select a,b from t1 into outfile 'skr' union select a,b from t2; select a,b from t1 into outfile 'skr' union select a,b from t2;
Wrong usage of UNION and INTO Wrong usage of UNION and INTO
select a,b from t1 order by a union select a,b from t2; select a,b from t1 order by a union select a,b from t2;
......
...@@ -24,6 +24,12 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g ...@@ -24,6 +24,12 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
# Test some error conditions with UNION # Test some error conditions with UNION
explain select a,b from t1 union all select a,b from t2; explain select a,b from t1 union all select a,b from t2;
--error 1054
explain select xx from t1 union select 1;
explain select a,b from t1 union select 1;
explain select 1 union select a,b from t1 union select 1;
explain select a,b from t1 union select 1 limit 0;
--error 1221 --error 1221
select a,b from t1 into outfile 'skr' union select a,b from t2; select a,b from t1 into outfile 'skr' union select a,b from t2;
......
...@@ -6964,13 +6964,16 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -6964,13 +6964,16 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{ {
List<Item> field_list; List<Item> field_list;
Item *item; Item *item;
List<Item> item_list;
THD *thd=join->thd; THD *thd=join->thd;
MYSQL_LOCK *save_lock;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex); SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
select_result *result=join->result;
DBUG_ENTER("select_describe"); DBUG_ENTER("select_describe");
/* Don't log this into the slow query log */ /* Don't log this into the slow query log */
select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED);
if (join->thd->lex.select == select_lex) if (thd->lex.select == select_lex)
{ {
field_list.push_back(new Item_empty_string("table",NAME_LEN)); field_list.push_back(new Item_empty_string("table",NAME_LEN));
field_list.push_back(new Item_empty_string("type",10)); field_list.push_back(new Item_empty_string("type",10));
...@@ -6986,24 +6989,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -6986,24 +6989,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item->maybe_null=1; item->maybe_null=1;
field_list.push_back(new Item_real("rows",0.0,0,10)); field_list.push_back(new Item_real("rows",0.0,0,10));
field_list.push_back(new Item_empty_string("Extra",255)); field_list.push_back(new Item_empty_string("Extra",255));
if (send_fields(thd,field_list,1)) if (result->send_fields(field_list,1))
return; return;
} }
char buff[512],*buff_ptr;
String tmp(buff,sizeof(buff)),*packet= &thd->packet;
if (message) if (message)
{ {
packet->length(0); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_empty_string("",0));
net_store_null(packet); item_list.push_back(new Item_string(message,strlen(message)));
net_store_data(packet,message,strlen(message)); if (result->send_data(item_list))
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length())) result->send_error(0,NullS);
DBUG_VOID_RETURN;
} }
else else
{ {
...@@ -7012,69 +7013,70 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -7012,69 +7013,70 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{ {
JOIN_TAB *tab=join->join_tab+i; JOIN_TAB *tab=join->join_tab+i;
TABLE *table=tab->table; TABLE *table=tab->table;
char buff[512],*buff_ptr=buff;
char buff1[512], buff2[512], bufff[512];
String tmp1(buff1,sizeof(buff1));
String tmp2(buff2,sizeof(buff2));
item_list.empty();
if (tab->type == JT_ALL && tab->select && tab->select->quick) if (tab->type == JT_ALL && tab->select && tab->select->quick)
tab->type= JT_RANGE; tab->type= JT_RANGE;
packet->length(0); item_list.push_back(new Item_string(table->table_name,strlen(table->table_name)));
net_store_data(packet,table->table_name); item_list.push_back(new Item_string(join_type_str[tab->type],strlen(join_type_str[tab->type])));
net_store_data(packet,join_type_str[tab->type]); tmp1.length(0); tmp2.length(0);
tmp.length(0);
key_map bits; key_map bits;
uint j; uint j;
for (j=0,bits=tab->keys ; bits ; j++,bits>>=1) for (j=0,bits=tab->keys ; bits ; j++,bits>>=1)
{ {
if (bits & 1) if (bits & 1)
{ {
if (tmp.length()) if (tmp1.length())
tmp.append(','); tmp1.append(',');
tmp.append(table->key_info[j].name); tmp1.append(table->key_info[j].name);
} }
} }
if (tmp.length()) if (tmp1.length())
net_store_data(packet,tmp.ptr(),tmp.length()); item_list.push_back(new Item_string(tmp1.ptr(),tmp1.length()));
else else
net_store_null(packet); item_list.push_back(new Item_null());
if (tab->ref.key_parts) if (tab->ref.key_parts)
{ {
net_store_data(packet,table->key_info[tab->ref.key].name); item_list.push_back(new Item_string(table->key_info[tab->ref.key].name,strlen(table->key_info[tab->ref.key].name)));
net_store_data(packet,(uint32) tab->ref.key_length); item_list.push_back(new Item_int((int) tab->ref.key_length));
tmp.length(0);
for (store_key **ref=tab->ref.key_copy ; *ref ; ref++) for (store_key **ref=tab->ref.key_copy ; *ref ; ref++)
{ {
if (tmp.length()) if (tmp2.length())
tmp.append(','); tmp2.append(',');
tmp.append((*ref)->name()); tmp2.append((*ref)->name());
} }
net_store_data(packet,tmp.ptr(),tmp.length()); item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length()));
} }
else if (tab->type == JT_NEXT) else if (tab->type == JT_NEXT)
{ {
net_store_data(packet,table->key_info[tab->index].name); item_list.push_back(new Item_string(table->key_info[tab->index].name,strlen(table->key_info[tab->index].name)));
net_store_data(packet,(uint32) table->key_info[tab->index].key_length); item_list.push_back(new Item_int((int) table->key_info[tab->index].key_length));
net_store_null(packet); item_list.push_back(new Item_null());
} }
else if (tab->select && tab->select->quick) else if (tab->select && tab->select->quick)
{ {
net_store_data(packet,table->key_info[tab->select->quick->index].name);; item_list.push_back(new Item_string(table->key_info[tab->select->quick->index].name,strlen(table->key_info[tab->select->quick->index].name)));
net_store_data(packet,(uint32) tab->select->quick->max_used_key_length); item_list.push_back(new Item_int((int) tab->select->quick->max_used_key_length));
net_store_null(packet); item_list.push_back(new Item_null());
} }
else else
{ {
net_store_null(packet); item_list.push_back(new Item_null());
net_store_null(packet); item_list.push_back(new Item_null());
net_store_null(packet); item_list.push_back(new Item_null());
} }
sprintf(buff,"%.0f",join->best_positions[i].records_read); sprintf(bufff,"%.0f",join->best_positions[i].records_read);
net_store_data(packet,buff); item_list.push_back(new Item_string(bufff,strlen(bufff)));
my_bool key_read=table->key_read; my_bool key_read=table->key_read;
if (tab->type == JT_NEXT && if (tab->type == JT_NEXT &&
((table->used_keys & ((key_map) 1 << tab->index)))) ((table->used_keys & ((key_map) 1 << tab->index))))
key_read=1; key_read=1;
buff_ptr=buff;
if (tab->info) if (tab->info)
net_store_data(packet,tab->info); item_list.push_back(new Item_string(tab->info,strlen(tab->info)));
else if (tab->select) else if (tab->select)
{ {
if (tab->use_quick == 2) if (tab->use_quick == 2)
...@@ -7128,16 +7130,20 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -7128,16 +7130,20 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
buff_ptr=strmov(buff_ptr,"Distinct"); buff_ptr=strmov(buff_ptr,"Distinct");
} }
net_store_data(packet,buff,(uint) (buff_ptr - buff)); item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff)));
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
DBUG_VOID_RETURN; /* Purecov: Inspected */
// For next iteration // For next iteration
used_tables|=table->map; used_tables|=table->map;
if (result->send_data(item_list))
result->send_error(0,NullS);
} }
} }
if (!join->thd->lex.select->next) if (!join->thd->lex.select->next)
send_eof(&thd->net); {
save_lock=thd->lock;
thd->lock=(MYSQL_LOCK *)0;
result->send_eof();
thd->lock=save_lock;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -31,10 +31,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -31,10 +31,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
ORDER *order; ORDER *order;
List<Item> item_list; List<Item> item_list;
TABLE *table; TABLE *table;
int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0;
int res;
TABLE_LIST result_table_list; TABLE_LIST result_table_list;
TMP_TABLE_PARAM tmp_table_param; TMP_TABLE_PARAM tmp_table_param;
select_union *union_result; select_union *union_result;
int res;
DBUG_ENTER("mysql_union"); DBUG_ENTER("mysql_union");
/* Fix tables 'to-be-unioned-from' list to point at opened tables */ /* Fix tables 'to-be-unioned-from' list to point at opened tables */
...@@ -71,32 +72,25 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -71,32 +72,25 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
order=0; order=0;
} }
if (lex->select_lex.options & SELECT_DESCRIBE) if (describe)
{
for (sl= &lex->select_lex; sl; sl=sl->next)
{ {
lex->select=sl; Item *item;
thd->offset_limit=sl->offset_limit; item_list.push_back(new Item_empty_string("table",NAME_LEN));
thd->select_limit=sl->select_limit+sl->offset_limit; item_list.push_back(new Item_empty_string("type",10));
if (thd->select_limit < sl->select_limit) item_list.push_back(item=new Item_empty_string("possible_keys",
thd->select_limit= HA_POS_ERROR; // no limit NAME_LEN*MAX_KEY));
if (thd->select_limit == HA_POS_ERROR) item->maybe_null=1;
sl->options&= ~OPTION_FOUND_ROWS; item_list.push_back(item=new Item_empty_string("key",NAME_LEN));
res=mysql_select(thd, (TABLE_LIST*) sl->table_list.first, item->maybe_null=1;
sl->item_list, item_list.push_back(item=new Item_int("key_len",0,3));
sl->where, item->maybe_null=1;
((sl->braces) ? item_list.push_back(item=new Item_empty_string("ref",
(ORDER *) sl->order_list.first : (ORDER *) 0), NAME_LEN*MAX_REF_PARTS));
(ORDER*) sl->group_list.first, item->maybe_null=1;
sl->having, item_list.push_back(new Item_real("rows",0.0,0,10));
(ORDER*) NULL, item_list.push_back(new Item_empty_string("Extra",255));
(sl->options | thd->options | SELECT_NO_UNLOCK |
SELECT_DESCRIBE),
result);
}
DBUG_RETURN(0);
} }
else
{ {
Item *item; Item *item;
List_iterator<Item> it(lex->select_lex.item_list); List_iterator<Item> it(lex->select_lex.item_list);
...@@ -113,7 +107,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -113,7 +107,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count=item_list.elements; tmp_table_param.field_count=item_list.elements;
if (!(table=create_tmp_table(thd, &tmp_table_param, item_list, if (!(table=create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0, !lex->union_option, (ORDER*) 0, !describe & !lex->union_option,
1, 0, 1, 0,
(lex->select_lex.options | thd->options | (lex->select_lex.options | thd->options |
TMP_TABLE_ALL_COLUMNS)))) TMP_TABLE_ALL_COLUMNS))))
...@@ -130,7 +124,9 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -130,7 +124,9 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
res= -1; res= -1;
goto exit; goto exit;
} }
for (sl= &lex->select_lex; sl; sl=sl->next) union_result->save_time_stamp=!describe;
for (sl=&lex->select_lex;sl;sl=sl->next)
{ {
thd->offset_limit=sl->offset_limit; thd->offset_limit=sl->offset_limit;
thd->select_limit=sl->select_limit+sl->offset_limit; thd->select_limit=sl->select_limit+sl->offset_limit;
...@@ -146,7 +142,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -146,7 +142,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
(ORDER*) sl->group_list.first, (ORDER*) sl->group_list.first,
sl->having, sl->having,
(ORDER*) NULL, (ORDER*) NULL,
sl->options | thd->options | SELECT_NO_UNLOCK, sl->options | thd->options | SELECT_NO_UNLOCK | ((describe) ? SELECT_DESCRIBE : 0),
union_result); union_result);
if (res) if (res)
goto exit; goto exit;
...@@ -187,6 +183,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -187,6 +183,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
if (thd->select_limit == HA_POS_ERROR) if (thd->select_limit == HA_POS_ERROR)
thd->options&= ~OPTION_FOUND_ROWS; thd->options&= ~OPTION_FOUND_ROWS;
} }
if (describe)
thd->select_limit= HA_POS_ERROR; // no limit
res=mysql_select(thd,&result_table_list, res=mysql_select(thd,&result_table_list,
item_list, NULL, /*ftfunc_list,*/ order, item_list, NULL, /*ftfunc_list,*/ order,
(ORDER*) NULL, NULL, (ORDER*) NULL, (ORDER*) NULL, NULL, (ORDER*) NULL,
...@@ -222,7 +220,7 @@ select_union::~select_union() ...@@ -222,7 +220,7 @@ select_union::~select_union()
int select_union::prepare(List<Item> &list) int select_union::prepare(List<Item> &list)
{ {
if (list.elements != table->fields) if (save_time_stamp && list.elements != table->fields)
{ {
my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0)); ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0));
......
...@@ -1928,7 +1928,7 @@ opt_else: ...@@ -1928,7 +1928,7 @@ opt_else:
| ELSE expr { $$= $2; } | ELSE expr { $$= $2; }
when_list: when_list:
{ Select->when_list.push_front(new List<Item>) } { Select->when_list.push_front(new List<Item>); }
when_list2 when_list2
{ $$= Select->when_list.pop(); } { $$= Select->when_list.pop(); }
...@@ -2031,7 +2031,7 @@ opt_key_definition: ...@@ -2031,7 +2031,7 @@ opt_key_definition:
} }
key_usage_list: key_usage_list:
key_or_index { Select->interval_list.empty() } '(' key_usage_list2 ')' key_or_index { Select->interval_list.empty(); } '(' key_usage_list2 ')'
{ $$= &Select->interval_list; } { $$= &Select->interval_list; }
key_usage_list2: key_usage_list2:
...@@ -2637,7 +2637,7 @@ describe: ...@@ -2637,7 +2637,7 @@ describe:
YYABORT; YYABORT;
} }
opt_describe_column opt_describe_column
| describe_command select { Lex->select_lex.options|= SELECT_DESCRIBE }; | describe_command select { Lex->select_lex.options|= SELECT_DESCRIBE; }
describe_command: describe_command:
...@@ -3077,7 +3077,7 @@ set: ...@@ -3077,7 +3077,7 @@ set:
lex->select->select_limit=lex->thd->default_select_limit; lex->select->select_limit=lex->thd->default_select_limit;
lex->tx_isolation=lex->thd->tx_isolation; lex->tx_isolation=lex->thd->tx_isolation;
lex->option_type=0; lex->option_type=0;
lex->option_list.empty() lex->option_list.empty();
} }
option_value_list option_value_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment