Skip to content

Commit de19721

Browse files
committed
Fix of error and warnings when compiling on linux
modifié : storage/connect/ha_connect.cc modifié : storage/connect/jsonudf.cpp nouveau fichier : storage/connect/mysql-test/connect/r/odbc_firebird.result modifié : storage/connect/mysql-test/connect/t/json.test nouveau fichier : storage/connect/mysql-test/connect/t/odbc_firebird.test modifié : storage/connect/tabodbc.cpp supprimé : storage/connect/Makefile
1 parent 1816eca commit de19721

File tree

7 files changed

+1868
-18
lines changed

7 files changed

+1868
-18
lines changed

storage/connect/Makefile

Lines changed: 1704 additions & 0 deletions
Large diffs are not rendered by default.

storage/connect/ha_connect.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
#define JSONMAX 10 // JSON Default max grp size
170170

171171
extern "C" {
172-
char version[]= "Version 1.04.0003 October 20, 2015";
172+
char version[]= "Version 1.04.0003 October 25, 2015";
173173
#if defined(__WIN__)
174174
char compver[]= "Version 1.04.0003 " __DATE__ " " __TIME__;
175175
char slash= '\\';
@@ -1114,7 +1114,7 @@ int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
11141114
else if (!stricmp(opname, "Compressed"))
11151115
opval= (options->compressed);
11161116

1117-
if (opval == NO_IVAL) {
1117+
if (opval == (unsigned)NO_IVAL) {
11181118
char *pv;
11191119

11201120
if ((pv= GetListOption(g, opname, options->oplist)))
@@ -2222,7 +2222,8 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
22222222
const key_range *kr)
22232223
{
22242224
const uchar *ptr;
2225-
uint i, rem, len, klen, stlen;
2225+
//uint i, rem, len, klen, stlen;
2226+
uint i, rem, len, stlen;
22262227
bool nq, both, oom= false;
22272228
OPVAL op;
22282229
Field *fp;
@@ -2255,7 +2256,8 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
22552256
else
22562257
oom|= qry->Append(" WHERE (");
22572258

2258-
klen= len= ranges[i]->length;
2259+
// klen= len= ranges[i]->length;
2260+
len= ranges[i]->length;
22592261
rem= kfp->user_defined_key_parts;
22602262
ptr= ranges[i]->key;
22612263

@@ -2541,6 +2543,8 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
25412543
case MYSQL_TYPE_YEAR:
25422544
case MYSQL_TYPE_NEWDATE:
25432545
return NULL;
2546+
default:
2547+
break;
25442548
} // endswitch type
25452549

25462550
if (trace) {

storage/connect/jsonudf.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515

1616
#include "jsonudf.h"
1717

18+
#if defined(UNIX) || defined(UNIV_LINUX)
19+
#define _O_RDONLY O_RDONLY
20+
#endif
21+
22+
1823
#define MEMFIX 4096
1924
#if defined(connect_EXPORTS)
20-
#define PUSH_WARNING(M) \
25+
#define PUSH_WARNING(M) \
2126
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, M)
2227
#else
2328
#define PUSH_WARNING(M) htrc(M)
@@ -1356,7 +1361,11 @@ static char *GetJsonFile(PGLOBAL g, char *fn)
13561361
char *str;
13571362
int h, n, len;
13581363

1364+
#if defined(UNIX) || defined(UNIV_LINUX)
1365+
h= open(fn, O_RDONLY);
1366+
#else
13591367
h= open(fn, _O_RDONLY, _O_TEXT);
1368+
#endif
13601369

13611370
if (h == -1) {
13621371
sprintf(g->Message, "Error %d opening %s", errno, fn);
@@ -1504,7 +1513,7 @@ char *jsonvalue(UDF_INIT *initid, UDF_ARGS *args, char *result,
15041513
return str;
15051514
} // end of JsonValue
15061515

1507-
void JsonValue_deinit(UDF_INIT* initid)
1516+
void jsonvalue_deinit(UDF_INIT* initid)
15081517
{
15091518
JsonFreeMem((PGLOBAL)initid->ptr);
15101519
} // end of jsonvalue_deinit
@@ -2804,12 +2813,12 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
28042813
strcpy(message, "Fourth argument is not an integer (memory)");
28052814
return true;
28062815
} else
2807-
more = (ulong)*(longlong*)args->args[2];
2816+
more += (ulong)*(longlong*)args->args[2];
28082817

28092818
CalcLen(args, false, reslen, memlen);
28102819

28112820
if (IsJson(args, 0) != 3)
2812-
memlen += 1000; // TODO: calculate this
2821+
memlen += more; // TODO: calculate this
28132822

28142823
return JsonInit(initid, args, message, true, reslen, memlen);
28152824
} // end of jsonlocate_init
@@ -2905,7 +2914,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
29052914
return NULL;
29062915
} // end of jsonlocate
29072916

2908-
void json_locate_deinit(UDF_INIT* initid)
2917+
void jsonlocate_deinit(UDF_INIT* initid)
29092918
{
29102919
JsonFreeMem((PGLOBAL)initid->ptr);
29112920
} // end of jsonlocate_deinit
@@ -2931,14 +2940,14 @@ my_bool json_locate_all_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
29312940
strcpy(message, "Fourth argument is not an integer (memory)");
29322941
return true;
29332942
} else
2934-
more = (ulong)*(longlong*)args->args[2];
2943+
more += (ulong)*(longlong*)args->args[2];
29352944

2936-
CalcLen(args, false, reslen, memlen);
2945+
CalcLen(args, false, reslen, memlen);
29372946

2938-
if (IsJson(args, 0) != 3)
2939-
memlen += 1000; // TODO: calculate this
2947+
if (IsJson(args, 0) != 3)
2948+
memlen += more; // TODO: calculate this
29402949

2941-
return JsonInit(initid, args, message, true, reslen, memlen);
2950+
return JsonInit(initid, args, message, true, reslen, memlen);
29422951
} // end of json_locate_all_init
29432952

29442953
char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
@@ -3237,6 +3246,8 @@ char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
32373246
case INT_RESULT:
32383247
pretty = (int)*(longlong*)args->args[i];
32393248
break;
3249+
default:
3250+
PUSH_WARNING("Unexpected argument type in jfile_make");
32403251
} // endswitch arg_type
32413252

