Skip to content

Commit 48a77e6

Browse files
committed
Make this repository aligned with 10.0 one
1 parent 464947e commit 48a77e6

File tree

17 files changed

+992
-687
lines changed

17 files changed

+992
-687
lines changed

.gitattributes

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.c text
7+
*.cc text
8+
*.cpp text
9+
*.h text
10+
*.test text
11+
12+
# Declare files that will always have LF line endings on checkout.
13+
*.result text eol=lf
14+
storage/connect/mysql-test/connect/std_data/*.txt text eol=lf
15+
storage/connect/mysql-test/connect/std_data/*.dat text eol=lf
16+
17+
# Denote all files that are truly binary and should not be modified.
18+
*.png binary
19+
*.jpg binary
20+
121
*.c diff=cpp
222
*.h diff=cpp
323
*.cc diff=cpp

storage/connect/ha_connect.cc

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,12 +2173,12 @@ int ha_connect::CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf)
21732173
/***********************************************************************/
21742174
/* Return the where clause for remote indexed read. */
21752175
/***********************************************************************/
2176-
bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
2176+
bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL op, char q,
21772177
const void *key, int klen)
21782178
{
21792179
const uchar *ptr;
21802180
uint rem, len, stlen; //, prtlen;
2181-
bool nq, b= false;
2181+
bool nq, oom, b= false;
21822182
Field *fp;
21832183
KEY *kfp;
21842184
KEY_PART_INFO *kpart;
@@ -2190,7 +2190,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
21902190
return true;
21912191
} // endif key
21922192

2193-
strcat(qry, " WHERE (");
2193+
oom= qry->Append(" WHERE (");
21942194
kfp= &table->key_info[active_index];
21952195
rem= kfp->user_defined_key_parts,
21962196
len= klen,
@@ -2203,42 +2203,44 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
22032203
nq= fp->str_needs_quotes();
22042204

22052205
if (b)
2206-
strcat(qry, " AND ");
2206+
oom|= qry->Append(" AND ");
22072207
else
22082208
b= true;
22092209

2210-
strcat(strncat(strcat(qry, q), fp->field_name, strlen(fp->field_name)), q);
2210+
oom|= qry->Append(q);
2211+
oom|= qry->Append((PSZ)fp->field_name);
2212+
oom|= qry->Append(q);
22112213

22122214
switch (op) {
22132215
case OP_EQ:
22142216
case OP_GT:
22152217
case OP_GE:
2216-
strcat(qry, GetValStr(op, false));
2218+
oom|= qry->Append((PSZ)GetValStr(op, false));
22172219
break;
22182220
default:
2219-
strcat(qry, " ??? ");
2221+
oom|= qry->Append(" ??? ");
22202222
} // endwitch op
22212223

22222224
if (nq)
2223-
strcat(qry, "'");
2225+
oom|= qry->Append('\'');
22242226

22252227
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
22262228
String varchar;
22272229
uint var_length= uint2korr(ptr);
22282230

22292231
varchar.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
22302232
var_length, &my_charset_bin);
2231-
strncat(qry, varchar.ptr(), varchar.length());
2233+
oom|= qry->Append(varchar.ptr(), varchar.length());
22322234
} else {
22332235
char strbuff[MAX_FIELD_WIDTH];
22342236
String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res;
22352237

22362238
res= fp->val_str(&str, ptr);
2237-
strncat(qry, res->ptr(), res->length());
2239+
oom|= qry->Append(res->ptr(), res->length());
22382240
} // endif flag
22392241

22402242
if (nq)
2241-
strcat(qry, "'");
2243+
oom|= qry->Append('\'');
22422244

22432245
if (stlen >= len)
22442246
break;
@@ -2251,8 +2253,10 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
22512253
ptr+= stlen - MY_TEST(kpart->null_bit);
22522254
} // endfor kpart
22532255

2254-
strcat(qry, ")");
2255-
return false;
2256+
if ((oom|= qry->Append(")")))
2257+
strcpy(g->Message, "Out of memory");
2258+
2259+
return oom;
22562260
} // end of MakeKeyWhere
22572261

22582262

