Commit 863b5da0 authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

Merge work:/home/bk/mysql-4.0

into serg.mysql.com:/usr/home/serg/Abk/mysql-4.0
parents 4e6150d4 dbf2e812
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
# 2002-02-15 zak@mysql.com
# Use -w to make perl print useful warnings about the script being run
sub fix_underscore {
$str = shift;
$str =~ tr/_/-/;
return $str;
};
# Fix the output of `makeinfo --docbook` version 4.0c
# Convert the broken docbook output to well-formed XML that conforms to the O'Reilly idiom
# See code for detailed comments
# Authors: Arjen Lentz and Zak Greant
sub strip_emph {
$str = shift;
$str =~ s{<emphasis>(.+?)</emphasis>}
{$1}gs;
return $str;
};
use strict;
print STDERR "\n--Post-processing makeinfo output--\n";
my $data = '';
my @apx = ();
my $apx = '';
my @nodes = ();
my $nodes = '';
# 2002-02-15 zak@mysql.com
print STDERR "Discard DTD - ORA can add the appropriate DTD for their flavour of DocBook\n";
<STDIN>;
msg ("\n-- Post-processing `makeinfo --docbook` output --");
msg ("** Written to work with makeinfo version 4.0c **\n");
print STDERR "Slurp! In comes the rest of the file. :)\n";
$data = join "", <STDIN>;
msg ("Discarding DTD - not required by subsequent scripts");
# <> is a magic filehandle - either reading lines from stdin or from file(s) specified on the command line
<>;
# 2002-02-15 zak@mysql.com
print STDERR "Add an XML processing instruction with the right character encoding\n";
$data = "<?xml version='1.0' encoding='ISO-8859-1'?>" . $data;
msg ("Create an XML PI with ISO-8859-1 character encoding");
$data = "<?xml version='1.0' encoding='ISO-8859-1'?>";
# 2002-02-15 zak@mysql.com
# Less than optimal - should be fixed in makeinfo
print STDERR "Put in missing <bookinfo> and <abstract>\n";
$data =~ s/<book lang="en">/<book lang="en"><bookinfo><abstract>/gs;
msg ("Get the rest of the data");
$data = $data . join "", <>;
# 2002-02-15 zak@mysql.com
print STDERR "Convert existing ampersands to escape sequences \n";
$data =~ s/&(?!\w+;)/&amp;/gs;
msg ("Add missing <bookinfo> and <abstract> opening tags");
# Note the absence of the g (global) pattern modified. This situation can only happen once.
# ...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
# Need to talk to Arjen about what the <n> bits are for
print STDERR "Rework references of the notation '<n>'\n";
$data =~ s/<(\d)>/[$1]/gs;
msg ("Removing mailto: from email addresses...");
$data =~ s/mailto://g;
msg ("Removing INFORMALFIGURE...");
$data =~ s{<informalfigure>.+?</informalfigure>}
{}gs;
msg ("Convert ampersands to XML escape sequences ");
$data =~ s/&(?!\w+;)/&amp;/g;
# 2002-02-15 zak@mysql.com
# We might need to encode the high-bit characters to ensure proper representation
# print STDERR "Converting high-bit characters to entities\n";
# $data =~ s/([\200-\400])/&get_entity($1)>/gs;
# There is no get_entity function yet - no point writing it til we need it :)
msg ("Changing @@ to @...");
$data =~ s/@@/@/g;
print STDERR "Changing @@ to @...\n";
$data =~ s/@@/@/gs;
msg ("Rework references of the notation '<n>'");
# Need to talk to Arjen about what the <n> bits are for
$data =~ s/<(\d)>/[$1]/g;
print STDERR "Changing '_' to '-' in references...\n";
$data =~ s{id=\"(.+?)\"}
{"id=\"".&fix_underscore($1)."\""}gsex;
$data =~ s{linkend=\"(.+?)\"}
{"linkend=\"".&fix_underscore($1)."\""}gsex;
msg ("Changing '_' to '-' in references...");
$data =~ s{((?:id|linkend)=\".+?\")}
{&underscore2hyphen($1)}gex;
print STDERR "Changing ULINK to SYSTEMITEM...\n";
$data =~ s{<ulink url=\"(.+?)\"></ulink>}
msg ("Changing ULINK to SYSTEMITEM...");
$data =~ s{<ulink url=\"(.+?)\">\s*</ulink>}
{<systemitem role=\"url\">$1</systemitem>}gs;
print STDERR "Removing INFORMALFIGURE...\n";
$data =~ s{<informalfigure>(.+?)</informalfigure>}
{}gs;
print STDERR "Adding PARA inside ENTRY...\n";
msg ("Adding PARA inside ENTRY...");
$data =~ s{<entry>(.*?)</entry>}
{<entry><para>$1</para></entry>}gs;
print STDERR "Removing mailto: from email addresses...\n";
$data =~ s{mailto:}
{}gs;
print STDERR "Fixing spacing problem with titles...\n";
$data =~ s{</(\w+)>(\w{2,})}
{</$1> $2}gs;
msg ("Fixing spacing problem with titles...");
$data =~ s{(</\w+>)(\w{2,})}
{$1 $2}gs;
# 2002-02-15 arjen@mysql.com
print STDERR "Adding closing / to XREF...\n";
$data =~ s{<xref (.+?)>}
{<xref $1 />}gs;
msg ("Adding closing / to XREF and COLSPEC tags...");
$data =~ s{<(xref|colspec) (.+?)>}
{<$1 $2 />}gs;
# 2002-02-22 arjen@mysql.com
print STDERR "Adding \"See \" to XREFs that used to be \@xref...\n";
$data =~ s{([\.\'\!\)])[\n ]*<xref }
# Probably need to strip these
msg ('Adding "See " to XREFs that used to be @xref...');
$data =~ s{([.'!)])\s*<xref }
{$1 See <xref }gs;
# 2002-02-22 arjen@mysql.com
print STDERR "Adding \"see \" to (XREFs) that used to be (\@pxref)...\n";
$data =~ s{(\(|[[,;])([\n]*[ ]*)<xref }
msg ('Adding "see " to (XREFs) that used to be (@pxref)...');
$data =~ s{([([,;])(\s*)<xref }
{$1$2see <xref }gs;
# 2002-01-30 arjen@mysql.com
print STDERR "Removing COLSPEC...\n";
$data =~ s{\n *<colspec colwidth=\"[0-9]+\*\">}
{}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;
msg ("Making first row in table THEAD...");
$data =~ s{( *)<tbody>(\s*<row>.+?</row>)}
{$1<thead>$2\n$1</thead>\n$1<tbody>}gs;
# 2002-01-31 arjen@mysql.com
print STDERR "Removing EMPHASIS inside THEAD...\n";
msg ("Removing EMPHASIS inside 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)
print STDERR "Removing whitespace before /PARA if not on separate line...\n";
$data =~ s{([^\n ])[ ]+</para>}
{$1</para>}gs;
msg ("Removing empty PARA...");
$data =~ s{<para>\s*</para>}
{}gs;
# 2002-01-31 arjen@mysql.com
print STDERR "Removing empty PARA in ENTRY...\n";
$data =~ s{<entry><para></para></entry>}
{<entry></entry>}gs;
msg ("Removing lf before /PARA in ENTRY...");
$data =~ s{\n(</para></entry>)}
{$1}gs;
# 2002-01-31 arjen@mysql.com
print STDERR "Removing PARA around INDEXENTRY if no text in PARA...\n";
$data =~ s{<para>((<indexterm role=\"(cp|fn)\">(<(primary|secondary)>[^<]+?</(primary|secondary)>)+?</indexterm>)+?)[\n]*</para>[\n]*}
{$1\n}gs;
msg ("Removing whitespace before /PARA if not on separate line...");
$data =~ s{(\S+)[\t ]+</para>}
{$1</para>}g;
# -----
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",
"GPL-license", "LGPL-license");
@apx = ("Users", "MySQL Testimonials", "News", "GPL-license", "LGPL-license");
foreach $apx (@apx) {
print STDERR "Removing appendix $apx...\n";
$data =~ s{<appendix id=\"$apx\">(.+?)</appendix>}
{}gs;
print STDERR " ... Building list of removed nodes ...\n";
foreach(split "\n", $&) {
push @nodes, $2 if(/<(\w+) id=\"(.+?)\">/)
};
};
msg ("Removing appendix $apx...");
$data =~ s{<appendix id=\"$apx\">(.+?)</appendix>}
{}gs;
# Skip to next appendix regex if the regex did not match anything
next unless (defined $&);
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)
print STDERR "Fixing references to removed nodes...\n";
foreach $node (@nodes) {
$web = $node;
$web =~ s/[ ]/_/;
$web = "http://www.mysql.com/doc/" .
(join "/", (split //, $web)[0..1])."/$web.html";
print STDERR "$node -> $web\n";
$data =~ s{<(\w+) linkend=\"$node\" />}
{$web}gs;
};
msg ("Fixing references to removed nodes...");
# Merge the list of node names into a set of regex alternations
$nodes = join "|", @nodes;
# Find all references to removed nodes and convert them to absolute URLs
$data =~ s{<\w+ linkend="($nodes)" />}
{&xref2link($1)}ges;
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.
# 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.
my $input_file;
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";
}
use strict;
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.
exit if not defined $line;
mkdir $directory unless -d $directory;
if ($line =~ /(?:.*)(<chapter.*)/i ) {
while (defined $line) {
if ($line =~ /(<chapter.+)/i ) {
$start_text = $1;
$output_name = &make_chapter_name($chap_num);
$chap_num++;
$output_name = sprintf("ch%02d%s", $chap_num, $ext);
++$chap_num;
&process_file("chapter");
}
elsif ($line =~ /(?:.*)(<appendix.*)/i ) {
elsif ($line =~ /(<appendix.+)/i ) {
$start_text = $1 ;
$output_name = &make_appendix_name($app_letter);
$app_letter++;
$output_name = "app$app_letter$ext";
++$app_letter;
&process_file("appendix");
}
elsif ($line =~ /(?:.*)(<index\s+id=")(.*?)(">.*)/i ) {
elsif ($line =~ /(<index\s+id=")(.*?)(">.*)/i ) {
$start_text = $1 . $2 . $3;
$output_name = lc($2) . ".xml";
$output_name = lc($2) . $ext;
&process_file("index");
}
else {
# Automatically skips junk in between chapters, appendices,
# and indexes.
$line = <INPUT_FILE>;
# Skip junk in between chapters, appendices and indexes.
$line = <>;
}
}
sub make_chapter_name {
my $num = shift;
my $name = "ch" . sprintf("%02d", $num) . ".xml";
return $name;
}
sub process_file {
my $marker = shift;
my $path = "$directory/$output_name";
sub make_appendix_name {
my $letter = shift;
my $name = "app" . sprintf("%s", $letter) . ".xml";
return $name;
}
open (OUTPUT_FILE, ">$path") or die "Cannot open $path";
sub process_file {
my $marker=shift;
open (OUTPUT_FILE, '>' . $directory . "/" . $output_name) or
die "Cannot open $output_name";
print STDERR "Creating $path\n";
# Print out XML PI
print OUTPUT_FILE "<?xml version='1.0' encoding='ISO-8859-1'?>\n";
# Print whatever happened to appear at the end of the previous chapter.
print OUTPUT_FILE $start_text . "\n" if $start_text;
while (1) {
$line = <INPUT_FILE>;
exit if not defined $line;
print OUTPUT_FILE "$start_text\n" if $start_text;
while (defined $line) {
$line = <>;
# Note: Anything after the terminating marker is lost, just like
# lines in between chapters.
if ($line =~ /(.*<\/\s*$marker\s*>)/i ) {
print OUTPUT_FILE $1 . "\n" if $1;
print OUTPUT_FILE "$1\n" if $1;
close OUTPUT_FILE;
return;
}
......
......@@ -18,3 +18,7 @@
# See if the XML output is well-formed
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
good results. Work on enhanced replication features is continuing
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
stable in the @code{MySQL} 3.23 development tree, starting from
version 3.23.47.
stable in the @code{MySQL} 3.23 tree, starting from version 3.23.49.
@code{InnoDB} is being used in large, heavy load production systems.
@item @code{BDB} tables -- Gamma
......@@ -291,6 +291,11 @@ WWW (@uref{http://mysql.tecnoera.com/})
@image{Flags/chile} Chile [Vision] @@
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
@strong{Asia:}
......
......@@ -737,7 +737,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
*end=0; /* Remove '=' */
}
/* Change all '_' in variable name to '-' */
for (end= *option ; (end= strcend(end,'_')) ; )
for (end= *option ; (end= strcend(end,'_')) && *end ; )
*end= '-';
switch (find_type(*option+2,&option_types,2)) {
case 1: /* port */
......
......@@ -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
t1 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;
Wrong usage of UNION and INTO
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
# Test some error conditions with UNION
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
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,
{
List<Item> field_list;
Item *item;
List<Item> item_list;
THD *thd=join->thd;
MYSQL_LOCK *save_lock;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
select_result *result=join->result;
DBUG_ENTER("select_describe");
/* Don't log this into the slow query log */
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("type",10));
......@@ -6986,24 +6989,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item->maybe_null=1;
field_list.push_back(new Item_real("rows",0.0,0,10));
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;
}
char buff[512],*buff_ptr;
String tmp(buff,sizeof(buff)),*packet= &thd->packet;
if (message)
{
packet->length(0);
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
net_store_data(packet,message,strlen(message));
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
DBUG_VOID_RETURN;
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_string(message,strlen(message)));
if (result->send_data(item_list))
result->send_error(0,NullS);
}
else
{
......@@ -7012,69 +7013,70 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{
JOIN_TAB *tab=join->join_tab+i;
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)
tab->type= JT_RANGE;
packet->length(0);
net_store_data(packet,table->table_name);
net_store_data(packet,join_type_str[tab->type]);
tmp.length(0);
item_list.push_back(new Item_string(table->table_name,strlen(table->table_name)));
item_list.push_back(new Item_string(join_type_str[tab->type],strlen(join_type_str[tab->type])));
tmp1.length(0); tmp2.length(0);
key_map bits;
uint j;
for (j=0,bits=tab->keys ; bits ; j++,bits>>=1)
{
if (bits & 1)
{
if (tmp.length())
tmp.append(',');
tmp.append(table->key_info[j].name);
if (tmp1.length())
tmp1.append(',');
tmp1.append(table->key_info[j].name);
}
}
if (tmp.length())
net_store_data(packet,tmp.ptr(),tmp.length());
if (tmp1.length())
item_list.push_back(new Item_string(tmp1.ptr(),tmp1.length()));
else
net_store_null(packet);
item_list.push_back(new Item_null());
if (tab->ref.key_parts)
{
net_store_data(packet,table->key_info[tab->ref.key].name);
net_store_data(packet,(uint32) tab->ref.key_length);
tmp.length(0);
item_list.push_back(new Item_string(table->key_info[tab->ref.key].name,strlen(table->key_info[tab->ref.key].name)));
item_list.push_back(new Item_int((int) tab->ref.key_length));
for (store_key **ref=tab->ref.key_copy ; *ref ; ref++)
{
if (tmp.length())
tmp.append(',');
tmp.append((*ref)->name());
if (tmp2.length())
tmp2.append(',');
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)
{
net_store_data(packet,table->key_info[tab->index].name);
net_store_data(packet,(uint32) table->key_info[tab->index].key_length);
net_store_null(packet);
item_list.push_back(new Item_string(table->key_info[tab->index].name,strlen(table->key_info[tab->index].name)));
item_list.push_back(new Item_int((int) table->key_info[tab->index].key_length));
item_list.push_back(new Item_null());
}
else if (tab->select && tab->select->quick)
{
net_store_data(packet,table->key_info[tab->select->quick->index].name);;
net_store_data(packet,(uint32) tab->select->quick->max_used_key_length);
net_store_null(packet);
item_list.push_back(new Item_string(table->key_info[tab->select->quick->index].name,strlen(table->key_info[tab->select->quick->index].name)));
item_list.push_back(new Item_int((int) tab->select->quick->max_used_key_length));
item_list.push_back(new Item_null());
}
else
{
net_store_null(packet);
net_store_null(packet);
net_store_null(packet);
item_list.push_back(new Item_null());
item_list.push_back(new Item_null());
item_list.push_back(new Item_null());
}
sprintf(buff,"%.0f",join->best_positions[i].records_read);
net_store_data(packet,buff);
sprintf(bufff,"%.0f",join->best_positions[i].records_read);
item_list.push_back(new Item_string(bufff,strlen(bufff)));
my_bool key_read=table->key_read;
if (tab->type == JT_NEXT &&
((table->used_keys & ((key_map) 1 << tab->index))))
key_read=1;
buff_ptr=buff;
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)
{
if (tab->use_quick == 2)
......@@ -7128,16 +7130,20 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
buff_ptr=strmov(buff_ptr,"Distinct");
}
net_store_data(packet,buff,(uint) (buff_ptr - buff));
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
DBUG_VOID_RETURN; /* Purecov: Inspected */
item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff)));
// For next iteration
used_tables|=table->map;
if (result->send_data(item_list))
result->send_error(0,NullS);
}
}
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;
}
......
......@@ -31,10 +31,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
ORDER *order;
List<Item> item_list;
TABLE *table;
int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0;
int res;
TABLE_LIST result_table_list;
TMP_TABLE_PARAM tmp_table_param;
select_union *union_result;
int res;
DBUG_ENTER("mysql_union");
/* Fix tables 'to-be-unioned-from' list to point at opened tables */
......@@ -70,33 +71,26 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
lex_sl=0;
order=0;
}
if (lex->select_lex.options & SELECT_DESCRIBE)
if (describe)
{
for (sl= &lex->select_lex; sl; sl=sl->next)
{
lex->select=sl;
thd->offset_limit=sl->offset_limit;
thd->select_limit=sl->select_limit+sl->offset_limit;
if (thd->select_limit < sl->select_limit)
thd->select_limit= HA_POS_ERROR; // no limit
if (thd->select_limit == HA_POS_ERROR)
sl->options&= ~OPTION_FOUND_ROWS;
res=mysql_select(thd, (TABLE_LIST*) sl->table_list.first,
sl->item_list,
sl->where,
((sl->braces) ?
(ORDER *) sl->order_list.first : (ORDER *) 0),
(ORDER*) sl->group_list.first,
sl->having,
(ORDER*) NULL,
(sl->options | thd->options | SELECT_NO_UNLOCK |
SELECT_DESCRIBE),
result);
}
DBUG_RETURN(0);
Item *item;
item_list.push_back(new Item_empty_string("table",NAME_LEN));
item_list.push_back(new Item_empty_string("type",10));
item_list.push_back(item=new Item_empty_string("possible_keys",
NAME_LEN*MAX_KEY));
item->maybe_null=1;
item_list.push_back(item=new Item_empty_string("key",NAME_LEN));
item->maybe_null=1;
item_list.push_back(item=new Item_int("key_len",0,3));
item->maybe_null=1;
item_list.push_back(item=new Item_empty_string("ref",
NAME_LEN*MAX_REF_PARTS));
item->maybe_null=1;
item_list.push_back(new Item_real("rows",0.0,0,10));
item_list.push_back(new Item_empty_string("Extra",255));
}
else
{
Item *item;
List_iterator<Item> it(lex->select_lex.item_list);
......@@ -113,7 +107,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count=item_list.elements;
if (!(table=create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0, !lex->union_option,
(ORDER*) 0, !describe & !lex->union_option,
1, 0,
(lex->select_lex.options | thd->options |
TMP_TABLE_ALL_COLUMNS))))
......@@ -130,7 +124,9 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
res= -1;
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->select_limit=sl->select_limit+sl->offset_limit;
......@@ -146,7 +142,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
(ORDER*) sl->group_list.first,
sl->having,
(ORDER*) NULL,
sl->options | thd->options | SELECT_NO_UNLOCK,
sl->options | thd->options | SELECT_NO_UNLOCK | ((describe) ? SELECT_DESCRIBE : 0),
union_result);
if (res)
goto exit;
......@@ -187,6 +183,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
if (thd->select_limit == HA_POS_ERROR)
thd->options&= ~OPTION_FOUND_ROWS;
}
if (describe)
thd->select_limit= HA_POS_ERROR; // no limit
res=mysql_select(thd,&result_table_list,
item_list, NULL, /*ftfunc_list,*/ order,
(ORDER*) NULL, NULL, (ORDER*) NULL,
......@@ -222,7 +220,7 @@ select_union::~select_union()
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,
ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),MYF(0));
......
......@@ -1928,7 +1928,7 @@ opt_else:
| ELSE expr { $$= $2; }
when_list:
{ Select->when_list.push_front(new List<Item>) }
{ Select->when_list.push_front(new List<Item>); }
when_list2
{ $$= Select->when_list.pop(); }
......@@ -2031,7 +2031,7 @@ opt_key_definition:
}
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; }
key_usage_list2:
......@@ -2637,7 +2637,7 @@ describe:
YYABORT;
}
opt_describe_column
| describe_command select { Lex->select_lex.options|= SELECT_DESCRIBE };
| describe_command select { Lex->select_lex.options|= SELECT_DESCRIBE; }
describe_command:
......@@ -3077,7 +3077,7 @@ set:
lex->select->select_limit=lex->thd->default_select_limit;
lex->tx_isolation=lex->thd->tx_isolation;
lex->option_type=0;
lex->option_list.empty()
lex->option_list.empty();
}
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