summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tulin@mysql.com>2005-02-04 17:32:18 +0100
committerunknown <tulin@mysql.com>2005-02-04 17:32:18 +0100
commit74ad9e8f1efde5295b9bf0b4bc4a3331d0faab4f (patch)
tree673a1a1d3d90ef7b9e00deb8297fd17f65616bef
parent5d16b7a93a553b7ec7678d6c0e83a345667895d2 (diff)
parent58fd4d94ce16eb473ccf56134bb51e1cd38c9c49 (diff)
downloadmariadb-git-74ad9e8f1efde5295b9bf0b4bc4a3331d0faab4f.tar.gz
Merge bk-internal:/home/bk/mysql-5.0
into mysql.com:/home/mysqldev/tulin/mysql-5.0 BitKeeper/etc/logging_ok: auto-union sql/ha_ndbcluster.cc: Auto merged
-rw-r--r--mysql-test/r/limit.result9
-rw-r--r--mysql-test/r/ndb_basic.result34
-rw-r--r--mysql-test/t/limit.test10
-rw-r--r--mysql-test/t/ndb_basic.test38
-rw-r--r--ndb/include/ndbapi/NdbDictionary.hpp6
-rw-r--r--ndb/src/kernel/blocks/dbdih/DbdihMain.cpp2
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp2
-rw-r--r--sql/ha_ndbcluster.cc45
-rw-r--r--sql/sql_yacc.yy9
9 files changed, 145 insertions, 10 deletions
diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result
index c82105e6a49..6a3d2bffab0 100644
--- a/mysql-test/r/limit.result
+++ b/mysql-test/r/limit.result
@@ -67,3 +67,12 @@ SELECT * FROM t1;
id id2
3 0
DROP TABLE t1;
+create table t1 (a integer);
+insert into t1 values (1);
+select 1 as a from t1 union all select 1 from dual limit 1;
+a
+1
+(select 1 as a from t1) union all (select 1 from dual) limit 1;
+a
+1
+drop table t1;
diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result
index 6ec5338acbe..a6396080ef0 100644
--- a/mysql-test/r/ndb_basic.result
+++ b/mysql-test/r/ndb_basic.result
@@ -573,3 +573,37 @@ select * from t1 where a12345678901234567890123456789a1234567890=2;
a1234567890123456789012345678901234567890 a12345678901234567890123456789a1234567890
5 2
drop table t1;
+create table t1
+(a bigint, b bigint, c bigint, d bigint,
+primary key (a,b,c,d))
+engine=ndb
+max_rows=200000000;
+Warnings:
+Warning 1105 Ndb might have problems storing the max amount of rows specified
+insert into t1 values
+(1,2,3,4),(2,3,4,5),(3,4,5,6),
+(3,2,3,4),(1,3,4,5),(2,4,5,6),
+(1,2,3,5),(2,3,4,8),(3,4,5,9),
+(3,2,3,5),(1,3,4,8),(2,4,5,9),
+(1,2,3,6),(2,3,4,6),(3,4,5,7),
+(3,2,3,6),(1,3,4,6),(2,4,5,7),
+(1,2,3,7),(2,3,4,7),(3,4,5,8),
+(3,2,3,7),(1,3,4,7),(2,4,5,8),
+(1,3,3,4),(2,4,4,5),(3,5,5,6),
+(3,3,3,4),(1,4,4,5),(2,5,5,6),
+(1,3,3,5),(2,4,4,8),(3,5,5,9),
+(3,3,3,5),(1,4,4,8),(2,5,5,9),
+(1,3,3,6),(2,4,4,6),(3,5,5,7),
+(3,3,3,6),(1,4,4,6),(2,5,5,7),
+(1,3,3,7),(2,4,4,7),(3,5,5,8),
+(3,3,3,7),(1,4,4,7),(2,5,5,8);
+select count(*) from t1;
+count(*)
+48
+drop table t1;
+create table t1
+(a bigint, b bigint, c bigint, d bigint,
+primary key (a))
+engine=ndb
+max_rows=1;
+drop table t1;
diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test
index 61c57c9b468..28b287a5d4a 100644
--- a/mysql-test/t/limit.test
+++ b/mysql-test/t/limit.test
@@ -49,3 +49,13 @@ SELECT * FROM t1;
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Bug#8023 - limit on UNION with from DUAL, causes syntax error
+#
+create table t1 (a integer);
+insert into t1 values (1);
+# both queries must return one row
+select 1 as a from t1 union all select 1 from dual limit 1;
+(select 1 as a from t1) union all (select 1 from dual) limit 1;
+drop table t1;
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test
index 2671223ada8..f460c573a9d 100644
--- a/mysql-test/t/ndb_basic.test
+++ b/mysql-test/t/ndb_basic.test
@@ -539,3 +539,41 @@ insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1);
explain select * from t1 where a12345678901234567890123456789a1234567890=2;
select * from t1 where a12345678901234567890123456789a1234567890=2;
drop table t1;
+
+#
+# test fragment creation
+#
+# first a table with _many_ fragments per node group
+# then a table with just one fragment per node group
+#
+create table t1
+ (a bigint, b bigint, c bigint, d bigint,
+ primary key (a,b,c,d))
+ engine=ndb
+ max_rows=200000000;
+insert into t1 values
+ (1,2,3,4),(2,3,4,5),(3,4,5,6),
+ (3,2,3,4),(1,3,4,5),(2,4,5,6),
+ (1,2,3,5),(2,3,4,8),(3,4,5,9),
+ (3,2,3,5),(1,3,4,8),(2,4,5,9),
+ (1,2,3,6),(2,3,4,6),(3,4,5,7),
+ (3,2,3,6),(1,3,4,6),(2,4,5,7),
+ (1,2,3,7),(2,3,4,7),(3,4,5,8),
+ (3,2,3,7),(1,3,4,7),(2,4,5,8),
+ (1,3,3,4),(2,4,4,5),(3,5,5,6),
+ (3,3,3,4),(1,4,4,5),(2,5,5,6),
+ (1,3,3,5),(2,4,4,8),(3,5,5,9),
+ (3,3,3,5),(1,4,4,8),(2,5,5,9),
+ (1,3,3,6),(2,4,4,6),(3,5,5,7),
+ (3,3,3,6),(1,4,4,6),(2,5,5,7),
+ (1,3,3,7),(2,4,4,7),(3,5,5,8),
+ (3,3,3,7),(1,4,4,7),(2,5,5,8);
+select count(*) from t1;
+drop table t1;
+
+create table t1
+ (a bigint, b bigint, c bigint, d bigint,
+ primary key (a))
+ engine=ndb
+ max_rows=1;
+drop table t1;
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp
index 91cfc0cb22a..6b9085fbdca 100644
--- a/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/ndb/include/ndbapi/NdbDictionary.hpp
@@ -140,9 +140,9 @@ public:
enum FragmentType {
FragUndefined = 0, ///< Fragmentation type undefined or default
FragSingle = 1, ///< Only one fragment
- FragAllSmall = 2, ///< One fragment per node group
- FragAllMedium = 3, ///< Default value. Two fragments per node group.
- FragAllLarge = 4 ///< Eight fragments per node group.
+ FragAllSmall = 2, ///< One fragment per node, default
+ FragAllMedium = 3, ///< two fragments per node
+ FragAllLarge = 4 ///< Four fragments per node.
};
};
diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
index cf0b1419697..af75707560a 100644
--- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
+++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
@@ -6178,7 +6178,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal){
break;
case DictTabInfo::AllNodesMediumTable:
jam();
- noOfFragments = csystemnodes;
+ noOfFragments = 2 * csystemnodes;
break;
case DictTabInfo::AllNodesLargeTable:
jam();
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index ca118cd0994..f917fcce18b 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -295,7 +295,7 @@ void
NdbTableImpl::init(){
clearNewProperties();
m_frm.clear();
- m_fragmentType = NdbDictionary::Object::FragAllMedium;
+ m_fragmentType = NdbDictionary::Object::FragAllSmall;
m_logging = true;
m_kvalue = 6;
m_minLoadFactor = 78;
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 5c44479aa12..890addf0c5b 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -3659,6 +3659,47 @@ static int create_ndb_column(NDBCOL &col,
Create a table in NDB Cluster
*/
+static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
+{
+ if (form->s->max_rows == 0) /* default setting, don't set fragmentation */
+ return;
+ /**
+ * get the number of fragments right
+ */
+ uint no_fragments;
+ {
+#if MYSQL_VERSION_ID >= 50000
+ uint acc_row_size= 25+2;
+#else
+ uint acc_row_size= pk_length*4;
+ /* add acc overhead */
+ if (pk_length <= 8)
+ acc_row_size+= 25+2; /* main page will set the limit */
+ else
+ acc_row_size+= 4+4; /* overflow page will set the limit */
+#endif
+ ulonglong acc_fragment_size= 512*1024*1024;
+ ulonglong max_rows= form->s->max_rows;
+ no_fragments= (max_rows*acc_row_size)/acc_fragment_size+1;
+ }
+ {
+ uint no_nodes= g_ndb_cluster_connection->no_db_nodes();
+ NDBTAB::FragmentType ftype;
+ if (no_fragments > 2*no_nodes)
+ {
+ ftype= NDBTAB::FragAllLarge;
+ if (no_fragments > 4*no_nodes)
+ push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
+ "Ndb might have problems storing the max amount of rows specified");
+ }
+ else if (no_fragments > no_nodes)
+ ftype= NDBTAB::FragAllMedium;
+ else
+ ftype= NDBTAB::FragAllSmall;
+ tab.setFragmentType(ftype);
+ }
+}
+
int ha_ndbcluster::create(const char *name,
TABLE *form,
HA_CREATE_INFO *info)
@@ -3760,7 +3801,9 @@ int ha_ndbcluster::create(const char *name,
break;
}
}
-
+
+ ndb_set_fragmentation(tab, form, pk_length);
+
if ((my_errno= check_ndb_connection()))
DBUG_RETURN(my_errno);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7070b6bc6bf..2ec49a76f45 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3895,10 +3895,11 @@ select_into:
select_from:
FROM join_table_list where_clause group_clause having_clause
opt_order_clause opt_limit_clause procedure_clause
- | FROM DUAL_SYM /* oracle compatibility: oracle always requires FROM
- clause, and DUAL is system table without fields.
- Is "SELECT 1 FROM DUAL" any better than
- "SELECT 1" ? Hmmm :) */
+ | FROM DUAL_SYM opt_limit_clause
+ /* oracle compatibility: oracle always requires FROM clause,
+ and DUAL is system table without fields.
+ Is "SELECT 1 FROM DUAL" any better than "SELECT 1" ?
+ Hmmm :) */
;
select_options: