Skip to content

Commit da60b60

Browse files
author
brian@zim.(none)
committed
Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.0
into zim.(none):/home/brian/mysql/mysql-5.0
2 parents d5c90ef + 63bac8c commit da60b60

14 files changed

+329
-99
lines changed

client/mysqldump.c

+78-70
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static struct my_option my_long_options[] =
386386
(gptr*) &opt_dump_triggers, (gptr*) &opt_dump_triggers, 0, GET_BOOL,
387387
NO_ARG, 1, 0, 0, 0, 0, 0},
388388
{"tz-utc", OPT_TZ_UTC,
389-
"SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data between servers with different time zones.",
389+
"SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.",
390390
(gptr*) &opt_tz_utc, (gptr*) &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
391391
#ifndef DONT_ALLOW_USER_CHANGE
392392
{"user", 'u', "User for login if not current user.",
@@ -1328,17 +1328,17 @@ static uint dump_routines_for_db(char *db)
13281328
static uint get_table_structure(char *table, char *db, char *table_type,
13291329
char *ignore_flag)
13301330
{
1331-
MYSQL_RES *tableRes;
1332-
MYSQL_ROW row;
13331331
my_bool init=0, delayed, write_data, complete_insert;
1334-
uint num_fields;
1332+
my_ulonglong num_fields;
13351333
char *result_table, *opt_quoted_table;
13361334
const char *insert_option;
13371335
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
1338-
char table_buff2[NAME_LEN*2+3];
1339-
char query_buff[512];
1336+
char table_buff2[NAME_LEN*2+3], query_buff[512];
13401337
FILE *sql_file = md_result_file;
13411338
int len;
1339+
MYSQL_RES *result;
1340+
MYSQL_ROW row;
1341+
13421342
DBUG_ENTER("get_table_structure");
13431343
DBUG_PRINT("enter", ("db: %s table: %s", db, table));
13441344

@@ -1424,71 +1424,79 @@ static uint get_table_structure(char *table, char *db, char *table_type,
14241424
check_io(sql_file);
14251425
}
14261426

1427-
tableRes= mysql_store_result(sock);
1428-
field= mysql_fetch_field_direct(tableRes, 0);
1427+
result= mysql_store_result(sock);
1428+
field= mysql_fetch_field_direct(result, 0);
14291429
if (strcmp(field->name, "View") == 0)
14301430
{
14311431
if (verbose)
14321432
fprintf(stderr, "-- It's a view, create dummy table for view\n");
14331433

1434-
mysql_free_result(tableRes);
1434+
mysql_free_result(result);
14351435

1436-
/* Create a dummy table for the view. ie. a table which has the
1437-
same columns as the view should have. This table is dropped
1438-
just before the view is created. The table is used to handle the
1439-
case where a view references another view, which hasn't yet been
1440-
created(during the load of the dump). BUG#10927 */
1436+
/*
1437+
Create a table with the same name as the view and with columns of
1438+
the same name in order to satisfy views that depend on this view.
1439+
The table will be removed when the actual view is created.
14411440
1442-
/* Create temp table by selecting from the view */
1441+
The properties of each column, aside from the data type, are not
1442+
preserved in this temporary table, because they are not necessary.
1443+
1444+
This will not be necessary once we can determine dependencies
1445+
between views and can simply dump them in the appropriate order.
1446+
*/
14431447
my_snprintf(query_buff, sizeof(query_buff),
1444-
"CREATE TEMPORARY TABLE %s SELECT * FROM %s WHERE 0",
1445-
result_table, result_table);
1448+
"SHOW FIELDS FROM %s", result_table);
14461449
if (mysql_query_with_error_report(sock, 0, query_buff))
14471450
{
14481451
safe_exit(EX_MYSQLERR);
14491452
DBUG_RETURN(0);
14501453
}
14511454

1452-
/* Get CREATE statement for the temp table */
1453-
my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE TABLE %s",
1454-
result_table);
1455-
if (mysql_query_with_error_report(sock, 0, query_buff))
1455+
if ((result= mysql_store_result(sock)))
14561456
{
1457-
safe_exit(EX_MYSQLERR);
1458-
DBUG_RETURN(0);
1459-
}
1460-
tableRes= mysql_store_result(sock);
1461-
row= mysql_fetch_row(tableRes);
1462-
1463-
if (opt_drop)
1464-
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
1465-
opt_quoted_table);
1466-
1467-
/* Print CREATE statement but remove TEMPORARY */
1468-
fprintf(sql_file, "/*!50001 CREATE %s*/;\n", row[1]+17);
1469-
check_io(sql_file);
1470-
1471-
mysql_free_result(tableRes);
1457+
if (mysql_num_rows(result))
1458+
{
1459+
if (opt_drop)
1460+
{
1461+
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
1462+
opt_quoted_table);
1463+
check_io(sql_file);
1464+
}
14721465

1473-
/* Drop the temp table */
1474-
my_snprintf(buff, sizeof(buff),
1475-
"DROP TEMPORARY TABLE %s", result_table);
1476-
if (mysql_query_with_error_report(sock, 0, buff))
1477-
{
1478-
safe_exit(EX_MYSQLERR);
1479-
DBUG_RETURN(0);
1466+
fprintf(sql_file, "/*!50001 CREATE TABLE %s (\n", result_table);
1467+
/*
1468+
Get first row, following loop will prepend comma - keeps
1469+
from having to know if the row being printed is last to
1470+
determine if there should be a _trailing_ comma.
1471+
*/
1472+
row= mysql_fetch_row(result);
1473+
1474+
fprintf(sql_file, " %s %s", quote_name(row[0], name_buff, 0), row[1]);
1475+
1476+
while((row= mysql_fetch_row(result)))
1477+
{
1478+
/* col name, col type */
1479+
fprintf(sql_file, ",\n %s %s",
1480+
quote_name(row[0], name_buff, 0), row[1]);
1481+
}
1482+
fprintf(sql_file, "\n) */;\n");
1483+
check_io(sql_file);
1484+
}
14801485
}
1486+
mysql_free_result(result);
1487+
14811488
was_views= 1;
14821489
DBUG_RETURN(0);
14831490
}
1484-
row= mysql_fetch_row(tableRes);
1491+
1492+
row= mysql_fetch_row(result);
14851493
fprintf(sql_file, "%s;\n", row[1]);
14861494
check_io(sql_file);
1487-
mysql_free_result(tableRes);
1495+
mysql_free_result(result);
14881496
}
14891497
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
14901498
result_table);
1491-
if (mysql_query_with_error_report(sock, &tableRes, query_buff))
1499+
if (mysql_query_with_error_report(sock, &result, query_buff))
14921500
{
14931501
if (path)
14941502
my_fclose(sql_file, MYF(MY_WME));
@@ -1520,7 +1528,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
15201528
}
15211529
}
15221530

