Skip to content

Commit 5f64276

Browse files
committed
- Fix MDEV-25863 : Replace __WIN__ by _WIN32
modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/bson.cpp modified: storage/connect/cmgoconn.cpp modified: storage/connect/colblk.cpp modified: storage/connect/domdoc.cpp modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamgz.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/fmdlex.c modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/javaconn.cpp modified: storage/connect/javaconn.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jmgfam.cpp modified: storage/connect/json.cpp modified: storage/connect/macutil.cpp modified: storage/connect/macutil.h modified: storage/connect/maputil.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/myconn.h modified: storage/connect/myutil.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/odbconn.h modified: storage/connect/os.h modified: storage/connect/osutil.c modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.cpp modified: storage/connect/rcmsg.c modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabext.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabrest.cpp modified: storage/connect/tabrest.h modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h - Fix Date errors and SSL warnings modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/jdbc_new.result modified: storage/connect/mysql-test/connect/t/jdbc.test modified: storage/connect/mysql-test/connect/t/jdbc_new.test - Update java source files modified: storage/connect/Mongo2Interface.java modified: storage/connect/Mongo3Interface.java added: storage/connect/Client2.java added: storage/connect/Client3.java added: storage/connect/TestInsert2.java added: storage/connect/TestInsert3.java
1 parent be7e41d commit 5f64276

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1317
-551
lines changed

storage/connect/Client2.java

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package wrappers;
2+
3+
import java.io.BufferedReader;
4+
import java.io.Console;
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
7+
import java.util.Set;
8+
9+
public class Client2 {
10+
static boolean DEBUG = true;
11+
static final Console c = System.console();
12+
static Mongo2Interface jdi = null;
13+
14+
public static void main(String[] args) {
15+
int rc, m, i = 0;
16+
boolean brc;
17+
Set<String> columns;
18+
String[] parms = new String[4];
19+
20+
jdi = new Mongo2Interface(DEBUG);
21+
22+
parms[0] = getLine("URI: ", false);
23+
parms[1] = getLine("DB: ", false);
24+
parms[2] = null;
25+
parms[3] = null;
26+
27+
if (parms[0] == null)
28+
parms[0] = "mongodb://localhost:27017";
29+
30+
if (parms[1] == null)
31+
parms[1] = "test";
32+
33+
rc = jdi.MongoConnect(parms);
34+
35+
if (rc == 0) {
36+
String name, pipeline, query, fields;
37+
System.out.println("Successfully connected to " + parms[1]);
38+
39+
while ((name = getLine("Collection: ", false)) != null) {
40+
if (jdi.GetCollection(name))
41+
System.out.println("GetCollection failed");
42+
else
43+
System.out.println("Collection size: " + jdi.GetCollSize());
44+
45+
pipeline = getLine("Pipeline: ", false);
46+
47+
if (pipeline == null) {
48+
query = getLine("Filter: ", false);
49+
fields = getLine("Proj: ", false);
50+
brc = jdi.FindColl(query, fields);
51+
} else
52+
brc = jdi.AggregateColl(pipeline);
53+
54+
System.out.println("Returned brc = " + brc);
55+
56+
if (!brc) {
57+
for (i = 0; i < 10; i++) {
58+
m = jdi.ReadNext();
59+
60+
if (m > 0) {
61+
columns = jdi.GetColumns();
62+
63+
for (String col : columns)
64+
System.out.println(col + "=" + jdi.GetField(col));
65+
66+
if (pipeline == null) {
67+
if (name.equalsIgnoreCase("gtst"))
68+
System.out.println("gtst=" + jdi.GetField("*"));
69+
70+
if (name.equalsIgnoreCase("inventory")) {
71+
System.out.println("warehouse=" + jdi.GetField("instock.0.warehouse"));
72+
System.out.println("quantity=" + jdi.GetField("instock.1.qty"));
73+
} // endif inventory
74+
75+
if (name.equalsIgnoreCase("restaurants")) {
76+
System.out.println("score=" + jdi.GetField("grades.0.score"));
77+
System.out.println("date=" + jdi.GetField("grades.0.date"));
78+
} // endif restaurants
79+
80+
} // endif pipeline
81+
82+
} else if (m < 0) {
83+
System.out.println("ReadNext: " + jdi.GetErrmsg());
84+
break;
85+
} else
86+
break;
87+
88+
} // endfor i
89+
90+
} // endif brc
91+
92+
} // endwhile name
93+
94+
rc = jdi.MongoDisconnect();
95+
System.out.println("Disconnect returned " + rc);
96+
} else
97+
System.out.println(jdi.GetErrmsg() + " rc=" + rc);
98+
99+
} // end of main
100+
101+
// ==================================================================
102+
private static String getLine(String p, boolean b) {
103+
String response;
104+
105+
if (c != null) {
106+
// Standard console mode
107+
if (b) {
108+
response = new String(c.readPassword(p));
109+
} else
110+
response = c.readLine(p);
111+
112+
} else {
113+
// For instance when testing from Eclipse
114+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
115+
116+
System.out.print(p);
117+
118+
try {
119+
// Cannot suppress echo for password entry
120+
response = in.readLine();
121+
} catch (IOException e) {
122+
response = "";
123+
} // end of try/catch
124+
125+
} // endif c
126+
127+
return (response.isEmpty()) ? null : response;
128+
} // end of getLine
129+
130+
} // end of class Client