@@ -2714,7 +2718,12 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
27142718
case MYSQL_TYPE_DATETIME:
27152719
if (tty == TYPE_AM_ODBC) {
27162720
strcat(body, "{ts '");
2717-
strcat(strncat(body, res->ptr(), res->length()), "'}");
2721+
strncat(body, res->ptr(), res->length());
2722+
2723+
if (res->length() < 19)
2724+
strcat(body, "1970-01-01 00:00:00" + res->length());
2725+
2726+
strcat(body, "'}");
27182727
break;
27192728
} // endif ODBC
27202729

@@ -2739,6 +2748,10 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
27392748
case MYSQL_TYPE_DATETIME:
27402749
strcat(body, "{ts '");
27412750
strncat(body, res->ptr(), res->length());
2751+
2752+
if (res->length() < 19)
2753+
strcat(body, "1970-01-01 00:00:00" + res->length());
2754+
27422755
strcat(body, "'}");
27432756
break;
27442757
case MYSQL_TYPE_DATE:
@@ -4134,6 +4147,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
41344147
break;
41354148
// } // endif partitioned
41364149

4150+
case SQLCOM_END:
4151+
// Met in procedures: IF(EXISTS(SELECT...
4152+
newmode= MODE_READ;
4153+
break;
41374154
default:
41384155
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
41394156
strcpy(g->Message, "CONNECT Unsupported command");

