Commit eb7c18d6 authored by unknown's avatar unknown

Merge gweir@bk-internal.mysql.com:/home/bk/mysql-4.0

into mysql.com:/bk/mysql-4.0

parents 945c2c1c 17d4afc6
...@@ -38,7 +38,11 @@ COPYING.LIB ...@@ -38,7 +38,11 @@ COPYING.LIB
Docs/#manual.texi# Docs/#manual.texi#
Docs/INSTALL-BINARY Docs/INSTALL-BINARY
Docs/include.texi Docs/include.texi
Docs/internals.html
Docs/internals.info Docs/internals.info
Docs/internals.pdf
Docs/internals.txt
Docs/internals_toc.html
Docs/manual.aux Docs/manual.aux
Docs/manual.cp Docs/manual.cp
Docs/manual.cps Docs/manual.cps
...@@ -221,6 +225,7 @@ extra/replace ...@@ -221,6 +225,7 @@ extra/replace
extra/resolve_stack_dump extra/resolve_stack_dump
extra/resolveip extra/resolveip
gmon.out gmon.out
hardcopy.0
heap/hp_test1 heap/hp_test1
heap/hp_test2 heap/hp_test2
include/my_config.h include/my_config.h
...@@ -251,11 +256,13 @@ libmysql/conf_to_src ...@@ -251,11 +256,13 @@ libmysql/conf_to_src
libmysql/my_static.h libmysql/my_static.h
libmysql/mysys_priv.h libmysql/mysys_priv.h
libmysql/net.c libmysql/net.c
libmysql/vio_priv.h
libmysql_r/*.c libmysql_r/*.c
libmysql_r/acconfig.h libmysql_r/acconfig.h
libmysql_r/conf_to_src libmysql_r/conf_to_src
libmysql_r/my_static.h libmysql_r/my_static.h
libmysql_r/mysys_priv.h libmysql_r/mysys_priv.h
libmysql_r/vio_priv.h
libmysqld/backup_dir libmysqld/backup_dir
libmysqld/convert.cc libmysqld/convert.cc
libmysqld/derror.cc libmysqld/derror.cc
...@@ -363,6 +370,7 @@ linked_libmysqldex_sources ...@@ -363,6 +370,7 @@ linked_libmysqldex_sources
linked_server_sources linked_server_sources
linked_tools_sources linked_tools_sources
locked locked
man/*.1
mit-pthreads/config.flags mit-pthreads/config.flags
mit-pthreads/include/bits mit-pthreads/include/bits
mit-pthreads/include/pthread/machdep.h mit-pthreads/include/pthread/machdep.h
...@@ -382,6 +390,7 @@ myisam/mi_test2 ...@@ -382,6 +390,7 @@ myisam/mi_test2
myisam/mi_test3 myisam/mi_test3
myisam/mi_test_all myisam/mi_test_all
myisam/myisam.log myisam/myisam.log
myisam/myisam_ftdump
myisam/myisamchk myisam/myisamchk
myisam/myisamlog myisam/myisamlog
myisam/myisampack myisam/myisampack
...@@ -429,6 +438,8 @@ repl-tests/test-repl/sum-wlen-slave.master. ...@@ -429,6 +438,8 @@ repl-tests/test-repl/sum-wlen-slave.master.
repl-tests/test-repl/sum-wlen-slave.master.re repl-tests/test-repl/sum-wlen-slave.master.re
repl-tests/test-repl/sum-wlen-slave.master.reje repl-tests/test-repl/sum-wlen-slave.master.reje
scripts/make_binary_distribution scripts/make_binary_distribution
scripts/make_sharedlib_distribution
scripts/make_win_src_distribution
scripts/msql2mysql scripts/msql2mysql
scripts/mysql_config scripts/mysql_config
scripts/mysql_convert_table_format scripts/mysql_convert_table_format
...@@ -496,6 +507,7 @@ sql/share/norwegian/errmsg.sys ...@@ -496,6 +507,7 @@ sql/share/norwegian/errmsg.sys
sql/sql_select.cc.orig sql/sql_select.cc.orig
sql/sql_yacc.cc sql/sql_yacc.cc
sql/sql_yacc.h sql/sql_yacc.h
sql/udf_example.so
stamp-h stamp-h
stamp-h.in stamp-h.in
stamp-h1 stamp-h1
...@@ -504,6 +516,7 @@ strings/ctype_autoconf.c ...@@ -504,6 +516,7 @@ strings/ctype_autoconf.c
strings/ctype_extra_sources.c strings/ctype_extra_sources.c
support-files/MacOSX/Description.plist support-files/MacOSX/Description.plist
support-files/MacOSX/Info.plist support-files/MacOSX/Info.plist
support-files/MacOSX/ReadMe.txt
support-files/MacOSX/StartupParameters.plist support-files/MacOSX/StartupParameters.plist
support-files/MacOSX/postinstall support-files/MacOSX/postinstall
support-files/MacOSX/preinstall support-files/MacOSX/preinstall
...@@ -530,16 +543,3 @@ vio/test-ssl ...@@ -530,16 +543,3 @@ vio/test-ssl
vio/test-sslclient vio/test-sslclient
vio/test-sslserver vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
support-files/MacOSX/ReadMe.txt
Docs/internals.html
Docs/internals.pdf
Docs/internals.txt
Docs/internals_toc.html
scripts/make_win_src_distribution
libmysql/vio_priv.h
libmysql_r/vio_priv.h
hardcopy.0
scripts/make_sharedlib_distribution
sql/udf_example.so
man/*.1
myisam/myisam_ftdump
...@@ -9,6 +9,6 @@ strip=yes ...@@ -9,6 +9,6 @@ strip=yes
extra_configs="$extra_configs --with-innodb --with-berkeley-db \ extra_configs="$extra_configs --with-innodb --with-berkeley-db \
--with-embedded-server --enable-thread-safe-client \ --with-embedded-server --enable-thread-safe-client \
--with-openssl --with-vio" --with-openssl --with-vio --with-raid"
. "$path/FINISH.sh" . "$path/FINISH.sh"
...@@ -72,15 +72,33 @@ class Load_log_processor ...@@ -72,15 +72,33 @@ class Load_log_processor
int target_dir_name_len; int target_dir_name_len;
DYNAMIC_ARRAY file_names; DYNAMIC_ARRAY file_names;
const char *create_file(Create_file_log_event *ce); /*
void append_to_file(const char* fname, int flags, Looking for new uniquie filename that doesn't exist yet by
gptr data, uint size) adding postfix -%x
SYNOPSIS
create_unique_file()
filename buffer for filename
file_name_end tail of buffer that should be changed
should point to a memory enough to printf("-%x",..)
RETURN VALUES
values less than 0 - can't find new filename
values great or equal 0 - created file with found filename
*/
File create_unique_file(char *filename, char *file_name_end)
{ {
File file; File res;
if (((file= my_open(fname,flags,MYF(MY_WME))) < 0) || /* If we have to try more than 1000 times, something is seriously wrong */
my_write(file,(byte*) data,size,MYF(MY_WME|MY_NABP)) || for (uint version= 0; version<1000; version++)
my_close(file,MYF(MY_WME))) {
exit(1); sprintf(file_name_end,"-%x",version);
if ((res= my_create(filename,0,
O_CREAT|O_EXCL|O_BINARY|O_WRONLY,MYF(0)))!=-1)
return res;
}
return -1;
} }
public: public:
...@@ -131,20 +149,21 @@ public: ...@@ -131,20 +149,21 @@ public:
*ptr= 0; *ptr= 0;
return res; return res;
} }
void process(Create_file_log_event *ce) int process(Create_file_log_event *ce);
{ int process(Append_block_log_event *ae)
const char *fname= create_file(ce);
append_to_file(fname,O_CREAT|O_EXCL|O_BINARY|O_WRONLY,ce->block,
ce->block_len);
}
void process(Append_block_log_event *ae)
{ {
File file;
Create_file_log_event* ce= (ae->file_id < file_names.elements) ? Create_file_log_event* ce= (ae->file_id < file_names.elements) ?
*((Create_file_log_event**)file_names.buffer + ae->file_id) : 0; *((Create_file_log_event**)file_names.buffer + ae->file_id) : 0;
if (ce) if (ce)
append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY, ae->block, {
ae->block_len); if (((file= my_open(ce->fname,
O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0) ||
my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)) ||
my_close(file,MYF(MY_WME)))
return -1;
}
else else
{ {
/* /*
...@@ -154,60 +173,209 @@ public: ...@@ -154,60 +173,209 @@ public:
*/ */
fprintf(stderr,"Warning: ignoring Append_block as there is no \ fprintf(stderr,"Warning: ignoring Append_block as there is no \
Create_file event for file_id: %u\n",ae->file_id); Create_file event for file_id: %u\n",ae->file_id);
return -1;
} }
return 0;
} }
File prepare_new_file_for_old_format(Load_log_event *le, char *filename);
int load_old_format_file(NET* net, const char *server_fname,
uint server_fname_len, File file);
}; };
File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le,
char *filename)
{
uint len;
char *tail;
File file;
fn_format(filename, le->fname, target_dir_name, "", 1);
len= strlen(filename);
tail= filename + len;
if ((file= create_unique_file(filename,tail)) < 0)
{
sql_print_error("Could not construct local filename %s",filename);
return -1;
}
le->set_fname_outside_temp_buf(filename,len+strlen(tail));
const char *Load_log_processor::create_file(Create_file_log_event *ce) return file;
}
int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
uint server_fname_len, File file)
{
char buf[FN_REFLEN+1];
buf[0] = 0;
memcpy(buf + 1, server_fname, server_fname_len + 1);
if (my_net_write(net, buf, server_fname_len +2) || net_flush(net))
{
sql_print_error("Failed requesting the remote dump of %s", server_fname);
return -1;
}
for (;;)
{
uint packet_len = my_net_read(net);
if (packet_len == 0)
{
if (my_net_write(net, "", 0) || net_flush(net))
{
sql_print_error("Failed sending the ack packet");
return -1;
}
/*
we just need to send something, as the server will read but
not examine the packet - this is because mysql_load() sends
an OK when it is done
*/
break;
}
else if (packet_len == packet_error)
{
sql_print_error("Failed reading a packet during the dump of %s ",
server_fname);
return -1;
}
if (my_write(file, (byte*) net->read_pos, packet_len,MYF(MY_WME|MY_NABP)))
return -1;
}
return 0;
}
int Load_log_processor::process(Create_file_log_event *ce)
{ {
const char *bname= ce->fname+dirname_length(ce->fname); const char *bname= ce->fname+dirname_length(ce->fname);
uint blen= ce->fname_len - (bname-ce->fname); uint blen= ce->fname_len - (bname-ce->fname);
uint full_len= target_dir_name_len + blen + 9 + 9 + 1; uint full_len= target_dir_name_len + blen + 9 + 9 + 1;
uint version= 0; char *fname, *ptr;
char *tmp, *ptr; File file;
if (!(tmp= my_malloc(full_len,MYF(MY_WME))) || if (!(fname= my_malloc(full_len,MYF(MY_WME))) ||
set_dynamic(&file_names,(gptr)&ce,ce->file_id)) set_dynamic(&file_names,(gptr)&ce,ce->file_id))
{ {
die("Could not construct local filename %s%s",target_dir_name,bname); sql_print_error("Could not construct local filename %s%s",
return 0; target_dir_name,bname);
return -1;
} }
memcpy(tmp, target_dir_name, target_dir_name_len); memcpy(fname, target_dir_name, target_dir_name_len);
ptr= tmp+ target_dir_name_len; ptr= fname + target_dir_name_len;
memcpy(ptr,bname,blen); memcpy(ptr,bname,blen);
ptr+= blen; ptr+= blen;
ptr+= my_sprintf(ptr,(ptr,"-%x",ce->file_id)); ptr+= my_sprintf(ptr,(ptr,"-%x",ce->file_id));
/* if ((file= create_unique_file(fname,ptr)) < 0)
Note that this code has a possible race condition if there was was {
many simultaneous clients running which tried to create files at the same sql_print_error("Could not construct local filename %s%s",
time. Fortunately this should never be the case. target_dir_name,bname);
return -1;
}
ce->set_fname_outside_temp_buf(fname,strlen(fname));
if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP)) ||
my_close(file,MYF(MY_WME)))
return -1;
}
A better way to do this would be to use 'create_tmp_file() and avoid this Load_log_processor load_processor;
race condition altogether on the expense of getting more cryptic file
names. void process_event(ulonglong *rec_count, char *last_db, Log_event *ev,
my_off_t pos, int old_format)
{
char ll_buff[21];
if ((*rec_count) >= offset)
{
if (!short_form)
fprintf(result_file, "# at %s\n",llstr(pos,ll_buff));
switch (ev->get_type_code()) {
case QUERY_EVENT:
if (one_database)
{
const char * log_dbname = ((Query_log_event*)ev)->db;
if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
{
(*rec_count)++;
delete ev;
return; // next
}
}
ev->print(result_file, short_form, last_db);
break;
case CREATE_FILE_EVENT:
{
Create_file_log_event* ce= (Create_file_log_event*)ev;
if (one_database)
{
/*
We test if this event has to be ignored. If yes, we don't save
this event; this will have the good side-effect of ignoring all
related Append_block and Exec_load.
Note that Load event from 3.23 is not tested.
*/ */
for (;;) const char * log_dbname = ce->db;
if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
{
(*rec_count)++;
delete ev;
return; // next
}
}
/*
We print the event, but with a leading '#': this is just to inform
the user of the original command; the command we want to execute
will be a derivation of this original command (we will change the
filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT'
below.
*/
ce->print(result_file, short_form, last_db, true);
if (!old_format)
{ {
sprintf(ptr,"-%x",version); load_processor.process(ce);
if (access(tmp,F_OK)) ev= 0;
}
break; break;
/* If we have to try more than 1000 times, something is seriously wrong */ }
if (version++ > 1000) case APPEND_BLOCK_EVENT:
ev->print(result_file, short_form, last_db);
load_processor.process((Append_block_log_event*)ev);
break;
case EXEC_LOAD_EVENT:
{ {
die("Could not construct local filename %s%s",target_dir_name,bname); ev->print(result_file, short_form, last_db);
return 0; Execute_load_log_event *exv= (Execute_load_log_event*)ev;
Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
/*
if ce is 0, it probably means that we have not seen the Create_file
event (a bad binlog, or most probably --position is after the
Create_file event). Print a warning comment.
*/
if (ce)
{
ce->print(result_file, short_form, last_db,true);
my_free((char*)ce->fname,MYF(MY_WME));
delete ce;
}
else
fprintf(stderr,"Warning: ignoring Exec_load as there is no \
Create_file event for file_id: %u\n",exv->file_id);
break;
}
default:
ev->print(result_file, short_form, last_db);
} }
} }
ce->set_fname_outside_temp_buf(tmp,strlen(tmp)); (*rec_count)++;
return tmp; if (ev)
delete ev;
} }
Load_log_processor load_processor;
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -243,7 +411,7 @@ static struct my_option my_long_options[] = ...@@ -243,7 +411,7 @@ static struct my_option my_long_options[] =
(gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &sock, (gptr*) &sock, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, (gptr*) &sock, (gptr*) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"user", 'u', "Connect to the remote server as username.", {"user", 'u', "Connect to the remote server as username.",
(gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
...@@ -305,37 +473,6 @@ the mysql command line client\n\n"); ...@@ -305,37 +473,6 @@ the mysql command line client\n\n");
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
static void dump_remote_file(NET* net, const char* fname)
{
char buf[FN_REFLEN+1];
uint len = (uint) strlen(fname);
buf[0] = 0;
memcpy(buf + 1, fname, len + 1);
if(my_net_write(net, buf, len +2) || net_flush(net))
die("Failed requesting the remote dump of %s", fname);
for(;;)
{
uint packet_len = my_net_read(net);
if(packet_len == 0)
{
if(my_net_write(net, "", 0) || net_flush(net))
die("Failed sending the ack packet");
// we just need to send something, as the server will read but
// not examine the packet - this is because mysql_load() sends an OK when it is done
break;
}
else if(packet_len == packet_error)
die("Failed reading a packet during the dump of %s ", fname);
if(!short_form)
(void)my_fwrite(result_file, (byte*) net->read_pos, packet_len,MYF(0));
}
fflush(result_file);
}
extern "C" my_bool extern "C" my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
...@@ -489,6 +626,10 @@ static void dump_remote_log_entries(const char* logname) ...@@ -489,6 +626,10 @@ static void dump_remote_log_entries(const char* logname)
if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1)) if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1))
die("Error sending the log dump command"); die("Error sending the log dump command");
my_off_t old_off= 0;
ulonglong rec_count= 0;
char fname[FN_REFLEN+1];
for (;;) for (;;)
{ {
const char *error; const char *error;
...@@ -501,15 +642,40 @@ static void dump_remote_log_entries(const char* logname) ...@@ -501,15 +642,40 @@ static void dump_remote_log_entries(const char* logname)
len, net->read_pos[5])); len, net->read_pos[5]));
Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 , Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error, old_format); len - 1, &error, old_format);
if (ev) if (!ev)
{ {
ev->print(result_file, short_form, last_db); die("Could not construct log event object");
if (ev->get_type_code() == LOAD_EVENT)
dump_remote_file(net, ((Load_log_event*)ev)->fname);
delete ev;
} }
else else
die("Could not construct log event object"); {
Log_event_type type= ev->get_type_code();
if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT ) )
{
process_event(&rec_count,last_db,ev,old_off,old_format);
}
else
{
Load_log_event *le= (Load_log_event*)ev;
const char *old_fname= le->fname;
uint old_len= le->fname_len;
File file= load_processor.prepare_new_file_for_old_format(le,fname);
if (file >= 0)
{
process_event(&rec_count,last_db,ev,old_off,old_format);
load_processor.load_old_format_file(net,old_fname,old_len,file);
my_close(file,MYF(MY_WME));
}
}
}
/*
Let's adjust offset for remote log as for local log to produce
similar text..
*/
if (old_off)
old_off+= len-1;
else
old_off= BIN_LOG_HEADER_SIZE;
} }
} }
...@@ -599,88 +765,7 @@ Could not read entry at offset %s : Error in log format or read error", ...@@ -599,88 +765,7 @@ Could not read entry at offset %s : Error in log format or read error",
// file->error == 0 means EOF, that's OK, we break in this case // file->error == 0 means EOF, that's OK, we break in this case
break; break;
} }
if (rec_count >= offset) process_event(&rec_count,last_db,ev,old_off,false);
{
if (!short_form)
fprintf(result_file, "# at %s\n",llstr(old_off,llbuff));
switch (ev->get_type_code()) {
case QUERY_EVENT:
if (one_database)
{
const char * log_dbname = ((Query_log_event*)ev)->db;
if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
{
rec_count++;
delete ev;
continue; // next
}
}
ev->print(result_file, short_form, last_db);
break;
case CREATE_FILE_EVENT:
{
Create_file_log_event* ce= (Create_file_log_event*)ev;
if (one_database)
{
/*
We test if this event has to be ignored. If yes, we don't save this
event; this will have the good side-effect of ignoring all related
Append_block and Exec_load.
Note that Load event from 3.23 is not tested.
*/
const char * log_dbname = ce->db;
if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
{
rec_count++;
delete ev;
continue; // next
}
}
/*
We print the event, but with a leading '#': this is just to inform
the user of the original command; the command we want to execute
will be a derivation of this original command (we will change the
filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT'
below.
*/
ce->print(result_file, short_form, last_db, true);
load_processor.process(ce);
ev= 0;
break;
}
case APPEND_BLOCK_EVENT:
ev->print(result_file, short_form, last_db);
load_processor.process((Append_block_log_event*)ev);
break;
case EXEC_LOAD_EVENT:
{
ev->print(result_file, short_form, last_db);
Execute_load_log_event *exv= (Execute_load_log_event*)ev;
Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
/*
if ce is 0, it probably means that we have not seen the Create_file
event (a bad binlog, or most probably --position is after the
Create_file event). Print a warning comment.
*/
if (ce)
{
ce->print(result_file, short_form, last_db,true);
my_free((char*)ce->fname,MYF(MY_WME));
delete ce;
}
else
fprintf(stderr,"Warning: ignoring Exec_load as there is no \
Create_file event for file_id: %u\n",exv->file_id);
break;
}
default:
ev->print(result_file, short_form, last_db);
}
}
rec_count++;
if (ev)
delete ev;
} }
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
......
#! /bin/sh #! /bin/sh
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# Free Software Foundation, Inc. # 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-08-21' timestamp='2003-07-02'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
...@@ -24,8 +24,9 @@ timestamp='2001-08-21' ...@@ -24,8 +24,9 @@ timestamp='2001-08-21'
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>. # Originally written by Per Bothner <per@bothner.com>.
# Please send patches to <config-patches@gnu.org>. # Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# #
# This script attempts to guess a canonical system name similar to # This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and # config.sub. If it succeeds, it prints the system name on stdout, and
...@@ -87,30 +88,42 @@ if test $# != 0; then ...@@ -87,30 +88,42 @@ if test $# != 0; then
exit 1 exit 1
fi fi
trap 'exit 1' 1 2 15
dummy=dummy-$$ # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated. # use `HOST_CC' if defined, but it is deprecated.
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in # Portable tmp directory creation inspired by the Autoconf team.
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 ; do set_cc_for_build='
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
if test $? = 0 ; then trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ; CC_FOR_BUILD="$c"; break ;
fi ; fi ;
done ; done ;
rm -f $dummy.c $dummy.o $dummy.rel ;
if test x"$CC_FOR_BUILD" = x ; then if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ; CC_FOR_BUILD=no_compiler_found ;
fi fi
;; ;;
,,*) CC_FOR_BUILD=$CC ;; ,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac' esac ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe. # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24) # (ghazi@noc.rutgers.edu 1994-08-24)
...@@ -136,29 +149,30 @@ esac ...@@ -136,29 +149,30 @@ esac
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*) *:NetBSD:*:*)
# Netbsd (nbsd) targets should (where applicable) match one or # NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old # switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward # object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the # compatibility and a consistent mechanism for selecting the
# object file format. # object file format.
# Determine the machine/vendor (is the vendor relevant). #
case "${UNAME_MACHINE}" in # Note: NetBSD doesn't particularly care about the vendor
amiga) machine=m68k-unknown ;; # portion of the name. We always set it to "unknown".
arm32) machine=arm-unknown ;; sysctl="sysctl -n hw.machine_arch"
atari*) machine=m68k-atari ;; UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
sun3*) machine=m68k-sun ;; /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
mac68k) machine=m68k-apple ;; case "${UNAME_MACHINE_ARCH}" in
macppc) machine=powerpc-apple ;; armeb) machine=armeb-unknown ;;
hp3[0-9][05]) machine=m68k-hp ;; arm*) machine=arm-unknown ;;
ibmrt|romp-ibm) machine=romp-ibm ;; sh3el) machine=shl-unknown ;;
*) machine=${UNAME_MACHINE}-unknown ;; sh3eb) machine=sh-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac esac
# The Operating System including object format, if it has switched # The Operating System including object format, if it has switched
# to ELF recently, or will in the future. # to ELF recently, or will in the future.
case "${UNAME_MACHINE}" in case "${UNAME_MACHINE_ARCH}" in
i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null | grep __ELF__ >/dev/null
...@@ -175,75 +189,112 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ...@@ -175,75 +189,112 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;; ;;
esac esac
# The OS release # The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form: # contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}" echo "${machine}-${os}${release}"
exit 0 ;; exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
macppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvmeppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mipseb-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
alpha:OSF1:*:*) alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
fi fi
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Vn.n version is a released version. # A Vn.n version is a released version.
# A Tn.n version is a released field test version. # A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel. # A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r. # 1.2 uses "1.2" for uname -r.
cat <<EOF >$dummy.s
.data
\$Lformat:
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
.text
.globl main
.align 4
.ent main
main:
.frame \$30,16,\$26,0
ldgp \$29,0(\$27)
.prologue 1
.long 0x47e03d80 # implver \$0
lda \$2,-1
.long 0x47e20c21 # amask \$2,\$1
lda \$16,\$Lformat
mov \$0,\$17
not \$1,\$18
jsr \$26,printf
ldgp \$29,0(\$26)
mov 0,\$16
jsr \$26,exit
.end main
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
1-0)
UNAME_MACHINE="alphaev5"
;;
1-1)
UNAME_MACHINE="alphaev56"
;;
1-101)
UNAME_MACHINE="alphapca56"
;;
2-303)
UNAME_MACHINE="alphaev6"
;;
2-307)
UNAME_MACHINE="alphaev67"
;;
2-1307)
UNAME_MACHINE="alphaev68"
;;
esac
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;; exit 0 ;;
Alpha*:OpenVMS:*:*)
echo alpha-hp-vms
exit 0 ;;
Alpha\ *:Windows_NT*:*) Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem? # How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead # Should we change UNAME_MACHINE based on the output of uname instead
...@@ -256,29 +307,11 @@ EOF ...@@ -256,29 +307,11 @@ EOF
Amiga*:UNIX_System_V:4.0:*) Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4 echo m68k-unknown-sysv4
exit 0;; exit 0;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*) *:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;; exit 0 ;;
arc64:OpenBSD:*:*) *:[Mm]orph[Oo][Ss]:*:*)
echo mips64el-unknown-openbsd${UNAME_RELEASE} echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hkmips:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:OS/390:*:*) *:OS/390:*:*)
echo i370-ibm-openedition echo i370-ibm-openedition
...@@ -300,6 +333,13 @@ EOF ...@@ -300,6 +333,13 @@ EOF
NILE*:*:*:dcosx) NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4 echo pyramid-pyramid-svr4
exit 0 ;; exit 0 ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit 0 ;;
DRS?6000:UNIX_SV:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7 && exit 0 ;;
esac ;;
sun4H:SunOS:5.*:*) sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;; exit 0 ;;
...@@ -328,7 +368,7 @@ EOF ...@@ -328,7 +368,7 @@ EOF
echo m68k-sun-sunos${UNAME_RELEASE} echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
sun*:*:4.2BSD:*) sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in case "`/bin/arch`" in
sun3) sun3)
...@@ -342,12 +382,6 @@ EOF ...@@ -342,12 +382,6 @@ EOF
aushp:SunOS:*:*) aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE} echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
sparc*:NetBSD:*)
echo `uname -p`-unknown-netbsd${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
# The situation for MiNT is a little confusing. The machine name # The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not # can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor # "atarist" or "atariste" at least should have a processor
...@@ -374,18 +408,6 @@ EOF ...@@ -374,18 +408,6 @@ EOF
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE} echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*) powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE} echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
...@@ -402,6 +424,7 @@ EOF ...@@ -402,6 +424,7 @@ EOF
echo clipper-intergraph-clix${UNAME_RELEASE} echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos) mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus #ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */ #include <stdio.h> /* for printf() prototype */
...@@ -423,16 +446,20 @@ EOF ...@@ -423,16 +446,20 @@ EOF
exit (-1); exit (-1);
} }
EOF EOF
eval $set_cc_for_build $CC_FOR_BUILD -o $dummy $dummy.c \
$CC_FOR_BUILD $dummy.c -o $dummy \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE} echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
Motorola:PowerMAX_OS:*:*) Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax echo powerpc-motorola-powermax
exit 0 ;; exit 0 ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*) Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix echo powerpc-harris-powerunix
exit 0 ;; exit 0 ;;
...@@ -493,6 +520,7 @@ EOF ...@@ -493,6 +520,7 @@ EOF
exit 0 ;; exit 0 ;;
*:AIX:2:3) *:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h> #include <sys/systemcfg.h>
...@@ -504,9 +532,7 @@ EOF ...@@ -504,9 +532,7 @@ EOF
exit(0); exit(0);
} }
EOF EOF
eval $set_cc_for_build $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5 echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4 echo rs6000-ibm-aix3.2.4
...@@ -515,7 +541,7 @@ EOF ...@@ -515,7 +541,7 @@ EOF
fi fi
exit 0 ;; exit 0 ;;
*:AIX:*:[45]) *:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000 IBM_ARCH=rs6000
else else
...@@ -555,8 +581,6 @@ EOF ...@@ -555,8 +581,6 @@ EOF
9000/31? ) HP_ARCH=m68000 ;; 9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;; 9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9]) 9000/[678][0-9][0-9])
case "${HPUX_REV}" in
11.[0-9][0-9])
if [ -x /usr/bin/getconf ]; then if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
...@@ -567,11 +591,12 @@ EOF ...@@ -567,11 +591,12 @@ EOF
case "${sc_kernel_bits}" in case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;; 32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;; 64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;; esac ;;
esac esac
fi ;; fi
esac
if [ "${HP_ARCH}" = "" ]; then if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE #define _HPUX_SOURCE
...@@ -605,12 +630,21 @@ EOF ...@@ -605,12 +630,21 @@ EOF
exit (0); exit (0);
} }
EOF EOF
eval $set_cc_for_build (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
rm -f $dummy.c $dummy
fi ;; fi ;;
esac esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
# avoid double evaluation of $set_cc_for_build
test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV} echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;; exit 0 ;;
ia64:HP-UX:*:*) ia64:HP-UX:*:*)
...@@ -618,6 +652,7 @@ EOF ...@@ -618,6 +652,7 @@ EOF
echo ia64-hp-hpux${HPUX_REV} echo ia64-hp-hpux${HPUX_REV}
exit 0 ;; exit 0 ;;
3050*:HI-UX:*:*) 3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#include <unistd.h> #include <unistd.h>
int int
...@@ -643,9 +678,7 @@ EOF ...@@ -643,9 +678,7 @@ EOF
exit (0); exit (0);
} }
EOF EOF
eval $set_cc_for_build $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2 echo unknown-hitachi-hiuxwe2
exit 0 ;; exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
...@@ -673,9 +706,6 @@ EOF ...@@ -673,9 +706,6 @@ EOF
parisc*:Lites*:*:*) parisc*:Lites*:*:*)
echo hppa1.1-hp-lites echo hppa1.1-hp-lites
exit 0 ;; exit 0 ;;
hppa*:OpenBSD:*:*)
echo hppa-unknown-openbsd
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd echo c1-convex-bsd
exit 0 ;; exit 0 ;;
...@@ -694,9 +724,6 @@ EOF ...@@ -694,9 +724,6 @@ EOF
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd echo c4-convex-bsd
exit 0 ;; exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*) CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;; exit 0 ;;
...@@ -709,17 +736,14 @@ EOF ...@@ -709,17 +736,14 @@ EOF
CRAY*TS:*:*:*) CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;; exit 0 ;;
CRAY*T3D:*:*:*)
echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*) CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;; exit 0 ;;
CRAY*SV1:*:*:*) CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;; exit 0 ;;
CRAY-2:*:*:*) *:UNICOS/mp:*:*)
echo cray2-cray-unicos echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;; exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
...@@ -727,9 +751,6 @@ EOF ...@@ -727,9 +751,6 @@ EOF
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;; exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
...@@ -739,11 +760,22 @@ EOF ...@@ -739,11 +760,22 @@ EOF
*:BSD/OS:*:*) *:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:FreeBSD:*:*) *:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` # Determine whether the default compiler uses glibc.
exit 0 ;; eval $set_cc_for_build
*:OpenBSD:*:*) sed 's/^ //' << EOF >$dummy.c
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` #include <features.h>
#if __GLIBC__ >= 2
LIBC=gnu
#else
LIBC=
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
# GNU/FreeBSD systems have a "k" prefix to indicate we are using
# FreeBSD's kernel, but not the complete OS.
case ${LIBC} in gnu) kernel_only='k' ;; esac
echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;; exit 0 ;;
i*:CYGWIN*:*) i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin echo ${UNAME_MACHINE}-pc-cygwin
...@@ -754,11 +786,17 @@ EOF ...@@ -754,11 +786,17 @@ EOF
i*:PW*:*) i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32 echo ${UNAME_MACHINE}-pc-pw32
exit 0 ;; exit 0 ;;
x86:Interix*:[34]*)
echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
exit 0 ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*) i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem? # How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386? # UNAME_MACHINE based on the output of uname instead of i386?
echo i386-pc-interix echo i586-pc-interix
exit 0 ;; exit 0 ;;
i*:UWIN*:*) i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin echo ${UNAME_MACHINE}-pc-uwin
...@@ -778,6 +816,9 @@ EOF ...@@ -778,6 +816,9 @@ EOF
arm*:Linux:*:*) arm*:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;; exit 0 ;;
cris:Linux:*:*)
echo cris-axis-linux
exit 0 ;;
ia64:Linux:*:*) ia64:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;; exit 0 ;;
...@@ -785,19 +826,48 @@ EOF ...@@ -785,19 +826,48 @@ EOF
echo ${UNAME_MACHINE}-${VENDOR}-linux echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;; exit 0 ;;
mips:Linux:*:*) mips:Linux:*:*)
case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in eval $set_cc_for_build
big) echo mips-${VENDOR}-linux && exit 0 ;; sed 's/^ //' << EOF >$dummy.c
little) echo mipsel-${VENDOR}-linux && exit 0 ;; #undef CPU
esac #undef mips
case `sed -n '/^system type/s/^.*: \([^ ]*\).*/\1/p' < /proc/cpuinfo` in #undef mipsel
SGI|sgi) echo mips-${VENDOR}-linux-gnu && exit 0 ;; #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
esac CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-${VENDOR}-linux" && exit 0
;; ;;
ppc:Linux:*:*|ppc64:Linux:*:*) mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-${VENDOR}-linux" && exit 0
;;
ppc:Linux:*:*)
echo powerpc-${VENDOR}-linux echo powerpc-${VENDOR}-linux
exit 0 ;; exit 0 ;;
ppc64:Linux:*:*) ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu echo powerpc64-${VENDOR}-linux
exit 0 ;; exit 0 ;;
alpha:Linux:*:*) alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
...@@ -810,7 +880,7 @@ EOF ...@@ -810,7 +880,7 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;; EV68*) UNAME_MACHINE=alphaev68 ;;
esac esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi if test "$?" = 0 ; then LIBC="-libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-${VENDOR}-linux${LIBC} echo ${UNAME_MACHINE}-${VENDOR}-linux${LIBC}
exit 0 ;; exit 0 ;;
parisc:Linux:*:* | hppa:Linux:*:*) parisc:Linux:*:* | hppa:Linux:*:*)
...@@ -827,6 +897,9 @@ EOF ...@@ -827,6 +897,9 @@ EOF
s390:Linux:*:* | s390x:Linux:*:*) s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux echo ${UNAME_MACHINE}-ibm-linux
exit 0 ;; exit 0 ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;;
sh*:Linux:*:*) sh*:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;; exit 0 ;;
...@@ -840,7 +913,8 @@ EOF ...@@ -840,7 +913,8 @@ EOF
# The BFD linker knows what the default object file format is, so # The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent # first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path. # problems with other programs or directories called `ld' in the path.
ld_supported_targets=`cd /; ld --help 2>&1 \ # Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d | sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g s/[ ][ ]*/ /g
s/.*supported targets: *// s/.*supported targets: *//
...@@ -863,33 +937,29 @@ EOF ...@@ -863,33 +937,29 @@ EOF
exit 0 ;; exit 0 ;;
esac esac
# Determine whether the default compiler is a.out or elf # Determine whether the default compiler is a.out or elf
cat >$dummy.c <<EOF
#include <features.h>
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
printf ("%s-${VENDOR}-linux\n", argv[1]);
# else
printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]);
# endif
# else
printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]);
# endif
#else
printf ("%s-${VENDOR}-linuxaout\n", argv[1]);
#endif
return 0;
}
EOF
eval $set_cc_for_build eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 sed 's/^ //' << EOF >$dummy.c
rm -f $dummy.c $dummy #include <features.h>
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#ifdef __INTEL_COMPILER
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}" | sed 's/linux-gnu/linux/' && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;; ;;
i*86:DYNIX/ptx:4*:*) i*86:DYNIX/ptx:4*:*)
...@@ -906,6 +976,23 @@ EOF ...@@ -906,6 +976,23 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it. # Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;; exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit 0 ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
...@@ -927,22 +1014,19 @@ EOF ...@@ -927,22 +1014,19 @@ EOF
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586 && UNAME_MACHINE=i586
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686 && UNAME_MACHINE=i686
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686 && UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else else
echo ${UNAME_MACHINE}-pc-sysv32 echo ${UNAME_MACHINE}-pc-sysv32
fi fi
exit 0 ;; exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*) pc:*:*:*)
# Left here for compatibility: # Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about # uname -m prints for DJGPP always 'pc', but it prints nothing about
...@@ -966,9 +1050,15 @@ EOF ...@@ -966,9 +1050,15 @@ EOF
# "miniframe" # "miniframe"
echo m68010-convergent-sysv echo m68010-convergent-sysv
exit 0 ;; exit 0 ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit 0 ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit 0 ;;
M68*:*:R3V[567]*:*) M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
OS_REL='' OS_REL=''
test -r /etc/.relid \ test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
...@@ -985,9 +1075,6 @@ EOF ...@@ -985,9 +1075,6 @@ EOF
mc68030:UNIX_System_V:4.*:*) mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4 echo m68k-atari-sysv4
exit 0 ;; exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*) TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE} echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
...@@ -1059,6 +1146,9 @@ EOF ...@@ -1059,6 +1146,9 @@ EOF
SX-5:SUPER-UX:*:*) SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE} echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit 0 ;;
Power*:Rhapsody:*:*) Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE} echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
...@@ -1066,18 +1156,24 @@ EOF ...@@ -1066,18 +1156,24 @@ EOF
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:Darwin:*:*) *:Darwin:*:*)
echo `uname -p`-apple-darwin${UNAME_RELEASE} case `uname -p` in
*86) UNAME_PROCESSOR=i686 ;;
powerpc) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*) *:procnto*:*:* | *:QNX:[0123456789]*:*)
if test "${UNAME_MACHINE}" = "x86pc"; then UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc UNAME_MACHINE=pc
fi fi
echo `uname -p`-${UNAME_MACHINE}-nto-qnx echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:QNX:*:4*) *:QNX:*:4*)
echo i386-pc-qnx echo i386-pc-qnx
exit 0 ;; exit 0 ;;
NSR-[KW]:NONSTOP_KERNEL:*:*) NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE} echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
*:NonStop-UX:*:*) *:NonStop-UX:*:*)
...@@ -1100,11 +1196,6 @@ EOF ...@@ -1100,11 +1196,6 @@ EOF
fi fi
echo ${UNAME_MACHINE}-unknown-plan9 echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;; exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
*:TOPS-10:*:*) *:TOPS-10:*:*)
echo pdp10-unknown-tops10 echo pdp10-unknown-tops10
exit 0 ;; exit 0 ;;
...@@ -1123,14 +1214,15 @@ EOF ...@@ -1123,14 +1214,15 @@ EOF
*:ITS:*:*) *:ITS:*:*)
echo pdp10-unknown-its echo pdp10-unknown-its
exit 0 ;; exit 0 ;;
i*86:XTS-300:*:STOP) SEI:*:*:SEIUX)
echo ${UNAME_MACHINE}-unknown-stop echo mips-sei-seiux${UNAME_RELEASE}
exit 0 ;; exit 0 ;;
esac esac
#echo '(No uname command or uname output not recognized.)' 1>&2 #echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <<EOF cat >$dummy.c <<EOF
#ifdef _SEQUENT_ #ifdef _SEQUENT_
# include <sys/types.h> # include <sys/types.h>
...@@ -1245,9 +1337,7 @@ main () ...@@ -1245,9 +1337,7 @@ main ()
} }
EOF EOF
eval $set_cc_for_build $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
# Apollos put the system type in the environment. # Apollos put the system type in the environment.
......
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# Free Software Foundation, Inc. # 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-08-13' timestamp='2003-07-04'
# This file is (in principle) common to ALL GNU software. # This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software # The presence of a machine in this file suggests that SOME GNU software
...@@ -29,7 +29,8 @@ timestamp='2001-08-13' ...@@ -29,7 +29,8 @@ timestamp='2001-08-13'
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>. # Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# #
# Configuration subroutine to validate and canonicalize a configuration type. # Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument. # Supply the specified configuration type as an argument.
...@@ -117,7 +118,7 @@ esac ...@@ -117,7 +118,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations. # Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in case $maybe_os in
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;; ;;
...@@ -226,31 +227,44 @@ case $basic_machine in ...@@ -226,31 +227,44 @@ case $basic_machine in
1750a | 580 \ 1750a | 580 \
| a29k \ | a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| c4x | clipper \ | c4x | clipper \
| d10v | d30v | dsp16xx \ | d10v | d30v | dlx | dsp16xx \
| fr30 \ | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \ | m32r | m68000 | m68k | m88k | mcore \
| mips16 | mips64 | mips64el | mips64orion | mips64orionel \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips64vr4100 | mips64vr4100el | mips64vr4300 \ | mips16 \
| mips64vr4300el | mips64vr5000 | mips64vr5000el \ | mips64 | mips64el \
| mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ | mips64vr | mips64vrel \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \ | mn10200 | mn10300 \
| msp430 \
| ns16k | ns32k \ | ns16k | ns32k \
| openrisc \ | openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \ | pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \ | pyramid \
| s390 | s390x \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh | sh[34] | sh[34]eb | shbe | shle \ | sh64 | sh64le \
| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \ | strongarm \
| tahoe | thumb | tic80 | tron \ | tahoe | thumb | tic4x | tic80 | tron \
| v850 \ | v850 | v850e \
| we32k \ | we32k \
| x86 | xscale \ | x86 | xscale | xstormy16 | xtensa \
| z8k) | z8k)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
...@@ -277,38 +291,55 @@ case $basic_machine in ...@@ -277,38 +291,55 @@ case $basic_machine in
580-* \ 580-* \
| a29k-* \ | a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alphapca5[67]-* | arc-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| arm-* | armbe-* | armle-* | armv*-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \ | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c54x-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | cray2-* | cydra-* \ | clipper-* | cydra-* \
| d10v-* | d30v-* \ | d10v-* | d30v-* | dlx-* \
| elxsi-* \ | elxsi-* \
| f30[01]-* | f700-* | fr30-* | fx80-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \ | h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* \
| m32r-* \ | m32r-* \
| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \ | m88110-* | m88k-* | mcore-* \
| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ | mips16-* \
| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ | mips64-* | mips64el-* \
| mipsle-* | mipstx39-* | mipstx39el-* \ | mips64vr-* | mips64vrel-* \
| none-* | np1-* | ns16k-* | ns32k-* \ | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| orion-* \ | orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | romp-* | rs6000-* \
| s390-* | s390x-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclite-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | tahoe-* | thumb-* \
| v850-* | vax-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| ymp-* \ | ymp-* \
| z8k-*) | z8k-*)
;; ;;
...@@ -342,6 +373,9 @@ case $basic_machine in ...@@ -342,6 +373,9 @@ case $basic_machine in
basic_machine=a29k-none basic_machine=a29k-none
os=-bsd os=-bsd
;; ;;
amd64)
basic_machine=x86_64-pc
;;
amdahl) amdahl)
basic_machine=580-amdahl basic_machine=580-amdahl
os=-sysv os=-sysv
...@@ -373,6 +407,10 @@ case $basic_machine in ...@@ -373,6 +407,10 @@ case $basic_machine in
basic_machine=ns32k-sequent basic_machine=ns32k-sequent
os=-dynix os=-dynix
;; ;;
c90)
basic_machine=c90-cray
os=-unicos
;;
convex-c1) convex-c1)
basic_machine=c1-convex basic_machine=c1-convex
os=-bsd os=-bsd
...@@ -393,16 +431,8 @@ case $basic_machine in ...@@ -393,16 +431,8 @@ case $basic_machine in
basic_machine=c38-convex basic_machine=c38-convex
os=-bsd os=-bsd
;; ;;
cray | ymp) cray | j90)
basic_machine=ymp-cray basic_machine=j90-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[cjt]90)
basic_machine=${basic_machine}-cray
os=-unicos os=-unicos
;; ;;
crds | unos) crds | unos)
...@@ -417,6 +447,14 @@ case $basic_machine in ...@@ -417,6 +447,14 @@ case $basic_machine in
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec basic_machine=mips-dec
;; ;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \ delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola) | 3300-motorola | delta-motorola)
basic_machine=m68k-motorola basic_machine=m68k-motorola
...@@ -597,12 +635,6 @@ case $basic_machine in ...@@ -597,12 +635,6 @@ case $basic_machine in
basic_machine=m68k-atari basic_machine=m68k-atari
os=-mint os=-mint
;; ;;
mipsel*-linux*)
basic_machine=mipsel-unknown
;;
mips*-linux*)
basic_machine=mips-unknown
;;
mips3*-*) mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;; ;;
...@@ -617,6 +649,10 @@ case $basic_machine in ...@@ -617,6 +649,10 @@ case $basic_machine in
basic_machine=m68k-rom68k basic_machine=m68k-rom68k
os=-coff os=-coff
;; ;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos) msdos)
basic_machine=i386-pc basic_machine=i386-pc
os=-msdos os=-msdos
...@@ -689,6 +725,10 @@ case $basic_machine in ...@@ -689,6 +725,10 @@ case $basic_machine in
np1) np1)
basic_machine=np1-gould basic_machine=np1-gould
;; ;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem) nsr-tandem)
basic_machine=nsr-tandem basic_machine=nsr-tandem
;; ;;
...@@ -696,6 +736,10 @@ case $basic_machine in ...@@ -696,6 +736,10 @@ case $basic_machine in
basic_machine=hppa1.1-oki basic_machine=hppa1.1-oki
os=-proelf os=-proelf
;; ;;
or32 | or32-*)
basic_machine=or32-unknown
os=-coff
;;
OSE68000 | ose68000) OSE68000 | ose68000)
basic_machine=m68000-ericsson basic_machine=m68000-ericsson
os=-ose os=-ose
...@@ -721,24 +765,30 @@ case $basic_machine in ...@@ -721,24 +765,30 @@ case $basic_machine in
pc532 | pc532-*) pc532 | pc532-*)
basic_machine=ns32k-pc532 basic_machine=ns32k-pc532
;; ;;
pentium | p5 | k5 | k6 | nexgen) pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc basic_machine=i586-pc
;; ;;
pentiumpro | p6 | 6x86 | athlon) pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc basic_machine=i686-pc
;; ;;
pentiumii | pentium2) pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc basic_machine=i686-pc
;; ;;
pentium-* | p5-* | k5-* | k6-* | nexgen-*) pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
pentiumpro-* | p6-* | 6x86-* | athlon-*) pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
pentiumii-* | pentium2-*) pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn) pn)
basic_machine=pn-gould basic_machine=pn-gould
;; ;;
...@@ -746,8 +796,6 @@ case $basic_machine in ...@@ -746,8 +796,6 @@ case $basic_machine in
;; ;;
ppc) basic_machine=powerpc-unknown ppc) basic_machine=powerpc-unknown
;; ;;
ppc64) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
ppcle | powerpclittle | ppc-le | powerpc-little) ppcle | powerpclittle | ppc-le | powerpc-little)
...@@ -783,10 +831,26 @@ case $basic_machine in ...@@ -783,10 +831,26 @@ case $basic_machine in
rtpc | rtpc-*) rtpc | rtpc-*)
basic_machine=romp-ibm basic_machine=romp-ibm
;; ;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200) sa29200)
basic_machine=a29k-amd basic_machine=a29k-amd
os=-udi os=-udi
;; ;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent) sequent)
basic_machine=i386-sequent basic_machine=i386-sequent
;; ;;
...@@ -794,7 +858,10 @@ case $basic_machine in ...@@ -794,7 +858,10 @@ case $basic_machine in
basic_machine=sh-hitachi basic_machine=sh-hitachi
os=-hms os=-hms
;; ;;
sparclite-wrs) sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs basic_machine=sparclite-wrs
os=-vxworks os=-vxworks
;; ;;
...@@ -861,19 +928,35 @@ case $basic_machine in ...@@ -861,19 +928,35 @@ case $basic_machine in
os=-dynix os=-dynix
;; ;;
t3e) t3e)
basic_machine=t3e-cray basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos os=-unicos
;; ;;
tic54x | c54x*) tic54x | c54x*)
basic_machine=tic54x-unknown basic_machine=tic54x-unknown
os=-coff os=-coff
;; ;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tx39) tx39)
basic_machine=mipstx39-unknown basic_machine=mipstx39-unknown
;; ;;
tx39el) tx39el)
basic_machine=mipstx39el-unknown basic_machine=mipstx39el-unknown
;; ;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32) tower | tower-32)
basic_machine=m68k-ncr basic_machine=m68k-ncr
;; ;;
...@@ -920,17 +1003,13 @@ case $basic_machine in ...@@ -920,17 +1003,13 @@ case $basic_machine in
basic_machine=hppa1.1-winbond basic_machine=hppa1.1-winbond
os=-proelf os=-proelf
;; ;;
windows32)
basic_machine=i386-pc
os=-windows32-msvcrt
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100) xps | xps100)
basic_machine=xps100-honeywell basic_machine=xps100-honeywell
;; ;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff) z8k-*-coff)
basic_machine=z8k-unknown basic_machine=z8k-unknown
os=-sim os=-sim
...@@ -951,16 +1030,6 @@ case $basic_machine in ...@@ -951,16 +1030,6 @@ case $basic_machine in
op60c) op60c)
basic_machine=hppa1.1-oki basic_machine=hppa1.1-oki
;; ;;
mips)
case $os in
linux*)
basic_machine=mips-unknown
;;
*)
basic_machine=mips-mips
;;
esac
;;
romp) romp)
basic_machine=romp-ibm basic_machine=romp-ibm
;; ;;
...@@ -980,9 +1049,12 @@ case $basic_machine in ...@@ -980,9 +1049,12 @@ case $basic_machine in
we32k) we32k)
basic_machine=we32k-att basic_machine=we32k-att
;; ;;
sh3 | sh4 | sh3eb | sh4eb) sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown basic_machine=sh-unknown
;; ;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b) sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun basic_machine=sparc-sun
;; ;;
...@@ -1001,10 +1073,6 @@ case $basic_machine in ...@@ -1001,10 +1073,6 @@ case $basic_machine in
pmac | pmac-mpw) pmac | pmac-mpw)
basic_machine=powerpc-apple basic_machine=powerpc-apple
;; ;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*-unknown) *-unknown)
# Make sure to match an already-canonicalized machine name. # Make sure to match an already-canonicalized machine name.
;; ;;
...@@ -1060,17 +1128,19 @@ case $os in ...@@ -1060,17 +1128,19 @@ case $os in
| -aos* \ | -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \ | -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos*) | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)
...@@ -1082,8 +1152,10 @@ case $os in ...@@ -1082,8 +1152,10 @@ case $os in
;; ;;
esac esac
;; ;;
-nto-qnx*)
;;
-nto*) -nto*)
os=-nto-qnx os=`echo $os | sed -e 's|nto|nto-qnx|'`
;; ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
...@@ -1119,12 +1191,18 @@ case $os in ...@@ -1119,12 +1191,18 @@ case $os in
-acis*) -acis*)
os=-aos os=-aos
;; ;;
-atheos*)
os=-atheos
;;
-386bsd) -386bsd)
os=-bsd os=-bsd
;; ;;
-ctix* | -uts*) -ctix* | -uts*)
os=-sysv os=-sysv
;; ;;
-nova*)
os=-rtmk-nova
;;
-ns2 ) -ns2 )
os=-nextstep2 os=-nextstep2
;; ;;
...@@ -1168,6 +1246,12 @@ case $os in ...@@ -1168,6 +1246,12 @@ case $os in
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint os=-mint
;; ;;
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-none) -none)
;; ;;
*) *)
...@@ -1199,6 +1283,10 @@ case $basic_machine in ...@@ -1199,6 +1283,10 @@ case $basic_machine in
arm*-semi) arm*-semi)
os=-aout os=-aout
;; ;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*) pdp10-*)
os=-tops20 os=-tops20
;; ;;
...@@ -1229,6 +1317,9 @@ case $basic_machine in ...@@ -1229,6 +1317,9 @@ case $basic_machine in
mips*-*) mips*-*)
os=-elf os=-elf
;; ;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os. *-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3 os=-sysv3
;; ;;
...@@ -1376,7 +1467,7 @@ case $basic_machine in ...@@ -1376,7 +1467,7 @@ case $basic_machine in
-ptx*) -ptx*)
vendor=sequent vendor=sequent
;; ;;
-vxsim* | -vxworks*) -vxsim* | -vxworks* | -windiss*)
vendor=wrs vendor=wrs
;; ;;
-aux*) -aux*)
......
...@@ -1815,7 +1815,7 @@ AC_CHECK_FUNCS(alarm bmove \ ...@@ -1815,7 +1815,7 @@ AC_CHECK_FUNCS(alarm bmove \
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_attr_getstacksize \ pthread_attr_getstacksize pthread_key_delete \
pthread_condattr_create rwlock_init pthread_rwlock_rdlock \ pthread_condattr_create rwlock_init pthread_rwlock_rdlock \
fsync fdatasync fchmod getpass getpassphrase initgroups mlockall) fsync fdatasync fchmod getpass getpassphrase initgroups mlockall)
......
...@@ -273,7 +273,9 @@ C_MODE_END ...@@ -273,7 +273,9 @@ C_MODE_END
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
#define CONFIG_SMP #define CONFIG_SMP
#endif #endif
C_MODE_START
#include <asm/atomic.h> #include <asm/atomic.h>
C_MODE_END
#endif #endif
#include <errno.h> /* Recommended by debian */ #include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */ /* We need the following to go around a problem with openssl on solaris */
......
...@@ -384,6 +384,11 @@ struct tm *localtime_r(const time_t *clock, struct tm *res); ...@@ -384,6 +384,11 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
#define pthread_condattr_destroy pthread_condattr_delete #define pthread_condattr_destroy pthread_condattr_delete
#endif #endif
/* FSU THREADS */
#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete)
#define pthread_key_delete(A) pthread_dummy(0)
#endif
#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */ #ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
#define pthread_cond_destroy(A) pthread_dummy(0) #define pthread_cond_destroy(A) pthread_dummy(0)
#define pthread_mutex_destroy(A) pthread_dummy(0) #define pthread_mutex_destroy(A) pthread_dummy(0)
......
...@@ -1171,23 +1171,36 @@ dict_create_or_check_foreign_constraint_tables(void) ...@@ -1171,23 +1171,36 @@ dict_create_or_check_foreign_constraint_tables(void)
} }
/************************************************************************ /************************************************************************
Adds foreign key definitions to data dictionary tables in the database. */ Adds foreign key definitions to data dictionary tables in the database. We
look at table->foreign_list, and also generate names to constraints that were
not named by the user. A generated constraint has a name of the format
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
given locally for this table, that is, the number is not global, as in the
old format constraints < 4.0.18 it used to be. */
ulint ulint
dict_create_add_foreigns_to_dictionary( dict_create_add_foreigns_to_dictionary(
/*===================================*/ /*===================================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
ulint start_id,/* in: if we are actually doing ALTER TABLE
ADD CONSTRAINT, we want to generate constraint
numbers which are bigger than in the table so
far; we number the constraints from
start_id + 1 up; start_id should be set to 0 if
we are creating a new table, or if the table
so far has no constraints for which the name
was generated here */
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
dict_foreign_t* foreign; dict_foreign_t* foreign;
que_thr_t* thr; que_thr_t* thr;
que_t* graph; que_t* graph;
dulint id; ulint number = start_id + 1;
ulint len; ulint len;
ulint error; ulint error;
char* ebuf = dict_foreign_err_buf;
ulint i; ulint i;
char buf2[50];
char buf[10000]; char buf[10000];
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
...@@ -1215,18 +1228,18 @@ loop: ...@@ -1215,18 +1228,18 @@ loop:
"PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n" "PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n"
"BEGIN\n"); "BEGIN\n");
/* We allocate the new id from the sequence of table id's */ if (foreign->id == NULL) {
id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); /* Generate a new constraint id */
foreign->id = mem_heap_alloc(foreign->heap,
sprintf(buf2, "%lu_%lu", ut_dulint_get_high(id), ut_strlen(table->name)
ut_dulint_get_low(id)); + 20);
foreign->id = mem_heap_alloc(foreign->heap, ut_strlen(buf2) + 1); sprintf(foreign->id, "%s_ibfk_%lu", table->name, number);
ut_memcpy(foreign->id, buf2, ut_strlen(buf2) + 1); number++;
}
len += sprintf(buf + len, len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN VALUES('%lu_%lu', '%s', '%s', %lu);\n", "INSERT INTO SYS_FOREIGN VALUES('%s', '%s', '%s', %lu);\n",
ut_dulint_get_high(id), foreign->id,
ut_dulint_get_low(id),
table->name, table->name,
foreign->referenced_table_name, foreign->referenced_table_name,
foreign->n_fields foreign->n_fields
...@@ -1235,9 +1248,8 @@ loop: ...@@ -1235,9 +1248,8 @@ loop:
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
len += sprintf(buf + len, len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN_COLS VALUES('%lu_%lu', %lu, '%s', '%s');\n", "INSERT INTO SYS_FOREIGN_COLS VALUES('%s', %lu, '%s', '%s');\n",
ut_dulint_get_high(id), foreign->id,
ut_dulint_get_low(id),
i, i,
foreign->foreign_col_names[i], foreign->foreign_col_names[i],
foreign->referenced_col_names[i]); foreign->referenced_col_names[i]);
...@@ -1262,29 +1274,30 @@ loop: ...@@ -1262,29 +1274,30 @@ loop:
que_graph_free(graph); que_graph_free(graph);
if (error != DB_SUCCESS) {
fprintf(stderr,
"InnoDB: Foreign key constraint creation failed:\n"
"InnoDB: internal error number %lu\n", error);
if (error == DB_DUPLICATE_KEY) { if (error == DB_DUPLICATE_KEY) {
fprintf(stderr, mutex_enter(&dict_foreign_err_mutex);
"InnoDB: Duplicate key error in system table %s index %s\n", ut_sprintf_timestamp(dict_foreign_err_buf);
((dict_index_t*)trx->error_info)->table_name, sprintf(ebuf + strlen(ebuf),
((dict_index_t*)trx->error_info)->name); " Error in foreign key constraint creation for table %.500s.\n"
"A foreign key constraint of name %.500s\n"
"already exists (note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n", table->name, foreign->id);
fprintf(stderr, "%s\n", buf); ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN);
fprintf(stderr, mutex_exit(&dict_foreign_err_mutex);
"InnoDB: Maybe the internal data dictionary of InnoDB is\n"
"InnoDB: out-of-sync from the .frm files of your tables.\n" return(error);
"InnoDB: See section 15.1 Troubleshooting data dictionary operations\n"
"InnoDB: at http://www.innodb.com/ibman.html\n");
} }
if (error != DB_SUCCESS) {
fprintf(stderr,
"InnoDB: Foreign key constraint creation failed:\n"
"InnoDB: internal error number %lu\n", error);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); ut_sprintf_timestamp(ebuf);
sprintf(buf + strlen(buf), sprintf(ebuf + strlen(ebuf),
" Internal error in foreign key constraint creation for table %.500s.\n" " Internal error in foreign key constraint creation for table %.500s.\n"
"See the MySQL .err log in the datadir for more information.\n", table->name); "See the MySQL .err log in the datadir for more information.\n", table->name);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
......
...@@ -236,6 +236,29 @@ dict_remove_db_name( ...@@ -236,6 +236,29 @@ dict_remove_db_name(
return(NULL); return(NULL);
} }
/************************************************************************
Get the database name length in a table name. */
ulint
dict_get_db_name_len(
/*=================*/
/* out: database name length */
char* name) /* in: table name in the form dbname '/' tablename */
{
ulint i;
for (i = 0; i < 100000 ; i++) {
if (name[i] == '/') {
return(i);
}
}
ut_a(0);
return(0);
}
/************************************************************************ /************************************************************************
Reserves the dictionary system mutex for MySQL. */ Reserves the dictionary system mutex for MySQL. */
...@@ -869,6 +892,7 @@ dict_table_rename_in_cache( ...@@ -869,6 +892,7 @@ dict_table_rename_in_cache(
ulint fold; ulint fold;
ulint old_size; ulint old_size;
char* name_buf; char* name_buf;
char* old_name;
ulint i; ulint i;
ut_ad(table); ut_ad(table);
...@@ -899,6 +923,9 @@ dict_table_rename_in_cache( ...@@ -899,6 +923,9 @@ dict_table_rename_in_cache(
/* Remove table from the hash tables of tables */ /* Remove table from the hash tables of tables */
HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
ut_fold_string(table->name), table); ut_fold_string(table->name), table);
old_name = mem_heap_alloc(table->heap, ut_strlen(table->name) + 1);
ut_strcpy(old_name, table->name);
name_buf = mem_heap_alloc(table->heap, ut_strlen(new_name) + 1); name_buf = mem_heap_alloc(table->heap, ut_strlen(new_name) + 1);
...@@ -956,7 +983,9 @@ dict_table_rename_in_cache( ...@@ -956,7 +983,9 @@ dict_table_rename_in_cache(
return(TRUE); return(TRUE);
} }
/* Update the table name fields in foreign constraints */ /* Update the table name fields in foreign constraints, and update also
the constraint id of new format >= 4.0.18 constraints. Note that at
this point we have already changed table->name to the new name. */
foreign = UT_LIST_GET_FIRST(table->foreign_list); foreign = UT_LIST_GET_FIRST(table->foreign_list);
...@@ -965,14 +994,68 @@ dict_table_rename_in_cache( ...@@ -965,14 +994,68 @@ dict_table_rename_in_cache(
ut_strlen(table->name)) { ut_strlen(table->name)) {
/* Allocate a longer name buffer; /* Allocate a longer name buffer;
TODO: store buf len to save memory */ TODO: store buf len to save memory */
foreign->foreign_table_name = mem_heap_alloc( foreign->foreign_table_name = mem_heap_alloc(
foreign->heap, foreign->heap,
ut_strlen(table->name) + 1); ut_strlen(table->name) + 1);
} }
ut_memcpy(foreign->foreign_table_name, table->name, sprintf(foreign->foreign_table_name, "%s", table->name);
ut_strlen(table->name) + 1);
foreign->foreign_table_name[ut_strlen(table->name)] = '\0'; if (ut_str_contains(foreign->id, '/')) {
ulint db_len;
char old_id[2000];
/* This is a >= 4.0.18 format id */
ut_a(ut_strlen(foreign->id) < 1999);
ut_strcpy(old_id, foreign->id);
if (ut_strlen(foreign->id) > ut_strlen(old_name)
+ ut_strlen("_ibfk_")
&& 0 == ut_memcmp(foreign->id, old_name,
ut_strlen(old_name))
&& 0 == ut_memcmp(
foreign->id + ut_strlen(old_name),
(char*)"_ibfk_", ut_strlen("_ibfk_"))) {
/* This is a generated >= 4.0.18 format id */
if (ut_strlen(table->name)
> ut_strlen(old_name)) {
foreign->id = mem_heap_alloc(
foreign->heap,
ut_strlen(table->name)
+ ut_strlen(old_id) + 1);
}
/* Replace the prefix 'databasename/tablename'
with the new names */
sprintf(foreign->id, "%s%s", table->name,
old_id + ut_strlen(old_name));
} else {
/* This is a >= 4.0.18 format id where the user
gave the id name */
db_len = dict_get_db_name_len(table->name) + 1;
if (dict_get_db_name_len(table->name)
> dict_get_db_name_len(foreign->id)) {
foreign->id = mem_heap_alloc(
foreign->heap,
db_len + ut_strlen(old_id) + 1);
}
/* Replace the database prefix in id with the
one from table->name */
ut_memcpy(foreign->id, table->name, db_len);
sprintf(foreign->id + db_len, "%s",
dict_remove_db_name(old_id));
}
}
foreign = UT_LIST_GET_NEXT(foreign_list, foreign); foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
} }
...@@ -984,14 +1067,13 @@ dict_table_rename_in_cache( ...@@ -984,14 +1067,13 @@ dict_table_rename_in_cache(
ut_strlen(table->name)) { ut_strlen(table->name)) {
/* Allocate a longer name buffer; /* Allocate a longer name buffer;
TODO: store buf len to save memory */ TODO: store buf len to save memory */
foreign->referenced_table_name = mem_heap_alloc( foreign->referenced_table_name = mem_heap_alloc(
foreign->heap, foreign->heap,
ut_strlen(table->name) + 1); ut_strlen(table->name) + 1);
} }
ut_memcpy(foreign->referenced_table_name, table->name, sprintf(foreign->referenced_table_name, "%s", table->name);
ut_strlen(table->name) + 1);
foreign->referenced_table_name[ut_strlen(table->name)] = '\0';
foreign = UT_LIST_GET_NEXT(referenced_list, foreign); foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
} }
...@@ -2042,7 +2124,7 @@ static ...@@ -2042,7 +2124,7 @@ static
char* char*
dict_scan_to( dict_scan_to(
/*=========*/ /*=========*/
/* out: scanned up to this */
char* ptr, /* in: scan from */ char* ptr, /* in: scan from */
const char *string) /* in: look for this */ const char *string) /* in: look for this */
{ {
...@@ -2299,12 +2381,7 @@ dict_scan_table_name( ...@@ -2299,12 +2381,7 @@ dict_scan_table_name(
database_name = name; database_name = name;
i = 0; database_name_len = dict_get_db_name_len(name);
while (name[i] != '/') {
i++;
}
database_name_len = i;
} }
if (table_name_len + database_name_len > 2000) { if (table_name_len + database_name_len > 2000) {
...@@ -2478,6 +2555,52 @@ scan_more: ...@@ -2478,6 +2555,52 @@ scan_more:
} }
} }
/*************************************************************************
Finds the highest <number> for foreign key constraints of the table. Looks
only at the >= 4.0.18-format id's, which are of the form
databasename/tablename_ibfk_<number>. */
static
ulint
dict_table_get_highest_foreign_id(
/*==============================*/
/* out: highest number, 0 if table has no new
format foreign key constraints */
dict_table_t* table) /* in: table in the dictionary memory cache */
{
dict_foreign_t* foreign;
char* endp;
ulint biggest_id = 0;
ulint id;
ut_a(table);
foreign = UT_LIST_GET_FIRST(table->foreign_list);
while (foreign) {
if (ut_strlen(foreign->id) > ut_strlen("_ibfk_")
+ ut_strlen(table->name)
&& 0 == ut_memcmp(foreign->id, table->name,
ut_strlen(table->name))
&& 0 == ut_memcmp(foreign->id + ut_strlen(table->name),
(char*)"_ibfk_", ut_strlen("_ibfk_"))) {
/* It is of the >= 4.0.18 format */
id = strtoul(foreign->id + ut_strlen(table->name)
+ ut_strlen("_ibfk_"),
&endp, 10);
ut_a(id != biggest_id);
if (id > biggest_id) {
biggest_id = id;
}
}
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
}
return(biggest_id);
}
/************************************************************************* /*************************************************************************
Reports a simple foreign key create clause syntax error. */ Reports a simple foreign key create clause syntax error. */
static static
...@@ -2520,19 +2643,26 @@ dict_create_foreign_constraints_low( ...@@ -2520,19 +2643,26 @@ dict_create_foreign_constraints_low(
FOREIGN KEY (a, b) REFERENCES table2(c, d), FOREIGN KEY (a, b) REFERENCES table2(c, d),
table2 can be written also with the database table2 can be written also with the database
name before it: test.table2; the default name before it: test.table2; the default
database id the database of parameter name */ database is the database of parameter name */
char* name) /* in: table full name in the normalized form char* name) /* in: table full name in the normalized form
database_name/table_name */ database_name/table_name */
{ {
dict_table_t* table; dict_table_t* table;
dict_table_t* referenced_table; dict_table_t* referenced_table;
dict_table_t* table_to_alter;
ulint highest_id_so_far = 0;
dict_index_t* index; dict_index_t* index;
dict_foreign_t* foreign; dict_foreign_t* foreign;
char* ptr = sql_string; char* ptr = sql_string;
char* start_of_latest_foreign = sql_string; char* start_of_latest_foreign = sql_string;
char* buf = dict_foreign_err_buf; char* buf = dict_foreign_err_buf;
char* constraint_name; /* this is NOT a null-
terminated string */
ulint constraint_name_len;
ibool success; ibool success;
ulint error; ulint error;
char* ptr1;
char* ptr2;
ulint i; ulint i;
ulint j; ulint j;
ibool is_on_delete; ibool is_on_delete;
...@@ -2559,16 +2689,89 @@ dict_create_foreign_constraints_low( ...@@ -2559,16 +2689,89 @@ dict_create_foreign_constraints_low(
return(DB_ERROR); return(DB_ERROR);
} }
/* First check if we are actually doing an ALTER TABLE, and in that
case look for the table being altered */
ptr = dict_accept(ptr, (char*) "ALTER", &success);
if (!success) {
goto loop;
}
ptr = dict_accept(ptr, (char*) "TABLE", &success);
if (!success) {
goto loop;
}
/* We are doing an ALTER TABLE: scan the table name we are altering;
in the call below we use the buffer 'referenced_table_name' as a dummy
buffer */
ptr = dict_scan_table_name(ptr, &table_to_alter, name,
&success, referenced_table_name);
if (!success) {
fprintf(stderr,
"InnoDB: Error: could not find the table being ALTERED in:\n%s\n", sql_string);
return(DB_ERROR);
}
/* Starting from 4.0.18 and 4.1.2, we generate foreign key id's in the
format databasename/tablename_ibfk_<number>, where <number> is local
to the table; look for the highest <number> for table_to_alter, so
that we can assign to new constraints higher numbers. */
/* If we are altering a temporary table, the table name after ALTER
TABLE does not correspond to the internal table name, and
table_to_alter is NULL. TODO: should we fix this somehow? */
if (table_to_alter == NULL) {
highest_id_so_far = 0;
} else {
highest_id_so_far = dict_table_get_highest_foreign_id(
table_to_alter);
}
/* Scan for foreign key declarations in a loop */
loop: loop:
ptr = dict_scan_to(ptr, (char *) "FOREIGN"); /* Scan either to "CONSTRAINT" or "FOREIGN", whichever is closer */
if (*ptr == '\0') { ptr1 = dict_scan_to(ptr, (char *) "CONSTRAINT");
ptr2 = dict_scan_to(ptr, (char *) "FOREIGN");
constraint_name = NULL;
if (ptr1 < ptr2) {
/* The user has specified a constraint name. Pick it so
that we can store 'databasename/constraintname' as the id of
the id of the constraint to system tables. */
ptr = ptr1;
ptr = dict_accept(ptr, (char *) "CONSTRAINT", &success);
ut_a(success);
if (!isspace(*ptr)) {
goto loop;
}
ptr = dict_scan_id(ptr, &constraint_name, &constraint_name_len,
FALSE);
} else {
ptr = ptr2;
}
if (*ptr == '\0') {
/**********************************************************/
/* The following call adds the foreign key constraints /* The following call adds the foreign key constraints
to the data dictionary system tables on disk */ to the data dictionary system tables on disk */
error = dict_create_add_foreigns_to_dictionary(table, trx); error = dict_create_add_foreigns_to_dictionary(
highest_id_so_far, table, trx);
return(error); return(error);
} }
...@@ -2676,6 +2879,28 @@ col_loop1: ...@@ -2676,6 +2879,28 @@ col_loop1:
foreign = dict_mem_foreign_create(); foreign = dict_mem_foreign_create();
if (constraint_name) {
ulint db_len;
/* Catenate 'databasename/' to the constraint name specified
by the user: we conceive the constraint as belonging to the
same MySQL 'database' as the table itself. We store the name
to foreign->id. */
db_len = dict_get_db_name_len(table->name);
foreign->id = mem_heap_alloc(foreign->heap,
db_len + 1 + constraint_name_len + 1);
ut_memcpy(foreign->id, table->name, db_len);
foreign->id[db_len] = '/';
ut_memcpy(foreign->id + db_len + 1, constraint_name,
constraint_name_len);
foreign->id[db_len + 1 + constraint_name_len] = '\0';
}
foreign->foreign_table = table; foreign->foreign_table = table;
foreign->foreign_table_name = table->name; foreign->foreign_table_name = table->name;
foreign->foreign_index = index; foreign->foreign_index = index;
...@@ -2977,7 +3202,7 @@ dict_create_foreign_constraints( ...@@ -2977,7 +3202,7 @@ dict_create_foreign_constraints(
FOREIGN KEY (a, b) REFERENCES table2(c, d), FOREIGN KEY (a, b) REFERENCES table2(c, d),
table2 can be written also with the database table2 can be written also with the database
name before it: test.table2; the default name before it: test.table2; the default
database id the database of parameter name */ database is the database of parameter name */
char* name) /* in: table full name in the normalized form char* name) /* in: table full name in the normalized form
database_name/table_name */ database_name/table_name */
{ {
...@@ -3079,8 +3304,10 @@ loop: ...@@ -3079,8 +3304,10 @@ loop:
foreign = UT_LIST_GET_FIRST(table->foreign_list); foreign = UT_LIST_GET_FIRST(table->foreign_list);
while (foreign != NULL) { while (foreign != NULL) {
if (0 == ut_strcmp(foreign->id, id)) { if (0 == ut_strcmp(foreign->id, id)
|| (ut_str_contains(foreign->id, '/')
&& 0 == ut_strcmp(id,
dict_remove_db_name(foreign->id)))) {
/* Found */ /* Found */
break; break;
} }
...@@ -3093,8 +3320,8 @@ loop: ...@@ -3093,8 +3320,8 @@ loop:
ut_sprintf_timestamp(buf); ut_sprintf_timestamp(buf);
sprintf(buf + strlen(buf), sprintf(buf + strlen(buf),
" Error in dropping of a foreign key constraint of table %.500s,\n" " Error in dropping of a foreign key constraint of table %.500s,\n"
"just before:\n%s\n in SQL command\n%s\nCannot find a constraint with the\n" "in SQL command\n%s\nCannot find a constraint with the\n"
"given id %s.\n", table->name, ptr, str, id); "given id %s.\n", table->name, str, id);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
...@@ -3896,11 +4123,20 @@ dict_print_info_on_foreign_key_in_create_format( ...@@ -3896,11 +4123,20 @@ dict_print_info_on_foreign_key_in_create_format(
char* buf) /* in: buffer of at least 5000 bytes */ char* buf) /* in: buffer of at least 5000 bytes */
{ {
char* buf2 = buf; char* buf2 = buf;
char* stripped_id;
ulint cpy_len; ulint cpy_len;
ulint i; ulint i;
if (ut_str_contains(foreign->id, '/')) {
/* Strip the preceding database name from the constraint id */
stripped_id = foreign->id + 1
+ dict_get_db_name_len(foreign->id);
} else {
stripped_id = foreign->id;
}
buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (", buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (",
foreign->id); stripped_id);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
if ((ulint)(buf2 - buf) >= 4000) { if ((ulint)(buf2 - buf) >= 4000) {
......
...@@ -81,12 +81,25 @@ dict_create_or_check_foreign_constraint_tables(void); ...@@ -81,12 +81,25 @@ dict_create_or_check_foreign_constraint_tables(void);
/*================================================*/ /*================================================*/
/* out: DB_SUCCESS or error code */ /* out: DB_SUCCESS or error code */
/************************************************************************ /************************************************************************
Adds foreign key definitions to data dictionary tables in the database. */ Adds foreign key definitions to data dictionary tables in the database. We
look at table->foreign_list, and also generate names to constraints that were
not named by the user. A generated constraint has a name of the format
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
given locally for this table, that is, the number is not global, as in the
old format constraints < 4.0.18 it used to be. */
ulint ulint
dict_create_add_foreigns_to_dictionary( dict_create_add_foreigns_to_dictionary(
/*===================================*/ /*===================================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
ulint start_id,/* in: if we are actually doing ALTER TABLE
ADD CONSTRAINT, we want to generate constraint
numbers which are bigger than in the table so
far; we number the constraints from
start_id + 1 up; start_id should be set to 0 if
we are creating a new table, or if the table
so far has no constraints for which the name
was generated here */
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
trx_t* trx); /* in: transaction */ trx_t* trx); /* in: transaction */
......
...@@ -26,6 +26,14 @@ Created 1/8/1996 Heikki Tuuri ...@@ -26,6 +26,14 @@ Created 1/8/1996 Heikki Tuuri
#include "ut0byte.h" #include "ut0byte.h"
#include "trx0types.h" #include "trx0types.h"
/************************************************************************
Get the database name length in a table name. */
ulint
dict_get_db_name_len(
/*=================*/
/* out: database name length */
char* name); /* in: table name in the form dbname '/' tablename */
/************************************************************************* /*************************************************************************
Accepts a specified string. Comparisons are case-insensitive. */ Accepts a specified string. Comparisons are case-insensitive. */
......
...@@ -85,10 +85,17 @@ ut_str_catenate( ...@@ -85,10 +85,17 @@ ut_str_catenate(
/* out, own: catenated null-terminated string */ /* out, own: catenated null-terminated string */
char* str1, /* in: null-terminated string */ char* str1, /* in: null-terminated string */
char* str2); /* in: null-terminated string */ char* str2); /* in: null-terminated string */
/**************************************************************************
Checks if a null-terminated string contains a certain character. */
ibool
ut_str_contains(
/*============*/
char* str, /* in: null-terminated string */
char c); /* in: character */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "ut0mem.ic" #include "ut0mem.ic"
#endif #endif
#endif #endif
...@@ -2185,7 +2185,7 @@ row_is_mysql_tmp_table_name( ...@@ -2185,7 +2185,7 @@ row_is_mysql_tmp_table_name(
{ {
ulint i; ulint i;
for (i = 0; i <= ut_strlen(name) - 5; i++) { for (i = 0; i + 5 <= ut_strlen(name); i++) {
if (ut_memcmp(name + i, (char*)"/#sql", 5) == 0) { if (ut_memcmp(name + i, (char*)"/#sql", 5) == 0) {
return(TRUE); return(TRUE);
...@@ -2221,6 +2221,7 @@ row_rename_table_for_mysql( ...@@ -2221,6 +2221,7 @@ row_rename_table_for_mysql(
ulint keywordlen; ulint keywordlen;
ulint len; ulint len;
ulint i; ulint i;
char* db_name;
char buf[10000]; char buf[10000];
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
...@@ -2285,6 +2286,15 @@ row_rename_table_for_mysql( ...@@ -2285,6 +2286,15 @@ row_rename_table_for_mysql(
"PROCEDURE RENAME_TABLE_PROC () IS\n" "PROCEDURE RENAME_TABLE_PROC () IS\n"
"new_table_name CHAR;\n" "new_table_name CHAR;\n"
"old_table_name CHAR;\n" "old_table_name CHAR;\n"
"gen_constr_prefix CHAR;\n"
"new_db_name CHAR;\n"
"foreign_id CHAR;\n"
"new_foreign_id CHAR;\n"
"old_db_name_len INT;\n"
"old_t_name_len INT;\n"
"new_db_name_len INT;\n"
"id_len INT;\n"
"found INT;\n"
"BEGIN\n" "BEGIN\n"
"new_table_name :='"; "new_table_name :='";
...@@ -2311,32 +2321,94 @@ row_rename_table_for_mysql( ...@@ -2311,32 +2321,94 @@ row_rename_table_for_mysql(
} }
str3 = mem_heap_alloc(heap, str3 = mem_heap_alloc(heap,
1000 + 500 * n_constraints_to_drop); 1000 + 1000 * n_constraints_to_drop);
*str3 = '\0'; *str3 = '\0';
sprintf(str3, sprintf(str3,
"';\n" "';\n"
"UPDATE SYS_TABLES SET NAME = new_table_name\n" "UPDATE SYS_TABLES SET NAME = new_table_name\n"
"WHERE NAME = old_table_name;\n"); "WHERE NAME = old_table_name;\n");
db_name = mem_heap_alloc(heap, 1 + dict_get_db_name_len(
old_name));
ut_memcpy(db_name, old_name, dict_get_db_name_len(old_name));
db_name[dict_get_db_name_len(old_name)] = '\0';
/* Internally, old format < 4.0.18 constraints have as the
constraint id <number>_<number>, while new format constraints
have <databasename>/<constraintname>. */
for (i = 0; i < n_constraints_to_drop; i++) { for (i = 0; i < n_constraints_to_drop; i++) {
sprintf(str3 + strlen(str3),
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s/%s';\n"
"DELETE FROM SYS_FOREIGN WHERE ID = '%s/%s';\n",
db_name, constraints_to_drop[i],
db_name, constraints_to_drop[i]);
if (!ut_str_contains(constraints_to_drop[i], '/')) {
/* If this happens to be an old format
constraint, let us delete it. Since all new
format constraints contain '/', it does no
harm to run these DELETEs anyway. */
sprintf(str3 + strlen(str3), sprintf(str3 + strlen(str3),
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n" "DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n"
"DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n", "DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n",
constraints_to_drop[i], constraints_to_drop[i],
constraints_to_drop[i]); constraints_to_drop[i]);
} }
}
sprintf(str3 + strlen(str3), sprintf(str3 + strlen(str3),
"END;\n"); "END;\n");
ut_a(strlen(str3) < 1000 + 500 * n_constraints_to_drop); ut_a(strlen(str3) < 1000 + 1000 * n_constraints_to_drop);
} else { } else {
str3 = (char*) str3 = (char*)
"';\n" "';\n"
"UPDATE SYS_TABLES SET NAME = new_table_name\n" "UPDATE SYS_TABLES SET NAME = new_table_name\n"
"WHERE NAME = old_table_name;\n" "WHERE NAME = old_table_name;\n"
"UPDATE SYS_FOREIGN SET FOR_NAME = new_table_name\n" "found := 1;\n"
"WHERE FOR_NAME = old_table_name;\n" "old_db_name_len := INSTR(old_table_name, '/') - 1;\n"
"new_db_name_len := INSTR(new_table_name, '/') - 1;\n"
"new_db_name := SUBSTR(new_table_name, 0, new_db_name_len);\n"
"old_t_name_len := LENGTH(old_table_name);\n"
"gen_constr_prefix := CONCAT(old_table_name, '_ibfk_');\n"
"WHILE found = 1 LOOP\n"
" SELECT ID INTO foreign_id\n"
" FROM SYS_FOREIGN\n"
" WHERE FOR_NAME = old_table_name;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSE\n"
" UPDATE SYS_FOREIGN\n"
" SET FOR_NAME = new_table_name\n"
" WHERE ID = foreign_id;\n"
" id_len := LENGTH(foreign_id);\n"
" IF (INSTR(foreign_id, '/') > 0) THEN\n"
" IF (INSTR(foreign_id,\n"
" gen_constr_prefix) > 0)\n"
" THEN\n"
" new_foreign_id :=\n"
" CONCAT(new_table_name,\n"
" SUBSTR(foreign_id, old_t_name_len,\n"
" id_len - old_t_name_len));\n"
" ELSE\n"
" new_foreign_id :=\n"
" CONCAT(new_db_name,\n"
" SUBSTR(foreign_id,\n"
" old_db_name_len,\n"
" id_len - old_db_name_len));\n"
" END IF;\n"
" UPDATE SYS_FOREIGN\n"
" SET ID = new_foreign_id\n"
" WHERE ID = foreign_id;\n"
" UPDATE SYS_FOREIGN_COLS\n"
" SET ID = new_foreign_id\n"
" WHERE ID = foreign_id;\n"
" END IF;\n"
" END IF;\n"
"END LOOP;\n"
"UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n" "UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n"
"WHERE REF_NAME = old_table_name;\n" "WHERE REF_NAME = old_table_name;\n"
"END;\n"; "END;\n";
......
...@@ -159,7 +159,7 @@ struct sync_thread_struct{ ...@@ -159,7 +159,7 @@ struct sync_thread_struct{
}; };
/* Number of slots reserved for each OS thread in the sync level array */ /* Number of slots reserved for each OS thread in the sync level array */
#define SYNC_THREAD_N_LEVELS 250 #define SYNC_THREAD_N_LEVELS 10000
struct sync_level_struct{ struct sync_level_struct{
void* latch; /* pointer to a mutex or an rw-lock; NULL means that void* latch; /* pointer to a mutex or an rw-lock; NULL means that
......
...@@ -221,3 +221,27 @@ ut_str_catenate( ...@@ -221,3 +221,27 @@ ut_str_catenate(
return(str); return(str);
} }
/**************************************************************************
Checks if a null-terminated string contains a certain character. */
ibool
ut_str_contains(
/*============*/
char* str, /* in: null-terminated string */
char c) /* in: character */
{
ulint len;
ulint i;
len = ut_strlen(str);
for (i = 0; i < len; i++) {
if (str[i] == c) {
return(TRUE);
}
}
return(FALSE);
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -350,3 +350,24 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE ...@@ -350,3 +350,24 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1; DROP TABLE t1;
create table t1 (name char(15));
insert into t1 (name) values ("current");
create database mysqltest;
create table mysqltest.t1 (name char(15));
insert into mysqltest.t1 (name) values ("mysqltest");
select * from t1;
name
current
select * from mysqltest.t1;
name
mysqltest
alter table t1 rename mysqltest.t1;
Table 't1' already exists
select * from t1;
name
current
select * from mysqltest.t1;
name
mysqltest
drop table t1;
drop database mysqltest;
...@@ -41,3 +41,21 @@ pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) ...@@ -41,3 +41,21 @@ pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1)
select degrees(pi()),radians(360); select degrees(pi()),radians(360);
degrees(pi()) radians(360) degrees(pi()) radians(360)
180 6.2831853071796 180 6.2831853071796
SELECT ACOS(1.0);
ACOS(1.0)
0.000000
SELECT ASIN(1.0);
ASIN(1.0)
1.570796
SELECT ACOS(0.2*5.0);
ACOS(0.2*5.0)
0.000000
SELECT ACOS(0.5*2.0);
ACOS(0.5*2.0)
0.000000
SELECT ASIN(0.8+0.2);
ASIN(0.8+0.2)
1.570796
SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2)
1.570796
...@@ -592,3 +592,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE ...@@ -592,3 +592,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121); INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1; INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1(
Month date NOT NULL,
Type tinyint(3) unsigned NOT NULL auto_increment,
Field int(10) unsigned NOT NULL,
Count int(10) unsigned NOT NULL,
UNIQUE KEY Month (Month,Type,Field)
);
insert into t1 Values
(20030901, 1, 1, 100),
(20030901, 1, 2, 100),
(20030901, 2, 1, 100),
(20030901, 2, 2, 100),
(20030901, 3, 1, 100);
select * from t1;
Month Type Field Count
2003-09-01 1 1 100
2003-09-01 1 2 100
2003-09-01 2 1 100
2003-09-01 2 2 100
2003-09-01 3 1 100
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
NULL Field Count
NULL 1 100
NULL 2 100
create table t2(No int not null, Field int not null, Count int not null);
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
select * from t2;
No Field Count
0 1 100
0 2 100
drop table t1, t2;
...@@ -54,6 +54,12 @@ insert into t1 values ("abirvalg"); ...@@ -54,6 +54,12 @@ insert into t1 values ("abirvalg");
SET INSERT_ID=1; SET INSERT_ID=1;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
insert into t2 values (); insert into t2 values ();
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
insert into t1 values ("Alas"); insert into t1 values ("Alas");
...@@ -63,18 +69,7 @@ SET TIMESTAMP=1000000000; ...@@ -63,18 +69,7 @@ SET TIMESTAMP=1000000000;
insert into t1 values ("Alas"); insert into t1 values ("Alas");
--- --database -- --- --database --
use test;
SET TIMESTAMP=1000000000;
create table t1 (word varchar(20));
SET TIMESTAMP=1000000000;
create table t2 (id int auto_increment not null primary key);
SET TIMESTAMP=1000000000;
insert into t1 values ("abirvalg");
SET INSERT_ID=1; SET INSERT_ID=1;
SET TIMESTAMP=1000000000;
insert into t2 values ();
SET TIMESTAMP=1000000000;
insert into t1 values ("Alas");
--- --position -- --- --position --
use test; use test;
......
create database test_raid; create database test_raid;
create table test_raid.r1 (i int) raid_type=1; create table test_raid.r1 (i int) raid_type=1;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=32;
drop database test_raid; drop database test_raid;
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
......
select * from mysql.user as t1, mysql.user as t2, mysql.user as t3, mysql.user as t4, mysql.user as t5, mysql.user as t6, mysql.user as t7, mysql.user as t8;
\ No newline at end of file
...@@ -204,3 +204,20 @@ LOCK TABLES t1 WRITE; ...@@ -204,3 +204,20 @@ LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #2628: 'alter table t1 rename mysqltest.t1' silently drops mysqltest.t1
# if it exists
#
create table t1 (name char(15));
insert into t1 (name) values ("current");
create database mysqltest;
create table mysqltest.t1 (name char(15));
insert into mysqltest.t1 (name) values ("mysqltest");
select * from t1;
select * from mysqltest.t1;
--error 1050
alter table t1 rename mysqltest.t1;
select * from t1;
select * from mysqltest.t1;
drop table t1;
drop database mysqltest;
...@@ -17,3 +17,14 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000; ...@@ -17,3 +17,14 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand(); select rand(999999),rand();
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
select degrees(pi()),radians(360); select degrees(pi()),radians(360);
#
# Bug #2338 Trignometric arithmatic problems
#
SELECT ACOS(1.0);
SELECT ASIN(1.0);
SELECT ACOS(0.2*5.0);
SELECT ACOS(0.5*2.0);
SELECT ASIN(0.8+0.2);
SELECT ASIN(1.2-0.2);
--init-file=$MYSQL_TEST_DIR/std_data/init_file.dat
#
# This is a regression test for bug #2526 "--init-file crashes MySQL if it
# contains a large select"
#
# See mysql-test/std_data/init_file.dat and
# mysql-test/t/init_file-master.opt for the actual test
#
...@@ -132,3 +132,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE ...@@ -132,3 +132,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121); INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1; INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2; drop table t1,t2;
#
# Another problem from Bug #2012
#
CREATE TABLE t1(
Month date NOT NULL,
Type tinyint(3) unsigned NOT NULL auto_increment,
Field int(10) unsigned NOT NULL,
Count int(10) unsigned NOT NULL,
UNIQUE KEY Month (Month,Type,Field)
);
insert into t1 Values
(20030901, 1, 1, 100),
(20030901, 1, 2, 100),
(20030901, 2, 1, 100),
(20030901, 2, 2, 100),
(20030901, 3, 1, 100);
select * from t1;
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
create table t2(No int not null, Field int not null, Count int not null);
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
select * from t2;
drop table t1, t2;
...@@ -64,10 +64,6 @@ select "--- --position --" as ""; ...@@ -64,10 +64,6 @@ select "--- --position --" as "";
# These are tests for remote binlog. # These are tests for remote binlog.
# They should return the same as previous test. # They should return the same as previous test.
# But now they are not. V. Vagin should fix this.
# We test all the same options second time since code for remote case is
# essentially different. If code for both cases will be unified we'll be
# able to throw out most of this.
--disable_query_log --disable_query_log
select "--- Remote --" as ""; select "--- Remote --" as "";
......
...@@ -9,6 +9,7 @@ enable_query_log; ...@@ -9,6 +9,7 @@ enable_query_log;
create database test_raid; create database test_raid;
create table test_raid.r1 (i int) raid_type=1; create table test_raid.r1 (i int) raid_type=1;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=32;
drop database test_raid; drop database test_raid;
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
......
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
...@@ -539,7 +539,7 @@ innobase_query_caching_of_table_permitted( ...@@ -539,7 +539,7 @@ innobase_query_caching_of_table_permitted(
if (thd->variables.tx_isolation == ISO_SERIALIZABLE) { if (thd->variables.tx_isolation == ISO_SERIALIZABLE) {
/* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every /* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every
plain SELECT */ plain SELECT if AUTOCOMMIT is not on. */
return((my_bool)FALSE); return((my_bool)FALSE);
} }
...@@ -4483,11 +4483,17 @@ ha_innobase::external_lock( ...@@ -4483,11 +4483,17 @@ ha_innobase::external_lock(
} }
if (trx->isolation_level == TRX_ISO_SERIALIZABLE if (trx->isolation_level == TRX_ISO_SERIALIZABLE
&& prebuilt->select_lock_type == LOCK_NONE) { && prebuilt->select_lock_type == LOCK_NONE
&& (thd->options
& (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
/* To get serializable execution we let InnoDB /* To get serializable execution, we let InnoDB
conceptually add 'LOCK IN SHARE MODE' to all SELECTs conceptually add 'LOCK IN SHARE MODE' to all SELECTs
which otherwise would have been consistent reads */ which otherwise would have been consistent reads. An
exception is consistent reads in the AUTOCOMMIT=1 mode:
we know that they are read-only transactions, and they
can be serialized also if performed as consistent
reads. */
prebuilt->select_lock_type = LOCK_S; prebuilt->select_lock_type = LOCK_S;
} }
......
...@@ -551,7 +551,8 @@ double Item_func_pow::val() ...@@ -551,7 +551,8 @@ double Item_func_pow::val()
double Item_func_acos::val() double Item_func_acos::val()
{ {
double value=args[0]->val(); // the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0; return 0.0;
return fix_result(acos(value)); return fix_result(acos(value));
...@@ -559,7 +560,8 @@ double Item_func_acos::val() ...@@ -559,7 +560,8 @@ double Item_func_acos::val()
double Item_func_asin::val() double Item_func_asin::val()
{ {
double value=args[0]->val(); // the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0; return 0.0;
return fix_result(asin(value)); return fix_result(asin(value));
......
...@@ -1189,7 +1189,7 @@ Load_log_event::Load_log_event(THD* thd_arg, sql_exchange* ex, ...@@ -1189,7 +1189,7 @@ Load_log_event::Load_log_event(THD* thd_arg, sql_exchange* ex,
num_fields(0),fields(0), num_fields(0),fields(0),
field_lens(0),field_block_len(0), field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""), table_name(table_name_arg ? table_name_arg : ""),
db(db_arg), fname(ex->file_name) db(db_arg), fname(ex->file_name), local_fname(FALSE)
{ {
time_t end_time; time_t end_time;
time(&end_time); time(&end_time);
...@@ -1265,7 +1265,7 @@ Load_log_event::Load_log_event(const char* buf, int event_len, ...@@ -1265,7 +1265,7 @@ Load_log_event::Load_log_event(const char* buf, int event_len,
bool old_format) bool old_format)
:Log_event(buf, old_format),num_fields(0),fields(0), :Log_event(buf, old_format),num_fields(0),fields(0),
field_lens(0),field_block_len(0), field_lens(0),field_block_len(0),
table_name(0),db(0),fname(0) table_name(0),db(0),fname(0),local_fname(FALSE)
{ {
if (!event_len) // derived class, will call copy_log_event() itself if (!event_len) // derived class, will call copy_log_event() itself
return; return;
......
...@@ -411,17 +411,19 @@ public: ...@@ -411,17 +411,19 @@ public:
const char* fname; const char* fname;
uint32 skip_lines; uint32 skip_lines;
sql_ex_info sql_ex; sql_ex_info sql_ex;
bool local_fname;
/* fname doesn't point to memory inside Log_event::temp_buf */ /* fname doesn't point to memory inside Log_event::temp_buf */
void set_fname_outside_temp_buf(const char *afname, uint alen) void set_fname_outside_temp_buf(const char *afname, uint alen)
{ {
fname= afname; fname= afname;
fname_len= alen; fname_len= alen;
local_fname= true;
} }
/* fname doesn't point to memory inside Log_event::temp_buf */ /* fname doesn't point to memory inside Log_event::temp_buf */
int check_fname_outside_temp_buf() int check_fname_outside_temp_buf()
{ {
return fname < temp_buf || fname > temp_buf+ cached_event_len; return local_fname;
} }
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
......
...@@ -495,6 +495,8 @@ bool select_send::send_data(List<Item> &items) ...@@ -495,6 +495,8 @@ bool select_send::send_data(List<Item> &items)
} }
} }
thd->sent_row_count++; thd->sent_row_count++;
if (!thd->net.vio)
DBUG_RETURN(0);
bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length()); bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length());
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -219,7 +219,7 @@ exit2: ...@@ -219,7 +219,7 @@ exit2:
/* /*
Removes files with known extensions plus all found subdirectories that Removes files with known extensions plus all found subdirectories that
are 2 digits (raid directories). are 2 hex digits (raid directories).
thd MUST be set when calling this function! thd MUST be set when calling this function!
*/ */
...@@ -245,7 +245,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, ...@@ -245,7 +245,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
DBUG_PRINT("info",("Examining: %s", file->name)); DBUG_PRINT("info",("Examining: %s", file->name));
/* Check if file is a raid directory */ /* Check if file is a raid directory */
if (isdigit(file->name[0]) && isdigit(file->name[1]) && if ((isdigit(file->name[0]) ||
(file->name[0] >= 'a' && file->name[0] <= 'f')) &&
(isdigit(file->name[1]) ||
(file->name[1] >= 'a' && file->name[1] <= 'f')) &&
!file->name[2] && !level) !file->name[2] && !level)
{ {
char newpath[FN_REFLEN]; char newpath[FN_REFLEN];
......
...@@ -2596,9 +2596,15 @@ store_val_in_field(Field *field,Item *item) ...@@ -2596,9 +2596,15 @@ store_val_in_field(Field *field,Item *item)
bool error; bool error;
THD *thd=current_thd; THD *thd=current_thd;
ha_rows cuted_fields=thd->cuted_fields; ha_rows cuted_fields=thd->cuted_fields;
/*
we should restore old value of count_cuted_fields because
store_val_in_field can be called from mysql_insert
with select_insert, which make count_cuted_fields= 1
*/
bool old_count_cuted_fields= thd->count_cuted_fields;
thd->count_cuted_fields=1; thd->count_cuted_fields=1;
error= item->save_in_field(field, 1); error= item->save_in_field(field, 1);
thd->count_cuted_fields=0; thd->count_cuted_fields= old_count_cuted_fields;
return error || cuted_fields != thd->cuted_fields; return error || cuted_fields != thd->cuted_fields;
} }
...@@ -2823,6 +2829,8 @@ make_join_readinfo(JOIN *join,uint options) ...@@ -2823,6 +2829,8 @@ make_join_readinfo(JOIN *join,uint options)
{ {
uint i; uint i;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex); SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
bool statistics= test(!(join->select_options & SELECT_DESCRIBE));
DBUG_ENTER("make_join_readinfo"); DBUG_ENTER("make_join_readinfo");
for (i=join->const_tables ; i < join->tables ; i++) for (i=join->const_tables ; i < join->tables ; i++)
...@@ -2907,6 +2915,7 @@ make_join_readinfo(JOIN *join,uint options) ...@@ -2907,6 +2915,7 @@ make_join_readinfo(JOIN *join,uint options)
{ {
select_lex->options|=QUERY_NO_GOOD_INDEX_USED; select_lex->options|=QUERY_NO_GOOD_INDEX_USED;
tab->read_first_record= join_init_quick_read_record; tab->read_first_record= join_init_quick_read_record;
if (statistics)
statistic_increment(select_range_check_count, &LOCK_status); statistic_increment(select_range_check_count, &LOCK_status);
} }
else else
...@@ -2916,11 +2925,13 @@ make_join_readinfo(JOIN *join,uint options) ...@@ -2916,11 +2925,13 @@ make_join_readinfo(JOIN *join,uint options)
{ {
if (tab->select && tab->select->quick) if (tab->select && tab->select->quick)
{ {
if (statistics)
statistic_increment(select_range_count, &LOCK_status); statistic_increment(select_range_count, &LOCK_status);
} }
else else
{ {
select_lex->options|=QUERY_NO_INDEX_USED; select_lex->options|=QUERY_NO_INDEX_USED;
if (statistics)
statistic_increment(select_scan_count, &LOCK_status); statistic_increment(select_scan_count, &LOCK_status);
} }
} }
...@@ -2928,11 +2939,13 @@ make_join_readinfo(JOIN *join,uint options) ...@@ -2928,11 +2939,13 @@ make_join_readinfo(JOIN *join,uint options)
{ {
if (tab->select && tab->select->quick) if (tab->select && tab->select->quick)
{ {
if (statistics)
statistic_increment(select_full_range_join_count, &LOCK_status); statistic_increment(select_full_range_join_count, &LOCK_status);
} }
else else
{ {
select_lex->options|=QUERY_NO_INDEX_USED; select_lex->options|=QUERY_NO_INDEX_USED;
if (statistics)
statistic_increment(select_full_join_count, &LOCK_status); statistic_increment(select_full_join_count, &LOCK_status);
} }
} }
......
...@@ -1478,8 +1478,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1478,8 +1478,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
alias= (lower_case_table_names == 2) ? table_list->alias : table_name; alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
db=table_list->db; db=table_list->db;
if (!new_db || !strcmp(new_db,db)) if (!new_db ||
new_db=db; lower_case_table_names && !my_strcasecmp(new_db, db) ||
!lower_case_table_names && !strcmp(new_db, db))
{
new_db= db;
}
used_fields=create_info->used_fields; used_fields=create_info->used_fields;
mysql_ha_closeall(thd, table_list); mysql_ha_closeall(thd, table_list);
...@@ -1491,7 +1495,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1491,7 +1495,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{ {
strmov(new_name_buff,new_name); strmov(new_name_buff,new_name);
strmov(new_alias= new_alias_buff, new_name); strmov(new_alias= new_alias_buff, new_name);
fn_same(new_name_buff,table_name,3);
if (lower_case_table_names) if (lower_case_table_names)
{ {
if (lower_case_table_names != 2) if (lower_case_table_names != 2)
...@@ -1501,11 +1504,18 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1501,11 +1504,18 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
} }
casedn_str(new_name); casedn_str(new_name);
} }
if ((lower_case_table_names && if (new_db == db &&
!my_strcasecmp(new_name_buff,table_name)) || (lower_case_table_names &&
(!lower_case_table_names && !my_strcasecmp(new_name_buff,table_name) ||
!lower_case_table_names &&
!strcmp(new_name_buff,table_name))) !strcmp(new_name_buff,table_name)))
new_alias= new_name= table_name; // No change. Make later check easier {
/*
Source and destination table names are equal: make later check
easier.
*/
new_alias= new_name= table_name;
}
else else
{ {
if (table->tmp_table) if (table->tmp_table)
......
...@@ -116,6 +116,7 @@ void udf_init() ...@@ -116,6 +116,7 @@ void udf_init()
udf_func *tmp; udf_func *tmp;
TABLE_LIST tables; TABLE_LIST tables;
READ_RECORD read_record_info; READ_RECORD read_record_info;
TABLE *table;
int error; int error;
DBUG_ENTER("ufd_init"); DBUG_ENTER("ufd_init");
...@@ -148,13 +149,11 @@ void udf_init() ...@@ -148,13 +149,11 @@ void udf_init()
if (open_and_lock_tables(new_thd, &tables)) if (open_and_lock_tables(new_thd, &tables))
{ {
DBUG_PRINT("error",("Can't open udf table")); DBUG_PRINT("error",("Can't open udf table"));
sql_print_error("Can't open mysql/func table"); sql_print_error("Can't open the mysql/func table. Please run the mysql_install_db script to create it.");
close_thread_tables(new_thd); goto end;
delete new_thd;
DBUG_VOID_RETURN;
} }
TABLE *table = tables.table; table= tables.table;
init_read_record(&read_record_info, new_thd, table, NULL,1,0); init_read_record(&read_record_info, new_thd, table, NULL,1,0);
while (!(error = read_record_info.read_record(&read_record_info))) while (!(error = read_record_info.read_record(&read_record_info)))
{ {
...@@ -200,6 +199,8 @@ void udf_init() ...@@ -200,6 +199,8 @@ void udf_init()
sql_print_error(ER(ER_GET_ERRNO), my_errno); sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info); end_read_record(&read_record_info);
new_thd->version--; // Force close to free memory new_thd->version--; // Force close to free memory
end:
close_thread_tables(new_thd); close_thread_tables(new_thd);
delete new_thd; delete new_thd;
/* Remember that we don't have a THD */ /* Remember that we don't have a THD */
......
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