Commit a2e2099a authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

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

into narttu.mysql.fi:/my/mysql-4.0
parents be227009 b2769e27
...@@ -46,9 +46,12 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef, ...@@ -46,9 +46,12 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef,
for (j=length=0 ; j < keydef[i].keysegs; j++) for (j=length=0 ; j < keydef[i].keysegs; j++)
{ {
length+=keydef[i].seg[j].length; length+=keydef[i].seg[j].length;
if (keydef[i].seg[j].null_bit && if (keydef[i].seg[j].null_bit)
!(keydef[i].flag & HA_NULL_ARE_EQUAL)) {
keydef[i].flag |= HA_NULL_PART_KEY; length++;
if (!(keydef[i].flag & HA_NULL_ARE_EQUAL))
keydef[i].flag |= HA_NULL_PART_KEY;
}
} }
keydef[i].length=length; keydef[i].length=length;
if (length > max_length) if (length > max_length)
......
...@@ -778,29 +778,53 @@ trx_commit_off_kernel( ...@@ -778,29 +778,53 @@ trx_commit_off_kernel(
efficient here: call os_thread_yield here to allow also other efficient here: call os_thread_yield here to allow also other
trxs to come to commit! */ trxs to come to commit! */
/* We now flush the log, as the transaction made changes to
the database, making the transaction committed on disk. It is
enough that any one of the log groups gets written to disk. */
/*-------------------------------------*/ /*-------------------------------------*/
/* Most MySQL users run with srv_flush_.. set to 0: */ /* Depending on the my.cnf options, we may now write the log
buffer to the log files, making the transaction durable if
if (srv_flush_log_at_trx_commit != 0) { the OS does not crash. We may also flush the log files to
if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC disk, making the transaction durable also at an OS crash or a
&& srv_flush_log_at_trx_commit != 2 power outage.
&& !trx->flush_log_later) {
The idea in InnoDB's group commit is that a group of
/* Write the log to the log files AND flush transactions gather behind a trx doing a physical disk write
them to disk */ to log files, and when that physical write has been completed,
one of those transactions does a write which commits the whole
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); group. Note that this group commit will only bring benefit if
} else { there are > 2 users in the database. Then at least 2 users can
/* Write the log but do not flush it to disk */ gather behind one doing the physical log write to disk.
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE); If we are calling trx_commit() under MySQL's binlog mutex, we
} will delay possible log write and flush to a separate function
} trx_commit_complete_for_mysql(), which is only called when the
thread has released the binlog mutex. This is to make the
group commit algorithm to work. Otherwise, the MySQL binlog
mutex would serialize all commits and prevent a group of
transactions from gathering. */
if (trx->flush_log_later) {
/* Do nothing yet */
} else if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
/* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
/* Write the log to the log files AND flush
them to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
}
} else if (srv_flush_log_at_trx_commit == 2) {
/* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
ut_a(0);
}
trx->commit_lsn = lsn; trx->commit_lsn = lsn;
...@@ -1497,21 +1521,33 @@ trx_commit_complete_for_mysql( ...@@ -1497,21 +1521,33 @@ trx_commit_complete_for_mysql(
/* out: 0 or error number */ /* out: 0 or error number */
trx_t* trx) /* in: trx handle */ trx_t* trx) /* in: trx handle */
{ {
ut_a(trx); dulint lsn = trx->commit_lsn;
if (srv_flush_log_at_trx_commit == 1 ut_a(trx);
&& srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
trx->op_info = (char *) "flushing log";
/* Flush the log files to disk */ if (srv_flush_log_at_trx_commit == 0) {
/* Do nothing */
} else if (srv_flush_log_at_trx_commit == 1) {
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
/* Write the log but do not flush it to disk */
log_write_up_to(trx->commit_lsn, LOG_WAIT_ONE_GROUP, TRUE); log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
/* Write the log to the log files AND flush them to
disk */
trx->op_info = (char *) ""; log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
} }
} else if (srv_flush_log_at_trx_commit == 2) {
return(0); /* Write the log but do not flush it to disk */
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
} else {
ut_a(0);
}
return(0);
} }
/************************************************************************** /**************************************************************************
......
...@@ -59,3 +59,14 @@ SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA', ...@@ -59,3 +59,14 @@ SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA',
Kundentyp kategorie Kundentyp kategorie
Privat (Private Nutzung) Mobilfunk Privat (Private Nutzung) Mobilfunk
drop table t1; drop table t1;
CREATE TABLE t1 (
AUFNR varchar(12) NOT NULL default '',
PLNFL varchar(6) NOT NULL default '',
VORNR varchar(4) NOT NULL default '',
xstatus_vor smallint(5) unsigned NOT NULL default '0',
);
INSERT INTO t1 VALUES ('40004712','000001','0010',9);
INSERT INTO t1 VALUES ('40004712','000001','0020',0);
UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr =
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
ASC LIMIT 1;
...@@ -197,6 +197,20 @@ a b ...@@ -197,6 +197,20 @@ a b
INSERT INTO t1 VALUES (1,3); INSERT INTO t1 VALUES (1,3);
Duplicate entry '3' for key 1 Duplicate entry '3' for key 1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
a int default NULL,
key a (a)
) TYPE=HEAP;
INSERT INTO t1 VALUES (10), (10), (10);
EXPLAIN SELECT * FROM t1 WHERE a=10;
table type possible_keys key key_len ref rows Extra
t1 ref a a 5 const 10 Using where
SELECT * FROM t1 WHERE a=10;
a
10
10
10
DROP TABLE t1;
CREATE TABLE t1 (a int not null, primary key(a)) type=heap; CREATE TABLE t1 (a int not null, primary key(a)) type=heap;
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
DELETE from t1 where a < 100; DELETE from t1 where a < 100;
......
...@@ -62,3 +62,22 @@ INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05 ...@@ -62,3 +62,22 @@ INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
drop table t1; drop table t1;
#
# test case for #570
#
CREATE TABLE t1 (
AUFNR varchar(12) NOT NULL default '',
PLNFL varchar(6) NOT NULL default '',
VORNR varchar(4) NOT NULL default '',
xstatus_vor smallint(5) unsigned NOT NULL default '0',
);
INSERT INTO t1 VALUES ('40004712','000001','0010',9);
INSERT INTO t1 VALUES ('40004712','000001','0020',0);
UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr =
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
ASC LIMIT 1;
...@@ -129,6 +129,15 @@ SELECT * FROM t1 WHERE b<=>NULL; ...@@ -129,6 +129,15 @@ SELECT * FROM t1 WHERE b<=>NULL;
INSERT INTO t1 VALUES (1,3); INSERT INTO t1 VALUES (1,3);
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
a int default NULL,
key a (a)
) TYPE=HEAP;
INSERT INTO t1 VALUES (10), (10), (10);
EXPLAIN SELECT * FROM t1 WHERE a=10;
SELECT * FROM t1 WHERE a=10;
DROP TABLE t1;
# #
# Test when deleting all rows # Test when deleting all rows
# #
......
...@@ -86,7 +86,8 @@ int mysql_update(THD *thd, ...@@ -86,7 +86,8 @@ int mysql_update(THD *thd,
table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege); table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege);
bzero((char*) &tables,sizeof(tables)); // For ORDER BY bzero((char*) &tables,sizeof(tables)); // For ORDER BY
tables.table = table; tables.table= table;
tables.alias= table_list->alias;
if (setup_tables(table_list) || setup_conds(thd,table_list,&conds) || if (setup_tables(table_list) || setup_conds(thd,table_list,&conds) ||
setup_order(thd, &tables, all_fields, all_fields, order) || setup_order(thd, &tables, all_fields, all_fields, order) ||
......
This diff is collapsed.
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