Commit 6e48347d authored by Olivier Bertrand's avatar Olivier Bertrand

Merge branch 'ob-10.0' into 10.0

parents cbe35113 8c9fd074
...@@ -757,7 +757,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) ...@@ -757,7 +757,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
sdvalout= NULL; sdvalout= NULL;
xmod= MODE_ANY; xmod= MODE_ANY;
istable= false; istable= false;
*partname= 0; memset(partname, 0, sizeof(partname));
bzero((char*) &xinfo, sizeof(XINFO)); bzero((char*) &xinfo, sizeof(XINFO));
valid_info= false; valid_info= false;
valid_query_id= 0; valid_query_id= 0;
...@@ -1150,7 +1150,7 @@ char *ha_connect::GetRealString(const char *s) ...@@ -1150,7 +1150,7 @@ char *ha_connect::GetRealString(const char *s)
{ {
char *sv; char *sv;
if (IsPartitioned() && s) { if (IsPartitioned() && s && partname && *partname) {
sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
sprintf(sv, s, partname); sprintf(sv, s, partname);
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
...@@ -1173,7 +1173,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) ...@@ -1173,7 +1173,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
: table->s->connect_string; : table->s->connect_string;
if (cnc.length) if (cnc.length)
opval= GetRealString(strz(xp->g, cnc)); opval= strz(xp->g, cnc);
else
opval= GetListOption(xp->g, opname, options->oplist);
} else if (!stricmp(opname, "Query_String")) } else if (!stricmp(opname, "Query_String"))
opval= thd_query_string(table->in_use)->str; opval= thd_query_string(table->in_use)->str;
...@@ -3121,13 +3123,14 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) ...@@ -3121,13 +3123,14 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked)
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
if (table->part_info) { if (table->part_info) {
if (GetStringOption("Filename") || GetStringOption("Tabname") if (GetStringOption("Filename") || GetStringOption("Tabname")
|| GetStringOption("Connect")) { || GetStringOption("Connect")) {
strcpy(partname, decode(g, strrchr(name, '#') + 1)); strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
// strcpy(partname, table->part_info->curr_part_elem->partition_name); // strcpy(partname, table->part_info->curr_part_elem->partition_name);
part_id= &table->part_info->full_part_field_set; // part_id= &table->part_info->full_part_field_set;
} else // Inward table } else // Inward table
strcpy(partname, strrchr(name, slash) + 1); strncpy(partname, strrchr(name, slash) + 1, sizeof(partname) - 1);
part_id= &table->part_info->full_part_field_set; // Temporary
part_id= &table->part_info->full_part_field_set; // Temporary
} // endif part_info } // endif part_info
#endif // WITH_PARTITION_STORAGE_ENGINE #endif // WITH_PARTITION_STORAGE_ENGINE
} else } else
...@@ -6142,7 +6145,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -6142,7 +6145,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcpy(dbpath, name); strcpy(dbpath, name);
p= strrchr(dbpath, slash); p= strrchr(dbpath, slash);
strcpy(partname, ++p); strncpy(partname, ++p, sizeof(partname) - 1);
strcat(strcat(strcpy(buf, p), "."), lwt); strcat(strcat(strcpy(buf, p), "."), lwt);
*p= 0; *p= 0;
} else { } else {
...@@ -6193,7 +6196,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -6193,7 +6196,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info && !inward) if (part_info && !inward)
strcpy(partname, decode(g, strrchr(name, '#') + 1)); strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
// strcpy(partname, part_info->curr_part_elem->partition_name); // strcpy(partname, part_info->curr_part_elem->partition_name);
#endif // WITH_PARTITION_STORAGE_ENGINE #endif // WITH_PARTITION_STORAGE_ENGINE
...@@ -6234,8 +6237,9 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -6234,8 +6237,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info) if (part_info)
strcpy(partname, strncpy(partname,
decode(g, strrchr(name, (inward ? slash : '#')) + 1)); decode(g, strrchr(name, (inward ? slash : '#')) + 1),
sizeof(partname) - 1);
#endif // WITH_PARTITION_STORAGE_ENGINE #endif // WITH_PARTITION_STORAGE_ENGINE
if ((rc= optimize(table->in_use, NULL))) { if ((rc= optimize(table->in_use, NULL))) {
......
...@@ -554,7 +554,7 @@ protected: ...@@ -554,7 +554,7 @@ protected:
PVAL sdvalin4; // Used to convert date values PVAL sdvalin4; // Used to convert date values
PVAL sdvalout; // Used to convert date values PVAL sdvalout; // Used to convert date values
bool istable; // True for table handler bool istable; // True for table handler
char partname[64]; // The partition name char partname[65]; // The partition name
MODE xmod; // Table mode MODE xmod; // Table mode
XINFO xinfo; // The table info structure XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid bool valid_info; // True if xinfo is valid
......
...@@ -191,6 +191,31 @@ id msg ...@@ -191,6 +191,31 @@ id msg
35 thirty five 35 thirty five
81 big 81 big
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
id INT KEY NOT NULL,
msg VARCHAR(32))
ENGINE=CONNECT TABLE_TYPE=MYSQL
OPTION_LIST='connect=mysql://root@localhost/test/xt%s'
PARTITION BY RANGE COLUMNS(id) (
PARTITION `1` VALUES LESS THAN(10),
PARTITION `2` VALUES LESS THAN(50),
PARTITION `3` VALUES LESS THAN(MAXVALUE));
Warnings:
Warning 1105 Data repartition in 1 is unchecked
Warning 1105 Data repartition in 2 is unchecked
Warning 1105 Data repartition in 3 is unchecked
SELECT * FROM t1;
id msg
4 four
7 sept
1 one
8 eight
40 forty
10 ten
11 eleven
35 thirty five
81 big
DROP TABLE t1;
DROP TABLE xt1; DROP TABLE xt1;
DROP TABLE xt2; DROP TABLE xt2;
DROP TABLE xt3; DROP TABLE xt3;
......
...@@ -82,6 +82,21 @@ SELECT * FROM t1; ...@@ -82,6 +82,21 @@ SELECT * FROM t1;
DELETE FROM t1 WHERE id in (60,72); DELETE FROM t1 WHERE id in (60,72);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Using a connection string
#
CREATE TABLE t1 (
id INT KEY NOT NULL,
msg VARCHAR(32))
ENGINE=CONNECT TABLE_TYPE=MYSQL
OPTION_LIST='connect=mysql://root@localhost/test/xt%s'
PARTITION BY RANGE COLUMNS(id) (
PARTITION `1` VALUES LESS THAN(10),
PARTITION `2` VALUES LESS THAN(50),
PARTITION `3` VALUES LESS THAN(MAXVALUE));
SELECT * FROM t1;
DROP TABLE t1;
DROP TABLE xt1; DROP TABLE xt1;
DROP TABLE xt2; DROP TABLE xt2;
DROP TABLE xt3; DROP TABLE xt3;
......
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