Skip to content

Commit 6e48347

Browse files
committed
Merge branch 'ob-10.0' into 10.0
2 parents cbe3511 + 8c9fd07 commit 6e48347

File tree

4 files changed

+57
-13
lines changed

4 files changed

+57
-13
lines changed

storage/connect/ha_connect.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
757757
sdvalout= NULL;
758758
xmod= MODE_ANY;
759759
istable= false;
760-
*partname= 0;
760+
memset(partname, 0, sizeof(partname));
761761
bzero((char*) &xinfo, sizeof(XINFO));
762762
valid_info= false;
763763
valid_query_id= 0;
@@ -1150,7 +1150,7 @@ char *ha_connect::GetRealString(const char *s)
11501150
{
11511151
char *sv;
11521152

1153-
if (IsPartitioned() && s) {
1153+
if (IsPartitioned() && s && partname && *partname) {
11541154
sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
11551155
sprintf(sv, s, partname);
11561156
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
@@ -1173,7 +1173,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
11731173
: table->s->connect_string;
11741174

11751175
if (cnc.length)
1176-
opval= GetRealString(strz(xp->g, cnc));
1176+
opval= strz(xp->g, cnc);
1177+
else
1178+
opval= GetListOption(xp->g, opname, options->oplist);
11771179

11781180
} else if (!stricmp(opname, "Query_String"))
11791181
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)
31213123
#if defined(WITH_PARTITION_STORAGE_ENGINE)
31223124
if (table->part_info) {
31233125
if (GetStringOption("Filename") || GetStringOption("Tabname")
3124-
|| GetStringOption("Connect")) {
3125-
strcpy(partname, decode(g, strrchr(name, '#') + 1));
3126+
|| GetStringOption("Connect")) {
3127+
strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
31263128
// strcpy(partname, table->part_info->curr_part_elem->partition_name);
3127-
part_id= &table->part_info->full_part_field_set;
3129+
// part_id= &table->part_info->full_part_field_set;
31283130
} else // Inward table
3129-
strcpy(partname, strrchr(name, slash) + 1);
3130-
part_id= &table->part_info->full_part_field_set; // Temporary
3131+
strncpy(partname, strrchr(name, slash) + 1, sizeof(partname) - 1);
3132+
3133+
part_id= &table->part_info->full_part_field_set; // Temporary
31313134
} // endif part_info
31323135
#endif // WITH_PARTITION_STORAGE_ENGINE
31333136
} else
@@ -6142,7 +6145,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
61426145

61436146
strcpy(dbpath, name);
61446147
p= strrchr(dbpath, slash);
6145-
strcpy(partname, ++p);
6148+
strncpy(partname, ++p, sizeof(partname) - 1);
61466149
strcat(strcat(strcpy(buf, p), "."), lwt);
61476150
*p= 0;
61486151
} else {
@@ -6193,7 +6196,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
61936196

61946197
#if defined(WITH_PARTITION_STORAGE_ENGINE)
61956198
if (part_info && !inward)
6196-
strcpy(partname, decode(g, strrchr(name, '#') + 1));
6199+
strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
61976200
// strcpy(partname, part_info->curr_part_elem->partition_name);
61986201
#endif // WITH_PARTITION_STORAGE_ENGINE
61996202

@@ -6234,8 +6237,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
62346237

62356238
#if defined(WITH_PARTITION_STORAGE_ENGINE)
62366239
if (part_info)
6237-
strcpy(partname,
6238-
decode(g, strrchr(name, (inward ? slash : '#')) + 1));
6240+
strncpy(partname,
6241+
decode(g, strrchr(name, (inward ? slash : '#')) + 1),
6242+
sizeof(partname) - 1);
62396243
#endif // WITH_PARTITION_STORAGE_ENGINE
62406244

62416245
if ((rc= optimize(table->in_use, NULL))) {

storage/connect/ha_connect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ int index_prev(uchar *buf);
554554
PVAL sdvalin4; // Used to convert date values
555555
PVAL sdvalout; // Used to convert date values
556556
bool istable; // True for table handler
557-
char partname[64]; // The partition name
557+
char partname[65]; // The partition name
558558
MODE xmod; // Table mode
559559
XINFO xinfo; // The table info structure
560560
bool valid_info; // True if xinfo is valid

storage/connect/mysql-test/connect/r/part_table.result

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,31 @@ id msg
191191
35 thirty five
192192
81 big
193193
DROP TABLE t1;
194+
CREATE TABLE t1 (
195+
id INT KEY NOT NULL,
196+
msg VARCHAR(32))
197+
ENGINE=CONNECT TABLE_TYPE=MYSQL
198+
OPTION_LIST='connect=mysql://root@localhost/test/xt%s'
199+
PARTITION BY RANGE COLUMNS(id) (
200+
PARTITION `1` VALUES LESS THAN(10),
201+
PARTITION `2` VALUES LESS THAN(50),
202+
PARTITION `3` VALUES LESS THAN(MAXVALUE));
203+
Warnings:
204+
Warning 1105 Data repartition in 1 is unchecked
205+
Warning 1105 Data repartition in 2 is unchecked
206+
Warning 1105 Data repartition in 3 is unchecked
207+
SELECT * FROM t1;
208+
id msg
209+
4 four
210+
7 sept
211+
1 one
212+
8 eight
213+
40 forty
214+
10 ten
215+
11 eleven
216+
35 thirty five
217+
81 big
218+
DROP TABLE t1;
194219
DROP TABLE xt1;
195220
DROP TABLE xt2;
196221
DROP TABLE xt3;

storage/connect/mysql-test/connect/t/part_table.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ SELECT * FROM t1;
8282
DELETE FROM t1 WHERE id in (60,72);
8383
SELECT * FROM t1;
8484
DROP TABLE t1;
85+
86+
#
87+
# Using a connection string
88+
#
89+
CREATE TABLE t1 (
90+
id INT KEY NOT NULL,
91+
msg VARCHAR(32))
92+
ENGINE=CONNECT TABLE_TYPE=MYSQL
93+
OPTION_LIST='connect=mysql://root@localhost/test/xt%s'
94+
PARTITION BY RANGE COLUMNS(id) (
95+
PARTITION `1` VALUES LESS THAN(10),
96+
PARTITION `2` VALUES LESS THAN(50),
97+
PARTITION `3` VALUES LESS THAN(MAXVALUE));
98+
SELECT * FROM t1;
99+
DROP TABLE t1;
85100
DROP TABLE xt1;
86101
DROP TABLE xt2;
87102
DROP TABLE xt3;

0 commit comments

Comments
 (0)