storage/connect/ha_connect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ha_connect: public handler
235235
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
236236
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
237237
uint key_len= 0);
238-
bool MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
238+
bool MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL op, char q,
239239
const void *key, int klen);
240240
inline char *Strz(LEX_STRING &ls);
241241

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

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TRANSLATION CHAR(32),
1212
TRANSLATOR CHAR(80),
1313
PUBLISHER CHAR(32),
1414
DATEPUB int(4)
15-
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.jsn';
15+
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
1616
SELECT * FROM t1;
1717
ISBN LANG SUBJECT AUTHOR TITLE TRANSLATION TRANSLATOR PUBLISHER DATEPUB
1818
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999
@@ -34,7 +34,7 @@ Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
3434
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
3535
Year int(4) FIELD_FORMAT='DATEPUB'
3636
)
37-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.jsn';
37+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
3838
SELECT * FROM t1;
3939
ISBN Language Subject Authors Title Translation Translator Publisher Location Year
4040
9782212090819 fr applications 2 Construire une application XML Eyrolles Paris 1999
@@ -57,7 +57,7 @@ Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
5757
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
5858
Year int(4) FIELD_FORMAT='DATEPUB'
5959
)
60-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.jsn';
60+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
6161
SELECT * FROM t1;
6262
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
6363
9782212090819 fr applications Jean-Christophe and Fran�ois Bernadac and Knab Construire une application XML Eyrolles Paris 1999
@@ -80,7 +80,7 @@ Publisher CHAR(20) FIELD_FORMAT='PUBLISHER:NAME',
8080
Location CHAR(16) FIELD_FORMAT='PUBLISHER:PLACE',
8181
Year int(4) FIELD_FORMAT='DATEPUB'
8282
)
83-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.jsn';
83+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json';
8484
SELECT * FROM t1;
8585
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
8686
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999
@@ -89,23 +89,23 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L
8989
UPDATE t1 SET AuthorFN = 'Philippe' WHERE AuthorLN = 'Knab';
9090
SELECT * FROM t1 WHERE ISBN = '9782212090819';
9191
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
92-
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999
93-
9782212090819 fr applications Philippe Knab Construire une application XML Eyrolles Paris 1999
92+
9782212090819 fr applications Philippe Bernadac Construire une application XML Eyrolles Paris 1999
93+
9782212090819 fr applications Fran�ois Knab Construire une application XML Eyrolles Paris 1999
9494
#
9595
# To add an author a new table must be created
9696
#
9797
CREATE TABLE t2 (
9898
FIRSTNAME CHAR(32),
9999
LASTNAME CHAR(32))
100-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.jsn' OPTION_LIST='Object=[2]:AUTHOR';
100+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='biblio.json' OPTION_LIST='Object=[2]:AUTHOR';
101101
SELECT * FROM t2;
102102
FIRSTNAME LASTNAME
103103
William J. Pardi
104104
INSERT INTO t2 VALUES('Charles','Dickens');
105105
SELECT * FROM t1;
106106
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
107-
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML Eyrolles Paris 1999
108-
9782212090819 fr applications Philippe Knab Construire une application XML Eyrolles Paris 1999
107+
9782212090819 fr applications Philippe Bernadac Construire une application XML Eyrolles Paris 1999
108+
9782212090819 fr applications Fran�ois Knab Construire une application XML Eyrolles Paris 1999
109109
9782840825685 fr applications William J. Pardi XML en Action adapt� de l'anglais par James Guerin Microsoft Press Paris 1999
110110
9782840825685 fr applications Charles Dickens XML en Action adapt� de l'anglais par James Guerin Microsoft Press Paris 1999
111111
DROP TABLE t1;
@@ -117,7 +117,7 @@ CREATE TABLE t1
117117
(
118118
line char(255)
119119
)
120-
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='biblio.jsn';
120+
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='biblio.json';
121121
SELECT * FROM t1;
122122
line
123123
[
@@ -127,11 +127,11 @@ line
127127
"SUBJECT": "applications",
128128
"AUTHOR": [
129129
{
130-
"FIRSTNAME": "Jean-Christophe",
130+
"FIRSTNAME": "Philippe",
131131
"LASTNAME": "Bernadac"
132132
},
133133
{
134-
"FIRSTNAME": "Philippe",
134+
"FIRSTNAME": "Fran�ois",
135135
"LASTNAME": "Knab"
136136
}
137137
],
@@ -178,7 +178,7 @@ WHO CHAR(12),
178178
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
179179
WHAT CHAR(32) FIELD_FORMAT='WEEK::EXPENSE:["+"]:WHAT',
180180
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK::EXPENSE:[+]:AMOUNT')
181-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.jsn';
181+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
182182
SELECT * FROM t1;
183183
WHO WEEK WHAT AMOUNT
184184
Joe 3 Beer+Food+Food+Car 69.00
@@ -192,16 +192,60 @@ Janet 4 Car 17.00
192192
Janet 5 Beer+Car+Beer+Food 57.00
193193
DROP TABLE t1;
194194
#
195-
# Cannot be fully expanded
195+
# Now it can be fully expanded
196196
#
197197
CREATE TABLE t1 (
198198
WHO CHAR(12),
199199
WEEK INT(2) FIELD_FORMAT='WEEK:[X]:NUMBER',
200200
WHAT CHAR(32) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:WHAT',
201201
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[X]:EXPENSE:[X]:AMOUNT')
202-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.jsn';
202+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
203+
SELECT * FROM t1;
204+
WHO WEEK WHAT AMOUNT
205+
Joe 3 Beer 18.00
206+
Joe 3 Food 12.00
207+
Joe 3 Food 19.00
208+
Joe 3 Car 20.00
209+
Joe 4 Beer 19.00
210+
Joe 4 Beer 16.00
211+
Joe 4 Food 17.00
212+
Joe 4 Food 17.00
213+
Joe 4 Beer 14.00
214+
Joe 5 Beer 14.00
215+
Joe 5 Food 12.00
216+
Beth 3 Beer 16.00
217+
Beth 4 Food 17.00
218+
Beth 4 Beer 15.00
219+
Beth 5 Food 12.00
220+
Beth 5 Beer 20.00
221+
Janet 3 Car 19.00
222+
Janet 3 Food 18.00
223+
Janet 3 Beer 18.00
224+
Janet 4 Car 17.00
225+
Janet 5 Beer 14.00
226+
Janet 5 Car 12.00
227+
Janet 5 Beer 19.00
228+
Janet 5 Food 12.00
229+
DROP TABLE t1;
230+
#
231+
# A table showing many calculated results
232+
#
233+
CREATE TABLE t1 (
234+
WHO CHAR(12) NOT NULL,
235+
WEEKS CHAR(12) NOT NULL FIELD_FORMAT='WEEK:[", "]:NUMBER',
236+
SUMS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[+]:AMOUNT',
237+
SUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[+]:AMOUNT',
238+
AVGS CHAR(64) NOT NULL FIELD_FORMAT='WEEK:["+"]:EXPENSE:[!]:AMOUNT',
239+
SUMAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[+]:EXPENSE:[!]:AMOUNT',
240+
AVGSUM DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[+]:AMOUNT',
241+
AVGAVG DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[!]:AMOUNT',
242+
AVERAGE DOUBLE(8,2) NOT NULL FIELD_FORMAT='WEEK:[!]:EXPENSE:[X]:AMOUNT')
243+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
203244
SELECT * FROM t1;
204-
ERROR HY000: Got error 174 'Cannot expand more than one array' from CONNECT
245+
WHO WEEKS SUMS SUM AVGS SUMAVG AVGSUM AVGAVG AVERAGE
246+
Joe 3, 4, 5 69.00+83.00+26.00 178.00 17.25+16.60+13.00 46.85 59.33 15.62 16.18
247+
Beth 3, 4, 5 16.00+32.00+32.00 80.00 16.00+16.00+16.00 48.00 26.67 16.00 16.00
248+
Janet 3, 4, 5 55.00+17.00+57.00 129.00 18.33+17.00+14.25 49.58 43.00 16.53 16.12
205249
DROP TABLE t1;
206250
#
207251
# Expand expense in 3 one week tables
@@ -211,7 +255,7 @@ WHO CHAR(12),
211255
WEEK INT(2) FIELD_FORMAT='WEEK:[1]:NUMBER',
212256
WHAT CHAR(32) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:WHAT',
213257
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[1]:EXPENSE:[X]:AMOUNT')
214-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.jsn';
258+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
215259
SELECT * FROM t2;
216260
WHO WEEK WHAT AMOUNT
217261
Joe 3 Beer 18.00
@@ -227,7 +271,7 @@ WHO CHAR(12),
227271
WEEK INT(2) FIELD_FORMAT='WEEK:[2]:NUMBER',
228272
WHAT CHAR(32) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:WHAT',
229273
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[2]:EXPENSE:[X]:AMOUNT')
230-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.jsn';
274+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
231275
SELECT * FROM t3;
232276
WHO WEEK WHAT AMOUNT
233277
Joe 4 Beer 19.00
@@ -243,7 +287,7 @@ WHO CHAR(12),
243287
WEEK INT(2) FIELD_FORMAT='WEEK:[3]:NUMBER',
244288
WHAT CHAR(32) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:WHAT',
245289
AMOUNT DOUBLE(8,2) FIELD_FORMAT='WEEK:[3]:EXPENSE:[X]:AMOUNT')
246-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.jsn';
290+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='expense.json';
247291
SELECT * FROM t4;
248292
WHO WEEK WHAT AMOUNT
249293
Joe 5 Beer 14.00
@@ -298,7 +342,7 @@ WHO CHAR(12),
298342
WEEK INT(2),
299343
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
300344
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
301-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp3.jsn';
345+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp3.json';
302346
SELECT * FROM t2;
303347
WHO WEEK WHAT AMOUNT
304348
Joe 3 Beer 18.00
@@ -314,7 +358,7 @@ WHO CHAR(12),
314358
WEEK INT(2),
315359
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
316360
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
317-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp4.jsn';
361+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp4.json';
318362
SELECT * FROM t3;
319363
WHO WEEK WHAT AMOUNT
320364
Joe 4 Beer 19.00
@@ -330,7 +374,7 @@ WHO CHAR(12),
330374
WEEK INT(2),
331375
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
332376
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
333-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp5.jsn';
377+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp5.json';
334378
SELECT * FROM t4;
335379
WHO WEEK WHAT AMOUNT
336380
Joe 5 Beer 14.00
@@ -349,7 +393,7 @@ WHO CHAR(12),
349393
WEEK INT(2),
350394
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
351395
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
352-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp*.jsn' MULTIPLE=1;
396+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp*.json' MULTIPLE=1;
353397
SELECT * FROM t1 ORDER BY WHO, WEEK, WHAT, AMOUNT;
354398
WHO WEEK WHAT AMOUNT
355399
Beth 3 Beer 16.00
@@ -385,7 +429,7 @@ WHO CHAR(12),
385429
WEEK INT(2),
386430
WHAT CHAR(32) FIELD_FORMAT='EXPENSE:[X]:WHAT',
387431
AMOUNT DOUBLE(8,2) FIELD_FORMAT='EXPENSE:[X]:AMOUNT')
388-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp%s.jsn';
432+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='mulexp%s.json';
389433
ALTER TABLE t1
390434
PARTITION BY LIST COLUMNS(WEEK) (
391435
PARTITION `3` VALUES IN(3),

0 commit comments

Comments
 (0)