32423253
if (fn) {
@@ -3397,12 +3408,12 @@ char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
33973408
if (!CheckMemory(g, initid, args, 2, false, true)) {
33983409
int *x = NULL;
33993410
uint n = 2;
3400-
PJSON jsp;
3411+
// PJSON jsp;
34013412
PJVAL jvp;
34023413
PJAR arp;
34033414

34043415
jvp = MakeValue(g, args, 0, &top);
3405-
jsp = jvp->GetJson();
3416+
// jsp = jvp->GetJson();
34063417
x = GetIntArgPtr(g, args, n);
34073418

34083419
if (CheckPath(g, args, top, jvp, n))
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
SET NAMES utf8;
2+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Bad connection string';
3+
ERROR HY000: SQLDriverConnect: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
4+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources;
5+
SHOW CREATE TABLE t1;
6+
Table Create Table
7+
t1 CREATE TABLE `t1` (
8+
`Name` varchar(256) NOT NULL,
9+
`Description` varchar(256) NOT NULL
10+
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Sources'
11+
SELECT * FROM t1;
12+
Name Description
13+
Firebird Firebird
14+
DROP TABLE t1;
15+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers;
16+
SHOW CREATE TABLE t1;
17+
Table Create Table
18+
t1 CREATE TABLE `t1` (
19+
`Description` char(128) NOT NULL,
20+
`Attributes` varchar(256) NOT NULL
21+
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Drivers'
22+
SELECT * FROM t1;
23+
Description Attributes
24+
Firebird Description=Firebird ODBC Driver in usr;Driver=/usr/local/lib/libOdbcFb.so;Setup=/usr/local/lib/libOdbcFb.so;FileUsage=1;
25+
DROP TABLE t1;
26+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Tables CONNECTION='Not important';
27+
SHOW CREATE TABLE t1;
28+
Table Create Table
29+
t1 CREATE TABLE `t1` (
30+
`Table_Cat` char(128) NOT NULL,
31+
`Table_Schema` char(128) NOT NULL,
32+
`Table_Name` char(128) NOT NULL,
33+
`Table_Type` char(16) NOT NULL,
34+
`Remark` char(255) NOT NULL
35+
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Tables'
36+
DROP TABLE t1;
37+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Columns CONNECTION='Not important';
38+
SHOW CREATE TABLE t1;
39+
Table Create Table
40+
t1 CREATE TABLE `t1` (
41+
`Table_Cat` char(128) NOT NULL,
42+
`Table_Schema` char(128) NOT NULL,
43+
`Table_Name` char(128) NOT NULL,
44+
`Column_Name` char(128) NOT NULL,
45+
`Data_Type` smallint(6) NOT NULL,
46+
`Type_Name` char(30) NOT NULL,
47+
`Column_Size` int(10) NOT NULL,
48+
`Buffer_Length` int(10) NOT NULL,
49+
`Decimal_Digits` smallint(6) NOT NULL,
50+
`Radix` smallint(6) NOT NULL,
51+
`Nullable` smallint(6) NOT NULL,
52+
`Remarks` char(255) NOT NULL
53+
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Columns'
54+
DROP TABLE t1;
55+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC TABNAME='EMPLOYEE' CONNECTION='DSN=Firebird;UID=SYSDBA;PWD=manager';
56+
SELECT * FROM t1;
57+
EMP_NO FIRST_NAME LAST_NAME PHONE_EXT HIRE_DATE DEPT_NO JOB_CODE JOB_GRADE JOB_COUNTRY SALARY FULL_NAME
58+
2 Robert Nelson 250 1988-12-28 00:00:00 600 VP 2 USA 105900.00 Nelson, Robert
59+
4 Bruce Young 233 1988-12-28 00:00:00 621 Eng 2 USA 97500.00 Young, Bruce
60+
5 Kim Lambert 22 1989-02-06 00:00:00 130 Eng 2 USA 102750.00 Lambert, Kim
61+
8 Leslie Johnson 410 1989-04-05 00:00:00 180 Mktg 3 USA 64635.00 Johnson, Leslie
62+
9 Phil Forest 229 1989-04-17 00:00:00 622 Mngr 3 USA 75060.00 Forest, Phil
63+
11 K. J. Weston 34 1990-01-17 00:00:00 130 SRep 4 USA 86292.94 Weston, K. J.
64+
12 Terri Lee 256 1990-05-01 00:00:00 000 Admin 4 USA 53793.00 Lee, Terri
65+
14 Stewart Hall 227 1990-06-04 00:00:00 900 Finan 3 USA 69482.63 Hall, Stewart
66+
15 Katherine Young 231 1990-06-14 00:00:00 623 Mngr 3 USA 67241.25 Young, Katherine
67+
20 Chris Papadopoulos 887 1990-01-01 00:00:00 671 Mngr 3 USA 89655.00 Papadopoulos, Chris
68+
24 Pete Fisher 888 1990-09-12 00:00:00 671 Eng 3 USA 81810.19 Fisher, Pete
69+
28 Ann Bennet 5 1991-02-01 00:00:00 120 Admin 5 England 22935.00 Bennet, Ann
70+
29 Roger De Souza 288 1991-02-18 00:00:00 623 Eng 3 USA 69482.63 De Souza, Roger
71+
34 Janet Baldwin 2 1991-03-21 00:00:00 110 Sales 3 USA 61637.81 Baldwin, Janet
72+
36 Roger Reeves 6 1991-04-25 00:00:00 120 Sales 3 England 33620.63 Reeves, Roger
73+
37 Willie Stansbury 7 1991-04-25 00:00:00 120 Eng 4 England 39224.06 Stansbury, Willie
74+
44 Leslie Phong 216 1991-06-03 00:00:00 623 Eng 4 USA 56034.38 Phong, Leslie
75+
45 Ashok Ramanathan 209 1991-08-01 00:00:00 621 Eng 3 USA 80689.50 Ramanathan, Ashok
76+
46 Walter Steadman 210 1991-08-09 00:00:00 900 CFO 1 USA 116100.00 Steadman, Walter
77+
52 Carol Nordstrom 420 1991-10-02 00:00:00 180 PRel 4 USA 42742.50 Nordstrom, Carol
78+
61 Luke Leung 3 1992-02-18 00:00:00 110 SRep 4 USA 68805.00 Leung, Luke
79+
65 Sue Anne O'Brien 877 1992-03-23 00:00:00 670 Admin 5 USA 31275.00 O'Brien, Sue Anne
80+
71 Jennifer M. Burbank 289 1992-04-15 00:00:00 622 Eng 3 USA 53167.50 Burbank, Jennifer M.
81+
72 Claudia Sutherland NULL 1992-04-20 00:00:00 140 SRep 4 Canada 100914.00 Sutherland, Claudia
82+
83 Dana Bishop 290 1992-06-01 00:00:00 621 Eng 3 USA 62550.00 Bishop, Dana
83+
85 Mary S. MacDonald 477 1992-06-01 00:00:00 100 VP 2 USA 111262.50 MacDonald, Mary S.
84+
94 Randy Williams 892 1992-08-08 00:00:00 672 Mngr 4 USA 56295.00 Williams, Randy
85+
105 Oliver H. Bender 255 1992-10-08 00:00:00 000 CEO 1 USA 212850.00 Bender, Oliver H.
86+
107 Kevin Cook 894 1993-02-01 00:00:00 670 Dir 2 USA 111262.50 Cook, Kevin
87+
109 Kelly Brown 202 1993-02-04 00:00:00 600 Admin 5 USA 27000.00 Brown, Kelly
88+
110 Yuki Ichida 22 1993-02-04 00:00:00 115 Eng 3 Japan 6000000.00 Ichida, Yuki
89+
113 Mary Page 845 1993-04-12 00:00:00 671 Eng 4 USA 48000.00 Page, Mary
90+
114 Bill Parker 247 1993-06-01 00:00:00 623 Eng 5 USA 35000.00 Parker, Bill
91+
118 Takashi Yamamoto 23 1993-07-01 00:00:00 115 SRep 4 Japan 7480000.00 Yamamoto, Takashi
92+
121 Roberto Ferrari 1 1993-07-12 00:00:00 125 SRep 4 Italy 99000000.00 Ferrari, Roberto
93+
127 Michael Yanowski 492 1993-08-09 00:00:00 100 SRep 4 USA 44000.00 Yanowski, Michael
94+
134 Jacques Glon NULL 1993-08-23 00:00:00 123 SRep 4 France 390500.00 Glon, Jacques
95+
136 Scott Johnson 265 1993-09-13 00:00:00 623 Doc 3 USA 60000.00 Johnson, Scott
96+
138 T.J. Green 218 1993-11-01 00:00:00 621 Eng 4 USA 36000.00 Green, T.J.
97+
141 Pierre Osborne NULL 1994-01-03 00:00:00 121 SRep 4 Switzerland 110000.00 Osborne, Pierre
98+
144 John Montgomery 820 1994-03-30 00:00:00 672 Eng 5 USA 35000.00 Montgomery, John
99+
145 Mark Guckenheimer 221 1994-05-02 00:00:00 622 Eng 5 USA 32000.00 Guckenheimer, Mark
100+
DROP TABLE t1;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ CREATE TABLE t1
135135
Year int(4) FIELD_FORMAT='DATEPUB',
136136
INDEX IX(ISBN)
137137
)
138-
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
138+
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=350 OPTION_LIST='Pretty=0';
139139
SHOW INDEX FROM t1;
140140
SELECT * FROM t1;
141141
DESCRIBE SELECT * FROM t1 WHERE ISBN = '9782212090819';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--source have_odbc.inc
2+
3+
SET NAMES utf8;
4+
5+
# MS ODBC and unixODBC return different error message text,
6+
# so disable displaying error messages
7+
#--disable_result_log ONCE
8+
--error ER_UNKNOWN_ERROR
9+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Bad connection string';
10+
11+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources;
12+
SHOW CREATE TABLE t1;
13+
SELECT * FROM t1;
14+
DROP TABLE t1;
15+
16+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers;
17+
SHOW CREATE TABLE t1;
18+
SELECT * FROM t1;
19+
DROP TABLE t1;
20+
21+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Tables CONNECTION='Not important';
22+
SHOW CREATE TABLE t1;
23+
DROP TABLE t1;
24+
25+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Columns CONNECTION='Not important';
26+
SHOW CREATE TABLE t1;
27+
DROP TABLE t1;
28+
29+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC TABNAME='EMPLOYEE' CONNECTION='DSN=Firebird;UID=SYSDBA;PWD=manager';
30+
SELECT * FROM t1;
31+
DROP TABLE t1;

storage/connect/tabodbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
513513
{
514514
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3];
515515
int len = 0;
516-
bool b = false, oom;
516+
bool b = false, oom = false;
517517
PTABLE tablep = To_Table;
518518
PCOL colp;
519519

0 commit comments

Comments
 (0)