1523-
while ((row=mysql_fetch_row(tableRes)))
1531+
while ((row= mysql_fetch_row(result)))
15241532
{
15251533
if (complete_insert)
15261534
{
@@ -1533,8 +1541,8 @@ static uint get_table_structure(char *table, char *db, char *table_type,
15331541
quote_name(row[SHOW_FIELDNAME], name_buff, 0));
15341542
}
15351543
}
1536-
num_fields= (uint) mysql_num_rows(tableRes);
1537-
mysql_free_result(tableRes);
1544+
num_fields= mysql_num_rows(result);
1545+
mysql_free_result(result);
15381546
}
15391547
else
15401548
{
@@ -1545,7 +1553,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
15451553

15461554
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
15471555
result_table);
1548-
if (mysql_query_with_error_report(sock, &tableRes, query_buff))
1556+
if (mysql_query_with_error_report(sock, &result, query_buff))
15491557
{
15501558
safe_exit(EX_MYSQLERR);
15511559
DBUG_RETURN(0);
@@ -1595,9 +1603,9 @@ static uint get_table_structure(char *table, char *db, char *table_type,
15951603
}
15961604
}
15971605

1598-
while ((row=mysql_fetch_row(tableRes)))
1606+
while ((row= mysql_fetch_row(result)))
15991607
{
1600-
ulong *lengths=mysql_fetch_lengths(tableRes);
1608+
ulong *lengths= mysql_fetch_lengths(result);
16011609
if (init)
16021610
{
16031611
if (!opt_xml && !tFlag)
@@ -1616,7 +1624,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
16161624
{
16171625
if (opt_xml)
16181626
{
1619-
print_xml_row(sql_file, "field", tableRes, &row);
1627+
print_xml_row(sql_file, "field", result, &row);
16201628
continue;
16211629
}
16221630

@@ -1640,15 +1648,15 @@ static uint get_table_structure(char *table, char *db, char *table_type,
16401648
check_io(sql_file);
16411649
}
16421650
}
1643-
num_fields = (uint) mysql_num_rows(tableRes);
1644-
mysql_free_result(tableRes);
1651+
num_fields= mysql_num_rows(result);
1652+
mysql_free_result(result);
16451653
if (!tFlag)
16461654
{
16471655
/* Make an sql-file, if path was given iow. option -T was given */
16481656
char buff[20+FN_REFLEN];
16491657
uint keynr,primary_key;
16501658
my_snprintf(buff, sizeof(buff), "show keys from %s", result_table);
1651-
if (mysql_query_with_error_report(sock, &tableRes, buff))
1659+
if (mysql_query_with_error_report(sock, &result, buff))
16521660
{
16531661
if (mysql_errno(sock) == ER_WRONG_OBJECT)
16541662
{
@@ -1667,7 +1675,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
16671675
/* Find first which key is primary key */
16681676
keynr=0;
16691677
primary_key=INT_MAX;
1670-
while ((row=mysql_fetch_row(tableRes)))
1678+
while ((row= mysql_fetch_row(result)))
16711679
{
16721680
if (atoi(row[3]) == 1)
16731681
{
@@ -1683,13 +1691,13 @@ static uint get_table_structure(char *table, char *db, char *table_type,
16831691
}
16841692
}
16851693
}
1686-
mysql_data_seek(tableRes,0);
1694+
mysql_data_seek(result,0);
16871695
keynr=0;
1688-
while ((row=mysql_fetch_row(tableRes)))
1696+
while ((row= mysql_fetch_row(result)))
16891697
{
16901698
if (opt_xml)
16911699
{
1692-
print_xml_row(sql_file, "key", tableRes, &row);
1700+
print_xml_row(sql_file, "key", result, &row);
16931701
continue;
16941702
}
16951703

@@ -1730,7 +1738,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
17301738
my_snprintf(buff, sizeof(buff), "show table status like %s",
17311739
quote_for_like(table, show_name_buff));
17321740

1733-
if (mysql_query_with_error_report(sock, &tableRes, buff))
1741+
if (mysql_query_with_error_report(sock, &result, buff))
17341742
{
17351743
if (mysql_errno(sock) != ER_PARSE_ERROR)
17361744
{ /* If old MySQL version */
@@ -1740,7 +1748,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
17401748
result_table,mysql_error(sock));
17411749
}
17421750
}
1743-
else if (!(row=mysql_fetch_row(tableRes)))
1751+
else if (!(row= mysql_fetch_row(result)))
17441752
{
17451753
fprintf(stderr,
17461754
"Error: Couldn't read status information for table %s (%s)\n",
@@ -1749,18 +1757,18 @@ static uint get_table_structure(char *table, char *db, char *table_type,
17491757
else
17501758
{
17511759
if (opt_xml)
1752-
print_xml_row(sql_file, "options", tableRes, &row);
1760+
print_xml_row(sql_file, "options", result, &row);
17531761
else
17541762
{
17551763
fputs("/*!",sql_file);
1756-
print_value(sql_file,tableRes,row,"engine=","Engine",0);
1757-
print_value(sql_file,tableRes,row,"","Create_options",0);
1758-
print_value(sql_file,tableRes,row,"comment=","Comment",1);
1764+
print_value(sql_file,result,row,"engine=","Engine",0);
1765+
print_value(sql_file,result,row,"","Create_options",0);
1766+
print_value(sql_file,result,row,"comment=","Comment",1);
17591767
fputs(" */",sql_file);
17601768
check_io(sql_file);
17611769
}
17621770
}
1763-
mysql_free_result(tableRes); /* Is always safe to free */
1771+
mysql_free_result(result); /* Is always safe to free */
17641772
}
17651773
continue_xml:
17661774
if (!opt_xml)
@@ -1827,7 +1835,7 @@ static void dump_triggers_for_table (char *table, char *db)
18271835
if (mysql_num_rows(result))
18281836
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
18291837
DELIMITER ;;\n");
1830-
while ((row=mysql_fetch_row(result)))
1838+
while ((row= mysql_fetch_row(result)))
18311839
{
18321840
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n\
18331841
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */;;\n\n",
@@ -2119,10 +2127,10 @@ static void dump_table(char *table, char *db)
21192127
check_io(md_result_file);
21202128
}
21212129

2122-
while ((row=mysql_fetch_row(res)))
2130+
while ((row= mysql_fetch_row(res)))
21232131
{
21242132
uint i;
2125-
ulong *lengths=mysql_fetch_lengths(res);
2133+
ulong *lengths= mysql_fetch_lengths(res);
21262134
rownr++;
21272135
if (!extended_insert && !opt_xml)
21282136
{

mysql-test/r/func_math.result

+27
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,30 @@ insert into t1 values (1);
170170
select rand(i) from t1;
171171
ERROR HY000: Incorrect arguments to RAND
172172
drop table t1;
173+
set sql_mode='traditional';
174+
select ln(-1);
175+
ln(-1)
176+
NULL
177+
Warnings:
178+
Error 1365 Division by 0
179+
select log10(-1);
180+
log10(-1)
181+
NULL
182+
Warnings:
183+
Error 1365 Division by 0
184+
select log2(-1);
185+
log2(-1)
186+
NULL
187+
Warnings:
188+
Error 1365 Division by 0
189+
select log(2,-1);
190+
log(2,-1)
191+
NULL
192+
Warnings:
193+
Error 1365 Division by 0
194+
select log(-2,1);
195+
log(-2,1)
196+
NULL
197+
Warnings:
198+
Error 1365 Division by 0
199+
set sql_mode='';

mysql-test/r/gis.result

+8
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,11 @@ select astext(fn3());
680680
astext(fn3())
681681
POINT(1 1)
682682
drop function fn3;
683+
create table t1(pt POINT);
684+
alter table t1 add primary key pti(pt);
685+
drop table t1;
686+
create table t1(pt GEOMETRY);
687+
alter table t1 add primary key pti(pt);
688+
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
689+
alter table t1 add primary key pti(pt(20));
690+
drop table t1;

0 commit comments

Comments
 (0)