storage/connect/Client3.java

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package wrappers;
2+
3+
import java.io.BufferedReader;
4+
import java.io.Console;
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
7+
import java.util.Set;
8+
9+
public class Client3 {
10+
static boolean DEBUG = true;
11+
static final Console c = System.console();
12+
static Mongo3Interface jdi = null;
13+
14+
public static void main(String[] args) {
15+
int rc, level = 0;
16+
boolean brc, desc = false;
17+
Set<String> columns;
18+
String[] parms = new String[4];
19+
20+
jdi = new Mongo3Interface(DEBUG);
21+
22+
parms[0] = getLine("URI: ", false);
23+
parms[1] = getLine("Database: ", false);
24+
parms[2] = null;
25+
parms[3] = null;
26+
27+
if (parms[0] == null)
28+
parms[0] = "mongodb://localhost:27017";
29+
30+
if (parms[1] == null)
31+
parms[1] = "test";
32+
33+
rc = jdi.MongoConnect(parms);
34+
35+
if (rc == 0) {
36+
String name, pipeline, query, fields;
37+
System.out.println("Successfully connected to " + parms[0]);
38+
39+
while ((name = getLine("Collection: ", false)) != null) {
40+
if (jdi.GetCollection(name))
41+
System.out.println("GetCollection failed");
42+
else
43+
System.out.println("Collection size: " + jdi.GetCollSize());
44+
45+
pipeline = getLine("Pipeline: ", false);
46+
47+
if (pipeline == null || (desc = pipeline.equals("*"))) {
48+
query = getLine("Filter: ", false);
49+
fields = getLine("Proj: ", false);
50+
51+
if (desc)
52+
level = Integer.parseInt(getLine("Level: ", false));
53+
54+
brc = jdi.FindColl(query, fields);
55+
} else
56+
brc = jdi.AggregateColl(pipeline);
57+
58+
System.out.println("Returned brc = " + brc);
59+
60+
if (!brc && !desc) {
61+
for (int i = 0; jdi.ReadNext() > 0 && i < 10; i++) {
62+
columns = jdi.GetColumns();
63+
64+
for (String col : columns)
65+
System.out.println(col + "=" + jdi.GetField(col));
66+
67+
if (name.equalsIgnoreCase("gtst"))
68+
System.out.println("gtst=" + jdi.GetField("*"));
69+
70+
if (name.equalsIgnoreCase("inventory")) {
71+
System.out.println("warehouse=" + jdi.GetField("instock.0.warehouse"));
72+
System.out.println("quantity=" + jdi.GetField("instock.1.qty"));
73+
} // endif inventory
74+
75+
if (name.equalsIgnoreCase("restaurants")) {
76+
System.out.println("score=" + jdi.GetField("grades.0.score"));
77+
System.out.println("date=" + jdi.GetField("grades.0.date"));
78+
} // endif inventory
79+
80+
} // endfor i
81+
82+
} else if (desc) {
83+
int ncol;
84+
85+
for (int i = 0; (ncol = jdi.ReadNext()) > 0 && i < 2; i++) {
86+
if (discovery(null, "", ncol, level))
87+
break;
88+
89+
System.out.println("--------------");
90+
} // endfor i
91+
92+
} // endif desc
93+
94+
} // endwhile query
95+
96+
rc = jdi.MongoDisconnect();
97+
System.out.println("Disconnect returned " + rc);
98+
} else
99+
System.out.println(jdi.GetErrmsg() + " rc=" + rc);
100+
101+
} // end of main
102+
103+
private static boolean discovery(Object obj, String name, int ncol, int level) {
104+
int[] val = new int[5];
105+
Object ret = null;
106+
String bvn = null;
107+
108+
for (int k = 0; k < ncol; k++) {
109+
ret = jdi.ColumnDesc(obj, k, val, level);
110+
bvn = jdi.ColDescName();
111+
112+
if (ret != null)
113+
discovery(ret, name.concat(bvn).concat("."), val[4], level - 1);
114+
else if (val[0] > 0)
115+
System.out.println(
116+
name + bvn + ": type=" + val[0] + " length=" + val[1] + " prec=" + val[2] + " nullable=" + val[3]);
117+
else if (val[0] < 0)
118+
System.out.println(jdi.GetErrmsg());
119+
120+
} // endfor k
121+
122+
return false;
123+
} // end of discovery
124+
125+
// ==================================================================
126+
private static String getLine(String p, boolean b) {
127+
String response;
128+
129+
if (c != null) {
130+
// Standard console mode
131+
if (b) {
132+
response = new String(c.readPassword(p));
133+
} else
134+
response = c.readLine(p);
135+
136+
} else {
137+
// For instance when testing from Eclipse
138+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
139+
140+
System.out.print(p);
141+
142+
try {
143+
// Cannot suppress echo for password entry
144+
response = in.readLine();
145+
} catch (IOException e) {
146+
response = "";
147+
} // end of try/catch
148+
149+
} // endif c
150+
151+
return (response.isEmpty()) ? null : response;
152+
} // end of getLine
153+
154+
} // end of class Client

0 commit comments

Comments
 (0)