Merge dfischer@bk-internal.mysql.com:/home/bk/mysql-4.1
into pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-4.1
This commit is contained in:
commit
ffe0e1b167
@ -818,3 +818,20 @@ a
|
||||
2
|
||||
1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
f1 int(10) unsigned NOT NULL auto_increment primary key,
|
||||
f2 varchar(100) NOT NULL default ''
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
f1 varchar(10) NOT NULL default '',
|
||||
f2 char(3) NOT NULL default '',
|
||||
PRIMARY KEY (`f1`),
|
||||
KEY `k1` (`f2`,`f1`)
|
||||
);
|
||||
INSERT INTO t1 values(NULL, '');
|
||||
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||
SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
avg(t2.f1)
|
||||
SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
avg(t2.f1)
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -690,3 +690,29 @@ CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 values (1), (2);
|
||||
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
f2 varchar(100) NOT NULL default ''
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
f1 varchar(10) NOT NULL default '',
|
||||
f2 char(3) NOT NULL default '',
|
||||
PRIMARY KEY (`f1`),
|
||||
KEY `k1` (`f2`, `f1`)
|
||||
);
|
||||
INSERT INTO t1 values(NULL, '');
|
||||
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
1
|
||||
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
min(t2.f1)
|
||||
INSERT INTO t1 (f2)
|
||||
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
1
|
||||
SELECT * FROM t1;
|
||||
f1 f2
|
||||
1
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -633,4 +633,27 @@ SELECT a FROM t1 ORDER BY 'a' DESC;
|
||||
SELECT a FROM t1 ORDER BY "a" DESC;
|
||||
SELECT a FROM t1 ORDER BY `a` DESC;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
#
|
||||
# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself
|
||||
# returns empty
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
f1 int(10) unsigned NOT NULL auto_increment primary key,
|
||||
f2 varchar(100) NOT NULL default ''
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
f1 varchar(10) NOT NULL default '',
|
||||
f2 char(3) NOT NULL default '',
|
||||
PRIMARY KEY (`f1`),
|
||||
KEY `k1` (`f2`,`f1`)
|
||||
);
|
||||
|
||||
INSERT INTO t1 values(NULL, '');
|
||||
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||
SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
@ -239,4 +239,32 @@ INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself returns empty
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (
|
||||
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
f2 varchar(100) NOT NULL default ''
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
f1 varchar(10) NOT NULL default '',
|
||||
f2 char(3) NOT NULL default '',
|
||||
PRIMARY KEY (`f1`),
|
||||
KEY `k1` (`f2`, `f1`)
|
||||
);
|
||||
|
||||
INSERT INTO t1 values(NULL, '');
|
||||
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||
SELECT COUNT(*) FROM t1;
|
||||
|
||||
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
|
||||
INSERT INTO t1 (f2)
|
||||
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||
|
||||
SELECT COUNT(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define SCHED_POLICY SCHED_OTHER
|
||||
#endif
|
||||
|
||||
uint thd_lib_detected;
|
||||
uint thd_lib_detected= 0;
|
||||
|
||||
#ifndef my_pthread_setprio
|
||||
void my_pthread_setprio(pthread_t thread_id,int prior)
|
||||
|
@ -19,13 +19,14 @@
|
||||
## 1.3 Applied patch provided by Martin Mokrejs <mmokrejs@natur.cuni.cz>
|
||||
## (General code cleanup, use the GRANT statement instead of updating
|
||||
## the privilege tables directly, added option to revoke privileges)
|
||||
## 1.4 Remove option 6 which attempted to erroneously grant global privileges
|
||||
|
||||
#### TODO
|
||||
#
|
||||
# empty ... suggestions ... mail them to me ...
|
||||
|
||||
|
||||
$version="1.3";
|
||||
$version="1.4";
|
||||
|
||||
use DBI;
|
||||
use Getopt::Long;
|
||||
@ -103,13 +104,9 @@ sub q1 { # first question ...
|
||||
print " existing database and host combination (user can do\n";
|
||||
print " SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,\n";
|
||||
print " LOCK TABLES,CREATE TEMPORARY TABLES)\n";
|
||||
print " 6. Create/append database administrative privileges for an\n";
|
||||
print " existing database and host combination (user can do\n";
|
||||
print " SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,\n";
|
||||
print " CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS)\n";
|
||||
print " 7. Create/append full privileges for an existing database\n";
|
||||
print " 6. Create/append full privileges for an existing database\n";
|
||||
print " and host combination (user has FULL privilege)\n";
|
||||
print " 8. Remove all privileges for for an existing database and\n";
|
||||
print " 7. Remove all privileges for for an existing database and\n";
|
||||
print " host combination.\n";
|
||||
print " (user will have all permission fields set to N)\n";
|
||||
print " 0. exit this program\n";
|
||||
@ -117,10 +114,10 @@ sub q1 { # first question ...
|
||||
while (<STDIN>) {
|
||||
$answer = $_;
|
||||
chomp($answer);
|
||||
if ($answer =~ /^[12345678]$/) {
|
||||
if ($answer =~ /^[1234567]$/) {
|
||||
if ($answer == 1) {
|
||||
setpwd();
|
||||
} elsif ($answer =~ /^[2345678]$/) {
|
||||
} elsif ($answer =~ /^[234567]$/) {
|
||||
addall($answer);
|
||||
} else {
|
||||
print "Sorry, something went wrong. With such option number you should not get here.\n\n";
|
||||
@ -233,7 +230,7 @@ sub addall {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( !$todo ) or not ( $todo =~ m/^[2-8]$/ ) ) {
|
||||
if ( ( !$todo ) or not ( $todo =~ m/^[2-7]$/ ) ) {
|
||||
print STDERR "Sorry, select option $todo isn't known inside the program .. See ya\n";
|
||||
quit();
|
||||
}
|
||||
@ -256,12 +253,9 @@ sub addall {
|
||||
# user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
|
||||
$sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
|
||||
} elsif ($todo == 6) {
|
||||
# admin privileges: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS
|
||||
$sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
|
||||
} elsif ($todo == 7) {
|
||||
# all privileges
|
||||
$sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
|
||||
} elsif ($todo == 8) {
|
||||
} elsif ($todo == 7) {
|
||||
# all privileges set to N
|
||||
$sth = $dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ character-set=latin1
|
||||
"NO",
|
||||
"YES",
|
||||
"Can't create file '%-.64s' (errno: %d)",
|
||||
"Can't create table '%-.64s' (errno: %d)",
|
||||
"Can't create table '%-.150s' (errno: %d)",
|
||||
"Can't create database '%-.64s' (errno: %d)",
|
||||
"Can't create database '%-.64s'; database exists",
|
||||
"Can't drop database '%-.64s'; database doesn't exist",
|
||||
@ -33,7 +33,7 @@ character-set=latin1
|
||||
"Can't get working directory (errno: %d)",
|
||||
"Can't lock file (errno: %d)",
|
||||
"Can't open file: '%-.64s' (errno: %d)",
|
||||
"Can't find file: '%-.64s' (errno: %d)",
|
||||
"Can't find file: '%-.150s' (errno: %d)",
|
||||
"Can't read dir of '%-.64s' (errno: %d)",
|
||||
"Can't change dir to '%-.64s' (errno: %d)",
|
||||
"Record has changed since last read in table '%-.64s'",
|
||||
@ -41,7 +41,7 @@ character-set=latin1
|
||||
"Can't write; duplicate key in table '%-.64s'",
|
||||
"Error on close of '%-.64s' (errno: %d)",
|
||||
"Error reading file '%-.64s' (errno: %d)",
|
||||
"Error on rename of '%-.64s' to '%-.64s' (errno: %d)",
|
||||
"Error on rename of '%-.107s' to '%-.107s' (errno: %d)",
|
||||
"Error writing file '%-.64s' (errno: %d)",
|
||||
"'%-.64s' is locked against change",
|
||||
"Sort aborted",
|
||||
|
@ -777,6 +777,7 @@ JOIN::optimize()
|
||||
order=0; // The output has only one row
|
||||
simple_order=1;
|
||||
select_distinct= 0; // No need in distinct for 1 row
|
||||
group_optimized_away= 1;
|
||||
}
|
||||
|
||||
calc_group_buffer(this, group_list);
|
||||
@ -6896,7 +6897,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
|
||||
if (!join->first_record || end_of_records ||
|
||||
(idx=test_if_group_changed(join->group_fields)) >= 0)
|
||||
{
|
||||
if (join->first_record || (end_of_records && !join->group))
|
||||
if (join->first_record ||
|
||||
(end_of_records && !join->group && !join->group_optimized_away))
|
||||
{
|
||||
if (join->procedure)
|
||||
join->procedure->end_group();
|
||||
|
@ -180,6 +180,14 @@ class JOIN :public Sql_alloc
|
||||
ROLLUP rollup; // Used with rollup
|
||||
|
||||
bool select_distinct; // Set if SELECT DISTINCT
|
||||
/*
|
||||
If we have the GROUP BY statement in the query,
|
||||
but the group_list was emptied by optimizer, this
|
||||
flag is TRUE.
|
||||
It happens when fields in the GROUP BY are from
|
||||
constant table
|
||||
*/
|
||||
bool group_optimized_away;
|
||||
|
||||
/*
|
||||
simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
|
||||
@ -276,6 +284,7 @@ class JOIN :public Sql_alloc
|
||||
ref_pointer_array_size= 0;
|
||||
zero_result_cause= 0;
|
||||
optimized= 0;
|
||||
group_optimized_away= 0;
|
||||
|
||||
fields_list= fields_arg;
|
||||
bzero((char*) &keyuse,sizeof(keyuse));
|
||||
|
Loading…
x
Reference in New Issue
Block a user