mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge remote-tracking branch 'connect/10.2' into 10.2
This commit is contained in:
130
storage/connect/Client2.java
Normal file
130
storage/connect/Client2.java
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
package wrappers;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Console;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Client2 {
|
||||||
|
static boolean DEBUG = true;
|
||||||
|
static final Console c = System.console();
|
||||||
|
static Mongo2Interface jdi = null;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int rc, m, i = 0;
|
||||||
|
boolean brc;
|
||||||
|
Set<String> columns;
|
||||||
|
String[] parms = new String[4];
|
||||||
|
|
||||||
|
jdi = new Mongo2Interface(DEBUG);
|
||||||
|
|
||||||
|
parms[0] = getLine("URI: ", false);
|
||||||
|
parms[1] = getLine("DB: ", false);
|
||||||
|
parms[2] = null;
|
||||||
|
parms[3] = null;
|
||||||
|
|
||||||
|
if (parms[0] == null)
|
||||||
|
parms[0] = "mongodb://localhost:27017";
|
||||||
|
|
||||||
|
if (parms[1] == null)
|
||||||
|
parms[1] = "test";
|
||||||
|
|
||||||
|
rc = jdi.MongoConnect(parms);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
String name, pipeline, query, fields;
|
||||||
|
System.out.println("Successfully connected to " + parms[1]);
|
||||||
|
|
||||||
|
while ((name = getLine("Collection: ", false)) != null) {
|
||||||
|
if (jdi.GetCollection(name))
|
||||||
|
System.out.println("GetCollection failed");
|
||||||
|
else
|
||||||
|
System.out.println("Collection size: " + jdi.GetCollSize());
|
||||||
|
|
||||||
|
pipeline = getLine("Pipeline: ", false);
|
||||||
|
|
||||||
|
if (pipeline == null) {
|
||||||
|
query = getLine("Filter: ", false);
|
||||||
|
fields = getLine("Proj: ", false);
|
||||||
|
brc = jdi.FindColl(query, fields);
|
||||||
|
} else
|
||||||
|
brc = jdi.AggregateColl(pipeline);
|
||||||
|
|
||||||
|
System.out.println("Returned brc = " + brc);
|
||||||
|
|
||||||
|
if (!brc) {
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
m = jdi.ReadNext();
|
||||||
|
|
||||||
|
if (m > 0) {
|
||||||
|
columns = jdi.GetColumns();
|
||||||
|
|
||||||
|
for (String col : columns)
|
||||||
|
System.out.println(col + "=" + jdi.GetField(col));
|
||||||
|
|
||||||
|
if (pipeline == null) {
|
||||||
|
if (name.equalsIgnoreCase("gtst"))
|
||||||
|
System.out.println("gtst=" + jdi.GetField("*"));
|
||||||
|
|
||||||
|
if (name.equalsIgnoreCase("inventory")) {
|
||||||
|
System.out.println("warehouse=" + jdi.GetField("instock.0.warehouse"));
|
||||||
|
System.out.println("quantity=" + jdi.GetField("instock.1.qty"));
|
||||||
|
} // endif inventory
|
||||||
|
|
||||||
|
if (name.equalsIgnoreCase("restaurants")) {
|
||||||
|
System.out.println("score=" + jdi.GetField("grades.0.score"));
|
||||||
|
System.out.println("date=" + jdi.GetField("grades.0.date"));
|
||||||
|
} // endif restaurants
|
||||||
|
|
||||||
|
} // endif pipeline
|
||||||
|
|
||||||
|
} else if (m < 0) {
|
||||||
|
System.out.println("ReadNext: " + jdi.GetErrmsg());
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
|
} // endfor i
|
||||||
|
|
||||||
|
} // endif brc
|
||||||
|
|
||||||
|
} // endwhile name
|
||||||
|
|
||||||
|
rc = jdi.MongoDisconnect();
|
||||||
|
System.out.println("Disconnect returned " + rc);
|
||||||
|
} else
|
||||||
|
System.out.println(jdi.GetErrmsg() + " rc=" + rc);
|
||||||
|
|
||||||
|
} // end of main
|
||||||
|
|
||||||
|
// ==================================================================
|
||||||
|
private static String getLine(String p, boolean b) {
|
||||||
|
String response;
|
||||||
|
|
||||||
|
if (c != null) {
|
||||||
|
// Standard console mode
|
||||||
|
if (b) {
|
||||||
|
response = new String(c.readPassword(p));
|
||||||
|
} else
|
||||||
|
response = c.readLine(p);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// For instance when testing from Eclipse
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
|
||||||
|
System.out.print(p);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Cannot suppress echo for password entry
|
||||||
|
response = in.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
response = "";
|
||||||
|
} // end of try/catch
|
||||||
|
|
||||||
|
} // endif c
|
||||||
|
|
||||||
|
return (response.isEmpty()) ? null : response;
|
||||||
|
} // end of getLine
|
||||||
|
|
||||||
|
} // end of class Client
|
154
storage/connect/Client3.java
Normal file
154
storage/connect/Client3.java
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
package wrappers;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Console;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Client3 {
|
||||||
|
static boolean DEBUG = true;
|
||||||
|
static final Console c = System.console();
|
||||||
|
static Mongo3Interface jdi = null;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int rc, level = 0;
|
||||||
|
boolean brc, desc = false;
|
||||||
|
Set<String> columns;
|
||||||
|
String[] parms = new String[4];
|
||||||
|
|
||||||
|
jdi = new Mongo3Interface(DEBUG);
|
||||||
|
|
||||||
|
parms[0] = getLine("URI: ", false);
|
||||||
|
parms[1] = getLine("Database: ", false);
|
||||||
|
parms[2] = null;
|
||||||
|
parms[3] = null;
|
||||||
|
|
||||||
|
if (parms[0] == null)
|
||||||
|
parms[0] = "mongodb://localhost:27017";
|
||||||
|
|
||||||
|
if (parms[1] == null)
|
||||||
|
parms[1] = "test";
|
||||||
|
|
||||||
|
rc = jdi.MongoConnect(parms);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
String name, pipeline, query, fields;
|
||||||
|
System.out.println("Successfully connected to " + parms[0]);
|
||||||
|
|
||||||
|
while ((name = getLine("Collection: ", false)) != null) {
|
||||||
|
if (jdi.GetCollection(name))
|
||||||
|
System.out.println("GetCollection failed");
|
||||||
|
else
|
||||||
|
System.out.println("Collection size: " + jdi.GetCollSize());
|
||||||
|
|
||||||
|
pipeline = getLine("Pipeline: ", false);
|
||||||
|
|
||||||
|
if (pipeline == null || (desc = pipeline.equals("*"))) {
|
||||||
|
query = getLine("Filter: ", false);
|
||||||
|
fields = getLine("Proj: ", false);
|
||||||
|
|
||||||
|
if (desc)
|
||||||
|
level = Integer.parseInt(getLine("Level: ", false));
|
||||||
|
|
||||||
|
brc = jdi.FindColl(query, fields);
|
||||||
|
} else
|
||||||
|
brc = jdi.AggregateColl(pipeline);
|
||||||
|
|
||||||
|
System.out.println("Returned brc = " + brc);
|
||||||
|
|
||||||
|
if (!brc && !desc) {
|
||||||
|
for (int i = 0; jdi.ReadNext() > 0 && i < 10; i++) {
|
||||||
|
columns = jdi.GetColumns();
|
||||||
|
|
||||||
|
for (String col : columns)
|
||||||
|
System.out.println(col + "=" + jdi.GetField(col));
|
||||||
|
|
||||||
|
if (name.equalsIgnoreCase("gtst"))
|
||||||
|
System.out.println("gtst=" + jdi.GetField("*"));
|
||||||
|
|
||||||
|
if (name.equalsIgnoreCase("inventory")) {
|
||||||
|
System.out.println("warehouse=" + jdi.GetField("instock.0.warehouse"));
|
||||||
|
System.out.println("quantity=" + jdi.GetField("instock.1.qty"));
|
||||||
|
} // endif inventory
|
||||||
|
|
||||||
|
if (name.equalsIgnoreCase("restaurants")) {
|
||||||
|
System.out.println("score=" + jdi.GetField("grades.0.score"));
|
||||||
|
System.out.println("date=" + jdi.GetField("grades.0.date"));
|
||||||
|
} // endif inventory
|
||||||
|
|
||||||
|
} // endfor i
|
||||||
|
|
||||||
|
} else if (desc) {
|
||||||
|
int ncol;
|
||||||
|
|
||||||
|
for (int i = 0; (ncol = jdi.ReadNext()) > 0 && i < 2; i++) {
|
||||||
|
if (discovery(null, "", ncol, level))
|
||||||
|
break;
|
||||||
|
|
||||||
|
System.out.println("--------------");
|
||||||
|
} // endfor i
|
||||||
|
|
||||||
|
} // endif desc
|
||||||
|
|
||||||
|
} // endwhile query
|
||||||
|
|
||||||
|
rc = jdi.MongoDisconnect();
|
||||||
|
System.out.println("Disconnect returned " + rc);
|
||||||
|
} else
|
||||||
|
System.out.println(jdi.GetErrmsg() + " rc=" + rc);
|
||||||
|
|
||||||
|
} // end of main
|
||||||
|
|
||||||
|
private static boolean discovery(Object obj, String name, int ncol, int level) {
|
||||||
|
int[] val = new int[5];
|
||||||
|
Object ret = null;
|
||||||
|
String bvn = null;
|
||||||
|
|
||||||
|
for (int k = 0; k < ncol; k++) {
|
||||||
|
ret = jdi.ColumnDesc(obj, k, val, level);
|
||||||
|
bvn = jdi.ColDescName();
|
||||||
|
|
||||||
|
if (ret != null)
|
||||||
|
discovery(ret, name.concat(bvn).concat("."), val[4], level - 1);
|
||||||
|
else if (val[0] > 0)
|
||||||
|
System.out.println(
|
||||||
|
name + bvn + ": type=" + val[0] + " length=" + val[1] + " prec=" + val[2] + " nullable=" + val[3]);
|
||||||
|
else if (val[0] < 0)
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
} // endfor k
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of discovery
|
||||||
|
|
||||||
|
// ==================================================================
|
||||||
|
private static String getLine(String p, boolean b) {
|
||||||
|
String response;
|
||||||
|
|
||||||
|
if (c != null) {
|
||||||
|
// Standard console mode
|
||||||
|
if (b) {
|
||||||
|
response = new String(c.readPassword(p));
|
||||||
|
} else
|
||||||
|
response = c.readLine(p);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// For instance when testing from Eclipse
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
|
||||||
|
System.out.print(p);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Cannot suppress echo for password entry
|
||||||
|
response = in.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
response = "";
|
||||||
|
} // end of try/catch
|
||||||
|
|
||||||
|
} // endif c
|
||||||
|
|
||||||
|
return (response.isEmpty()) ? null : response;
|
||||||
|
} // end of getLine
|
||||||
|
|
||||||
|
} // end of class Client
|
@@ -21,6 +21,7 @@ import com.mongodb.util.JSON;
|
|||||||
public class Mongo2Interface {
|
public class Mongo2Interface {
|
||||||
boolean DEBUG = false;
|
boolean DEBUG = false;
|
||||||
String Errmsg = "No error";
|
String Errmsg = "No error";
|
||||||
|
String ovalName = null;
|
||||||
Set<String> Colnames = null;
|
Set<String> Colnames = null;
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
MongoClient client = null;
|
MongoClient client = null;
|
||||||
@@ -220,7 +221,7 @@ public class Mongo2Interface {
|
|||||||
System.out.println("Class doc = " + doc.getClass());
|
System.out.println("Class doc = " + doc.getClass());
|
||||||
|
|
||||||
Colnames = doc.keySet();
|
Colnames = doc.keySet();
|
||||||
return 1;
|
return Colnames.size();
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -253,30 +254,106 @@ public class Mongo2Interface {
|
|||||||
|
|
||||||
} // end of GetColumns
|
} // end of GetColumns
|
||||||
|
|
||||||
public String ColumnDesc(int n, int[] val) {
|
public Object ColumnDesc(Object obj, int n, int[] val, int lvl) {
|
||||||
// if (rsmd == null) {
|
Object ret = null;
|
||||||
// System.out.println("No result metadata");
|
Object oval = ((obj != null) ? obj : doc);
|
||||||
// return null;
|
BasicDBObject dob = (oval instanceof BasicDBObject) ? (BasicDBObject) oval : null;
|
||||||
// } else try {
|
BasicDBList ary = (oval instanceof BasicDBList) ? (BasicDBList) oval : null;
|
||||||
// val[0] = rsmd.getColumnType(n);
|
|
||||||
// val[1] = rsmd.getPrecision(n);
|
|
||||||
// val[2] = rsmd.getScale(n);
|
|
||||||
// val[3] = rsmd.isNullable(n);
|
|
||||||
// return rsmd.getColumnLabel(n);
|
|
||||||
// } catch (SQLException se) {
|
|
||||||
// SetErrmsg(se);
|
|
||||||
// } //end try/catch
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (ary != null) {
|
||||||
|
oval = ary.get(n);
|
||||||
|
ovalName = Integer.toString(n);
|
||||||
|
} else if (dob != null) {
|
||||||
|
// String[] k = dob.keySet().toArray(new String[0]);
|
||||||
|
Object[] k = dob.keySet().toArray();
|
||||||
|
oval = dob.get(k[n]);
|
||||||
|
ovalName = (String) k[n];
|
||||||
|
} else
|
||||||
|
ovalName = "x" + Integer.toString(n);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
System.out.println("Class of " + ovalName + " = " + oval.getClass());
|
||||||
|
|
||||||
|
val[0] = 0; // ColumnType
|
||||||
|
val[1] = 0; // Precision
|
||||||
|
val[2] = 0; // Scale
|
||||||
|
val[3] = 0; // Nullable
|
||||||
|
val[4] = 0; // ncol
|
||||||
|
|
||||||
|
if (oval == null) {
|
||||||
|
val[3] = 1;
|
||||||
|
} else if (oval instanceof String) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = ((String) oval).length();
|
||||||
|
} else if (oval instanceof org.bson.types.ObjectId) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = ((org.bson.types.ObjectId) oval).toString().length();
|
||||||
|
} else if (oval instanceof Integer) {
|
||||||
|
val[0] = 7;
|
||||||
|
val[1] = Integer.toString(((Integer) oval).intValue()).length();
|
||||||
|
} else if (oval instanceof Long) {
|
||||||
|
val[0] = 5;
|
||||||
|
val[1] = Long.toString(((Long) oval).longValue()).length();
|
||||||
|
} else if (oval instanceof Date) {
|
||||||
|
Long TS = (((Date) oval).getTime() / 1000);
|
||||||
|
val[0] = 8;
|
||||||
|
val[1] = TS.toString().length();
|
||||||
|
} else if (oval instanceof Double) {
|
||||||
|
String d = Double.toString(((Double) oval).doubleValue());
|
||||||
|
int i = d.indexOf('.') + 1;
|
||||||
|
|
||||||
|
val[0] = 2;
|
||||||
|
val[1] = d.length();
|
||||||
|
val[2] = (i > 0) ? val[1] - i : 0;
|
||||||
|
} else if (oval instanceof Boolean) {
|
||||||
|
val[0] = 4;
|
||||||
|
val[1] = 1;
|
||||||
|
} else if (oval instanceof BasicDBObject) {
|
||||||
|
if (lvl > 0) {
|
||||||
|
ret = oval;
|
||||||
|
val[0] = 1;
|
||||||
|
val[4] = ((BasicDBObject) oval).size();
|
||||||
|
} else if (lvl == 0) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = oval.toString().length();
|
||||||
|
} // endif lvl
|
||||||
|
|
||||||
|
} else if (oval instanceof BasicDBList) {
|
||||||
|
if (lvl > 0) {
|
||||||
|
ret = oval;
|
||||||
|
val[0] = 2;
|
||||||
|
val[4] = ((BasicDBList) oval).size();
|
||||||
|
} else if (lvl == 0) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = oval.toString().length();
|
||||||
|
} // endif lvl
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SetErrmsg("Type " + " of " + ovalName + " not supported");
|
||||||
|
val[0] = -1;
|
||||||
|
} // endif's
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
SetErrmsg(ex);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
val[0] = -1;
|
||||||
return null;
|
return null;
|
||||||
} // end of ColumnDesc
|
} // end of ColumnDesc
|
||||||
|
|
||||||
|
public String ColDescName() {
|
||||||
|
return ovalName;
|
||||||
|
} // end of ColDescName
|
||||||
|
|
||||||
protected Object GetFieldObject(String path) {
|
protected Object GetFieldObject(String path) {
|
||||||
Object o = null;
|
Object o = null;
|
||||||
BasicDBObject dob = null;
|
BasicDBObject dob = null;
|
||||||
BasicDBList lst = null;
|
BasicDBList lst = null;
|
||||||
String[] names = null;
|
String[] names = null;
|
||||||
|
|
||||||
if (path == null || path.equals("*"))
|
if (path == null || path.equals("") || path.equals("*"))
|
||||||
return doc;
|
return doc;
|
||||||
else if (doc instanceof BasicDBObject)
|
else if (doc instanceof BasicDBObject)
|
||||||
dob = doc;
|
dob = doc;
|
||||||
@@ -325,9 +402,10 @@ public class Mongo2Interface {
|
|||||||
|
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
if (o instanceof Date) {
|
if (o instanceof Date) {
|
||||||
Integer TS = (int) (((Date) o).getTime() / 1000);
|
Long TS = (((Date) o).getTime() / 1000);
|
||||||
return TS.toString();
|
return TS.toString();
|
||||||
} // endif Date
|
} else if (o instanceof Boolean)
|
||||||
|
return (Boolean) o ? "1" : "0";
|
||||||
|
|
||||||
return o.toString();
|
return o.toString();
|
||||||
} else
|
} else
|
||||||
@@ -335,13 +413,25 @@ public class Mongo2Interface {
|
|||||||
|
|
||||||
} // end of GetField
|
} // end of GetField
|
||||||
|
|
||||||
|
public Object MakeBson(String s, int json) {
|
||||||
|
if (json == 1 || json == 2) {
|
||||||
|
return com.mongodb.util.JSON.parse(s);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} // end of MakeBson
|
||||||
|
|
||||||
public Object MakeDocument() {
|
public Object MakeDocument() {
|
||||||
return new BasicDBObject();
|
return new BasicDBObject();
|
||||||
} // end of MakeDocument
|
} // end of MakeDocument
|
||||||
|
|
||||||
public boolean DocAdd(Object bdc, String key, Object val) {
|
public boolean DocAdd(Object bdc, String key, Object val, int json) {
|
||||||
try {
|
try {
|
||||||
((BasicDBObject) bdc).append(key, val);
|
if (json != 0 && val instanceof String)
|
||||||
|
((BasicDBObject) bdc).append(key, JSON.parse((String) val));
|
||||||
|
else
|
||||||
|
((BasicDBObject) bdc).append(key, val);
|
||||||
|
|
||||||
} catch (MongoException me) {
|
} catch (MongoException me) {
|
||||||
SetErrmsg(me);
|
SetErrmsg(me);
|
||||||
return true;
|
return true;
|
||||||
@@ -354,9 +444,13 @@ public class Mongo2Interface {
|
|||||||
return new BasicDBList();
|
return new BasicDBList();
|
||||||
} // end of MakeArray
|
} // end of MakeArray
|
||||||
|
|
||||||
public boolean ArrayAdd(Object bar, int n, Object val) {
|
public boolean ArrayAdd(Object bar, int n, Object val, int json) {
|
||||||
try {
|
try {
|
||||||
((BasicDBList) bar).put(n, val);
|
if (json != 0 && val instanceof String)
|
||||||
|
((BasicDBList) bar).put(n, JSON.parse((String) val));
|
||||||
|
else
|
||||||
|
((BasicDBList) bar).put(n, val);
|
||||||
|
|
||||||
} catch (MongoException me) {
|
} catch (MongoException me) {
|
||||||
SetErrmsg(me);
|
SetErrmsg(me);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package wrappers;
|
package wrappers;
|
||||||
|
|
||||||
|
//import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -9,6 +10,7 @@ import java.util.Set;
|
|||||||
import org.bson.BsonArray;
|
import org.bson.BsonArray;
|
||||||
import org.bson.BsonBoolean;
|
import org.bson.BsonBoolean;
|
||||||
import org.bson.BsonDateTime;
|
import org.bson.BsonDateTime;
|
||||||
|
//import org.bson.BsonDecimal128;
|
||||||
import org.bson.BsonDocument;
|
import org.bson.BsonDocument;
|
||||||
import org.bson.BsonDouble;
|
import org.bson.BsonDouble;
|
||||||
import org.bson.BsonInt32;
|
import org.bson.BsonInt32;
|
||||||
@@ -18,6 +20,7 @@ import org.bson.BsonString;
|
|||||||
import org.bson.BsonValue;
|
import org.bson.BsonValue;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
|
//import org.bson.types.Decimal128;
|
||||||
|
|
||||||
import com.mongodb.MongoClient;
|
import com.mongodb.MongoClient;
|
||||||
import com.mongodb.MongoClientURI;
|
import com.mongodb.MongoClientURI;
|
||||||
@@ -34,6 +37,7 @@ import com.mongodb.client.result.UpdateResult;
|
|||||||
public class Mongo3Interface {
|
public class Mongo3Interface {
|
||||||
boolean DEBUG = false;
|
boolean DEBUG = false;
|
||||||
String Errmsg = "No error";
|
String Errmsg = "No error";
|
||||||
|
String bvalName = null;
|
||||||
Set<String> Colnames = null;
|
Set<String> Colnames = null;
|
||||||
MongoClient client = null;
|
MongoClient client = null;
|
||||||
MongoDatabase db = null;
|
MongoDatabase db = null;
|
||||||
@@ -167,7 +171,7 @@ public class Mongo3Interface {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
Bson dbq = Document.parse((query != null) ? query : "{}");
|
Bson dbq = Document.parse(query);
|
||||||
finditer = coll.find(dbq);
|
finditer = coll.find(dbq);
|
||||||
} else
|
} else
|
||||||
finditer = coll.find();
|
finditer = coll.find();
|
||||||
@@ -218,17 +222,23 @@ public class Mongo3Interface {
|
|||||||
} // end of Rewind
|
} // end of Rewind
|
||||||
|
|
||||||
public int ReadNext() {
|
public int ReadNext() {
|
||||||
if (cursor.hasNext()) {
|
try {
|
||||||
doc = cursor.next();
|
if (cursor.hasNext()) {
|
||||||
|
doc = cursor.next();
|
||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
System.out.println("Class doc = " + doc.getClass());
|
System.out.println("Class doc = " + doc.getClass());
|
||||||
|
|
||||||
Colnames = doc.keySet();
|
Colnames = doc.keySet();
|
||||||
return 1;
|
return Colnames.size();
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
} catch (MongoException mx) {
|
||||||
|
SetErrmsg(mx);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
return -1;
|
||||||
} // end of ReadNext
|
} // end of ReadNext
|
||||||
|
|
||||||
public boolean Fetch(int row) {
|
public boolean Fetch(int row) {
|
||||||
@@ -254,13 +264,11 @@ public class Mongo3Interface {
|
|||||||
} // end of GetColumns
|
} // end of GetColumns
|
||||||
|
|
||||||
public String ColumnName(int n) {
|
public String ColumnName(int n) {
|
||||||
int i = 1;
|
if (n < Colnames.size())
|
||||||
|
return (String) Colnames.toArray()[n];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
for (String name : Colnames)
|
|
||||||
if (i++ == n)
|
|
||||||
return name;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
} // end of ColumnName
|
} // end of ColumnName
|
||||||
|
|
||||||
public int ColumnType(int n, String name) {
|
public int ColumnType(int n, String name) {
|
||||||
@@ -278,30 +286,111 @@ public class Mongo3Interface {
|
|||||||
return 666; // Not a type
|
return 666; // Not a type
|
||||||
} // end of ColumnType
|
} // end of ColumnType
|
||||||
|
|
||||||
public String ColumnDesc(int n, int[] val) {
|
public Object ColumnDesc(Object obj, int n, int[] val, int lvl) {
|
||||||
// if (rsmd == null) {
|
Object ret = null;
|
||||||
// System.out.println("No result metadata");
|
BsonValue bval = (BsonValue) ((obj != null) ? obj : doc);
|
||||||
// return null;
|
BsonDocument dob = (bval instanceof BsonDocument) ? (BsonDocument) bval : null;
|
||||||
// } else try {
|
BsonArray ary = (bval instanceof BsonArray) ? (BsonArray) bval : null;
|
||||||
// val[0] = rsmd.getColumnType(n);
|
|
||||||
// val[1] = rsmd.getPrecision(n);
|
|
||||||
// val[2] = rsmd.getScale(n);
|
|
||||||
// val[3] = rsmd.isNullable(n);
|
|
||||||
// return rsmd.getColumnLabel(n);
|
|
||||||
// } catch (SQLException se) {
|
|
||||||
// SetErrmsg(se);
|
|
||||||
// } //end try/catch
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (ary != null) {
|
||||||
|
bval = ary.get(n);
|
||||||
|
bvalName = Integer.toString(n);
|
||||||
|
} else if (dob != null) {
|
||||||
|
// String[] k = dob.keySet().toArray(new String[0]);
|
||||||
|
Object[] k = dob.keySet().toArray();
|
||||||
|
bval = dob.get(k[n]);
|
||||||
|
bvalName = (String) k[n];
|
||||||
|
} else
|
||||||
|
bvalName = "x" + Integer.toString(n);
|
||||||
|
|
||||||
|
val[0] = 0; // ColumnType
|
||||||
|
val[1] = 0; // Precision
|
||||||
|
val[2] = 0; // Scale
|
||||||
|
val[3] = 0; // Nullable
|
||||||
|
val[4] = 0; // ncol
|
||||||
|
|
||||||
|
if (bval.isString()) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = bval.asString().getValue().length();
|
||||||
|
} else if (bval.isInt32()) {
|
||||||
|
val[0] = 7;
|
||||||
|
val[1] = Integer.toString(bval.asInt32().getValue()).length();
|
||||||
|
} else if (bval.isInt64()) {
|
||||||
|
val[0] = 5;
|
||||||
|
val[1] = Long.toString(bval.asInt64().getValue()).length();
|
||||||
|
} else if (bval.isObjectId()) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = bval.asObjectId().getValue().toString().length();
|
||||||
|
} else if (bval.isDateTime()) {
|
||||||
|
Long TS = (bval.asDateTime().getValue() / 1000);
|
||||||
|
val[0] = 8;
|
||||||
|
val[1] = TS.toString().length();
|
||||||
|
} else if (bval.isDouble()) {
|
||||||
|
String d = Double.toString(bval.asDouble().getValue());
|
||||||
|
int i = d.indexOf('.') + 1;
|
||||||
|
|
||||||
|
val[0] = 2;
|
||||||
|
val[1] = d.length();
|
||||||
|
val[2] = (i > 0) ? val[1] - i : 0;
|
||||||
|
} else if (bval.isBoolean()) {
|
||||||
|
val[0] = 4;
|
||||||
|
val[1] = 1;
|
||||||
|
} else if (bval.isDocument()) {
|
||||||
|
if (lvl > 0) {
|
||||||
|
ret = bval;
|
||||||
|
val[0] = 1;
|
||||||
|
val[4] = bval.asDocument().keySet().size();
|
||||||
|
} else if (lvl == 0) {
|
||||||
|
val[0] = 1;
|
||||||
|
val[1] = bval.asDocument().toJson().length();
|
||||||
|
} // endif lvl
|
||||||
|
|
||||||
|
} else if (bval.isArray()) {
|
||||||
|
if (lvl > 0) {
|
||||||
|
ret = bval;
|
||||||
|
val[0] = 2;
|
||||||
|
val[4] = bval.asArray().size();
|
||||||
|
} else if (lvl == 0) {
|
||||||
|
val[0] = 1;
|
||||||
|
util = new BsonDocument("arr", bval.asArray());
|
||||||
|
String s = util.toJson();
|
||||||
|
int i1 = s.indexOf('[');
|
||||||
|
int i2 = s.lastIndexOf(']');
|
||||||
|
val[1] = i2 - i1 + 1;
|
||||||
|
} // endif lvl
|
||||||
|
|
||||||
|
} else if (bval.isDecimal128()) {
|
||||||
|
val[0] = 9;
|
||||||
|
val[1] = bval.asDecimal128().toString().length();
|
||||||
|
} else if (bval.isNull()) {
|
||||||
|
val[0] = 0;
|
||||||
|
val[3] = 1;
|
||||||
|
} else {
|
||||||
|
SetErrmsg("Type " + bval.getBsonType() + " of " + bvalName + " not supported");
|
||||||
|
val[0] = -1;
|
||||||
|
} // endif's
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
SetErrmsg(ex);
|
||||||
|
} // end try/catch
|
||||||
|
|
||||||
|
val[0] = -1;
|
||||||
return null;
|
return null;
|
||||||
} // end of ColumnDesc
|
} // end of ColumnDesc
|
||||||
|
|
||||||
|
public String ColDescName() {
|
||||||
|
return bvalName;
|
||||||
|
} // end of ColDescName
|
||||||
|
|
||||||
protected BsonValue GetFieldObject(String path) {
|
protected BsonValue GetFieldObject(String path) {
|
||||||
BsonValue o = doc;
|
BsonValue o = doc;
|
||||||
BsonDocument dob = null;
|
BsonDocument dob = null;
|
||||||
BsonArray ary = null;
|
BsonArray ary = null;
|
||||||
String[] names = null;
|
String[] names = null;
|
||||||
|
|
||||||
if (path == null || path.equals("*"))
|
if (path == null || path.equals("") || path.equals("*"))
|
||||||
return doc;
|
return doc;
|
||||||
else if (o instanceof BsonDocument)
|
else if (o instanceof BsonDocument)
|
||||||
dob = doc;
|
dob = doc;
|
||||||
@@ -362,6 +451,8 @@ public class Mongo3Interface {
|
|||||||
return TS.toString();
|
return TS.toString();
|
||||||
} else if (o.isDouble()) {
|
} else if (o.isDouble()) {
|
||||||
return Double.toString(o.asDouble().getValue());
|
return Double.toString(o.asDouble().getValue());
|
||||||
|
} else if (o.isBoolean()) {
|
||||||
|
return o.asBoolean().getValue() ? "1" : "0";
|
||||||
} else if (o.isDocument()) {
|
} else if (o.isDocument()) {
|
||||||
return o.asDocument().toJson();
|
return o.asDocument().toJson();
|
||||||
} else if (o.isArray()) {
|
} else if (o.isArray()) {
|
||||||
@@ -370,6 +461,8 @@ public class Mongo3Interface {
|
|||||||
int i1 = s.indexOf('[');
|
int i1 = s.indexOf('[');
|
||||||
int i2 = s.lastIndexOf(']');
|
int i2 = s.lastIndexOf(']');
|
||||||
return s.substring(i1, i2 + 1);
|
return s.substring(i1, i2 + 1);
|
||||||
|
} else if (o.isDecimal128()) {
|
||||||
|
return o.asDecimal128().toString();
|
||||||
} else if (o.isNull()) {
|
} else if (o.isNull()) {
|
||||||
return null;
|
return null;
|
||||||
} else
|
} else
|
||||||
@@ -380,14 +473,33 @@ public class Mongo3Interface {
|
|||||||
|
|
||||||
} // end of GetField
|
} // end of GetField
|
||||||
|
|
||||||
protected BsonValue ObjToBson(Object val) {
|
public Object MakeBson(String s, int json) {
|
||||||
|
BsonValue bval;
|
||||||
|
|
||||||
|
if (json == 1)
|
||||||
|
bval = BsonDocument.parse(s);
|
||||||
|
else if (json == 2)
|
||||||
|
bval = BsonArray.parse(s);
|
||||||
|
else
|
||||||
|
bval = null;
|
||||||
|
|
||||||
|
return bval;
|
||||||
|
} // end of MakeBson
|
||||||
|
|
||||||
|
protected BsonValue ObjToBson(Object val, int json) {
|
||||||
BsonValue bval = null;
|
BsonValue bval = null;
|
||||||
|
|
||||||
if (val == null)
|
if (val == null)
|
||||||
bval = bsonull;
|
bval = bsonull;
|
||||||
else if (val.getClass() == String.class)
|
else if (val.getClass() == String.class) {
|
||||||
bval = new BsonString((String) val);
|
if (json == 1)
|
||||||
else if (val.getClass() == Integer.class)
|
bval = BsonDocument.parse((String) val);
|
||||||
|
else if (json == 2)
|
||||||
|
bval = BsonArray.parse((String) val);
|
||||||
|
else
|
||||||
|
bval = new BsonString((String) val);
|
||||||
|
|
||||||
|
} else if (val.getClass() == Integer.class)
|
||||||
bval = new BsonInt32((int) val);
|
bval = new BsonInt32((int) val);
|
||||||
else if (val.getClass() == Double.class)
|
else if (val.getClass() == Double.class)
|
||||||
bval = new BsonDouble((double) val);
|
bval = new BsonDouble((double) val);
|
||||||
@@ -401,6 +513,8 @@ public class Mongo3Interface {
|
|||||||
bval = (BsonDocument) val;
|
bval = (BsonDocument) val;
|
||||||
else if (val.getClass() == BsonArray.class)
|
else if (val.getClass() == BsonArray.class)
|
||||||
bval = (BsonArray) val;
|
bval = (BsonArray) val;
|
||||||
|
// else if (val.getClass() == BigDecimal.class)
|
||||||
|
// bval = new BsonDecimal128((BigDecimal) val);
|
||||||
|
|
||||||
return bval;
|
return bval;
|
||||||
} // end of ObjToBson
|
} // end of ObjToBson
|
||||||
@@ -409,9 +523,9 @@ public class Mongo3Interface {
|
|||||||
return new BsonDocument();
|
return new BsonDocument();
|
||||||
} // end of MakeDocument
|
} // end of MakeDocument
|
||||||
|
|
||||||
public boolean DocAdd(Object bdc, String key, Object val) {
|
public boolean DocAdd(Object bdc, String key, Object val, int json) {
|
||||||
try {
|
try {
|
||||||
((BsonDocument) bdc).append(key, ObjToBson(val));
|
((BsonDocument) bdc).append(key, ObjToBson(val, json));
|
||||||
} catch (MongoException me) {
|
} catch (MongoException me) {
|
||||||
SetErrmsg(me);
|
SetErrmsg(me);
|
||||||
return true;
|
return true;
|
||||||
@@ -424,12 +538,12 @@ public class Mongo3Interface {
|
|||||||
return new BsonArray();
|
return new BsonArray();
|
||||||
} // end of MakeArray
|
} // end of MakeArray
|
||||||
|
|
||||||
public boolean ArrayAdd(Object bar, int n, Object val) {
|
public boolean ArrayAdd(Object bar, int n, Object val, int json) {
|
||||||
try {
|
try {
|
||||||
for (int i = ((BsonArray) bar).size(); i < n; i++)
|
for (int i = ((BsonArray) bar).size(); i < n; i++)
|
||||||
((BsonArray) bar).add(bsonull);
|
((BsonArray) bar).add(bsonull);
|
||||||
|
|
||||||
((BsonArray) bar).add(ObjToBson(val));
|
((BsonArray) bar).add(ObjToBson(val, json));
|
||||||
} catch (MongoException me) {
|
} catch (MongoException me) {
|
||||||
SetErrmsg(me);
|
SetErrmsg(me);
|
||||||
return true;
|
return true;
|
||||||
@@ -501,4 +615,4 @@ public class Mongo3Interface {
|
|||||||
return n;
|
return n;
|
||||||
} // end of CollDelete
|
} // end of CollDelete
|
||||||
|
|
||||||
} // end of class MongoInterface
|
} // end of class Mongo3Interface
|
||||||
|
131
storage/connect/TestInsert2.java
Normal file
131
storage/connect/TestInsert2.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package wrappers;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Console;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class TestInsert2 {
|
||||||
|
static boolean DEBUG = true;
|
||||||
|
static final Console c = System.console();
|
||||||
|
static Mongo2Interface jdi = null;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int rc;
|
||||||
|
String[] parms = new String[4];
|
||||||
|
|
||||||
|
jdi = new Mongo2Interface(DEBUG);
|
||||||
|
|
||||||
|
parms[0] = getLine("URI: ", false);
|
||||||
|
parms[1] = getLine("Database: ", false);
|
||||||
|
parms[2] = null;
|
||||||
|
parms[3] = null;
|
||||||
|
|
||||||
|
if (parms[0] == null)
|
||||||
|
parms[0] = "mongodb://localhost:27017";
|
||||||
|
|
||||||
|
if (parms[1] == null)
|
||||||
|
parms[1] = "test";
|
||||||
|
|
||||||
|
rc = jdi.MongoConnect(parms);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
Object bdoc = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "_id", (Object) 1, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Name", (Object) "Smith", 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Age", (Object) 39, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Pi", (Object) 3.14, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Phone", (Object) "{\"ext\":[4,5,7]}", 1))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Scores", (Object) "[24,2,13]", 2))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object bar = jdi.MakeArray();
|
||||||
|
|
||||||
|
for (int i = 1; i < 3; i++)
|
||||||
|
if (jdi.ArrayAdd(bar, i, (Object) (Math.random() * 10.0), 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Prices", bar, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object dat = new Date();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Date", dat, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
System.out.println(bdoc);
|
||||||
|
|
||||||
|
// Try to update
|
||||||
|
if (!jdi.GetCollection("updtest") && !jdi.FindColl(null, null)) {
|
||||||
|
if (jdi.CollDelete(true) < 0)
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.CollInsert(bdoc))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object updlist = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(updlist, "Age", (Object) 45, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object upd = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(upd, "$set", updlist, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.ReadNext() > 0 && jdi.CollUpdate(upd) < 0)
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (!jdi.Rewind() && jdi.ReadNext() > 0)
|
||||||
|
System.out.println(jdi.GetDoc());
|
||||||
|
else
|
||||||
|
System.out.println("Failed Rewind");
|
||||||
|
|
||||||
|
} // endif n
|
||||||
|
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
} // end of main
|
||||||
|
|
||||||
|
// ==================================================================
|
||||||
|
private static String getLine(String p, boolean b) {
|
||||||
|
String response;
|
||||||
|
|
||||||
|
if (c != null) {
|
||||||
|
// Standard console mode
|
||||||
|
if (b) {
|
||||||
|
response = new String(c.readPassword(p));
|
||||||
|
} else
|
||||||
|
response = c.readLine(p);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// For instance when testing from Eclipse
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
|
||||||
|
System.out.print(p);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Cannot suppress echo for password entry
|
||||||
|
response = in.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
response = "";
|
||||||
|
} // end of try/catch
|
||||||
|
|
||||||
|
} // endif c
|
||||||
|
|
||||||
|
return (response.isEmpty()) ? null : response;
|
||||||
|
} // end of getLine
|
||||||
|
|
||||||
|
}
|
131
storage/connect/TestInsert3.java
Normal file
131
storage/connect/TestInsert3.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package wrappers;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Console;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class TestInsert3 {
|
||||||
|
static boolean DEBUG = true;
|
||||||
|
static final Console c = System.console();
|
||||||
|
static Mongo3Interface jdi = null;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int rc;
|
||||||
|
String[] parms = new String[4];
|
||||||
|
|
||||||
|
jdi = new Mongo3Interface(DEBUG);
|
||||||
|
|
||||||
|
parms[0] = getLine("URI: ", false);
|
||||||
|
parms[1] = getLine("Database: ", false);
|
||||||
|
parms[2] = null;
|
||||||
|
parms[3] = null;
|
||||||
|
|
||||||
|
if (parms[0] == null)
|
||||||
|
parms[0] = "mongodb://localhost:27017";
|
||||||
|
|
||||||
|
if (parms[1] == null)
|
||||||
|
parms[1] = "test";
|
||||||
|
|
||||||
|
rc = jdi.MongoConnect(parms);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
Object bdoc = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "_id", (Object) 1, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Name", (Object) "Smith", 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Age", (Object) 39, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Pi", (Object) 3.14, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Phone", (Object) "{\"ext\":[4,5,7]}", 1))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Scores", (Object) "[24,2,13]", 2))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object bar = jdi.MakeArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
if (jdi.ArrayAdd(bar, i, (Object) (Math.random() * 10.0), 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Prices", bar, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object dat = new Date();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(bdoc, "Date", dat, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
System.out.println(bdoc);
|
||||||
|
|
||||||
|
// Try to update
|
||||||
|
if (!jdi.GetCollection("updtest") && !jdi.FindColl(null, null)) {
|
||||||
|
if (jdi.CollDelete(true) < 0)
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.CollInsert(bdoc))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object updlist = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(updlist, "Age", (Object) 40, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
Object upd = jdi.MakeDocument();
|
||||||
|
|
||||||
|
if (jdi.DocAdd(upd, "$set", updlist, 0))
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (jdi.ReadNext() > 0 && jdi.CollUpdate(upd) < 0)
|
||||||
|
System.out.println(jdi.GetErrmsg());
|
||||||
|
|
||||||
|
if (!jdi.Rewind() && jdi.ReadNext() > 0)
|
||||||
|
System.out.println(jdi.GetDoc());
|
||||||
|
else
|
||||||
|
System.out.println("Failed Rewind");
|
||||||
|
|
||||||
|
} // endif n
|
||||||
|
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
|
} // end of main
|
||||||
|
|
||||||
|
// ==================================================================
|
||||||
|
private static String getLine(String p, boolean b) {
|
||||||
|
String response;
|
||||||
|
|
||||||
|
if (c != null) {
|
||||||
|
// Standard console mode
|
||||||
|
if (b) {
|
||||||
|
response = new String(c.readPassword(p));
|
||||||
|
} else
|
||||||
|
response = c.readLine(p);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// For instance when testing from Eclipse
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
|
||||||
|
System.out.print(p);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Cannot suppress echo for password entry
|
||||||
|
response = in.readLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
response = "";
|
||||||
|
} // end of try/catch
|
||||||
|
|
||||||
|
} // endif c
|
||||||
|
|
||||||
|
return (response.isEmpty()) ? null : response;
|
||||||
|
} // end of getLine
|
||||||
|
|
||||||
|
}
|
@@ -19,14 +19,14 @@
|
|||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
//#include "sql_time.h"
|
//#include "sql_time.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdint.h> // for uintprt_h
|
#include <stdint.h> // for uintprt_h
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include required application header files */
|
/* Include required application header files */
|
||||||
|
@@ -20,13 +20,13 @@
|
|||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
//#include "sql_time.h"
|
//#include "sql_time.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
|
@@ -24,11 +24,11 @@
|
|||||||
#if !defined(BLOCK_DEFINED)
|
#if !defined(BLOCK_DEFINED)
|
||||||
#define BLOCK_DEFINED
|
#define BLOCK_DEFINED
|
||||||
|
|
||||||
#if defined(__WIN__) && !defined(NOEX)
|
#if defined(_WIN32) && !defined(NOEX)
|
||||||
#define DllExport __declspec( dllexport )
|
#define DllExport __declspec( dllexport )
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#define DllExport
|
#define DllExport
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Definition of class BLOCK with its method function new. */
|
/* Definition of class BLOCK with its method function new. */
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#define CheckType(X,Y)
|
#define CheckType(X,Y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#define EL "\r\n"
|
#define EL "\r\n"
|
||||||
#else
|
#else
|
||||||
#define EL "\n"
|
#define EL "\n"
|
||||||
@@ -1205,15 +1205,14 @@ void BJSON::SetArrayValue(PBVAL bap, PBVAL nvp, int n)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
PBVAL bvp = NULL;
|
PBVAL bvp = NULL;
|
||||||
|
|
||||||
if (bap->To_Val)
|
for (bvp = GetArray(bap); i < n; i++, bvp = bvp ? GetNext(bvp) : NULL)
|
||||||
for (bvp = GetArray(bap); bvp; i++, bvp = GetNext(bvp))
|
if (!bvp)
|
||||||
if (i == n) {
|
AddArrayValue(bap, NewVal());
|
||||||
SetValueVal(bvp, nvp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bvp)
|
if (!bvp)
|
||||||
AddArrayValue(bap, MOF(nvp));
|
AddArrayValue(bap, MOF(nvp));
|
||||||
|
else
|
||||||
|
SetValueVal(bvp, nvp);
|
||||||
|
|
||||||
} // end of SetValue
|
} // end of SetValue
|
||||||
|
|
||||||
|
@@ -1889,24 +1889,31 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
int IsArgJson(UDF_ARGS *args, uint i)
|
int IsArgJson(UDF_ARGS *args, uint i)
|
||||||
{
|
{
|
||||||
int n = 0;
|
char *pat = args->attributes[i];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (*pat == '@') {
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
if (*pat == '\'' || *pat == '"')
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
} // endif pat
|
||||||
|
|
||||||
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
||||||
} else if (!strnicmp(args->attributes[i], "Bson_", 5) ||
|
} else if (!strnicmp(pat, "Bson_", 5) || !strnicmp(pat, "Json_", 5)) {
|
||||||
!strnicmp(args->attributes[i], "Json_", 5)) {
|
|
||||||
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
||||||
n = 1; // arg should be is a json item
|
n = 1; // arg should be is a json item
|
||||||
// else
|
// else
|
||||||
// n = 2; // A file name may have been returned
|
// n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Bbin_", 5)) {
|
} else if (!strnicmp(pat, "Bbin_", 5)) {
|
||||||
if (args->lengths[i] == sizeof(BSON))
|
if (args->lengths[i] == sizeof(BSON))
|
||||||
n = 3; // arg is a binary json item
|
n = 3; // arg is a binary json item
|
||||||
// else
|
// else
|
||||||
// n = 2; // A file name may have been returned
|
// n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Bfile_", 6) ||
|
} else if (!strnicmp(pat, "Bfile_", 6) || !strnicmp(pat, "Jfile_", 6)) {
|
||||||
!strnicmp(args->attributes[i], "Jfile_", 6)) {
|
|
||||||
n = 2; // arg is a json file name
|
n = 2; // arg is a json file name
|
||||||
#if 0
|
#if 0
|
||||||
} else if (args->lengths[i]) {
|
} else if (args->lengths[i]) {
|
||||||
@@ -4682,7 +4689,7 @@ char *bfile_convert(UDF_INIT* initid, UDF_ARGS* args, char* result,
|
|||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
PUSH_WARNING(g->Message ? g->Message : "Unexpected error");
|
PUSH_WARNING(*g->Message ? g->Message : "Unexpected error");
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
*error = 1;
|
*error = 1;
|
||||||
*res_length = 0;
|
*res_length = 0;
|
||||||
@@ -4742,7 +4749,7 @@ char *bfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
int msgid = MSGID_OPEN_MODE_STRERROR;
|
int msgid = MSGID_OPEN_MODE_STRERROR;
|
||||||
FILE *fout;
|
FILE *fout = NULL;
|
||||||
FILE *fin;
|
FILE *fin;
|
||||||
|
|
||||||
if (!(fin = global_fopen(g, msgid, fn, "rt")))
|
if (!(fin = global_fopen(g, msgid, fn, "rt")))
|
||||||
@@ -4805,7 +4812,7 @@ char *bfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
if (g->Message)
|
if (*g->Message)
|
||||||
str = strcpy(result, g->Message);
|
str = strcpy(result, g->Message);
|
||||||
else
|
else
|
||||||
str = strcpy(result, "Unexpected error");
|
str = strcpy(result, "Unexpected error");
|
||||||
|
@@ -56,6 +56,7 @@ CMGFAM::CMGFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
|
|||||||
Pcg.Coll_name = tdp->Collname;
|
Pcg.Coll_name = tdp->Collname;
|
||||||
Pcg.Options = tdp->Options;
|
Pcg.Options = tdp->Options;
|
||||||
Pcg.Filter = tdp->Filter;
|
Pcg.Filter = tdp->Filter;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = tdp->Pipe && tdp->Options != NULL;
|
Pcg.Pipe = tdp->Pipe && tdp->Options != NULL;
|
||||||
Lrecl = tdp->Lrecl + tdp->Ending;
|
Lrecl = tdp->Lrecl + tdp->Ending;
|
||||||
} else {
|
} else {
|
||||||
@@ -64,6 +65,7 @@ CMGFAM::CMGFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
|
|||||||
Pcg.Coll_name = NULL;
|
Pcg.Coll_name = NULL;
|
||||||
Pcg.Options = NULL;
|
Pcg.Options = NULL;
|
||||||
Pcg.Filter = NULL;
|
Pcg.Filter = NULL;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = false;
|
Pcg.Pipe = false;
|
||||||
Lrecl = 0;
|
Lrecl = 0;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
@@ -88,6 +90,7 @@ CMGFAM::CMGFAM(PBDEF tdp) : DOSFAM((PDOSDEF)NULL)
|
|||||||
Pcg.Coll_name = tdp->Collname;
|
Pcg.Coll_name = tdp->Collname;
|
||||||
Pcg.Options = tdp->Options;
|
Pcg.Options = tdp->Options;
|
||||||
Pcg.Filter = tdp->Filter;
|
Pcg.Filter = tdp->Filter;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = tdp->Pipe && tdp->Options != NULL;
|
Pcg.Pipe = tdp->Pipe && tdp->Options != NULL;
|
||||||
Lrecl = tdp->Lrecl + tdp->Ending;
|
Lrecl = tdp->Lrecl + tdp->Ending;
|
||||||
} else {
|
} else {
|
||||||
@@ -96,6 +99,7 @@ CMGFAM::CMGFAM(PBDEF tdp) : DOSFAM((PDOSDEF)NULL)
|
|||||||
Pcg.Coll_name = NULL;
|
Pcg.Coll_name = NULL;
|
||||||
Pcg.Options = NULL;
|
Pcg.Options = NULL;
|
||||||
Pcg.Filter = NULL;
|
Pcg.Filter = NULL;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = false;
|
Pcg.Pipe = false;
|
||||||
Lrecl = 0;
|
Lrecl = 0;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
@@ -280,6 +284,7 @@ int CMGFAM::ReadBuffer(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int CMGFAM::WriteBuffer(PGLOBAL g)
|
int CMGFAM::WriteBuffer(PGLOBAL g)
|
||||||
{
|
{
|
||||||
|
Pcg.Line = Tdbp->GetLine();
|
||||||
return Cmgp->Write(g);
|
return Cmgp->Write(g);
|
||||||
} // end of WriteBuffer
|
} // end of WriteBuffer
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ CMgoConn C++ Functions Source Code File (.CPP) ***********/
|
/************ CMgoConn C++ Functions Source Code File (.CPP) ***********/
|
||||||
/* Name: CMgoConn.CPP Version 1.0 */
|
/* Name: CMgoConn.CPP Version 1.1 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the MongoDB C connection classes functions. */
|
/* This file contains the MongoDB C connection classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -24,8 +24,9 @@
|
|||||||
|
|
||||||
bool CMgoConn::IsInit = false;
|
bool CMgoConn::IsInit = false;
|
||||||
|
|
||||||
bool IsNum(PSZ s);
|
bool IsArray(PSZ s);
|
||||||
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
||||||
|
int GetDefaultPrec(void);
|
||||||
|
|
||||||
/* --------------------------- Class INCOL --------------------------- */
|
/* --------------------------- Class INCOL --------------------------- */
|
||||||
|
|
||||||
@@ -47,12 +48,13 @@ void INCOL::AddCol(PGLOBAL g, PCOL colp, char *jp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!kp) {
|
if (!kp) {
|
||||||
icp = new(g) INCOL(IsNum(p));
|
icp = new(g) INCOL();
|
||||||
kcp = (PKC)PlugSubAlloc(g, NULL, sizeof(KEYCOL));
|
kcp = (PKC)PlugSubAlloc(g, NULL, sizeof(KEYCOL));
|
||||||
kcp->Next = NULL;
|
kcp->Next = NULL;
|
||||||
kcp->Incolp = icp;
|
kcp->Incolp = icp;
|
||||||
kcp->Colp = NULL;
|
kcp->Colp = NULL;
|
||||||
kcp->Key = PlugDup(g, jp);
|
kcp->Key = PlugDup(g, jp);
|
||||||
|
kcp->Array = IsArray(p);
|
||||||
|
|
||||||
if (Klist) {
|
if (Klist) {
|
||||||
for (kp = Klist; kp->Next; kp = kp->Next);
|
for (kp = Klist; kp->Next; kp = kp->Next);
|
||||||
@@ -73,6 +75,7 @@ void INCOL::AddCol(PGLOBAL g, PCOL colp, char *jp)
|
|||||||
kcp->Incolp = NULL;
|
kcp->Incolp = NULL;
|
||||||
kcp->Colp = colp;
|
kcp->Colp = colp;
|
||||||
kcp->Key = jp;
|
kcp->Key = jp;
|
||||||
|
kcp->Array = IsArray(jp);
|
||||||
|
|
||||||
if (Klist) {
|
if (Klist) {
|
||||||
for (kp = Klist; kp->Next; kp = kp->Next);
|
for (kp = Klist; kp->Next; kp = kp->Next);
|
||||||
@@ -120,11 +123,12 @@ CMgoConn::CMgoConn(PGLOBAL g, PCPARM pcg)
|
|||||||
{
|
{
|
||||||
Pcg = pcg;
|
Pcg = pcg;
|
||||||
Uri = NULL;
|
Uri = NULL;
|
||||||
Pool = NULL;
|
//Pool = NULL;
|
||||||
Client = NULL;
|
Client = NULL;
|
||||||
Database = NULL;
|
Database = NULL;
|
||||||
Collection = NULL;
|
Collection = NULL;
|
||||||
Cursor = NULL;
|
Cursor = NULL;
|
||||||
|
Document = NULL;
|
||||||
Query = NULL;
|
Query = NULL;
|
||||||
Opts = NULL;
|
Opts = NULL;
|
||||||
Fpc = NULL;
|
Fpc = NULL;
|
||||||
@@ -157,24 +161,26 @@ bool CMgoConn::Connect(PGLOBAL g)
|
|||||||
} // endif name
|
} // endif name
|
||||||
|
|
||||||
if (!IsInit)
|
if (!IsInit)
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
__try {
|
__try {
|
||||||
mongo_init(true);
|
mongo_init(true);
|
||||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||||
strcpy(g->Message, "Cannot load MongoDB C driver");
|
strcpy(g->Message, "Cannot load MongoDB C driver");
|
||||||
return true;
|
return true;
|
||||||
} // end try/except
|
} // end try/except
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
mongo_init(true);
|
mongo_init(true);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
Uri = mongoc_uri_new(Pcg->Uristr);
|
Uri = mongoc_uri_new_with_error(Pcg->Uristr, &Error);
|
||||||
|
|
||||||
if (!Uri) {
|
if (!Uri) {
|
||||||
sprintf(g->Message, "Failed to parse URI: \"%s\"", Pcg->Uristr);
|
sprintf(g->Message, "Failed to parse URI: \"%s\" Msg: %s",
|
||||||
|
Pcg->Uristr, Error.message);
|
||||||
return true;
|
return true;
|
||||||
} // endif Uri
|
} // endif Uri
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Create a new client pool instance
|
// Create a new client pool instance
|
||||||
Pool = mongoc_client_pool_new(Uri);
|
Pool = mongoc_client_pool_new(Uri);
|
||||||
mongoc_client_pool_set_error_api(Pool, 2);
|
mongoc_client_pool_set_error_api(Pool, 2);
|
||||||
@@ -185,13 +191,24 @@ bool CMgoConn::Connect(PGLOBAL g)
|
|||||||
|
|
||||||
// Create a new client instance
|
// Create a new client instance
|
||||||
Client = mongoc_client_pool_pop(Pool);
|
Client = mongoc_client_pool_pop(Pool);
|
||||||
|
#else
|
||||||
|
// Create a new client instance
|
||||||
|
Client = mongoc_client_new_from_uri (Uri);
|
||||||
|
|
||||||
if (!Client) {
|
if (!Client) {
|
||||||
sprintf(g->Message, "Failed to get Client");
|
sprintf(g->Message, "Failed to get Client");
|
||||||
return true;
|
return true;
|
||||||
} // endif Client
|
} // endif Client
|
||||||
|
|
||||||
// Get a handle on the collection Coll_name
|
// Register the application name so we can track it in the profile logs
|
||||||
|
// on the server. This can also be done from the URI (see other examples).
|
||||||
|
mongoc_client_set_appname (Client, "Connect");
|
||||||
|
|
||||||
|
// Get a handle on the database
|
||||||
|
// Database = mongoc_client_get_database (Client, Pcg->Db_name);
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
// Get a handle on the collection
|
||||||
Collection = mongoc_client_get_collection(Client, Pcg->Db_name, Pcg->Coll_name);
|
Collection = mongoc_client_get_collection(Client, Pcg->Db_name, Pcg->Coll_name);
|
||||||
|
|
||||||
if (!Collection) {
|
if (!Collection) {
|
||||||
@@ -228,8 +245,8 @@ bool CMgoConn::Connect(PGLOBAL g)
|
|||||||
int CMgoConn::CollSize(PGLOBAL g)
|
int CMgoConn::CollSize(PGLOBAL g)
|
||||||
{
|
{
|
||||||
int cnt;
|
int cnt;
|
||||||
bson_t *query;
|
bson_t* query;
|
||||||
const char *jf = NULL;
|
const char* jf = NULL;
|
||||||
|
|
||||||
if (Pcg->Pipe)
|
if (Pcg->Pipe)
|
||||||
return 10;
|
return 10;
|
||||||
@@ -237,7 +254,7 @@ int CMgoConn::CollSize(PGLOBAL g)
|
|||||||
jf = Pcg->Filter;
|
jf = Pcg->Filter;
|
||||||
|
|
||||||
if (jf) {
|
if (jf) {
|
||||||
query = bson_new_from_json((const uint8_t *)jf, -1, &Error);
|
query = bson_new_from_json((const uint8_t*)jf, -1, &Error);
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
htrc("Wrong filter: %s", Error.message);
|
htrc("Wrong filter: %s", Error.message);
|
||||||
@@ -247,8 +264,17 @@ int CMgoConn::CollSize(PGLOBAL g)
|
|||||||
} else
|
} else
|
||||||
query = bson_new();
|
query = bson_new();
|
||||||
|
|
||||||
|
#if defined(DEVELOPMENT)
|
||||||
|
if (jf)
|
||||||
|
cnt = (int)mongoc_collection_count_documents(Collection,
|
||||||
|
query, NULL, NULL, NULL, &Error);
|
||||||
|
else
|
||||||
|
cnt = (int)mongoc_collection_estimated_document_count(
|
||||||
|
Collection, NULL, NULL, NULL, &Error);
|
||||||
|
#else
|
||||||
cnt = (int)mongoc_collection_count(Collection,
|
cnt = (int)mongoc_collection_count(Collection,
|
||||||
MONGOC_QUERY_NONE, query, 0, 0, NULL, &Error);
|
MONGOC_QUERY_NONE, query, 0, 0, NULL, &Error);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cnt < 0) {
|
if (cnt < 0) {
|
||||||
htrc("Collection count: %s", Error.message);
|
htrc("Collection count: %s", Error.message);
|
||||||
@@ -260,30 +286,91 @@ int CMgoConn::CollSize(PGLOBAL g)
|
|||||||
} // end of CollSize
|
} // end of CollSize
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OpenDB: Data Base open routine for MONGO access method. */
|
/* Project: make the projection avoid path collision. */
|
||||||
|
/***********************************************************************/
|
||||||
|
void CMgoConn::Project(PGLOBAL g, PSTRG s)
|
||||||
|
{
|
||||||
|
bool m, b = false;
|
||||||
|
size_t n;
|
||||||
|
PSZ path;
|
||||||
|
PCOL cp;
|
||||||
|
PTDB tp = Pcg->Tdbp;
|
||||||
|
PTHP hp, php = NULL, * nphp = &php;
|
||||||
|
|
||||||
|
for (cp = tp->GetColumns(); cp; cp = cp->GetNext()) {
|
||||||
|
path = cp->GetJpath(g, true);
|
||||||
|
|
||||||
|
// Resolve path collision
|
||||||
|
for (hp = php; hp; hp = hp->Next) {
|
||||||
|
if (strlen(path) < strlen(hp->Path)) {
|
||||||
|
n = strlen(path);
|
||||||
|
m = true;
|
||||||
|
} else {
|
||||||
|
n = strlen(hp->Path);
|
||||||
|
m = false;
|
||||||
|
} // endif path
|
||||||
|
|
||||||
|
if (!strncmp(path, hp->Path, n))
|
||||||
|
break;
|
||||||
|
|
||||||
|
} // endfor hp
|
||||||
|
|
||||||
|
if (!hp) {
|
||||||
|
// New path
|
||||||
|
hp = (PTHP)PlugSubAlloc(g, NULL, sizeof(PTH));
|
||||||
|
hp->Path = path;
|
||||||
|
hp->Name = cp->GetName();
|
||||||
|
hp->Next = NULL;
|
||||||
|
*nphp = hp;
|
||||||
|
nphp = &hp->Next;
|
||||||
|
} else if (m) // Smaller path must replace longer one
|
||||||
|
hp->Path = path;
|
||||||
|
|
||||||
|
} // endfor cp
|
||||||
|
|
||||||
|
for (hp = php; hp; hp = hp->Next) {
|
||||||
|
if (b)
|
||||||
|
s->Append(",\"");
|
||||||
|
else
|
||||||
|
b = true;
|
||||||
|
|
||||||
|
if (*hp->Path == '{') {
|
||||||
|
// This is a Mongo defined column
|
||||||
|
s->Append(hp->Name);
|
||||||
|
s->Append("\":");
|
||||||
|
s->Append(hp->Path);
|
||||||
|
} else {
|
||||||
|
s->Append(hp->Path);
|
||||||
|
s->Append("\":1");
|
||||||
|
} // endif Path
|
||||||
|
|
||||||
|
} // endfor hp
|
||||||
|
|
||||||
|
} // end of Project
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* MakeCursor: make the cursor used to retrieve documents. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool CMgoConn::MakeCursor(PGLOBAL g)
|
bool CMgoConn::MakeCursor(PGLOBAL g)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
bool id, b = false, all = false;
|
bool id, all = false;
|
||||||
PCSZ options = Pcg->Options;
|
PCSZ options = Pcg->Options;
|
||||||
PTDB tp = Pcg->Tdbp;
|
PTDB tp = Pcg->Tdbp;
|
||||||
PCOL cp;
|
PCOL cp;
|
||||||
PSTRG s = NULL;
|
PSTRG s = NULL;
|
||||||
PFIL filp = tp->GetFilter();
|
PFIL filp = tp->GetFilter();
|
||||||
|
|
||||||
id = (tp->GetMode() != MODE_READ);
|
id = (tp->GetMode() == MODE_UPDATE || tp->GetMode() == MODE_DELETE);
|
||||||
|
|
||||||
if (options && !stricmp(options, "all")) {
|
if (options && !stricmp(options, "all")) {
|
||||||
options = NULL;
|
options = NULL;
|
||||||
all = true;
|
all = true;
|
||||||
} // endif Options
|
} else for (cp = tp->GetColumns(); cp && !all; cp = cp->GetNext())
|
||||||
|
if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !options)
|
||||||
for (cp = tp->GetColumns(); cp; cp = cp->GetNext())
|
|
||||||
if (!strcmp(cp->GetName(), "_id"))
|
|
||||||
id = true;
|
|
||||||
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !options)
|
|
||||||
all = true;
|
all = true;
|
||||||
|
else if (!id)
|
||||||
|
id = !strcmp(cp->GetFmt() ? cp->GetFmt() : cp->GetName(), "_id");
|
||||||
|
|
||||||
if (Pcg->Pipe) {
|
if (Pcg->Pipe) {
|
||||||
if (trace(1))
|
if (trace(1))
|
||||||
@@ -311,23 +398,14 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
|
|||||||
tp->SetFilter(NULL); // Not needed anymore
|
tp->SetFilter(NULL); // Not needed anymore
|
||||||
} // endif To_Filter
|
} // endif To_Filter
|
||||||
|
|
||||||
if (!all && tp->GetColumns()) {
|
if (tp->GetColumns() && !strstr(s->GetStr(), "$project")) {
|
||||||
// Project list
|
// Project list
|
||||||
s->Append(",{\"$project\":{\"");
|
s->Append(",{\"$project\":{\"");
|
||||||
|
|
||||||
if (!id)
|
if (!id)
|
||||||
s->Append("_id\":0,\"");
|
s->Append("_id\":0,\"");
|
||||||
|
|
||||||
for (cp = tp->GetColumns(); cp; cp = cp->GetNext()) {
|
Project(g, s);
|
||||||
if (b)
|
|
||||||
s->Append(",\"");
|
|
||||||
else
|
|
||||||
b = true;
|
|
||||||
|
|
||||||
s->Append(cp->GetJpath(g, true));
|
|
||||||
s->Append("\":1");
|
|
||||||
} // endfor cp
|
|
||||||
|
|
||||||
s->Append("}}");
|
s->Append("}}");
|
||||||
} // endif all
|
} // endif all
|
||||||
|
|
||||||
@@ -377,7 +455,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
|
|||||||
|
|
||||||
if (MakeSelector(g, filp, s)) {
|
if (MakeSelector(g, filp, s)) {
|
||||||
strcpy(g->Message, "Failed making selector");
|
strcpy(g->Message, "Failed making selector");
|
||||||
return NULL;
|
return true;
|
||||||
} // endif Selector
|
} // endif Selector
|
||||||
|
|
||||||
tp->SetFilter(NULL); // Not needed anymore
|
tp->SetFilter(NULL); // Not needed anymore
|
||||||
@@ -391,7 +469,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
|
|||||||
|
|
||||||
if (!Query) {
|
if (!Query) {
|
||||||
sprintf(g->Message, "Wrong filter: %s", Error.message);
|
sprintf(g->Message, "Wrong filter: %s", Error.message);
|
||||||
return NULL;
|
return true;
|
||||||
} // endif Query
|
} // endif Query
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -413,16 +491,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
|
|||||||
if (!id)
|
if (!id)
|
||||||
s->Append("_id\":0,\"");
|
s->Append("_id\":0,\"");
|
||||||
|
|
||||||
for (cp = tp->GetColumns(); cp; cp = cp->GetNext()) {
|
Project(g, s);
|
||||||
if (b)
|
|
||||||
s->Append(",\"");
|
|
||||||
else
|
|
||||||
b = true;
|
|
||||||
|
|
||||||
s->Append(cp->GetJpath(g, true));
|
|
||||||
s->Append("\":1");
|
|
||||||
} // endfor cp
|
|
||||||
|
|
||||||
s->Append("}}");
|
s->Append("}}");
|
||||||
s->Resize(s->GetLength() + 1);
|
s->Resize(s->GetLength() + 1);
|
||||||
p = s->GetStr();
|
p = s->GetStr();
|
||||||
@@ -435,7 +504,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g)
|
|||||||
|
|
||||||
if (!Opts) {
|
if (!Opts) {
|
||||||
sprintf(g->Message, "Wrong options: %s", Error.message);
|
sprintf(g->Message, "Wrong options: %s", Error.message);
|
||||||
return NULL;
|
return true;
|
||||||
} // endif Opts
|
} // endif Opts
|
||||||
|
|
||||||
} // endif all
|
} // endif all
|
||||||
@@ -495,44 +564,54 @@ void CMgoConn::ShowDocument(bson_iter_t *iter, const bson_t *doc, const char *k)
|
|||||||
key = bson_iter_key(iter);
|
key = bson_iter_key(iter);
|
||||||
htrc("Found element key: \"%s\"\n", key);
|
htrc("Found element key: \"%s\"\n", key);
|
||||||
|
|
||||||
if (BSON_ITER_HOLDS_UTF8(iter))
|
switch (bson_iter_type(iter)) {
|
||||||
htrc("%s.%s=\"%s\"\n", k, key, bson_iter_utf8(iter, NULL));
|
case BSON_TYPE_UTF8:
|
||||||
else if (BSON_ITER_HOLDS_INT32(iter))
|
htrc("%s.%s=\"%s\"\n", k, key, bson_iter_utf8(iter, NULL));
|
||||||
htrc("%s.%s=%d\n", k, key, bson_iter_int32(iter));
|
break;
|
||||||
else if (BSON_ITER_HOLDS_INT64(iter))
|
case BSON_TYPE_INT32:
|
||||||
htrc("%s.%s=%lld\n", k, key, bson_iter_int64(iter));
|
htrc("%s.%s=%d\n", k, key, bson_iter_int32(iter));
|
||||||
else if (BSON_ITER_HOLDS_DOUBLE(iter))
|
break;
|
||||||
htrc("%s.%s=%g\n", k, key, bson_iter_double(iter));
|
case BSON_TYPE_INT64:
|
||||||
else if (BSON_ITER_HOLDS_DATE_TIME(iter))
|
htrc("%s.%s=%lld\n", k, key, bson_iter_int64(iter));
|
||||||
htrc("%s.%s=date(%lld)\n", k, key, bson_iter_date_time(iter));
|
break;
|
||||||
else if (BSON_ITER_HOLDS_OID(iter)) {
|
case BSON_TYPE_DOUBLE:
|
||||||
char str[25];
|
htrc("%s.%s=%g\n", k, key, bson_iter_double(iter));
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DATE_TIME:
|
||||||
|
htrc("%s.%s=date(%lld)\n", k, key, bson_iter_date_time(iter));
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_OID: {
|
||||||
|
char str[25];
|
||||||
|
|
||||||
bson_oid_to_string(bson_iter_oid(iter), str);
|
bson_oid_to_string(bson_iter_oid(iter), str);
|
||||||
htrc("%s.%s=%s\n", k, key, str);
|
htrc("%s.%s=%s\n", k, key, str);
|
||||||
} else if (BSON_ITER_HOLDS_DECIMAL128(iter)) {
|
} break;
|
||||||
char *str = NULL;
|
case BSON_TYPE_DECIMAL128: {
|
||||||
bson_decimal128_t dec;
|
char str[BSON_DECIMAL128_STRING];
|
||||||
|
bson_decimal128_t dec;
|
||||||
|
|
||||||
bson_iter_decimal128(iter, &dec);
|
bson_iter_decimal128(iter, &dec);
|
||||||
bson_decimal128_to_string(&dec, str);
|
bson_decimal128_to_string(&dec, str);
|
||||||
htrc("%s.%s=%s\n", k, key, str);
|
htrc("%s.%s=%s\n", k, key, str);
|
||||||
} else if (BSON_ITER_HOLDS_DOCUMENT(iter)) {
|
} break;
|
||||||
bson_iter_t child;
|
case BSON_TYPE_DOCUMENT: {
|
||||||
|
bson_iter_t child;
|
||||||
|
|
||||||
if (bson_iter_recurse(iter, &child))
|
if (bson_iter_recurse(iter, &child))
|
||||||
ShowDocument(&child, NULL, key);
|
ShowDocument(&child, NULL, key);
|
||||||
|
|
||||||
} else if (BSON_ITER_HOLDS_ARRAY(iter)) {
|
} break;
|
||||||
bson_t *arr;
|
case BSON_TYPE_ARRAY: {
|
||||||
bson_iter_t itar;
|
bson_t* arr;
|
||||||
const uint8_t *data = NULL;
|
bson_iter_t itar;
|
||||||
uint32_t len = 0;
|
const uint8_t* data = NULL;
|
||||||
|
uint32_t len = 0;
|
||||||
|
|
||||||
bson_iter_array(iter, &len, &data);
|
bson_iter_array(iter, &len, &data);
|
||||||
arr = bson_new_from_data(data, len);
|
arr = bson_new_from_data(data, len);
|
||||||
ShowDocument(&itar, arr, key);
|
ShowDocument(&itar, arr, key);
|
||||||
} // endif's
|
} break;
|
||||||
|
} // endswitch iter
|
||||||
|
|
||||||
} // endwhile bson_iter_next
|
} // endwhile bson_iter_next
|
||||||
|
|
||||||
@@ -545,7 +624,7 @@ void CMgoConn::ShowDocument(bson_iter_t *iter, const bson_t *doc, const char *k)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void CMgoConn::MakeColumnGroups(PGLOBAL g)
|
void CMgoConn::MakeColumnGroups(PGLOBAL g)
|
||||||
{
|
{
|
||||||
Fpc = new(g) INCOL(false);
|
Fpc = new(g) INCOL();
|
||||||
|
|
||||||
for (PCOL colp = Pcg->Tdbp->GetColumns(); colp; colp = colp->GetNext())
|
for (PCOL colp = Pcg->Tdbp->GetColumns(); colp; colp = colp->GetNext())
|
||||||
if (!colp->IsSpecial())
|
if (!colp->IsSpecial())
|
||||||
@@ -560,7 +639,7 @@ bool CMgoConn::DocWrite(PGLOBAL g, PINCOL icp)
|
|||||||
{
|
{
|
||||||
for (PKC kp = icp->Klist; kp; kp = kp->Next)
|
for (PKC kp = icp->Klist; kp; kp = kp->Next)
|
||||||
if (kp->Incolp) {
|
if (kp->Incolp) {
|
||||||
bool isdoc = !kp->Incolp->Array;
|
bool isdoc = !kp->Array;
|
||||||
|
|
||||||
if (isdoc)
|
if (isdoc)
|
||||||
BSON_APPEND_DOCUMENT_BEGIN(icp->Child, kp->Key, kp->Incolp->Child);
|
BSON_APPEND_DOCUMENT_BEGIN(icp->Child, kp->Key, kp->Incolp->Child);
|
||||||
@@ -582,7 +661,7 @@ bool CMgoConn::DocWrite(PGLOBAL g, PINCOL icp)
|
|||||||
} // end of DocWrite
|
} // end of DocWrite
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* WriteDB: Data Base write routine for DOS access method. */
|
/* WriteDB: Data Base write routine for CMGO access method. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int CMgoConn::Write(PGLOBAL g)
|
int CMgoConn::Write(PGLOBAL g)
|
||||||
{
|
{
|
||||||
@@ -590,22 +669,45 @@ int CMgoConn::Write(PGLOBAL g)
|
|||||||
PTDB tp = Pcg->Tdbp;
|
PTDB tp = Pcg->Tdbp;
|
||||||
|
|
||||||
if (tp->GetMode() == MODE_INSERT) {
|
if (tp->GetMode() == MODE_INSERT) {
|
||||||
Fpc->Init();
|
if (!Pcg->Line) {
|
||||||
|
Fpc->Init();
|
||||||
|
|
||||||
if (DocWrite(g, Fpc))
|
if (DocWrite(g, Fpc))
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
if (trace(2)) {
|
if (trace(2)) {
|
||||||
char *str = bson_as_json(Fpc->Child, NULL);
|
char* str = bson_as_json(Fpc->Child, NULL);
|
||||||
htrc("Inserting: %s\n", str);
|
htrc("Inserting: %s\n", str);
|
||||||
bson_free(str);
|
bson_free(str);
|
||||||
} // endif trace
|
} // endif trace
|
||||||
|
|
||||||
if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE,
|
if (!mongoc_collection_insert(Collection, MONGOC_INSERT_NONE,
|
||||||
Fpc->Child, NULL, &Error)) {
|
Fpc->Child, NULL, &Error)) {
|
||||||
sprintf(g->Message, "Mongo insert: %s", Error.message);
|
sprintf(g->Message, "Mongo insert: %s", Error.message);
|
||||||
rc = RC_FX;
|
rc = RC_FX;
|
||||||
} // endif insert
|
} // endif insert
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const uint8_t* val = (const uint8_t*)Pcg->Line;
|
||||||
|
bson_t* doc = bson_new_from_json(val, -1, &Error);
|
||||||
|
|
||||||
|
if (doc && trace(2)) {
|
||||||
|
char* str = bson_as_json(doc, NULL);
|
||||||
|
htrc("Inserting: %s\n", str);
|
||||||
|
bson_free(str);
|
||||||
|
} // endif trace
|
||||||
|
|
||||||
|
if (!doc) {
|
||||||
|
sprintf(g->Message, "bson_new_from_json: %s", Error.message);
|
||||||
|
rc = RC_FX;
|
||||||
|
} else if (!mongoc_collection_insert(Collection,
|
||||||
|
MONGOC_INSERT_NONE, doc, NULL, &Error)) {
|
||||||
|
sprintf(g->Message, "Mongo insert: %s", Error.message);
|
||||||
|
bson_destroy(doc);
|
||||||
|
rc = RC_FX;
|
||||||
|
} // endif insert
|
||||||
|
|
||||||
|
} // endif Line
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bool b = false;
|
bool b = false;
|
||||||
@@ -614,19 +716,26 @@ int CMgoConn::Write(PGLOBAL g)
|
|||||||
|
|
||||||
bson_iter_init(&iter, Document);
|
bson_iter_init(&iter, Document);
|
||||||
|
|
||||||
if (bson_iter_find(&iter, "_id")) {
|
if (bson_iter_find(&iter, "_id"))
|
||||||
if (BSON_ITER_HOLDS_OID(&iter))
|
switch (bson_iter_type(&iter)) {
|
||||||
b = BSON_APPEND_OID(query, "_id", bson_iter_oid(&iter));
|
case BSON_TYPE_OID:
|
||||||
else if (BSON_ITER_HOLDS_INT32(&iter))
|
b = BSON_APPEND_OID(query, "_id", bson_iter_oid(&iter));
|
||||||
b = BSON_APPEND_INT32(query, "_id", bson_iter_int32(&iter));
|
break;
|
||||||
else if (BSON_ITER_HOLDS_INT64(&iter))
|
case BSON_TYPE_UTF8:
|
||||||
b = BSON_APPEND_INT64(query, "_id", bson_iter_int64(&iter));
|
b = BSON_APPEND_UTF8(query, "_id", bson_iter_utf8(&iter, NULL));
|
||||||
else if (BSON_ITER_HOLDS_DOUBLE(&iter))
|
break;
|
||||||
b = BSON_APPEND_DOUBLE(query, "_id", bson_iter_double(&iter));
|
case BSON_TYPE_INT32:
|
||||||
else if (BSON_ITER_HOLDS_UTF8(&iter))
|
b = BSON_APPEND_INT32(query, "_id", bson_iter_int32(&iter));
|
||||||
b = BSON_APPEND_UTF8(query, "_id", bson_iter_utf8(&iter, NULL));
|
break;
|
||||||
|
case BSON_TYPE_INT64:
|
||||||
} // endif iter
|
b = BSON_APPEND_INT64(query, "_id", bson_iter_int64(&iter));
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DOUBLE:
|
||||||
|
b = BSON_APPEND_DOUBLE(query, "_id", bson_iter_double(&iter));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
} // endswitch iter
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
if (trace(2)) {
|
if (trace(2)) {
|
||||||
@@ -708,8 +817,9 @@ void CMgoConn::Close(void)
|
|||||||
if (Opts) bson_destroy(Opts);
|
if (Opts) bson_destroy(Opts);
|
||||||
if (Cursor) mongoc_cursor_destroy(Cursor);
|
if (Cursor) mongoc_cursor_destroy(Cursor);
|
||||||
if (Collection) mongoc_collection_destroy(Collection);
|
if (Collection) mongoc_collection_destroy(Collection);
|
||||||
if (Client) mongoc_client_pool_push(Pool, Client);
|
//if (Client) mongoc_client_pool_push(Pool, Client);
|
||||||
if (Pool) mongoc_client_pool_destroy(Pool);
|
//if (Pool) mongoc_client_pool_destroy(Pool);
|
||||||
|
if (Client) mongoc_client_destroy(Client);
|
||||||
if (Uri) mongoc_uri_destroy(Uri);
|
if (Uri) mongoc_uri_destroy(Uri);
|
||||||
if (Fpc) Fpc->Destroy();
|
if (Fpc) Fpc->Destroy();
|
||||||
if (fp) fp->Count = 0;
|
if (fp) fp->Count = 0;
|
||||||
@@ -720,23 +830,51 @@ void CMgoConn::Close(void)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
char *CMgoConn::Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b)
|
char *CMgoConn::Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b)
|
||||||
{
|
{
|
||||||
char *s, *str = NULL;
|
char *s, *str = NULL;
|
||||||
char *Mbuf = (char*)PlugSubAlloc(g, NULL, colp->GetLength() + 1);
|
char *Mbuf = (char*)PlugSubAlloc(g, NULL, (size_t)colp->GetLength() + 1);
|
||||||
int i, k = 0;
|
int i, j = 0, k = 0, n = 0, m = GetDefaultPrec();
|
||||||
bool ok = true;
|
bool ok = true, dbl = false;
|
||||||
|
double d;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
s = str = bson_array_as_json(bson, NULL);
|
s = str = bson_array_as_json(bson, &len);
|
||||||
else
|
else
|
||||||
s = str = bson_as_json(bson, NULL);
|
s = str = bson_as_json(bson, &len);
|
||||||
|
|
||||||
|
if (len > (size_t)colp->GetLength()) {
|
||||||
|
sprintf(g->Message, "Value too long for column %s", colp->GetName());
|
||||||
|
bson_free(str);
|
||||||
|
throw (int)TYPE_AM_MGO;
|
||||||
|
} // endif len
|
||||||
|
|
||||||
for (i = 0; i < colp->GetLength() && s[i]; i++) {
|
for (i = 0; i < colp->GetLength() && s[i]; i++) {
|
||||||
switch (s[i]) {
|
switch (s[i]) {
|
||||||
case ' ':
|
case ' ':
|
||||||
if (ok) continue;
|
if (ok) continue;
|
||||||
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
ok = !ok;
|
ok = !ok;
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
if (j) dbl = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (ok) {
|
||||||
|
if (isdigit(s[i])) {
|
||||||
|
if (!j) j = k;
|
||||||
|
if (dbl) n++;
|
||||||
|
} else if (dbl && n > m) {
|
||||||
|
Mbuf[k] = 0;
|
||||||
|
d = atof(Mbuf + j);
|
||||||
|
n = sprintf(Mbuf + j, "%.*f", m, d);
|
||||||
|
k = j + n;
|
||||||
|
j = n = 0;
|
||||||
|
} else if (j)
|
||||||
|
j = n = 0;
|
||||||
|
|
||||||
|
} // endif ok
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} // endswitch s[i]
|
} // endswitch s[i]
|
||||||
|
|
||||||
@@ -745,11 +883,6 @@ char *CMgoConn::Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b)
|
|||||||
|
|
||||||
bson_free(str);
|
bson_free(str);
|
||||||
|
|
||||||
if (i >= colp->GetLength()) {
|
|
||||||
sprintf(g->Message, "Value too long for column %s", colp->GetName());
|
|
||||||
throw (int)TYPE_AM_MGO;
|
|
||||||
} // endif i
|
|
||||||
|
|
||||||
Mbuf[k] = 0;
|
Mbuf[k] = 0;
|
||||||
return Mbuf;
|
return Mbuf;
|
||||||
} // end of Mini
|
} // end of Mini
|
||||||
@@ -759,97 +892,103 @@ char *CMgoConn::Mini(PGLOBAL g, PCOL colp, const bson_t *bson, bool b)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void CMgoConn::GetColumnValue(PGLOBAL g, PCOL colp)
|
void CMgoConn::GetColumnValue(PGLOBAL g, PCOL colp)
|
||||||
{
|
{
|
||||||
char *jpath = colp->GetJpath(g, false);
|
char *jpath = colp->GetJpath(g, false);
|
||||||
PVAL value = colp->GetValue();
|
bool b = false;
|
||||||
|
PVAL value = colp->GetValue();
|
||||||
|
bson_iter_t Iter; // Used to retrieve column value
|
||||||
|
bson_iter_t Desc; // Descendant iter
|
||||||
|
|
||||||
if (!strcmp(jpath, "*")) {
|
if (*jpath == '{')
|
||||||
|
jpath = colp->GetName(); // This is a Mongo defined column
|
||||||
|
|
||||||
|
if (!*jpath || !strcmp(jpath, "*")) {
|
||||||
value->SetValue_psz(Mini(g, colp, Document, false));
|
value->SetValue_psz(Mini(g, colp, Document, false));
|
||||||
} else if (bson_iter_init(&Iter, Document) &&
|
} else if (bson_iter_init(&Iter, Document) &&
|
||||||
bson_iter_find_descendant(&Iter, jpath, &Desc)) {
|
bson_iter_find_descendant(&Iter, jpath, &Desc)) {
|
||||||
if (BSON_ITER_HOLDS_UTF8(&Desc))
|
switch (bson_iter_type(&Desc)) {
|
||||||
value->SetValue_psz((PSZ)bson_iter_utf8(&Desc, NULL));
|
case BSON_TYPE_UTF8:
|
||||||
else if (BSON_ITER_HOLDS_INT32(&Desc))
|
value->SetValue_psz((PSZ)bson_iter_utf8(&Desc, NULL));
|
||||||
value->SetValue(bson_iter_int32(&Desc));
|
break;
|
||||||
else if (BSON_ITER_HOLDS_INT64(&Desc))
|
case BSON_TYPE_INT32:
|
||||||
value->SetValue(bson_iter_int64(&Desc));
|
value->SetValue(bson_iter_int32(&Desc));
|
||||||
else if (BSON_ITER_HOLDS_DOUBLE(&Desc))
|
break;
|
||||||
value->SetValue(bson_iter_double(&Desc));
|
case BSON_TYPE_INT64:
|
||||||
else if (BSON_ITER_HOLDS_DATE_TIME(&Desc))
|
value->SetValue(bson_iter_int64(&Desc));
|
||||||
value->SetValue(bson_iter_date_time(&Desc) / 1000);
|
break;
|
||||||
else if (BSON_ITER_HOLDS_BOOL(&Desc)) {
|
case BSON_TYPE_DOUBLE:
|
||||||
bool b = bson_iter_bool(&Desc);
|
value->SetValue(bson_iter_double(&Desc));
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DATE_TIME:
|
||||||
|
value->SetValue(bson_iter_date_time(&Desc) / 1000);
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_BOOL:
|
||||||
|
b = bson_iter_bool(&Desc);
|
||||||
|
|
||||||
if (value->IsTypeNum())
|
if (value->IsTypeNum())
|
||||||
value->SetValue(b ? 1 : 0);
|
value->SetValue(b ? 1 : 0);
|
||||||
else
|
else
|
||||||
value->SetValue_psz(b ? "true" : "false");
|
value->SetValue_psz(b ? "true" : "false");
|
||||||
|
|
||||||
} else if (BSON_ITER_HOLDS_OID(&Desc)) {
|
break;
|
||||||
char str[25];
|
case BSON_TYPE_OID: {
|
||||||
|
char str[25];
|
||||||
|
|
||||||
bson_oid_to_string(bson_iter_oid(&Desc), str);
|
bson_oid_to_string(bson_iter_oid(&Desc), str);
|
||||||
value->SetValue_psz(str);
|
value->SetValue_psz(str);
|
||||||
} else if (BSON_ITER_HOLDS_NULL(&Iter)) {
|
} break;
|
||||||
// Apparently this does not work...
|
case BSON_TYPE_ARRAY:
|
||||||
value->Reset();
|
b = true;
|
||||||
value->SetNull(true);
|
// passthru
|
||||||
} else if (BSON_ITER_HOLDS_DECIMAL128(&Desc)) {
|
case BSON_TYPE_DOCUMENT:
|
||||||
char *str = NULL;
|
{ // All this because MongoDB can return the wrong type
|
||||||
bson_decimal128_t dec;
|
int i = 0;
|
||||||
|
const uint8_t *data = NULL;
|
||||||
|
uint32_t len = 0;
|
||||||
|
|
||||||
bson_iter_decimal128(&Desc, &dec);
|
for (; i < 2; i++) {
|
||||||
bson_decimal128_to_string(&dec, str);
|
if (b) // Try array first
|
||||||
value->SetValue_psz(str);
|
bson_iter_array(&Desc, &len, &data);
|
||||||
bson_free(str);
|
else
|
||||||
} else if (BSON_ITER_HOLDS_DOCUMENT(&Iter)) {
|
bson_iter_document(&Desc, &len, &data);
|
||||||
bson_t *doc;
|
|
||||||
const uint8_t *data = NULL;
|
|
||||||
uint32_t len = 0;
|
|
||||||
|
|
||||||
bson_iter_document(&Desc, &len, &data);
|
if (!data) {
|
||||||
|
len = 0;
|
||||||
|
b = !b;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
|
||||||
if (data) {
|
} // endfor i
|
||||||
doc = bson_new_from_data(data, len);
|
|
||||||
value->SetValue_psz(Mini(g, colp, doc, false));
|
|
||||||
bson_destroy(doc);
|
|
||||||
} else {
|
|
||||||
// ... but we can come here in case of NULL!
|
|
||||||
value->Reset();
|
|
||||||
value->SetNull(true);
|
|
||||||
} // endif data
|
|
||||||
|
|
||||||
} else if (BSON_ITER_HOLDS_ARRAY(&Iter)) {
|
|
||||||
bson_t *arr;
|
|
||||||
const uint8_t *data = NULL;
|
|
||||||
uint32_t len = 0;
|
|
||||||
|
|
||||||
bson_iter_array(&Desc, &len, &data);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
arr = bson_new_from_data(data, len);
|
|
||||||
value->SetValue_psz(Mini(g, colp, arr, true));
|
|
||||||
bson_destroy(arr);
|
|
||||||
} else {
|
|
||||||
// This is a bug in returning the wrong type
|
|
||||||
// This fix is only for document items
|
|
||||||
bson_t *doc;
|
|
||||||
|
|
||||||
bson_iter_document(&Desc, &len, &data);
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
doc = bson_new_from_data(data, len);
|
bson_t *doc = bson_new_from_data(data, len);
|
||||||
value->SetValue_psz(Mini(g, colp, doc, false));
|
|
||||||
|
value->SetValue_psz(Mini(g, colp, doc, b));
|
||||||
bson_destroy(doc);
|
bson_destroy(doc);
|
||||||
} else {
|
} else {
|
||||||
// ... or we can also come here in case of NULL!
|
// ... or we can also come here in case of NULL!
|
||||||
value->Reset();
|
value->Reset();
|
||||||
value->SetNull(true);
|
value->SetNull(true);
|
||||||
} // endif data
|
} // endif data
|
||||||
|
|
||||||
} // endif data
|
} break;
|
||||||
|
case BSON_TYPE_NULL:
|
||||||
|
// Apparently this does not work...
|
||||||
|
value->Reset();
|
||||||
|
value->SetNull(true);
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DECIMAL128: {
|
||||||
|
char str[BSON_DECIMAL128_STRING];
|
||||||
|
bson_decimal128_t dec;
|
||||||
|
|
||||||
} else
|
bson_iter_decimal128(&Desc, &dec);
|
||||||
value->Reset();
|
bson_decimal128_to_string(&dec, str);
|
||||||
|
value->SetValue_psz(str);
|
||||||
|
// bson_free(str);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
value->Reset();
|
||||||
|
break;
|
||||||
|
} // endswitch Desc
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Field does not exist
|
// Field does not exist
|
||||||
@@ -868,14 +1007,35 @@ bool CMgoConn::AddValue(PGLOBAL g, PCOL colp, bson_t *doc, char *key, bool upd)
|
|||||||
PVAL value = colp->GetValue();
|
PVAL value = colp->GetValue();
|
||||||
|
|
||||||
if (value->IsNull()) {
|
if (value->IsNull()) {
|
||||||
if (upd)
|
// if (upd)
|
||||||
rc = BSON_APPEND_NULL(doc, key);
|
rc = BSON_APPEND_NULL(doc, key);
|
||||||
else
|
// else
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
} else switch (colp->GetResultType()) {
|
} else switch (colp->GetResultType()) {
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
rc = BSON_APPEND_UTF8(doc, key, value->GetCharValue());
|
if (colp->Stringify()) {
|
||||||
|
const uint8_t *val = (const uint8_t*)value->GetCharValue();
|
||||||
|
bson_t *bsn = bson_new_from_json(val, -1, &Error);
|
||||||
|
|
||||||
|
if (!bsn) {
|
||||||
|
sprintf (g->Message, "AddValue: %s", Error.message);
|
||||||
|
return true;
|
||||||
|
} else if (*key) {
|
||||||
|
if (*val == '[')
|
||||||
|
rc = BSON_APPEND_ARRAY(doc, key, bsn);
|
||||||
|
else
|
||||||
|
rc = BSON_APPEND_DOCUMENT(doc, key, bsn);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bson_copy_to (bsn, doc);
|
||||||
|
rc = true;
|
||||||
|
} // endif's
|
||||||
|
|
||||||
|
bson_free(bsn);
|
||||||
|
} else
|
||||||
|
rc = BSON_APPEND_UTF8(doc, key, value->GetCharValue());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
case TYPE_SHORT:
|
case TYPE_SHORT:
|
||||||
|
@@ -28,11 +28,8 @@ typedef struct mongo_parms {
|
|||||||
PCSZ Coll_name;
|
PCSZ Coll_name;
|
||||||
PCSZ Options;
|
PCSZ Options;
|
||||||
PCSZ Filter;
|
PCSZ Filter;
|
||||||
|
PCSZ Line;
|
||||||
bool Pipe;
|
bool Pipe;
|
||||||
//PCSZ User; // User connect info
|
|
||||||
//PCSZ Pwd; // Password connect info
|
|
||||||
//int Fsize; // Fetch size
|
|
||||||
//bool Scrollable; // Scrollable cursor
|
|
||||||
} CMGOPARM, *PCPARM;
|
} CMGOPARM, *PCPARM;
|
||||||
|
|
||||||
typedef struct KEYCOL {
|
typedef struct KEYCOL {
|
||||||
@@ -40,15 +37,24 @@ typedef struct KEYCOL {
|
|||||||
PINCOL Incolp;
|
PINCOL Incolp;
|
||||||
PCOL Colp;
|
PCOL Colp;
|
||||||
char *Key;
|
char *Key;
|
||||||
|
bool Array;
|
||||||
} *PKC;
|
} *PKC;
|
||||||
|
|
||||||
|
typedef struct _path_list *PTHP;
|
||||||
|
|
||||||
|
typedef struct _path_list {
|
||||||
|
PSZ Path;
|
||||||
|
PSZ Name;
|
||||||
|
PTHP Next;
|
||||||
|
} PTH;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Used when inserting values in a MongoDB collection. */
|
/* Used when inserting values in a MongoDB collection. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class INCOL : public BLOCK {
|
class INCOL : public BLOCK {
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
INCOL(bool ar) { Child = bson_new(); Klist = NULL; Array = ar; }
|
INCOL(void) { Child = bson_new(); Klist = NULL; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void AddCol(PGLOBAL g, PCOL colp, char *jp);
|
void AddCol(PGLOBAL g, PCOL colp, char *jp);
|
||||||
@@ -58,7 +64,6 @@ public:
|
|||||||
//Members
|
//Members
|
||||||
bson_t *Child;
|
bson_t *Child;
|
||||||
PKC Klist;
|
PKC Klist;
|
||||||
bool Array;
|
|
||||||
}; // end of INCOL;
|
}; // end of INCOL;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -80,6 +85,7 @@ public:
|
|||||||
bool IsConnected(void) { return m_Connected; }
|
bool IsConnected(void) { return m_Connected; }
|
||||||
bool Connect(PGLOBAL g);
|
bool Connect(PGLOBAL g);
|
||||||
int CollSize(PGLOBAL g);
|
int CollSize(PGLOBAL g);
|
||||||
|
void CMgoConn::Project(PGLOBAL g, PSTRG s);
|
||||||
bool MakeCursor(PGLOBAL g);
|
bool MakeCursor(PGLOBAL g);
|
||||||
int ReadNext(PGLOBAL g);
|
int ReadNext(PGLOBAL g);
|
||||||
PSZ GetDocument(PGLOBAL g);
|
PSZ GetDocument(PGLOBAL g);
|
||||||
@@ -99,7 +105,7 @@ protected:
|
|||||||
// Members
|
// Members
|
||||||
PCPARM Pcg;
|
PCPARM Pcg;
|
||||||
mongoc_uri_t *Uri;
|
mongoc_uri_t *Uri;
|
||||||
mongoc_client_pool_t *Pool; // Thread safe client pool
|
//mongoc_client_pool_t *Pool; // Thread safe client pool
|
||||||
mongoc_client_t *Client; // The MongoDB client
|
mongoc_client_t *Client; // The MongoDB client
|
||||||
mongoc_database_t *Database; // The MongoDB database
|
mongoc_database_t *Database; // The MongoDB database
|
||||||
mongoc_collection_t *Collection; // The MongoDB collection
|
mongoc_collection_t *Collection; // The MongoDB collection
|
||||||
@@ -108,8 +114,6 @@ protected:
|
|||||||
bson_t *Query; // MongoDB cursor filter
|
bson_t *Query; // MongoDB cursor filter
|
||||||
bson_t *Opts; // MongoDB cursor options
|
bson_t *Opts; // MongoDB cursor options
|
||||||
bson_error_t Error;
|
bson_error_t Error;
|
||||||
bson_iter_t Iter; // Used to retrieve column value
|
|
||||||
bson_iter_t Desc; // Descendant iter
|
|
||||||
PINCOL Fpc; // To insert INCOL classes
|
PINCOL Fpc; // To insert INCOL classes
|
||||||
PFBLOCK fp;
|
PFBLOCK fp;
|
||||||
bool m_Connected;
|
bool m_Connected;
|
||||||
|
@@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
|
|||||||
Buf_Type = TYPE_STRING;
|
Buf_Type = TYPE_STRING;
|
||||||
*Format.Type = 'C';
|
*Format.Type = 'C';
|
||||||
Format.Length = Long;
|
Format.Length = Long;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
Format.Prec = 1; // Case insensitive
|
Format.Prec = 1; // Case insensitive
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
Constant = (!To_Tdb->GetDef()->GetMultiple() &&
|
Constant = (!To_Tdb->GetDef()->GetMultiple() &&
|
||||||
To_Tdb->GetAmType() != TYPE_AM_PLG &&
|
To_Tdb->GetAmType() != TYPE_AM_PLG &&
|
||||||
To_Tdb->GetAmType() != TYPE_AM_PLM);
|
To_Tdb->GetAmType() != TYPE_AM_PLM);
|
||||||
|
@@ -38,7 +38,8 @@ class DllExport COLBLK : public XOBJECT {
|
|||||||
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
|
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
|
||||||
virtual int GetClustered(void) {return 0;}
|
virtual int GetClustered(void) {return 0;}
|
||||||
virtual int IsClustered(void) {return FALSE;}
|
virtual int IsClustered(void) {return FALSE;}
|
||||||
virtual PSZ GetJpath(PGLOBAL g, bool proj) {return NULL;}
|
virtual bool Stringify(void) {return FALSE;}
|
||||||
|
virtual PSZ GetJpath(PGLOBAL g, bool proj) {return NULL;}
|
||||||
PCOL GetNext(void) {return Next;}
|
PCOL GetNext(void) {return Next;}
|
||||||
PSZ GetName(void) {return Name;}
|
PSZ GetName(void) {return Name;}
|
||||||
int GetIndex(void) {return Index;}
|
int GetIndex(void) {return Index;}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#if defined(MSX2)
|
#if defined(MSX2)
|
||||||
#import "msxml2.dll" //Does not exist on Vista
|
#import "msxml2.dll" //Does not exist on Vista
|
||||||
|
@@ -17,12 +17,12 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -197,11 +197,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
|
|||||||
return true;
|
return true;
|
||||||
} // endif Memory
|
} // endif Memory
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (mode != MODE_DELETE) {
|
if (mode != MODE_DELETE) {
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (mode == MODE_READ) {
|
if (mode == MODE_READ) {
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
CloseFileHandle(hFile); // Not used anymore
|
CloseFileHandle(hFile); // Not used anymore
|
||||||
hFile = INVALID_HANDLE_VALUE; // For Fblock
|
hFile = INVALID_HANDLE_VALUE; // For Fblock
|
||||||
} // endif Mode
|
} // endif Mode
|
||||||
@@ -468,7 +468,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
n = (int)(Tpos - Memory);
|
n = (int)(Tpos - Memory);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
||||||
|
|
||||||
if (drc == 0xFFFFFFFF) {
|
if (drc == 0xFFFFFFFF) {
|
||||||
@@ -498,7 +498,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
#endif // UNIX
|
#endif // UNIX
|
||||||
} // endif Abort
|
} // endif Abort
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
CloseHandle(fp->Handle);
|
CloseHandle(fp->Handle);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
close(fp->Handle);
|
close(fp->Handle);
|
||||||
|
@@ -22,12 +22,12 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
//#include <errno.h>
|
//#include <errno.h>
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
//#include <io.h>
|
//#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
//#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -649,7 +649,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
|
|||||||
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
|
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
|
||||||
|
|
||||||
if (mode == MODE_INSERT) {
|
if (mode == MODE_INSERT) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Now we can revert to binary mode in particular because the eventual */
|
/* Now we can revert to binary mode in particular because the eventual */
|
||||||
/* writing of a new header must be done in binary mode to avoid */
|
/* writing of a new header must be done in binary mode to avoid */
|
||||||
@@ -659,7 +659,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
|
|||||||
sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno));
|
sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno));
|
||||||
return true;
|
return true;
|
||||||
} // endif setmode
|
} // endif setmode
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* If this is a new file, the header must be generated. */
|
/* If this is a new file, the header must be generated. */
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -338,7 +338,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
|
|||||||
} else if (feof(Stream)) {
|
} else if (feof(Stream)) {
|
||||||
rc = RC_EF;
|
rc = RC_EF;
|
||||||
} else {
|
} else {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
||||||
#else
|
#else
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
||||||
@@ -678,7 +678,7 @@ BGXFAM::BGXFAM(PBGXFAM txfp) : FIXFAM(txfp)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
|
bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
DWORD drc;
|
DWORD drc;
|
||||||
LARGE_INTEGER of;
|
LARGE_INTEGER of;
|
||||||
@@ -694,14 +694,14 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
|
|||||||
sprintf(g->Message, MSG(SFP_ERROR), buf);
|
sprintf(g->Message, MSG(SFP_ERROR), buf);
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (lseek64(h, pos, org) < 0) {
|
if (lseek64(h, pos, org) < 0) {
|
||||||
// sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
|
// sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
|
||||||
sprintf(g->Message, "lseek64: %s", strerror(errno));
|
sprintf(g->Message, "lseek64: %s", strerror(errno));
|
||||||
printf("%s\n", g->Message);
|
printf("%s\n", g->Message);
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of BigSeek
|
} // end of BigSeek
|
||||||
@@ -714,7 +714,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD nbr, drc, len = (DWORD)req;
|
DWORD nbr, drc, len = (DWORD)req;
|
||||||
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
|
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
|
||||||
|
|
||||||
@@ -736,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)),
|
|||||||
rc = -1;
|
rc = -1;
|
||||||
} else
|
} else
|
||||||
rc = (int)nbr;
|
rc = (int)nbr;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
size_t len = (size_t)req;
|
size_t len = (size_t)req;
|
||||||
ssize_t nbr = read(h, inbuf, len);
|
ssize_t nbr = read(h, inbuf, len);
|
||||||
|
|
||||||
rc = (int)nbr;
|
rc = (int)nbr;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of BigRead
|
} // end of BigRead
|
||||||
@@ -753,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
{
|
{
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD nbw, drc, len = (DWORD)req;
|
DWORD nbw, drc, len = (DWORD)req;
|
||||||
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
|
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
|
||||||
|
|
||||||
@@ -781,7 +781,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif brc || nbw
|
} // endif brc || nbw
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
size_t len = (size_t)req;
|
size_t len = (size_t)req;
|
||||||
ssize_t nbw = write(h, inbuf, len);
|
ssize_t nbw = write(h, inbuf, len);
|
||||||
|
|
||||||
@@ -796,7 +796,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif nbr
|
} // endif nbr
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of BigWrite
|
} // end of BigWrite
|
||||||
@@ -831,7 +831,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
|
|||||||
if (trace(1))
|
if (trace(1))
|
||||||
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
|
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD rc, access, creation, share = 0;
|
DWORD rc, access, creation, share = 0;
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -989,7 +989,7 @@ int BGXFAM::Cardinality(PGLOBAL g)
|
|||||||
|
|
||||||
PlugSetPath(filename, To_File, Tdbp->GetPath());
|
PlugSetPath(filename, To_File, Tdbp->GetPath());
|
||||||
|
|
||||||
#if defined(__WIN__) // OB
|
#if defined(_WIN32) // OB
|
||||||
LARGE_INTEGER len;
|
LARGE_INTEGER len;
|
||||||
DWORD rc = 0;
|
DWORD rc = 0;
|
||||||
|
|
||||||
@@ -1348,7 +1348,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
/* Remove extra records. */
|
/* Remove extra records. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl))
|
if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl))
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
@@ -1358,12 +1358,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
|
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif error
|
} // endif error
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
|
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
|
||||||
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
|
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif
|
} // endif
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
} // endif UseTemp
|
} // endif UseTemp
|
||||||
|
|
||||||
@@ -1388,7 +1388,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g)
|
|||||||
strcat(PlugRemoveType(tempname, tempname), ".t");
|
strcat(PlugRemoveType(tempname, tempname), ".t");
|
||||||
remove(tempname); // Be sure it does not exist yet
|
remove(tempname); // Be sure it does not exist yet
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
|
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
|
||||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
@@ -1528,7 +1528,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||||||
void BGXFAM::Rewind(void)
|
void BGXFAM::Rewind(void)
|
||||||
{
|
{
|
||||||
#if 0 // This is probably unuseful because file is accessed directly
|
#if 0 // This is probably unuseful because file is accessed directly
|
||||||
#if defined(__WIN__) //OB
|
#if defined(_WIN32) //OB
|
||||||
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
|
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
lseek64(Hfile, 0, SEEK_SET);
|
lseek64(Hfile, 0, SEEK_SET);
|
||||||
|
@@ -17,21 +17,21 @@
|
|||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif
|
#endif
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#else // !UNIX
|
#else // !UNIX
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -89,11 +89,11 @@ int GZFAM::Zerror(PGLOBAL g)
|
|||||||
strcpy(g->Message, gzerror(Zfile, &errnum));
|
strcpy(g->Message, gzerror(Zfile, &errnum));
|
||||||
|
|
||||||
if (errnum == Z_ERRNO)
|
if (errnum == Z_ERRNO)
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL));
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return (errnum == Z_STREAM_END) ? RC_EF : RC_FX;
|
return (errnum == Z_STREAM_END) ? RC_EF : RC_FX;
|
||||||
} // end of Zerror
|
} // end of Zerror
|
||||||
@@ -764,9 +764,9 @@ bool GZXFAM::AllocateBuffer(PGLOBAL g)
|
|||||||
if (Tdbp->GetFtype() < 2)
|
if (Tdbp->GetFtype() < 2)
|
||||||
// if not binary, the file is physically a text file
|
// if not binary, the file is physically a text file
|
||||||
for (int len = Lrecl; len <= Buflen; len += Lrecl) {
|
for (int len = Lrecl; len <= Buflen; len += Lrecl) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
To_Buf[len - 2] = '\r';
|
To_Buf[len - 2] = '\r';
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
To_Buf[len - 1] = '\n';
|
To_Buf[len - 1] = '\n';
|
||||||
} // endfor len
|
} // endfor len
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX) || defined(UNIV_LINUX)
|
#if defined(UNIX) || defined(UNIV_LINUX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -82,7 +82,7 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
|
|||||||
To_File = NULL;
|
To_File = NULL;
|
||||||
Lrecl = 0;
|
Lrecl = 0;
|
||||||
Eof = false;
|
Eof = false;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
Ending = 2;
|
Ending = 2;
|
||||||
#else
|
#else
|
||||||
Ending = 1;
|
Ending = 1;
|
||||||
@@ -731,7 +731,7 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header)
|
|||||||
if (feof(Stream))
|
if (feof(Stream))
|
||||||
return RC_EF;
|
return RC_EF;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
||||||
#else
|
#else
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
||||||
@@ -814,7 +814,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
|
|||||||
if (trace(2))
|
if (trace(2))
|
||||||
htrc(" Read: To_Buf=%p p=%c\n", To_Buf, p);
|
htrc(" Read: To_Buf=%p p=%c\n", To_Buf, p);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (Bin) {
|
if (Bin) {
|
||||||
// Data file is read in binary so CRLF remains
|
// Data file is read in binary so CRLF remains
|
||||||
#else
|
#else
|
||||||
@@ -848,7 +848,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
|
|||||||
} else if (feof(Stream)) {
|
} else if (feof(Stream)) {
|
||||||
rc = RC_EF;
|
rc = RC_EF;
|
||||||
} else {
|
} else {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
||||||
#else
|
#else
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
||||||
@@ -1043,7 +1043,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
/* Remove extra records. */
|
/* Remove extra records. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (chsize(h, Tpos)) {
|
if (chsize(h, Tpos)) {
|
||||||
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
|
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
|
||||||
close(h);
|
close(h);
|
||||||
@@ -1482,7 +1482,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
|
|||||||
} else if (feof(Stream)) {
|
} else if (feof(Stream)) {
|
||||||
rc = RC_EF;
|
rc = RC_EF;
|
||||||
} else {
|
} else {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
||||||
#else
|
#else
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
|
||||||
@@ -1567,11 +1567,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
|
|||||||
Spos = GetNextPos(); // New start position
|
Spos = GetNextPos(); // New start position
|
||||||
|
|
||||||
// Prepare the output buffer
|
// Prepare the output buffer
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
crlf = "\r\n";
|
crlf = "\r\n";
|
||||||
#else
|
#else
|
||||||
crlf = "\n";
|
crlf = "\n";
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf);
|
strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf);
|
||||||
len = strlen(OutBuf);
|
len = strlen(OutBuf);
|
||||||
} else {
|
} else {
|
||||||
@@ -1871,7 +1871,7 @@ int BINFAM::ReadBuffer(PGLOBAL g)
|
|||||||
} else if (feof(Stream)) {
|
} else if (feof(Stream)) {
|
||||||
rc = RC_EF;
|
rc = RC_EF;
|
||||||
} else {
|
} else {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
|
||||||
#else
|
#else
|
||||||
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
|
||||||
@@ -2065,7 +2065,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
/* Remove extra records. */
|
/* Remove extra records. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (chsize(h, Tpos)) {
|
if (chsize(h, Tpos)) {
|
||||||
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
|
sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
|
||||||
close(h);
|
close(h);
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
#endif // __BORLAND__
|
#endif // __BORLAND__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -371,11 +371,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
|||||||
int h, n;
|
int h, n;
|
||||||
|
|
||||||
PlugSetPath(filename, fn, Tdbp->GetPath());
|
PlugSetPath(filename, fn, Tdbp->GetPath());
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
|
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
|
h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
if (h == -1)
|
if (h == -1)
|
||||||
return true;
|
return true;
|
||||||
@@ -1672,7 +1672,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
// Remove extra blocks
|
// Remove extra blocks
|
||||||
n = Block * Blksize;
|
n = Block * Blksize;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
||||||
|
|
||||||
if (drc == 0xFFFFFFFF) {
|
if (drc == 0xFFFFFFFF) {
|
||||||
@@ -2579,11 +2579,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
|
|||||||
char fn[_MAX_PATH];
|
char fn[_MAX_PATH];
|
||||||
|
|
||||||
sprintf(fn, Colfn, colp->Index);
|
sprintf(fn, Colfn, colp->Index);
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (feof(Streams[i]))
|
if (feof(Streams[i]))
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (errno == NO_ERROR)
|
if (errno == NO_ERROR)
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
|
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
|
||||||
else
|
else
|
||||||
sprintf(g->Message, MSG(READ_ERROR),
|
sprintf(g->Message, MSG(READ_ERROR),
|
||||||
@@ -2979,7 +2979,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
n = Tpos * Clens[i];
|
n = Tpos * Clens[i];
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
|
||||||
|
|
||||||
if (drc == 0xFFFFFFFF) {
|
if (drc == 0xFFFFFFFF) {
|
||||||
@@ -3059,7 +3059,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
|
bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
DWORD drc, m = (b) ? FILE_END : FILE_BEGIN;
|
DWORD drc, m = (b) ? FILE_END : FILE_BEGIN;
|
||||||
LARGE_INTEGER of;
|
LARGE_INTEGER of;
|
||||||
@@ -3075,12 +3075,12 @@ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b)
|
|||||||
sprintf(g->Message, MSG(SFP_ERROR), buf);
|
sprintf(g->Message, MSG(SFP_ERROR), buf);
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
|
if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) {
|
||||||
sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
|
sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of BigSeek
|
} // end of BigSeek
|
||||||
@@ -3092,7 +3092,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
{
|
{
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD nbr, drc, len = (DWORD)req;
|
DWORD nbr, drc, len = (DWORD)req;
|
||||||
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
|
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
|
||||||
|
|
||||||
@@ -3118,7 +3118,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif brc || nbr
|
} // endif brc || nbr
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
size_t len = (size_t)req;
|
size_t len = (size_t)req;
|
||||||
ssize_t nbr = read(h, inbuf, len);
|
ssize_t nbr = read(h, inbuf, len);
|
||||||
|
|
||||||
@@ -3133,7 +3133,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif nbr
|
} // endif nbr
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of BigRead
|
} // end of BigRead
|
||||||
@@ -3145,7 +3145,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
{
|
{
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD nbw, drc, len = (DWORD)req;
|
DWORD nbw, drc, len = (DWORD)req;
|
||||||
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
|
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
|
||||||
|
|
||||||
@@ -3173,7 +3173,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif brc || nbw
|
} // endif brc || nbw
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
size_t len = (size_t)req;
|
size_t len = (size_t)req;
|
||||||
ssize_t nbw = write(h, inbuf, len);
|
ssize_t nbw = write(h, inbuf, len);
|
||||||
|
|
||||||
@@ -3188,7 +3188,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
|||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif nbr
|
} // endif nbr
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of BigWrite
|
} // end of BigWrite
|
||||||
@@ -3214,7 +3214,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
|
|||||||
if (Header == 2)
|
if (Header == 2)
|
||||||
strcat(PlugRemoveType(filename, filename), ".blk");
|
strcat(PlugRemoveType(filename, filename), ".blk");
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
LARGE_INTEGER len;
|
LARGE_INTEGER len;
|
||||||
|
|
||||||
h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
@@ -3226,11 +3226,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
|
|||||||
} // endif h
|
} // endif h
|
||||||
|
|
||||||
if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
|
if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
h = open64(filename, O_RDONLY, 0);
|
h = open64(filename, O_RDONLY, 0);
|
||||||
|
|
||||||
if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
|
if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
// Consider this is a void table
|
// Consider this is a void table
|
||||||
if (trace(1))
|
if (trace(1))
|
||||||
htrc("Void table h=%d\n", h);
|
htrc("Void table h=%d\n", h);
|
||||||
@@ -3291,17 +3291,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
|
|||||||
strcat(PlugRemoveType(filename, filename), ".blk");
|
strcat(PlugRemoveType(filename, filename), ".blk");
|
||||||
|
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING;
|
DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING;
|
||||||
|
|
||||||
h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0,
|
h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0,
|
||||||
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC;
|
int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC;
|
||||||
|
|
||||||
h = open64(filename, oflag, 0);
|
h = open64(filename, oflag, 0);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
sprintf(g->Message, "Error opening header file %s", filename);
|
sprintf(g->Message, "Error opening header file %s", filename);
|
||||||
@@ -3339,7 +3339,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
|||||||
|
|
||||||
PlugSetPath(filename, fn, Tdbp->GetPath());
|
PlugSetPath(filename, fn, Tdbp->GetPath());
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
PCSZ p;
|
PCSZ p;
|
||||||
DWORD rc;
|
DWORD rc;
|
||||||
bool brc;
|
bool brc;
|
||||||
@@ -3391,7 +3391,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
|||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
int h;
|
int h;
|
||||||
BIGINT pos;
|
BIGINT pos;
|
||||||
|
|
||||||
@@ -3420,7 +3420,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
|||||||
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
|
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
|
||||||
close(h);
|
close(h);
|
||||||
return true;
|
return true;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} // end of MakeEmptyFile
|
} // end of MakeEmptyFile
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -3451,7 +3451,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g)
|
|||||||
htrc("OpenTableFile: filename=%s mode=%d Last=%d\n",
|
htrc("OpenTableFile: filename=%s mode=%d Last=%d\n",
|
||||||
filename, mode, Last);
|
filename, mode, Last);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD access, creation, share = 0, rc = 0;
|
DWORD access, creation, share = 0, rc = 0;
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -3779,7 +3779,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g)
|
|||||||
|
|
||||||
if (!Closing && !MaxBlk) {
|
if (!Closing && !MaxBlk) {
|
||||||
// Close the VCT file and reopen it in mode Insert
|
// Close the VCT file and reopen it in mode Insert
|
||||||
//#if defined(__WIN__) //OB
|
//#if defined(_WIN32) //OB
|
||||||
// CloseHandle(Hfile);
|
// CloseHandle(Hfile);
|
||||||
//#else // UNIX
|
//#else // UNIX
|
||||||
// close(Hfile);
|
// close(Hfile);
|
||||||
@@ -3906,7 +3906,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* Remove extra records. */
|
/* Remove extra records. */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
BIGINT pos = (BIGINT)Block * (BIGINT)Blksize;
|
BIGINT pos = (BIGINT)Block * (BIGINT)Blksize;
|
||||||
|
|
||||||
if (BigSeek(g, Hfile, pos))
|
if (BigSeek(g, Hfile, pos))
|
||||||
@@ -3918,12 +3918,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc)
|
|||||||
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
|
sprintf(g->Message, MSG(SETEOF_ERROR), drc);
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif error
|
} // endif error
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
|
if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) {
|
||||||
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
|
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif
|
} // endif
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} else // MaxBlk
|
} else // MaxBlk
|
||||||
// Clean the unused space in the file, this is required when
|
// Clean the unused space in the file, this is required when
|
||||||
// inserting again with a partial column list.
|
// inserting again with a partial column list.
|
||||||
@@ -3960,7 +3960,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g)
|
|||||||
else if (MakeEmptyFile(g, tempname))
|
else if (MakeEmptyFile(g, tempname))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW;
|
DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW;
|
||||||
|
|
||||||
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
|
Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL,
|
||||||
@@ -4231,7 +4231,7 @@ void BGVFAM::Rewind(void)
|
|||||||
CurNum = Nrec - 1;
|
CurNum = Nrec - 1;
|
||||||
|
|
||||||
#if 0 // This is probably unuseful as the file is directly accessed
|
#if 0 // This is probably unuseful as the file is directly accessed
|
||||||
#if defined(__WIN__) //OB
|
#if defined(_WIN32) //OB
|
||||||
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
|
SetFilePointer(Hfile, 0, NULL, FILE_BEGIN);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
lseek64(Hfile, 0, SEEK_SET);
|
lseek64(Hfile, 0, SEEK_SET);
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -154,7 +154,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
strcpy(filename, pat);
|
strcpy(filename, pat);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char drive[_MAX_DRIVE], direc[_MAX_DIR];
|
char drive[_MAX_DRIVE], direc[_MAX_DIR];
|
||||||
WIN32_FIND_DATA FileData;
|
WIN32_FIND_DATA FileData;
|
||||||
HANDLE hSearch;
|
HANDLE hSearch;
|
||||||
@@ -210,7 +210,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
|
|||||||
return true;
|
return true;
|
||||||
} // endif FindClose
|
} // endif FindClose
|
||||||
|
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN];
|
char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN];
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
@@ -251,7 +251,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
|
|||||||
|
|
||||||
// Close the dir handle.
|
// Close the dir handle.
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of ZipFiles
|
} // end of ZipFiles
|
||||||
@@ -275,9 +275,9 @@ bool ZipLoadFile(PGLOBAL g, PCSZ zfn, PCSZ fn, PCSZ entry, bool append, bool mul
|
|||||||
|
|
||||||
if (!entry) { // entry defaults to the file name
|
if (!entry) { // entry defaults to the file name
|
||||||
char* p = strrchr((char*)fn, '/');
|
char* p = strrchr((char*)fn, '/');
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (!p) p = strrchr((char*)fn, '\\');
|
if (!p) p = strrchr((char*)fn, '\\');
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
entp = (p) ? p + 1 : entry;
|
entp = (p) ? p + 1 : entry;
|
||||||
} else
|
} else
|
||||||
entp = entry;
|
entp = entry;
|
||||||
@@ -467,7 +467,7 @@ UNZIPUTL::UNZIPUTL(PCSZ tgt, PCSZ pw, bool mul)
|
|||||||
memset(fn, 0, sizeof(fn));
|
memset(fn, 0, sizeof(fn));
|
||||||
|
|
||||||
// Init the case mapping table.
|
// Init the case mapping table.
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
||||||
#else
|
#else
|
||||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
||||||
@@ -487,7 +487,7 @@ UNZIPUTL::UNZIPUTL(PDOSDEF tdp)
|
|||||||
memset(fn, 0, sizeof(fn));
|
memset(fn, 0, sizeof(fn));
|
||||||
|
|
||||||
// Init the case mapping table.
|
// Init the case mapping table.
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
||||||
#else
|
#else
|
||||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
||||||
|
@@ -13,13 +13,13 @@
|
|||||||
//#include "sql_class.h"
|
//#include "sql_class.h"
|
||||||
//#include "sql_time.h"
|
//#include "sql_time.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -106,7 +106,7 @@ class FILTERX : public FILTER {
|
|||||||
|
|
||||||
// Fake operator new used to change a filter into a derived filter
|
// Fake operator new used to change a filter into a derived filter
|
||||||
void * operator new(size_t, PFIL filp) {return filp;}
|
void * operator new(size_t, PFIL filp) {return filp;}
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// Avoid warning C4291 by defining a matching dummy delete operator
|
// Avoid warning C4291 by defining a matching dummy delete operator
|
||||||
void operator delete(void *, PFIL) {}
|
void operator delete(void *, PFIL) {}
|
||||||
#else
|
#else
|
||||||
|
@@ -22,12 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define FLEX_SCANNER
|
#define FLEX_SCANNER
|
||||||
#ifdef __WIN__
|
#ifdef _WIN32
|
||||||
#define __STDC__ 1
|
#define __STDC__ 1
|
||||||
#define isatty _isatty
|
#define isatty _isatty
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifndef __WIN__
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -14,11 +14,11 @@
|
|||||||
#include <time.h> /* time_t type declaration */
|
#include <time.h> /* time_t type declaration */
|
||||||
#include <setjmp.h> /* Long jump declarations */
|
#include <setjmp.h> /* Long jump declarations */
|
||||||
|
|
||||||
#if defined(__WIN__) && !defined(NOEX)
|
#if defined(_WIN32) && !defined(NOEX)
|
||||||
#define DllExport __declspec( dllexport )
|
#define DllExport __declspec( dllexport )
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#define DllExport
|
#define DllExport
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
|
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
|
||||||
#define XML_SUPPORT 1
|
#define XML_SUPPORT 1
|
||||||
@@ -43,11 +43,11 @@
|
|||||||
#define STEP(I) MSG_##I
|
#define STEP(I) MSG_##I
|
||||||
#endif // !XMSG and !NEWMSG
|
#endif // !XMSG and !NEWMSG
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#define CRLF 2
|
#define CRLF 2
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#define CRLF 1
|
#define CRLF 1
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Define access to the thread based trace value. */
|
/* Define access to the thread based trace value. */
|
||||||
@@ -204,9 +204,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *);
|
|||||||
#elif defined(NEWMSG)
|
#elif defined(NEWMSG)
|
||||||
DllExport char *PlugGetMessage(PGLOBAL, int);
|
DllExport char *PlugGetMessage(PGLOBAL, int);
|
||||||
#endif // XMSG || NEWMSG
|
#endif // XMSG || NEWMSG
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DllExport short GetLineLength(PGLOBAL); // Console line length
|
DllExport short GetLineLength(PGLOBAL); // Console line length
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
DllExport PGLOBAL PlugInit(LPCSTR, size_t); // Plug global initialization
|
DllExport PGLOBAL PlugInit(LPCSTR, size_t); // Plug global initialization
|
||||||
DllExport PGLOBAL PlugExit(PGLOBAL); // Plug global termination
|
DllExport PGLOBAL PlugExit(PGLOBAL); // Plug global termination
|
||||||
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
|
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
|
||||||
|
@@ -139,10 +139,10 @@
|
|||||||
//#include "reldef.h"
|
//#include "reldef.h"
|
||||||
#include "tabcol.h"
|
#include "tabcol.h"
|
||||||
#include "xindex.h"
|
#include "xindex.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include "tabwmi.h"
|
#include "tabwmi.h"
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
#include "user_connect.h"
|
#include "user_connect.h"
|
||||||
#include "ha_connect.h"
|
#include "ha_connect.h"
|
||||||
@@ -167,16 +167,16 @@
|
|||||||
#define SZCONV 1024 // Default converted text size
|
#define SZCONV 1024 // Default converted text size
|
||||||
#define SZWORK 67108864 // Default work area size 64M
|
#define SZWORK 67108864 // Default work area size 64M
|
||||||
#define SZWMIN 4194304 // Minimum work area size 4M
|
#define SZWMIN 4194304 // Minimum work area size 4M
|
||||||
#define JSONMAX 10 // JSON Default max grp size
|
#define JSONMAX 50 // JSON Default max grp size
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
char version[]= "Version 1.07.0002 March 22, 2021";
|
char version[]= "Version 1.07.0003 June 06, 2021";
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
|
char compver[]= "Version 1.07.0003 " __DATE__ " " __TIME__;
|
||||||
char slash= '\\';
|
char slash= '\\';
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
char slash= '/';
|
char slash= '/';
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID > 100200
|
#if MYSQL_VERSION_ID > 100200
|
||||||
@@ -290,10 +290,14 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
static char *strz(PGLOBAL g, LEX_STRING &ls)
|
static char *strz(PGLOBAL g, LEX_STRING &ls)
|
||||||
{
|
{
|
||||||
char *str= (char*)PlugSubAlloc(g, NULL, ls.length + 1);
|
char* str= NULL;
|
||||||
|
|
||||||
|
if (ls.str) {
|
||||||
|
str= (char*)PlugSubAlloc(g, NULL, ls.length + 1);
|
||||||
|
memcpy(str, ls.str, ls.length);
|
||||||
|
str[ls.length] = 0;
|
||||||
|
} // endif str
|
||||||
|
|
||||||
memcpy(str, ls.str, ls.length);
|
|
||||||
str[ls.length]= 0;
|
|
||||||
return str;
|
return str;
|
||||||
} // end of strz
|
} // end of strz
|
||||||
|
|
||||||
@@ -508,7 +512,7 @@ char *GetJsonNull(void)
|
|||||||
int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);}
|
int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);}
|
||||||
int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);}
|
int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);}
|
||||||
uint GetJsonGrpSize(void)
|
uint GetJsonGrpSize(void)
|
||||||
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;}
|
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 50;}
|
||||||
size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
|
size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
|
||||||
void SetWorkSize(size_t)
|
void SetWorkSize(size_t)
|
||||||
{
|
{
|
||||||
@@ -802,11 +806,11 @@ static int connect_init_func(void *p)
|
|||||||
}
|
}
|
||||||
#endif // 0 (LINUX)
|
#endif // 0 (LINUX)
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sql_print_information("CONNECT: %s", compver);
|
sql_print_information("CONNECT: %s", compver);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
sql_print_information("CONNECT: %s", version);
|
sql_print_information("CONNECT: %s", version);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
pthread_mutex_init(&parmut, NULL);
|
pthread_mutex_init(&parmut, NULL);
|
||||||
pthread_mutex_init(&usrmut, NULL);
|
pthread_mutex_init(&usrmut, NULL);
|
||||||
pthread_mutex_init(&tblmut, NULL);
|
pthread_mutex_init(&tblmut, NULL);
|
||||||
@@ -865,9 +869,9 @@ static int connect_done_func(void *)
|
|||||||
JAVAConn::ResetJVM();
|
JAVAConn::ResetJVM();
|
||||||
#endif // JAVA_SUPPORT
|
#endif // JAVA_SUPPORT
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
PROFILE_End();
|
PROFILE_End();
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
pthread_mutex_lock(&usrmut);
|
pthread_mutex_lock(&usrmut);
|
||||||
for (pc= user_connect::to_users; pc; pc= pn) {
|
for (pc= user_connect::to_users; pc; pc= pn) {
|
||||||
@@ -941,11 +945,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
|
|||||||
xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
|
xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
|
||||||
if (xp)
|
if (xp)
|
||||||
xp->SetHandler(this);
|
xp->SetHandler(this);
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
datapath= ".\\";
|
datapath= ".\\";
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
datapath= "./";
|
datapath= "./";
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
tdbp= NULL;
|
tdbp= NULL;
|
||||||
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
|
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
|
||||||
sdvalout= NULL;
|
sdvalout= NULL;
|
||||||
@@ -4373,7 +4377,6 @@ int ha_connect::info(uint flag)
|
|||||||
// tdbp must be available to get updated info
|
// tdbp must be available to get updated info
|
||||||
if (xp->CheckQuery(valid_query_id) || !tdbp) {
|
if (xp->CheckQuery(valid_query_id) || !tdbp) {
|
||||||
PDBUSER dup= PlgGetUser(g);
|
PDBUSER dup= PlgGetUser(g);
|
||||||
PCATLG cat= (dup) ? dup->Catalog : NULL;
|
|
||||||
|
|
||||||
if (xmod == MODE_ANY || xmod == MODE_ALTER) {
|
if (xmod == MODE_ANY || xmod == MODE_ALTER) {
|
||||||
// Pure info, not a query
|
// Pure info, not a query
|
||||||
@@ -4549,11 +4552,11 @@ static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options,
|
|||||||
strcpy(dbpath, mysql_real_data_home);
|
strcpy(dbpath, mysql_real_data_home);
|
||||||
|
|
||||||
if (db)
|
if (db)
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
strcat(strcat(dbpath, db), "\\");
|
strcat(strcat(dbpath, db), "\\");
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
strcat(strcat(dbpath, db), "/");
|
strcat(strcat(dbpath, db), "/");
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
(void)fn_format(path, options->filename, dbpath, "",
|
(void)fn_format(path, options->filename, dbpath, "",
|
||||||
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
|
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
|
||||||
@@ -5470,14 +5473,13 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
|
|||||||
} // endif rem
|
} // endif rem
|
||||||
|
|
||||||
if (fmt && *fmt) {
|
if (fmt && *fmt) {
|
||||||
switch (ttp) {
|
switch (ttp) {
|
||||||
case TAB_JSON: error |= sql->append(" JPATH='"); break;
|
case TAB_MONGO:
|
||||||
#if defined(BSON_SUPPORT)
|
case TAB_BSON:
|
||||||
case TAB_BSON: error |= sql->append(" JPATH='"); break;
|
case TAB_JSON: error |= sql->append(" JPATH='"); break;
|
||||||
#endif // BSON_SUPPORT
|
case TAB_XML: error |= sql->append(" XPATH='"); break;
|
||||||
case TAB_XML: error |= sql->append(" XPATH='"); break;
|
default: error |= sql->append(" FIELD_FORMAT='");
|
||||||
default: error |= sql->append(" FIELD_FORMAT='");
|
} // endswitch ttp
|
||||||
} // endswitch ttp
|
|
||||||
|
|
||||||
error |= sql->append_for_single_quote(fmt, strlen(fmt));
|
error |= sql->append_for_single_quote(fmt, strlen(fmt));
|
||||||
error |= sql->append("'");
|
error |= sql->append("'");
|
||||||
@@ -5608,11 +5610,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
PCSZ user, fn, db, host, pwd, sep, tbl, src;
|
PCSZ user, fn, db, host, pwd, sep, tbl, src;
|
||||||
PCSZ col, ocl, rnk, pic, fcl, skc, zfn;
|
PCSZ col, ocl, rnk, pic, fcl, skc, zfn;
|
||||||
char *tab, *dsn, *shm, *dpath, *url;
|
char *tab, *dsn, *shm, *dpath, *url;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
PCSZ nsp= NULL, cls= NULL;
|
PCSZ nsp= NULL, cls= NULL;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
//int hdr, mxe;
|
//int hdr, mxe;
|
||||||
int port= 0, mxr= 0, rc= 0, mul= 0, lrecl= 0;
|
int port= 0, mxr= 0, rc= 0, mul= 0;
|
||||||
//PCSZ tabtyp= NULL;
|
//PCSZ tabtyp= NULL;
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
POPARM sop= NULL;
|
POPARM sop= NULL;
|
||||||
@@ -5626,7 +5628,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
#endif // JAVA_SUPPORT
|
#endif // JAVA_SUPPORT
|
||||||
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
|
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
|
||||||
bool bif, ok= false, dbf= false;
|
bool bif, ok= false, dbf= false;
|
||||||
TABTYPE ttp= TAB_UNDEF;
|
TABTYPE ttp= TAB_UNDEF, ttr=TAB_UNDEF;
|
||||||
PQRYRES qrp= NULL;
|
PQRYRES qrp= NULL;
|
||||||
PCOLRES crp;
|
PCOLRES crp;
|
||||||
PCONNECT xp= NULL;
|
PCONNECT xp= NULL;
|
||||||
@@ -5635,8 +5637,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
if (!g)
|
if (!g)
|
||||||
return HA_ERR_INTERNAL_ERROR;
|
return HA_ERR_INTERNAL_ERROR;
|
||||||
|
|
||||||
PDBUSER dup= PlgGetUser(g);
|
|
||||||
PCATLG cat= (dup) ? dup->Catalog : NULL;
|
|
||||||
PTOS topt= table_s->option_struct;
|
PTOS topt= table_s->option_struct;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
String sql(buf, sizeof(buf), system_charset_info);
|
String sql(buf, sizeof(buf), system_charset_info);
|
||||||
@@ -5671,10 +5671,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
|
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
|
||||||
rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
|
rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
|
||||||
pwd= GetListOption(g, "password", topt->oplist);
|
pwd= GetListOption(g, "password", topt->oplist);
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
nsp= GetListOption(g, "namespace", topt->oplist);
|
nsp= GetListOption(g, "namespace", topt->oplist);
|
||||||
cls= GetListOption(g, "class", topt->oplist);
|
cls= GetListOption(g, "class", topt->oplist);
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
|
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
// tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL);
|
// tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL);
|
||||||
@@ -5708,7 +5708,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
|
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
|
||||||
ttp= GetTypeID(topt->type);
|
ttp= GetTypeID(topt->type);
|
||||||
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
|
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
|
||||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
||||||
} else if (ttp == TAB_NIY) {
|
} else if (ttp == TAB_NIY) {
|
||||||
sprintf(g->Message, "Unsupported table type %s", topt->type);
|
sprintf(g->Message, "Unsupported table type %s", topt->type);
|
||||||
rc= HA_ERR_INTERNAL_ERROR;
|
rc= HA_ERR_INTERNAL_ERROR;
|
||||||
@@ -5716,13 +5716,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
#if defined(REST_SUPPORT)
|
#if defined(REST_SUPPORT)
|
||||||
} else if (topt->http) {
|
} else if (topt->http) {
|
||||||
if (ttp == TAB_UNDEF) {
|
if (ttp == TAB_UNDEF) {
|
||||||
topt->type = "JSON";
|
ttr= TAB_JSON;
|
||||||
ttp= GetTypeID(topt->type);
|
strcpy(g->Message, "No table_type. Was set to JSON");
|
||||||
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
||||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
} else
|
||||||
} // endif ttp
|
ttr= ttp;
|
||||||
|
|
||||||
switch (ttp) {
|
switch (ttr) {
|
||||||
case TAB_JSON:
|
case TAB_JSON:
|
||||||
#if defined(BSON_SUPPORT)
|
#if defined(BSON_SUPPORT)
|
||||||
case TAB_BSON:
|
case TAB_BSON:
|
||||||
@@ -5905,11 +5905,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
ok= false;
|
ok= false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case TAB_WMI:
|
case TAB_WMI:
|
||||||
ok= true;
|
ok= true;
|
||||||
break;
|
break;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
case TAB_PIVOT:
|
case TAB_PIVOT:
|
||||||
supfnc= FNC_NO;
|
supfnc= FNC_NO;
|
||||||
case TAB_PRX:
|
case TAB_PRX:
|
||||||
@@ -5941,9 +5941,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
|
|
||||||
if (!fn && !zfn && !mul && !dsn)
|
if (!fn && !zfn && !mul && !dsn)
|
||||||
sprintf(g->Message, "Missing %s file name", topt->type);
|
sprintf(g->Message, "Missing %s file name", topt->type);
|
||||||
else
|
else if (dsn && !topt->tabname)
|
||||||
ok= true;
|
topt->tabname= tab;
|
||||||
|
|
||||||
|
ok= true;
|
||||||
break;
|
break;
|
||||||
#if defined(JAVA_SUPPORT)
|
#if defined(JAVA_SUPPORT)
|
||||||
case TAB_MONGO:
|
case TAB_MONGO:
|
||||||
@@ -5956,7 +5957,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
#if defined(REST_SUPPORT)
|
#if defined(REST_SUPPORT)
|
||||||
case TAB_REST:
|
case TAB_REST:
|
||||||
if (!topt->http)
|
if (!topt->http)
|
||||||
sprintf(g->Message, "Missing %s HTTP address", topt->type);
|
strcpy(g->Message, "Missing REST HTTP option");
|
||||||
else
|
else
|
||||||
ok = true;
|
ok = true;
|
||||||
|
|
||||||
@@ -6072,11 +6073,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
case TAB_CSV:
|
case TAB_CSV:
|
||||||
qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case TAB_WMI:
|
case TAB_WMI:
|
||||||
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
case TAB_PRX:
|
case TAB_PRX:
|
||||||
case TAB_TBL:
|
case TAB_TBL:
|
||||||
case TAB_XCL:
|
case TAB_XCL:
|
||||||
@@ -6176,7 +6177,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
|
|
||||||
// Restore language type
|
// Restore language type
|
||||||
if (ttp == TAB_REST)
|
if (ttp == TAB_REST)
|
||||||
ttp = GetTypeID(topt->type);
|
ttp = ttr;
|
||||||
|
|
||||||
for (i= 0; !rc && i < qrp->Nblin; i++) {
|
for (i= 0; !rc && i < qrp->Nblin; i++) {
|
||||||
typ= len= prec= dec= flg= 0;
|
typ= len= prec= dec= flg= 0;
|
||||||
@@ -6606,11 +6607,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
|
|||||||
// on Windows and libxml2 otherwise
|
// on Windows and libxml2 otherwise
|
||||||
switch (toupper(*xsup)) {
|
switch (toupper(*xsup)) {
|
||||||
case '*':
|
case '*':
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
dom= true;
|
dom= true;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
dom= false;
|
dom= false;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
case 'D':
|
case 'D':
|
||||||
@@ -6993,11 +6994,11 @@ bool ha_connect::FileExists(const char *fn, bool bf)
|
|||||||
int n;
|
int n;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
s= "\\";
|
s= "\\";
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
s= "/";
|
s= "/";
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
if (IsPartitioned()) {
|
if (IsPartitioned()) {
|
||||||
sprintf(tfn, fn, GetPartName());
|
sprintf(tfn, fn, GetPartName());
|
||||||
|
|
||||||
@@ -7512,7 +7513,7 @@ maria_declare_plugin(connect)
|
|||||||
0x0107, /* version number (1.07) */
|
0x0107, /* version number (1.07) */
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
connect_system_variables, /* system variables */
|
connect_system_variables, /* system variables */
|
||||||
"1.07.0002", /* string version */
|
"1.07.0003", /* string version */
|
||||||
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
||||||
}
|
}
|
||||||
maria_declare_plugin_end;
|
maria_declare_plugin_end;
|
||||||
|
@@ -6,24 +6,24 @@
|
|||||||
/* This file contains the JAVA connection classes functions. */
|
/* This file contains the JAVA connection classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// This is needed for RegGetValue
|
// This is needed for RegGetValue
|
||||||
#define _WINVER 0x0601
|
#define _WINVER 0x0601
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0601
|
#define _WIN32_WINNT 0x0601
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
//#include <m_string.h>
|
//#include <m_string.h>
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <direct.h> // for getcwd
|
#include <direct.h> // for getcwd
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#else // !UNIX
|
#else // !UNIX
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h> // for getenv
|
#include <stdlib.h> // for getenv
|
||||||
#define NODW
|
#define NODW
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Required objects includes. */
|
/* Required objects includes. */
|
||||||
@@ -47,9 +47,9 @@
|
|||||||
#include "valblk.h"
|
#include "valblk.h"
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
extern "C" HINSTANCE s_hModule; // Saved module handle
|
extern "C" HINSTANCE s_hModule; // Saved module handle
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
|
|
||||||
//TYPCONV GetTypeConv();
|
//TYPCONV GetTypeConv();
|
||||||
@@ -57,6 +57,8 @@ extern "C" HINSTANCE s_hModule; // Saved module handle
|
|||||||
extern char *JvmPath; // The connect_jvm_path global variable value
|
extern char *JvmPath; // The connect_jvm_path global variable value
|
||||||
extern char *ClassPath; // The connect_class_path global variable value
|
extern char *ClassPath; // The connect_class_path global variable value
|
||||||
|
|
||||||
|
char *GetPluginDir(void);
|
||||||
|
char *GetMessageDir(void);
|
||||||
char *GetJavaWrapper(void); // The connect_java_wrapper variable value
|
char *GetJavaWrapper(void); // The connect_java_wrapper variable value
|
||||||
extern MYSQL_PLUGIN_IMPORT char lc_messages_dir[FN_REFLEN];
|
extern MYSQL_PLUGIN_IMPORT char lc_messages_dir[FN_REFLEN];
|
||||||
|
|
||||||
@@ -199,11 +201,11 @@ int JAVAConn::GetMaxValue(int n)
|
|||||||
void JAVAConn::ResetJVM(void)
|
void JAVAConn::ResetJVM(void)
|
||||||
{
|
{
|
||||||
if (LibJvm) {
|
if (LibJvm) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
FreeLibrary((HMODULE)LibJvm);
|
FreeLibrary((HMODULE)LibJvm);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
dlclose(LibJvm);
|
dlclose(LibJvm);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
LibJvm = NULL;
|
LibJvm = NULL;
|
||||||
CreateJavaVM = NULL;
|
CreateJavaVM = NULL;
|
||||||
GetCreatedJavaVMs = NULL;
|
GetCreatedJavaVMs = NULL;
|
||||||
@@ -226,7 +228,7 @@ bool JAVAConn::GetJVM(PGLOBAL g)
|
|||||||
if (!LibJvm) {
|
if (!LibJvm) {
|
||||||
char soname[512];
|
char soname[512];
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
for (ntry = 0; !LibJvm && ntry < 3; ntry++) {
|
for (ntry = 0; !LibJvm && ntry < 3; ntry++) {
|
||||||
if (!ntry && JvmPath) {
|
if (!ntry && JvmPath) {
|
||||||
strcat(strcpy(soname, JvmPath), "\\jvm.dll");
|
strcat(strcpy(soname, JvmPath), "\\jvm.dll");
|
||||||
@@ -294,7 +296,7 @@ bool JAVAConn::GetJVM(PGLOBAL g)
|
|||||||
LibJvm = NULL;
|
LibJvm = NULL;
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
} // endif LibJvm
|
} // endif LibJvm
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
|
|
||||||
for (ntry = 0; !LibJvm && ntry < 2; ntry++) {
|
for (ntry = 0; !LibJvm && ntry < 2; ntry++) {
|
||||||
@@ -335,7 +337,7 @@ bool JAVAConn::GetJVM(PGLOBAL g)
|
|||||||
LibJvm = NULL;
|
LibJvm = NULL;
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
} // endif LibJvm
|
} // endif LibJvm
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
} // endif LibJvm
|
} // endif LibJvm
|
||||||
|
|
||||||
@@ -377,7 +379,7 @@ bool JAVAConn::Open(PGLOBAL g)
|
|||||||
char *cp = NULL;
|
char *cp = NULL;
|
||||||
char sep;
|
char sep;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
sep = ';';
|
sep = ';';
|
||||||
#define N 1
|
#define N 1
|
||||||
//#define N 2
|
//#define N 2
|
||||||
@@ -400,24 +402,17 @@ bool JAVAConn::Open(PGLOBAL g)
|
|||||||
jpop->Append(ClassPath);
|
jpop->Append(ClassPath);
|
||||||
} // endif ClassPath
|
} // endif ClassPath
|
||||||
|
|
||||||
#if 0
|
// All wrappers are pre-compiled in JavaWrappers.jar in the share dir
|
||||||
// Java source will be compiled as a jar file installed in the mysql share dir
|
|
||||||
jpop->Append(sep);
|
jpop->Append(sep);
|
||||||
jpop->Append(lc_messages_dir);
|
jpop->Append(GetMessageDir());
|
||||||
jpop->Append("JdbcInterface.jar");
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
// All wrappers are pre-compiled in JavaWrappers.jar in the mysql share dir
|
|
||||||
jpop->Append(sep);
|
|
||||||
jpop->Append(lc_messages_dir);
|
|
||||||
jpop->Append("JavaWrappers.jar");
|
jpop->Append("JavaWrappers.jar");
|
||||||
|
|
||||||
#if defined(MONGO_SUPPORT)
|
#if defined(MONGO_SUPPORT)
|
||||||
jpop->Append(sep);
|
jpop->Append(sep);
|
||||||
jpop->Append(lc_messages_dir);
|
jpop->Append(GetMessageDir());
|
||||||
jpop->Append("Mongo3.jar");
|
jpop->Append("Mongo3.jar");
|
||||||
jpop->Append(sep);
|
jpop->Append(sep);
|
||||||
jpop->Append(lc_messages_dir);
|
jpop->Append(GetMessageDir());
|
||||||
jpop->Append("Mongo2.jar");
|
jpop->Append("Mongo2.jar");
|
||||||
#endif // MONGO_SUPPORT
|
#endif // MONGO_SUPPORT
|
||||||
|
|
||||||
|
@@ -27,9 +27,9 @@
|
|||||||
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
|
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
|
||||||
//efine DEFAULT_FIELD_TYPE 0 // TYPE_NULL
|
//efine DEFAULT_FIELD_TYPE 0 // TYPE_NULL
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
typedef unsigned char *PUCHAR;
|
typedef unsigned char *PUCHAR;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
enum JCATINFO {
|
enum JCATINFO {
|
||||||
JCAT_TAB = 1, // JDBC Tables
|
JCAT_TAB = 1, // JDBC Tables
|
||||||
@@ -104,11 +104,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
static HANDLE LibJvm; // Handle to the jvm DLL
|
static HANDLE LibJvm; // Handle to the jvm DLL
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
static void *LibJvm; // Handle for the jvm shared library
|
static void *LibJvm; // Handle for the jvm shared library
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
static CRTJVM CreateJavaVM;
|
static CRTJVM CreateJavaVM;
|
||||||
static GETJVM GetCreatedJavaVMs;
|
static GETJVM GetCreatedJavaVMs;
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
|
@@ -6,19 +6,19 @@
|
|||||||
/* This file contains the JDBC connection classes functions. */
|
/* This file contains the JDBC connection classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// This is needed for RegGetValue
|
// This is needed for RegGetValue
|
||||||
#define _WINVER 0x0601
|
#define _WINVER 0x0601
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0601
|
#define _WIN32_WINNT 0x0601
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//nclude <io.h>
|
//nclude <io.h>
|
||||||
//nclude <fcntl.h>
|
//nclude <fcntl.h>
|
||||||
#include <direct.h> // for getcwd
|
#include <direct.h> // for getcwd
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#else // !UNIX
|
#else // !UNIX
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#include <stdlib.h> // for getenv
|
#include <stdlib.h> // for getenv
|
||||||
//nclude <fcntl.h>
|
//nclude <fcntl.h>
|
||||||
#define NODW
|
#define NODW
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Required objects includes. */
|
/* Required objects includes. */
|
||||||
@@ -53,9 +53,9 @@
|
|||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
|
|
||||||
|
|
||||||
//#if defined(__WIN__)
|
//#if defined(_WIN32)
|
||||||
//extern "C" HINSTANCE s_hModule; // Saved module handle
|
//extern "C" HINSTANCE s_hModule; // Saved module handle
|
||||||
//#endif // __WIN__
|
//#endif // _WIN32
|
||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
|
|
||||||
TYPCONV GetTypeConv();
|
TYPCONV GetTypeConv();
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/************ JMONGO FAM C++ Program Source Code File (.CPP) ***********/
|
/************ JMONGO FAM C++ Program Source Code File (.CPP) ***********/
|
||||||
/* PROGRAM NAME: jmgfam.cpp */
|
/* PROGRAM NAME: jmgfam.cpp */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 1.1 */
|
/* Version 1.2 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 20017 - 2020 */
|
/* (C) Copyright to the author Olivier BERTRAND 20017 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <io.h>
|
//#include <io.h>
|
||||||
//#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
//#include <errno.h>
|
//#include <errno.h>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX) || defined(UNIV_LINUX)
|
#if defined(UNIX) || defined(UNIV_LINUX)
|
||||||
//#include <errno.h>
|
//#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
//#include <io.h>
|
//#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
//#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -241,8 +241,8 @@ bool JMGFAM::OpenTableFile(PGLOBAL g)
|
|||||||
return true;
|
return true;
|
||||||
} // endif Mode
|
} // endif Mode
|
||||||
|
|
||||||
if (Mode == MODE_INSERT)
|
//if (Mode == MODE_INSERT)
|
||||||
Jcp->MakeColumnGroups(g, Tdbp);
|
// Jcp->MakeColumnGroups(g, Tdbp);
|
||||||
|
|
||||||
if (Mode != MODE_UPDATE)
|
if (Mode != MODE_UPDATE)
|
||||||
return Jcp->MakeCursor(g, Tdbp, Options, Filter, Pipe);
|
return Jcp->MakeCursor(g, Tdbp, Options, Filter, Pipe);
|
||||||
@@ -346,14 +346,14 @@ int JMGFAM::ReadBuffer(PGLOBAL g)
|
|||||||
} // end of ReadBuffer
|
} // end of ReadBuffer
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* WriteBuffer: File write routine for MGO access method. */
|
/* WriteBuffer: File write routine for JMG access method. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int JMGFAM::WriteBuffer(PGLOBAL g)
|
int JMGFAM::WriteBuffer(PGLOBAL g)
|
||||||
{
|
{
|
||||||
int rc = RC_OK;
|
int rc = RC_OK;
|
||||||
|
|
||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
rc = Jcp->DocWrite(g);
|
rc = Jcp->DocWrite(g, Tdbp->GetLine());
|
||||||
} else if (Mode == MODE_DELETE) {
|
} else if (Mode == MODE_DELETE) {
|
||||||
rc = Jcp->DocDelete(g, false);
|
rc = Jcp->DocDelete(g, false);
|
||||||
} else if (Mode == MODE_UPDATE) {
|
} else if (Mode == MODE_UPDATE) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ JMgoConn C++ Functions Source Code File (.CPP) ***********/
|
/************ JMgoConn C++ Functions Source Code File (.CPP) ***********/
|
||||||
/* Name: JMgoConn.CPP Version 1.1 */
|
/* Name: JMgoConn.CPP Version 1.2 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the MongoDB Java connection classes functions. */
|
/* This file contains the MongoDB Java connection classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
|
|
||||||
bool IsNum(PSZ s);
|
bool IsArray(PSZ s);
|
||||||
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
||||||
|
|
||||||
/* --------------------------- Class JNCOL --------------------------- */
|
/* --------------------------- Class JNCOL --------------------------- */
|
||||||
@@ -43,19 +43,21 @@ void JNCOL::AddCol(PGLOBAL g, PCOL colp, PSZ jp)
|
|||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
|
||||||
for (kp = Klist; kp; kp = kp->Next)
|
for (kp = Klist; kp; kp = kp->Next)
|
||||||
if (kp->Jncolp && !strcmp(jp, kp->Key))
|
if (kp->Jncolp && ((kp->Key && !strcmp(jp, kp->Key))
|
||||||
|
|| (!kp->Key && IsArray(jp) && kp->N == atoi(jp))))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!kp) {
|
if (!kp) {
|
||||||
icp = new(g) JNCOL(IsNum(p));
|
icp = new(g) JNCOL();
|
||||||
kcp = (PJKC)PlugSubAlloc(g, NULL, sizeof(JKCOL));
|
kcp = (PJKC)PlugSubAlloc(g, NULL, sizeof(JKCOL));
|
||||||
kcp->Next = NULL;
|
kcp->Next = NULL;
|
||||||
kcp->Jncolp = icp;
|
kcp->Jncolp = icp;
|
||||||
kcp->Colp = NULL;
|
kcp->Colp = NULL;
|
||||||
|
kcp->Array = IsArray(jp);
|
||||||
|
|
||||||
if (Array) {
|
if (kcp->Array) {
|
||||||
kcp->Key = NULL;
|
kcp->Key = NULL;
|
||||||
kcp->N = atoi(p);
|
kcp->N = atoi(jp);
|
||||||
} else {
|
} else {
|
||||||
kcp->Key = PlugDup(g, jp);
|
kcp->Key = PlugDup(g, jp);
|
||||||
kcp->N = 0;
|
kcp->N = 0;
|
||||||
@@ -75,12 +77,12 @@ void JNCOL::AddCol(PGLOBAL g, PCOL colp, PSZ jp)
|
|||||||
icp->AddCol(g, colp, p);
|
icp->AddCol(g, colp, p);
|
||||||
} else {
|
} else {
|
||||||
kcp = (PJKC)PlugSubAlloc(g, NULL, sizeof(JKCOL));
|
kcp = (PJKC)PlugSubAlloc(g, NULL, sizeof(JKCOL));
|
||||||
|
|
||||||
kcp->Next = NULL;
|
kcp->Next = NULL;
|
||||||
kcp->Jncolp = NULL;
|
kcp->Jncolp = NULL;
|
||||||
kcp->Colp = colp;
|
kcp->Colp = colp;
|
||||||
|
kcp->Array = IsArray(jp);
|
||||||
|
|
||||||
if (Array) {
|
if (kcp->Array) {
|
||||||
kcp->Key = NULL;
|
kcp->Key = NULL;
|
||||||
kcp->N = atoi(jp);
|
kcp->N = atoi(jp);
|
||||||
} else {
|
} else {
|
||||||
@@ -108,7 +110,7 @@ JMgoConn::JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper)
|
|||||||
CollName = collname;
|
CollName = collname;
|
||||||
readid = fetchid = getdocid = objfldid = fcollid = acollid =
|
readid = fetchid = getdocid = objfldid = fcollid = acollid =
|
||||||
mkdocid = docaddid = mkarid = araddid = insertid = updateid =
|
mkdocid = docaddid = mkarid = araddid = insertid = updateid =
|
||||||
deleteid = gcollid = countid = rewindid = nullptr;
|
deleteid = gcollid = countid = rewindid = mkbsonid = nullptr;
|
||||||
DiscFunc = "MongoDisconnect";
|
DiscFunc = "MongoDisconnect";
|
||||||
Fpc = NULL;
|
Fpc = NULL;
|
||||||
m_Fetch = 0;
|
m_Fetch = 0;
|
||||||
@@ -235,7 +237,7 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options,
|
|||||||
PCSZ filter, bool pipe)
|
PCSZ filter, bool pipe)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
bool b = false, id = (tdbp->GetMode() != MODE_READ), all = false;
|
bool id, b = false, all = false;
|
||||||
uint len;
|
uint len;
|
||||||
PCOL cp;
|
PCOL cp;
|
||||||
PSZ jp;
|
PSZ jp;
|
||||||
@@ -246,13 +248,14 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options,
|
|||||||
if (Options && !stricmp(Options, "all")) {
|
if (Options && !stricmp(Options, "all")) {
|
||||||
Options = NULL;
|
Options = NULL;
|
||||||
all = true;
|
all = true;
|
||||||
} // endif Options
|
} else
|
||||||
|
id = (tdbp->GetMode() == MODE_UPDATE || tdbp->GetMode() == MODE_DELETE);
|
||||||
|
|
||||||
for (cp = tdbp->GetColumns(); cp; cp = cp->GetNext())
|
for (cp = tdbp->GetColumns(); cp && !all; cp = cp->GetNext())
|
||||||
if (!strcmp(cp->GetName(), "_id"))
|
if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && (!Options || pipe))
|
||||||
id = true;
|
|
||||||
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && (!Options || pipe))
|
|
||||||
all = true;
|
all = true;
|
||||||
|
else if (!id)
|
||||||
|
id = !strcmp(cp->GetJpath(g, false), "_id");
|
||||||
|
|
||||||
if (pipe && Options) {
|
if (pipe && Options) {
|
||||||
if (trace(1))
|
if (trace(1))
|
||||||
@@ -535,7 +538,7 @@ PSZ JMgoConn::GetDocument(void)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void JMgoConn::MakeColumnGroups(PGLOBAL g, PTDB tdbp)
|
void JMgoConn::MakeColumnGroups(PGLOBAL g, PTDB tdbp)
|
||||||
{
|
{
|
||||||
Fpc = new(g) JNCOL(false);
|
Fpc = new(g) JNCOL();
|
||||||
|
|
||||||
for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext())
|
for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext())
|
||||||
if (!colp->IsSpecial())
|
if (!colp->IsSpecial())
|
||||||
@@ -553,7 +556,7 @@ bool JMgoConn::GetMethodId(PGLOBAL g, MODE mode)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (gmID(g, docaddid, "DocAdd",
|
if (gmID(g, docaddid, "DocAdd",
|
||||||
"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z"))
|
"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;I)Z"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (gmID(g, updateid, "CollUpdate", "(Ljava/lang/Object;)J"))
|
if (gmID(g, updateid, "CollUpdate", "(Ljava/lang/Object;)J"))
|
||||||
@@ -563,14 +566,19 @@ bool JMgoConn::GetMethodId(PGLOBAL g, MODE mode)
|
|||||||
if (gmID(g, mkdocid, "MakeDocument", "()Ljava/lang/Object;"))
|
if (gmID(g, mkdocid, "MakeDocument", "()Ljava/lang/Object;"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (gmID(g, mkbsonid, "MakeBson",
|
||||||
|
"(Ljava/lang/String;I)Ljava/lang/Object;"))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (gmID(g, docaddid, "DocAdd",
|
if (gmID(g, docaddid, "DocAdd",
|
||||||
"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z"))
|
"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;I)Z"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (gmID(g, mkarid, "MakeArray", "()Ljava/lang/Object;"))
|
if (gmID(g, mkarid, "MakeArray", "()Ljava/lang/Object;"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (gmID(g, araddid, "ArrayAdd", "(Ljava/lang/Object;ILjava/lang/Object;)Z"))
|
if (gmID(g, araddid, "ArrayAdd",
|
||||||
|
"(Ljava/lang/Object;ILjava/lang/Object;I)Z"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (gmID(g, insertid, "CollInsert", "(Ljava/lang/Object;)Z"))
|
if (gmID(g, insertid, "CollInsert", "(Ljava/lang/Object;)Z"))
|
||||||
@@ -638,49 +646,82 @@ jobject JMgoConn::MakeObject(PGLOBAL g, PCOL colp, bool&error )
|
|||||||
return val;
|
return val;
|
||||||
} // end of MakeObject
|
} // end of MakeObject
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Stringify. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool JMgoConn::Stringify(PCOL colp)
|
||||||
|
{
|
||||||
|
bool b = false;
|
||||||
|
|
||||||
|
if (colp)
|
||||||
|
b = (colp->Stringify() && colp->GetResultType() == TYPE_STRING);
|
||||||
|
|
||||||
|
return b;
|
||||||
|
} // end of Stringify
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* MakeDoc. */
|
/* MakeDoc. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
|
jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
|
||||||
{
|
{
|
||||||
bool error = false;
|
int j;
|
||||||
|
bool b, error = false;
|
||||||
jobject parent, child, val;
|
jobject parent, child, val;
|
||||||
jstring jkey;
|
jstring jkey;
|
||||||
|
PJKC kp = jcp->Klist;
|
||||||
if (jcp->Array)
|
|
||||||
|
if (kp->Array)
|
||||||
parent = env->CallObjectMethod(job, mkarid);
|
parent = env->CallObjectMethod(job, mkarid);
|
||||||
else
|
else
|
||||||
parent = env->CallObjectMethod(job, mkdocid);
|
parent = env->CallObjectMethod(job, mkdocid);
|
||||||
|
|
||||||
for (PJKC kp = jcp->Klist; kp; kp = kp->Next)
|
for (j = 0; kp; j = 0, kp = kp->Next) {
|
||||||
|
if (Stringify(kp->Colp)) {
|
||||||
|
switch (*kp->Colp->GetCharValue()) {
|
||||||
|
case '{': j = 1; break;
|
||||||
|
case '[': j = 2; break;
|
||||||
|
default: break;
|
||||||
|
} // endswitch
|
||||||
|
|
||||||
|
b = (!kp->Key || !*kp->Key || *kp->Key == '*');
|
||||||
|
} else
|
||||||
|
b = false;
|
||||||
|
|
||||||
if (kp->Jncolp) {
|
if (kp->Jncolp) {
|
||||||
if (!(child = MakeDoc(g, kp->Jncolp)))
|
if (!(child = MakeDoc(g, kp->Jncolp)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!jcp->Array) {
|
if (!kp->Array) {
|
||||||
jkey = env->NewStringUTF(kp->Key);
|
jkey = env->NewStringUTF(kp->Key);
|
||||||
|
|
||||||
if (env->CallBooleanMethod(job, docaddid, parent, jkey, child))
|
if (env->CallBooleanMethod(job, docaddid, parent, jkey, child, j))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
env->DeleteLocalRef(jkey);
|
env->DeleteLocalRef(jkey);
|
||||||
} else
|
} else
|
||||||
if (env->CallBooleanMethod(job, araddid, parent, kp->N, child))
|
if (env->CallBooleanMethod(job, araddid, parent, kp->N, child, j))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
env->DeleteLocalRef(child);
|
||||||
} else {
|
} else {
|
||||||
if (!(val = MakeObject(g, kp->Colp, error))) {
|
if (!(val = MakeObject(g, kp->Colp, error))) {
|
||||||
if (error)
|
if (error)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
} else if (!jcp->Array) {
|
} else if (!kp->Array) {
|
||||||
jkey = env->NewStringUTF(kp->Key);
|
if (!b) {
|
||||||
|
jkey = env->NewStringUTF(kp->Key);
|
||||||
|
|
||||||
if (env->CallBooleanMethod(job, docaddid, parent, jkey, val))
|
if (env->CallBooleanMethod(job, docaddid, parent, jkey, val, j))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
env->DeleteLocalRef(jkey);
|
env->DeleteLocalRef(jkey);
|
||||||
} else if (env->CallBooleanMethod(job, araddid, parent, kp->N, val)) {
|
} else {
|
||||||
|
env->DeleteLocalRef(parent);
|
||||||
|
parent = env->CallObjectMethod(job, mkbsonid, val, j);
|
||||||
|
} // endif b
|
||||||
|
|
||||||
|
} else if (env->CallBooleanMethod(job, araddid, parent, kp->N, val, j)) {
|
||||||
if (Check(-1))
|
if (Check(-1))
|
||||||
sprintf(g->Message, "ArrayAdd: %s", Msg);
|
sprintf(g->Message, "ArrayAdd: %s", Msg);
|
||||||
else
|
else
|
||||||
@@ -689,19 +730,38 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // endif ArrayAdd
|
} // endif ArrayAdd
|
||||||
|
|
||||||
|
env->DeleteLocalRef(val);
|
||||||
} // endif Jncolp
|
} // endif Jncolp
|
||||||
|
|
||||||
|
} // endfor kp
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
} // end of MakeDoc
|
} // end of MakeDoc
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Insert a new document in the collation. */
|
/* Insert a new document in the collation. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int JMgoConn::DocWrite(PGLOBAL g)
|
int JMgoConn::DocWrite(PGLOBAL g, PCSZ line)
|
||||||
{
|
{
|
||||||
jobject doc;
|
int rc = RC_OK;
|
||||||
|
jobject doc = nullptr;
|
||||||
|
|
||||||
if (!Fpc || !(doc = MakeDoc(g, Fpc)))
|
if (line) {
|
||||||
|
int j;
|
||||||
|
jobject val = env->NewStringUTF(line);
|
||||||
|
|
||||||
|
switch (*line) {
|
||||||
|
case '{': j = 1; break;
|
||||||
|
case '[': j = 2; break;
|
||||||
|
default: j = 0; break;
|
||||||
|
} // endswitch line
|
||||||
|
|
||||||
|
doc = env->CallObjectMethod(job, mkbsonid, val, j);
|
||||||
|
env->DeleteLocalRef(val);
|
||||||
|
} else if (Fpc)
|
||||||
|
doc = MakeDoc(g, Fpc);
|
||||||
|
|
||||||
|
if (!doc)
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
if (env->CallBooleanMethod(job, insertid, doc)) {
|
if (env->CallBooleanMethod(job, insertid, doc)) {
|
||||||
@@ -710,10 +770,11 @@ int JMgoConn::DocWrite(PGLOBAL g)
|
|||||||
else
|
else
|
||||||
sprintf(g->Message, "CollInsert: unknown error");
|
sprintf(g->Message, "CollInsert: unknown error");
|
||||||
|
|
||||||
return RC_FX;
|
rc = RC_FX;
|
||||||
} // endif Insert
|
} // endif Insert
|
||||||
|
|
||||||
return RC_OK;
|
env->DeleteLocalRef(doc);
|
||||||
|
return rc;
|
||||||
} // end of DocWrite
|
} // end of DocWrite
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -721,7 +782,7 @@ int JMgoConn::DocWrite(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
|
int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
|
||||||
{
|
{
|
||||||
int rc = RC_OK;
|
int j = 0, rc = RC_OK;
|
||||||
bool error;
|
bool error;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
jstring jkey;
|
jstring jkey;
|
||||||
@@ -734,8 +795,14 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
|
|||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
else if (Stringify(colp))
|
||||||
|
switch (*colp->GetCharValue()) {
|
||||||
|
case '{': j = 1; break;
|
||||||
|
case '[': j = 2; break;
|
||||||
|
default: break;
|
||||||
|
} // endswitch
|
||||||
|
|
||||||
if (env->CallBooleanMethod(job, docaddid, updlist, jkey, val))
|
if (env->CallBooleanMethod(job, docaddid, updlist, jkey, val, j))
|
||||||
return RC_OK;
|
return RC_OK;
|
||||||
|
|
||||||
env->DeleteLocalRef(jkey);
|
env->DeleteLocalRef(jkey);
|
||||||
@@ -745,7 +812,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp)
|
|||||||
upd = env->CallObjectMethod(job, mkdocid);
|
upd = env->CallObjectMethod(job, mkdocid);
|
||||||
jkey = env->NewStringUTF("$set");
|
jkey = env->NewStringUTF("$set");
|
||||||
|
|
||||||
if (env->CallBooleanMethod(job, docaddid, upd, jkey, updlist))
|
if (env->CallBooleanMethod(job, docaddid, upd, jkey, updlist, 0))
|
||||||
return RC_OK;
|
return RC_OK;
|
||||||
|
|
||||||
env->DeleteLocalRef(jkey);
|
env->DeleteLocalRef(jkey);
|
||||||
|
@@ -25,6 +25,7 @@ typedef struct JKCOL {
|
|||||||
PCOL Colp;
|
PCOL Colp;
|
||||||
char *Key;
|
char *Key;
|
||||||
int N;
|
int N;
|
||||||
|
bool Array;
|
||||||
} *PJKC;
|
} *PJKC;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -33,18 +34,18 @@ typedef struct JKCOL {
|
|||||||
class JNCOL : public BLOCK {
|
class JNCOL : public BLOCK {
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
JNCOL(bool ar) { Klist = NULL; Array = ar; }
|
//JNCOL(bool ar) { Klist = NULL; Array = ar; }
|
||||||
|
JNCOL(void) { Klist = NULL; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void AddCol(PGLOBAL g, PCOL colp, PSZ jp);
|
void AddCol(PGLOBAL g, PCOL colp, PSZ jp);
|
||||||
|
|
||||||
//Members
|
//Members
|
||||||
PJKC Klist;
|
PJKC Klist;
|
||||||
bool Array;
|
|
||||||
}; // end of JNCOL;
|
}; // end of JNCOL;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* JMgoConn class. */
|
/* JMgoConn class. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class JMgoConn : public JAVAConn {
|
class JMgoConn : public JAVAConn {
|
||||||
friend class TDBJMG;
|
friend class TDBJMG;
|
||||||
@@ -81,11 +82,12 @@ public:
|
|||||||
bool GetMethodId(PGLOBAL g, MODE mode);
|
bool GetMethodId(PGLOBAL g, MODE mode);
|
||||||
jobject MakeObject(PGLOBAL g, PCOL colp, bool& error);
|
jobject MakeObject(PGLOBAL g, PCOL colp, bool& error);
|
||||||
jobject MakeDoc(PGLOBAL g, PJNCOL jcp);
|
jobject MakeDoc(PGLOBAL g, PJNCOL jcp);
|
||||||
int DocWrite(PGLOBAL g);
|
int DocWrite(PGLOBAL g, PCSZ line);
|
||||||
int DocUpdate(PGLOBAL g, PTDB tdbp);
|
int DocUpdate(PGLOBAL g, PTDB tdbp);
|
||||||
int DocDelete(PGLOBAL g, bool all);
|
int DocDelete(PGLOBAL g, bool all);
|
||||||
bool Rewind(void);
|
bool Rewind(void);
|
||||||
PSZ GetDocument(void);
|
PSZ GetDocument(void);
|
||||||
|
bool Stringify(PCOL colp);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
@@ -100,6 +102,7 @@ protected:
|
|||||||
jmethodID getdocid; // The GetDoc method ID
|
jmethodID getdocid; // The GetDoc method ID
|
||||||
jmethodID objfldid; // The ObjectField method ID
|
jmethodID objfldid; // The ObjectField method ID
|
||||||
jmethodID mkdocid; // The MakeDocument method ID
|
jmethodID mkdocid; // The MakeDocument method ID
|
||||||
|
jmethodID mkbsonid; // The MakeBson method ID
|
||||||
jmethodID docaddid; // The DocAdd method ID
|
jmethodID docaddid; // The DocAdd method ID
|
||||||
jmethodID mkarid; // The MakeArray method ID
|
jmethodID mkarid; // The MakeArray method ID
|
||||||
jmethodID araddid; // The ArrayAdd method ID
|
jmethodID araddid; // The ArrayAdd method ID
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*************** json CPP Declares Source Code File (.H) ***************/
|
/*************** json CPP Declares Source Code File (.H) ***************/
|
||||||
/* Name: json.cpp Version 1.5 */
|
/* Name: json.cpp Version 1.6 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2020 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the JSON classes functions. */
|
/* This file contains the JSON classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#define ARGS MY_MIN(24,(int)len-i),s+MY_MAX(i-3,0)
|
#define ARGS MY_MIN(24,(int)len-i),s+MY_MAX(i-3,0)
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#define EL "\r\n"
|
#define EL "\r\n"
|
||||||
#else
|
#else
|
||||||
#define EL "\n"
|
#define EL "\n"
|
||||||
@@ -55,6 +55,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
|
|||||||
|
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
int GetDefaultPrec(void);
|
int GetDefaultPrec(void);
|
||||||
|
int PrepareColist(char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* IsNum: check whether this string is all digits. */
|
/* IsNum: check whether this string is all digits. */
|
||||||
@@ -77,6 +78,24 @@ bool IsNum(PSZ s)
|
|||||||
return true;
|
return true;
|
||||||
} // end of IsNum
|
} // end of IsNum
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* IsArray: check whether this is a Mongo array path. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool IsArray(PSZ s)
|
||||||
|
{
|
||||||
|
char* p = s;
|
||||||
|
|
||||||
|
if (!p || !*p)
|
||||||
|
return false;
|
||||||
|
else for (; *p; p++)
|
||||||
|
if (*p == '.')
|
||||||
|
break;
|
||||||
|
else if (!isdigit(*p))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} // end of IsArray
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* NextChr: return the first found '[' or Sep pointer. */
|
/* NextChr: return the first found '[' or Sep pointer. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -93,6 +112,27 @@ char* NextChr(PSZ s, char sep)
|
|||||||
return p2;
|
return p2;
|
||||||
} // end of NextChr
|
} // end of NextChr
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Stringified: check that this column is in the stringified list. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool Stringified(PCSZ strfy, char *colname)
|
||||||
|
{
|
||||||
|
if (strfy) {
|
||||||
|
char *p, colist[512];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
strncpy(colist, strfy, sizeof(colist) - 1);
|
||||||
|
n = PrepareColist(colist);
|
||||||
|
|
||||||
|
for (p = colist; n && p; p += (strlen(p) + 1), n--)
|
||||||
|
if (!stricmp(p, colname))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // endif strfy
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of Stringified
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate a VAL structure, make sure common field and Nd are zeroed. */
|
/* Allocate a VAL structure, make sure common field and Nd are zeroed. */
|
||||||
@@ -227,6 +267,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char* fn, int pretty) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
jdp = new(g) JDOC; // MUST BE ALLOCATED BEFORE jp !!!!!
|
jdp = new(g) JDOC; // MUST BE ALLOCATED BEFORE jp !!!!!
|
||||||
|
jdp->dfp = GetDefaultPrec();
|
||||||
|
|
||||||
if (!jsp) {
|
if (!jsp) {
|
||||||
strcpy(g->Message, "Null json tree");
|
strcpy(g->Message, "Null json tree");
|
||||||
@@ -987,8 +1028,8 @@ bool JDOC::SerializeValue(PJVAL jvp)
|
|||||||
case TYPE_BINT:
|
case TYPE_BINT:
|
||||||
sprintf(buf, "%lld", jvp->LLn);
|
sprintf(buf, "%lld", jvp->LLn);
|
||||||
return js->WriteStr(buf);
|
return js->WriteStr(buf);
|
||||||
case TYPE_DBL:
|
case TYPE_DBL: // dfp to limit to the default number of decimals
|
||||||
sprintf(buf, "%.*lf", jvp->Nd, jvp->F);
|
sprintf(buf, "%.*f", MY_MIN(jvp->Nd, dfp), jvp->F);
|
||||||
return js->WriteStr(buf);
|
return js->WriteStr(buf);
|
||||||
case TYPE_NULL:
|
case TYPE_NULL:
|
||||||
return js->WriteStr("null");
|
return js->WriteStr("null");
|
||||||
@@ -1326,9 +1367,9 @@ bool JARRAY::Merge(PGLOBAL g, PJSON jsp)
|
|||||||
} // end of Merge
|
} // end of Merge
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Set the nth Value of the Array Value list. */
|
/* Set the nth Value of the Array Value list or add it. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n)
|
void JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
PJVAL jp, *jpp = &First;
|
PJVAL jp, *jpp = &First;
|
||||||
@@ -1339,7 +1380,6 @@ bool JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n)
|
|||||||
|
|
||||||
*jpp = jvp;
|
*jpp = jvp;
|
||||||
jvp->Next = (jp ? jp->Next : NULL);
|
jvp->Next = (jp ? jp->Next : NULL);
|
||||||
return false;
|
|
||||||
} // end of SetValue
|
} // end of SetValue
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1417,7 +1457,7 @@ bool JARRAY::IsNull(void)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
JVALUE::JVALUE(PJSON jsp) : JSON()
|
JVALUE::JVALUE(PJSON jsp) : JSON()
|
||||||
{
|
{
|
||||||
if (jsp->GetType() == TYPE_JVAL) {
|
if (jsp && jsp->GetType() == TYPE_JVAL) {
|
||||||
PJVAL jvp = (PJVAL)jsp;
|
PJVAL jvp = (PJVAL)jsp;
|
||||||
|
|
||||||
// Val = ((PJVAL)jsp)->GetVal();
|
// Val = ((PJVAL)jsp)->GetVal();
|
||||||
@@ -1434,7 +1474,7 @@ JVALUE::JVALUE(PJSON jsp) : JSON()
|
|||||||
} else {
|
} else {
|
||||||
Jsp = jsp;
|
Jsp = jsp;
|
||||||
// Val = NULL;
|
// Val = NULL;
|
||||||
DataType = TYPE_JSON;
|
DataType = Jsp ? TYPE_JSON : TYPE_NULL;
|
||||||
Nd = 0;
|
Nd = 0;
|
||||||
} // endif Type
|
} // endif Type
|
||||||
|
|
||||||
|
@@ -66,6 +66,8 @@ const char* GetFmt(int type, bool un);
|
|||||||
PJSON ParseJson(PGLOBAL g, char* s, size_t n, int* prty = NULL, bool* b = NULL);
|
PJSON ParseJson(PGLOBAL g, char* s, size_t n, int* prty = NULL, bool* b = NULL);
|
||||||
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
|
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
|
||||||
DllExport bool IsNum(PSZ s);
|
DllExport bool IsNum(PSZ s);
|
||||||
|
bool IsArray(PSZ s);
|
||||||
|
bool Stringified(PCSZ strfy, char *colname);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Class JDOC. The class for parsing and serializing json documents. */
|
/* Class JDOC. The class for parsing and serializing json documents. */
|
||||||
@@ -74,7 +76,7 @@ class JDOC: public BLOCK {
|
|||||||
friend PJSON ParseJson(PGLOBAL, char*, size_t, int*, bool*);
|
friend PJSON ParseJson(PGLOBAL, char*, size_t, int*, bool*);
|
||||||
friend PSZ Serialize(PGLOBAL, PJSON, char*, int);
|
friend PSZ Serialize(PGLOBAL, PJSON, char*, int);
|
||||||
public:
|
public:
|
||||||
JDOC(void) : js(NULL), s(NULL), len(0), pty(NULL) {}
|
JDOC(void) : js(NULL), s(NULL), len(0), dfp(0), pty(NULL) {}
|
||||||
|
|
||||||
void SetJp(JOUT* jp) { js = jp; }
|
void SetJp(JOUT* jp) { js = jp; }
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
JOUT* js;
|
JOUT* js;
|
||||||
char *s;
|
char *s;
|
||||||
int len;
|
int len, dfp;
|
||||||
bool *pty;
|
bool *pty;
|
||||||
}; // end of class JDOC
|
}; // end of class JDOC
|
||||||
|
|
||||||
@@ -184,7 +186,7 @@ class JARRAY : public JSON {
|
|||||||
|
|
||||||
// Specific
|
// Specific
|
||||||
PJVAL AddArrayValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL);
|
PJVAL AddArrayValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL);
|
||||||
bool SetArrayValue(PGLOBAL g, PJVAL jvp, int i);
|
void SetArrayValue(PGLOBAL g, PJVAL jvp, int i);
|
||||||
void InitArray(PGLOBAL g);
|
void InitArray(PGLOBAL g);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -1524,22 +1524,31 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
int IsJson(UDF_ARGS *args, uint i, bool b)
|
int IsJson(UDF_ARGS *args, uint i, bool b)
|
||||||
{
|
{
|
||||||
int n = 0;
|
char *pat = args->attributes[i];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (*pat == '@') {
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
if (*pat == '\'' || *pat == '"')
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
} // endif pat
|
||||||
|
|
||||||
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
||||||
} else if (!strnicmp(args->attributes[i], "Json_", 5)) {
|
} else if (!strnicmp(pat, "Json_", 5)) {
|
||||||
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
||||||
n = 1; // arg should be is a json item
|
n = 1; // arg should be is a json item
|
||||||
else
|
else
|
||||||
n = 2; // A file name may have been returned
|
n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Jbin_", 5)) {
|
} else if (!strnicmp(pat, "Jbin_", 5)) {
|
||||||
if (args->lengths[i] == sizeof(BSON))
|
if (args->lengths[i] == sizeof(BSON))
|
||||||
n = 3; // arg is a binary json item
|
n = 3; // arg is a binary json item
|
||||||
else
|
else
|
||||||
n = 2; // A file name may have been returned
|
n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Jfile_", 6)) {
|
} else if (!strnicmp(pat, "Jfile_", 6)) {
|
||||||
n = 2; // arg is a json file name
|
n = 2; // arg is a json file name
|
||||||
} else if (b) {
|
} else if (b) {
|
||||||
char *sap;
|
char *sap;
|
||||||
@@ -5943,7 +5952,7 @@ char *jfile_convert(UDF_INIT* initid, UDF_ARGS* args, char* result,
|
|||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
PUSH_WARNING(g->Message ? g->Message : "Unexpected error");
|
PUSH_WARNING(*g->Message ? g->Message : "Unexpected error");
|
||||||
*is_null = 1;
|
*is_null = 1;
|
||||||
*error = 1;
|
*error = 1;
|
||||||
*res_length = 0;
|
*res_length = 0;
|
||||||
@@ -6004,7 +6013,7 @@ char *jfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
int msgid = MSGID_OPEN_MODE_STRERROR;
|
int msgid = MSGID_OPEN_MODE_STRERROR;
|
||||||
FILE *fout;
|
FILE *fout = NULL;
|
||||||
FILE *fin;
|
FILE *fin;
|
||||||
|
|
||||||
if (!(fin = global_fopen(g, msgid, fn, "rt")))
|
if (!(fin = global_fopen(g, msgid, fn, "rt")))
|
||||||
@@ -6071,7 +6080,7 @@ char *jfile_bjson(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
str = (char*)g->Xchk;
|
str = (char*)g->Xchk;
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
if (g->Message)
|
if (*g->Message)
|
||||||
str = strcpy(result, g->Message);
|
str = strcpy(result, g->Message);
|
||||||
else
|
else
|
||||||
str = strcpy(result, "Unexpected error");
|
str = strcpy(result, "Unexpected error");
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
|
/* MACUTIL: Author Olivier Bertrand -- 2008-2012 */
|
||||||
/* From the article and sample code by Khalid Shaikh. */
|
/* From the article and sample code by Khalid Shaikh. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#error This is WINDOWS only DLL
|
#error This is WINDOWS only DLL
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
#include "macutil.h"
|
#include "macutil.h"
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
// MACUTIL.H Olivier Bertrand 2008-2012
|
// MACUTIL.H Olivier Bertrand 2008-2012
|
||||||
// Get Mac Addresses via GetAdaptersInfo
|
// Get Mac Addresses via GetAdaptersInfo
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#error This is WINDOWS only
|
#error This is WINDOWS only
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
|
|
||||||
typedef class MACINFO *MACIP;
|
typedef class MACINFO *MACIP;
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
#include "maputil.h"
|
#include "maputil.h"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef _WIN32
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* In Insert mode, just open the file for append. Otherwise */
|
/* In Insert mode, just open the file for append. Otherwise */
|
||||||
/* create the mapping file object. The map handle can be released */
|
/* create the mapping file object. The map handle can be released */
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/************** mongo C++ Program Source Code File (.CPP) **************/
|
/************** mongo C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: mongo Version 1.0 */
|
/* PROGRAM NAME: mongo Version 1.1 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2021 */
|
||||||
/* These programs are the MGODEF class execution routines. */
|
/* These programs are the MGODEF class execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
||||||
bool IsNum(PSZ s);
|
bool IsNum(PSZ s);
|
||||||
int GetDefaultDepth(void);
|
int GetDefaultDepth(void);
|
||||||
|
bool JsonAllPath(void);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Make selector json representation for Mongo tables. */
|
/* Make selector json representation for Mongo tables. */
|
||||||
@@ -350,7 +351,7 @@ void MGODISC::AddColumn(PGLOBAL g, PCSZ colname, PCSZ fmt, int k)
|
|||||||
bcp->Name = PlugDup(g, colname);
|
bcp->Name = PlugDup(g, colname);
|
||||||
length[0] = MY_MAX(length[0], (signed)strlen(colname));
|
length[0] = MY_MAX(length[0], (signed)strlen(colname));
|
||||||
|
|
||||||
if (k) {
|
if (k || JsonAllPath()) {
|
||||||
bcp->Fmt = PlugDup(g, fmt);
|
bcp->Fmt = PlugDup(g, fmt);
|
||||||
length[7] = MY_MAX(length[7], (signed)strlen(fmt));
|
length[7] = MY_MAX(length[7], (signed)strlen(fmt));
|
||||||
} else
|
} else
|
||||||
@@ -395,6 +396,7 @@ bool MGODEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
|
|||||||
Uri = GetStringCatInfo(g, "Connect", "mongodb://localhost:27017");
|
Uri = GetStringCatInfo(g, "Connect", "mongodb://localhost:27017");
|
||||||
Colist = GetStringCatInfo(g, "Colist", NULL);
|
Colist = GetStringCatInfo(g, "Colist", NULL);
|
||||||
Filter = GetStringCatInfo(g, "Filter", NULL);
|
Filter = GetStringCatInfo(g, "Filter", NULL);
|
||||||
|
Strfy = GetStringCatInfo(g, "Stringify", NULL);
|
||||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||||
Version = GetIntCatInfo("Version", 3);
|
Version = GetIntCatInfo("Version", 3);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/**************** mongo H Declares Source Code File (.H) ***************/
|
/**************** mongo H Declares Source Code File (.H) ***************/
|
||||||
/* Name: mongo.h Version 1.0 */
|
/* Name: mongo.h Version 1.1 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the common MongoDB classes declares. */
|
/* This file contains the common MongoDB classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -82,6 +82,7 @@ protected:
|
|||||||
PSZ Wrapname; /* Java wrapper name */
|
PSZ Wrapname; /* Java wrapper name */
|
||||||
PCSZ Colist; /* Options list */
|
PCSZ Colist; /* Options list */
|
||||||
PCSZ Filter; /* Filtering query */
|
PCSZ Filter; /* Filtering query */
|
||||||
|
PCSZ Strfy; /* The stringify columns */
|
||||||
int Base; /* The array index base */
|
int Base; /* The array index base */
|
||||||
int Version; /* The Java driver version */
|
int Version; /* The Java driver version */
|
||||||
bool Pipe; /* True is Colist is a pipeline */
|
bool Pipe; /* True is Colist is a pipeline */
|
||||||
|
@@ -62,10 +62,10 @@
|
|||||||
#include "tabvct.h"
|
#include "tabvct.h"
|
||||||
#endif // VCT_SUPPORT
|
#endif // VCT_SUPPORT
|
||||||
#include "tabsys.h"
|
#include "tabsys.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include "tabmac.h"
|
#include "tabmac.h"
|
||||||
#include "tabwmi.h"
|
#include "tabwmi.h"
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
//#include "tabtbl.h"
|
//#include "tabtbl.h"
|
||||||
#include "tabxcl.h"
|
#include "tabxcl.h"
|
||||||
#include "tabtbl.h"
|
#include "tabtbl.h"
|
||||||
@@ -105,9 +105,9 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Extern static variables. */
|
/* Extern static variables. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
extern "C" HINSTANCE s_hModule; // Saved module handle
|
extern "C" HINSTANCE s_hModule; // Saved module handle
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
||||||
bool MongoEnabled(void);
|
bool MongoEnabled(void);
|
||||||
#endif // JAVA_SUPPORT || CMGO_SUPPORT
|
#endif // JAVA_SUPPORT || CMGO_SUPPORT
|
||||||
@@ -123,6 +123,15 @@ char *GetPluginDir(void)
|
|||||||
return opt_plugin_dir;
|
return opt_plugin_dir;
|
||||||
} // end of GetPluginDir
|
} // end of GetPluginDir
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Get the lc_messages_dir, it is where error messages for various */
|
||||||
|
/* languages are installed, and by default the INSTALL_MYSQLSHAREDIR. */
|
||||||
|
/***********************************************************************/
|
||||||
|
char *GetMessageDir(void)
|
||||||
|
{
|
||||||
|
return lc_messages_dir;
|
||||||
|
} // end of GetMessageDir
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Get a unique enum table type ID. */
|
/* Get a unique enum table type ID. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -152,10 +161,10 @@ TABTYPE GetTypeID(const char *type)
|
|||||||
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL
|
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL
|
||||||
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL
|
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL
|
||||||
: (!stricmp(type, "DIR")) ? TAB_DIR
|
: (!stricmp(type, "DIR")) ? TAB_DIR
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
: (!stricmp(type, "MAC")) ? TAB_MAC
|
: (!stricmp(type, "MAC")) ? TAB_MAC
|
||||||
: (!stricmp(type, "WMI")) ? TAB_WMI
|
: (!stricmp(type, "WMI")) ? TAB_WMI
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
: (!stricmp(type, "TBL")) ? TAB_TBL
|
: (!stricmp(type, "TBL")) ? TAB_TBL
|
||||||
: (!stricmp(type, "XCOL")) ? TAB_XCL
|
: (!stricmp(type, "XCOL")) ? TAB_XCL
|
||||||
: (!stricmp(type, "OCCUR")) ? TAB_OCCUR
|
: (!stricmp(type, "OCCUR")) ? TAB_OCCUR
|
||||||
@@ -374,11 +383,11 @@ uint GetFuncID(const char *func)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
CATALOG::CATALOG(void)
|
CATALOG::CATALOG(void)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//DataPath= ".\\";
|
//DataPath= ".\\";
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
//DataPath= "./";
|
//DataPath= "./";
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
memset(&Ctb, 0, sizeof(CURTAB));
|
memset(&Ctb, 0, sizeof(CURTAB));
|
||||||
Cbuf= NULL;
|
Cbuf= NULL;
|
||||||
Cblen= 0;
|
Cblen= 0;
|
||||||
@@ -472,10 +481,10 @@ PTABDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
|
|||||||
#if defined(JAVA_SUPPORT)
|
#if defined(JAVA_SUPPORT)
|
||||||
case TAB_JDBC: tdp= new(g) JDBCDEF; break;
|
case TAB_JDBC: tdp= new(g) JDBCDEF; break;
|
||||||
#endif // JAVA_SUPPORT
|
#endif // JAVA_SUPPORT
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case TAB_MAC: tdp= new(g) MACDEF; break;
|
case TAB_MAC: tdp= new(g) MACDEF; break;
|
||||||
case TAB_WMI: tdp= new(g) WMIDEF; break;
|
case TAB_WMI: tdp= new(g) WMIDEF; break;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
case TAB_OEM: tdp= new(g) OEMDEF; break;
|
case TAB_OEM: tdp= new(g) OEMDEF; break;
|
||||||
case TAB_TBL: tdp= new(g) TBLDEF; break;
|
case TAB_TBL: tdp= new(g) TBLDEF; break;
|
||||||
case TAB_XCL: tdp= new(g) XCLDEF; break;
|
case TAB_XCL: tdp= new(g) XCLDEF; break;
|
||||||
|
@@ -78,7 +78,8 @@ struct ha_table_option_struct {
|
|||||||
|
|
||||||
typedef class ha_connect *PHC;
|
typedef class ha_connect *PHC;
|
||||||
|
|
||||||
char *GetPluginDir(void);
|
char *GetPluginDir(void);
|
||||||
|
char *GetMessageDir(void);
|
||||||
TABTYPE GetTypeID(const char *type);
|
TABTYPE GetTypeID(const char *type);
|
||||||
bool IsFileType(TABTYPE type);
|
bool IsFileType(TABTYPE type);
|
||||||
bool IsExactType(TABTYPE type);
|
bool IsExactType(TABTYPE type);
|
||||||
|
@@ -35,11 +35,11 @@
|
|||||||
#include "my_sys.h"
|
#include "my_sys.h"
|
||||||
#include "mysqld_error.h"
|
#include "mysqld_error.h"
|
||||||
#endif // !MYSQL_PREPARED_STATEMENTS
|
#endif // !MYSQL_PREPARED_STATEMENTS
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
@@ -492,15 +492,15 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
|
|||||||
//mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
|
//mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
|
||||||
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
|
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (!strcmp(host, ".")) {
|
if (!strcmp(host, ".")) {
|
||||||
mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
|
mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
|
||||||
pipe = mysqld_unix_port;
|
pipe = mysqld_unix_port;
|
||||||
} // endif host
|
} // endif host
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (!strcmp(host, "localhost"))
|
if (!strcmp(host, "localhost"))
|
||||||
pipe = mysqld_unix_port;
|
pipe = mysqld_unix_port;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (pwd && !strcmp(pwd, "*")) {
|
if (pwd && !strcmp(pwd, "*")) {
|
||||||
|
@@ -7,24 +7,24 @@
|
|||||||
/* DO NOT define DLL_EXPORT in your application so these items are */
|
/* DO NOT define DLL_EXPORT in your application so these items are */
|
||||||
/* declared are imported from the Myconn DLL. */
|
/* declared are imported from the Myconn DLL. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <errmsg.h>
|
#include <errmsg.h>
|
||||||
#include "myutil.h"
|
#include "myutil.h"
|
||||||
|
|
||||||
#if defined(__WIN__) && defined(MYCONN_EXPORTS)
|
#if defined(_WIN32) && defined(MYCONN_EXPORTS)
|
||||||
#if defined(DLL_EXPORT)
|
#if defined(DLL_EXPORT)
|
||||||
#define DllItem _declspec(dllexport)
|
#define DllItem _declspec(dllexport)
|
||||||
#else // !DLL_EXPORT
|
#else // !DLL_EXPORT
|
||||||
#define DllItem _declspec(dllimport)
|
#define DllItem _declspec(dllimport)
|
||||||
#endif // !DLL_EXPORT
|
#endif // !DLL_EXPORT
|
||||||
#else // !__WIN__ || !MYCONN_EXPORTS
|
#else // !_WIN32 || !MYCONN_EXPORTS
|
||||||
#define DllItem
|
#define DllItem
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
#define MYSQL_ENABLED 0x00000001
|
#define MYSQL_ENABLED 0x00000001
|
||||||
#define MYSQL_LOGON 0x00000002
|
#define MYSQL_LOGON 0x00000002
|
||||||
|
@@ -363,7 +363,7 @@ _id item prices_0 prices_1 prices_2 prices_3 prices_4
|
|||||||
1 journal 87 45 63 12 78
|
1 journal 87 45 63 12 78
|
||||||
2 notebook 123 456 789 NULL NULL
|
2 notebook 123 456 789 NULL NULL
|
||||||
3 paper 5 7 3 8 NULL
|
3 paper 5 7 3 8 NULL
|
||||||
4 planner 25 71 44 27 NULL
|
4 planner 25 71 NULL 44 27
|
||||||
5 postcard 5 7 3 8 NULL
|
5 postcard 5 7 3 8 NULL
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
CREATE DATABASE connect;
|
CREATE DATABASE connect;
|
||||||
USE connect;
|
USE connect;
|
||||||
CREATE TABLE t2 (
|
CREATE TABLE t2 (
|
||||||
@@ -16,7 +17,7 @@ id msg tm dt dtm ts
|
|||||||
# Testing JDBC connection to MySQL driver
|
# Testing JDBC connection to MySQL driver
|
||||||
#
|
#
|
||||||
USE test;
|
USE test;
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=t2 CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root';
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=t2 CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root&useSSL=false';
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id msg tm dt dtm ts
|
id msg tm dt dtm ts
|
||||||
455000000000 A very big number 18:10:25 2016-03-16 1999-12-11 23:01:52 2015-07-24 09:32:45
|
455000000000 A very big number 18:10:25 2016-03-16 1999-12-11 23:01:52 2015-07-24 09:32:45
|
||||||
@@ -26,7 +27,7 @@ Note 1105 t2: 1 affected rows
|
|||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id msg tm dt dtm ts
|
id msg tm dt dtm ts
|
||||||
455000000000 A very big number 18:10:25 2016-03-16 1999-12-11 23:01:52 2015-07-24 09:32:45
|
455000000000 A very big number 18:10:25 2016-03-16 1999-12-11 23:01:52 2015-07-24 09:32:45
|
||||||
786325481247 Hello! 19:45:03 1933-08-09 1985-11-12 09:02:44 2014-06-17 10:32:01
|
786325481247 Hello! 19:45:03 1933-08-10 1985-11-12 09:02:44 2014-06-17 10:32:01
|
||||||
DELETE FROM t1 WHERE msg = 'Hello!';
|
DELETE FROM t1 WHERE msg = 'Hello!';
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1105 t2: 1 affected rows
|
Note 1105 t2: 1 affected rows
|
||||||
@@ -37,7 +38,7 @@ DROP TABLE t1;
|
|||||||
#
|
#
|
||||||
# Testing JDBC view
|
# Testing JDBC view
|
||||||
#
|
#
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC SRCDEF='select id, msg, tm, dt from t2' CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root';
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC SRCDEF='select id, msg, tm, dt from t2' CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root&useSSL=false';
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id msg tm dt
|
id msg tm dt
|
||||||
455000000000 A very big number 18:10:25 2016-03-16
|
455000000000 A very big number 18:10:25 2016-03-16
|
||||||
@@ -74,7 +75,7 @@ SELECT * FROM t3;
|
|||||||
name city birth hired
|
name city birth hired
|
||||||
Donald Atlanta 1999-04-01 2016-03-31
|
Donald Atlanta 1999-04-01 2016-03-31
|
||||||
Mick New York 1980-01-20 2002-09-11
|
Mick New York 1980-01-20 2002-09-11
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=boys CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root' OPTION_LIST='scrollable=1';
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=boys CONNECTION='jdbc:mysql://localhost:PORT/connect?user=root&useSSL=false' OPTION_LIST='scrollable=1';
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
name city birth hired
|
name city birth hired
|
||||||
John Boston 1986-01-25 2010-06-02
|
John Boston 1986-01-25 2010-06-02
|
||||||
@@ -100,9 +101,9 @@ George San Jose 1981-08-10 2010-06-02
|
|||||||
Sam Chicago 1979-11-22 2007-10-10
|
Sam Chicago 1979-11-22 2007-10-10
|
||||||
James Dallas 1992-05-13 2009-12-14
|
James Dallas 1992-05-13 2009-12-14
|
||||||
Bill Boston 1986-09-11 2008-02-10
|
Bill Boston 1986-09-11 2008-02-10
|
||||||
Donald Atlanta 1999-03-31 2016-03-30
|
Donald Atlanta 1999-04-01 2016-03-31
|
||||||
Mick New York 1980-01-20 2002-09-10
|
Mick New York 1980-01-20 2002-09-11
|
||||||
Tom Seatle 2002-03-15 1970-01-01
|
Tom Seatle 2002-03-15 NULL
|
||||||
DROP TABLE t3;
|
DROP TABLE t3;
|
||||||
#
|
#
|
||||||
# Testing JDBC join operations
|
# Testing JDBC join operations
|
||||||
@@ -280,3 +281,4 @@ DROP TABLE t1;
|
|||||||
DROP TABLE connect.tx1;
|
DROP TABLE connect.tx1;
|
||||||
DROP DATABASE connect;
|
DROP DATABASE connect;
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
|
@@ -2,7 +2,8 @@ connect master,127.0.0.1,root,,test,$MASTER_MYPORT,;
|
|||||||
connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
|
connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
|
||||||
connection master;
|
connection master;
|
||||||
connection slave;
|
connection slave;
|
||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
CREATE TABLE t1 (a int, b char(10));
|
CREATE TABLE t1 (a int, b char(10));
|
||||||
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
|
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -16,31 +17,32 @@ NULL NULL
|
|||||||
# Testing errors
|
# Testing errors
|
||||||
#
|
#
|
||||||
connection master;
|
connection master;
|
||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown&useSSL=false';
|
||||||
ERROR HY000: Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2
|
ERROR HY000: Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/unknown?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/unknown?user=root&useSSL=false';
|
||||||
ERROR HY000: Connecting: java.sql.SQLSyntaxErrorException: Unknown database 'unknown' rc=-2
|
ERROR HY000: Connecting: java.sql.SQLSyntaxErrorException: Unknown database 'unknown' rc=-2
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='unknown'
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='unknown'
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
ERROR HY000: Cannot get columns from unknown
|
ERROR HY000: Cannot get columns from unknown
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||||
CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`x` int(11) DEFAULT NULL,
|
`x` int(11) DEFAULT NULL,
|
||||||
`y` char(10) DEFAULT NULL
|
`y` char(10) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`=JDBC
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT
|
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
connection slave;
|
connection slave;
|
||||||
ALTER TABLE t1 RENAME t1backup;
|
ALTER TABLE t1 RENAME t1backup;
|
||||||
connection master;
|
connection master;
|
||||||
@@ -54,13 +56,13 @@ DROP TABLE t1;
|
|||||||
# Testing SELECT, etc.
|
# Testing SELECT, etc.
|
||||||
#
|
#
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` int(10) DEFAULT NULL,
|
`a` int(10) DEFAULT NULL,
|
||||||
`b` char(10) DEFAULT NULL
|
`b` char(10) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`='JDBC'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b
|
a b
|
||||||
NULL NULL
|
NULL NULL
|
||||||
@@ -70,13 +72,13 @@ NULL NULL
|
|||||||
3 test03
|
3 test03
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='t1'
|
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='t1'
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` int(11) DEFAULT NULL,
|
`a` int(11) DEFAULT NULL,
|
||||||
`b` char(10) DEFAULT NULL
|
`b` char(10) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC `TABNAME`='t1'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`=JDBC `TABNAME`='t1'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b
|
a b
|
||||||
NULL NULL
|
NULL NULL
|
||||||
@@ -86,13 +88,13 @@ NULL NULL
|
|||||||
3 test03
|
3 test03
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` int(11) NOT NULL,
|
`a` int(11) NOT NULL,
|
||||||
`b` char(10) NOT NULL
|
`b` char(10) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`=JDBC
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b
|
a b
|
||||||
0
|
0
|
||||||
@@ -102,13 +104,13 @@ a b
|
|||||||
3 test03
|
3 test03
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` char(10) DEFAULT NULL,
|
`a` char(10) DEFAULT NULL,
|
||||||
`b` int(11) DEFAULT NULL
|
`b` int(11) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`=JDBC
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b
|
a b
|
||||||
NULL NULL
|
NULL NULL
|
||||||
@@ -138,7 +140,7 @@ t1 CREATE TABLE `t1` (
|
|||||||
INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.14159265,3141.59265);
|
INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.14159265,3141.59265);
|
||||||
connection master;
|
connection master;
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
@@ -150,7 +152,7 @@ t1 CREATE TABLE `t1` (
|
|||||||
`f` double(14,0) DEFAULT NULL,
|
`f` double(14,0) DEFAULT NULL,
|
||||||
`g` double(24,0) DEFAULT NULL,
|
`g` double(24,0) DEFAULT NULL,
|
||||||
`h` decimal(27,5) DEFAULT NULL
|
`h` decimal(27,5) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`='JDBC'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b c d e f g h
|
a b c d e f g h
|
||||||
100 3333 41235 1234567890 235000000000 3 3 3141.59265
|
100 3333 41235 1234567890 235000000000 3 3 3141.59265
|
||||||
@@ -173,13 +175,13 @@ a b
|
|||||||
Welcome Hello, World
|
Welcome Hello, World
|
||||||
connection master;
|
connection master;
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`a` char(12) DEFAULT NULL,
|
`a` char(12) DEFAULT NULL,
|
||||||
`b` varchar(12) DEFAULT NULL
|
`b` varchar(12) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`='JDBC'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b
|
a b
|
||||||
Welcome Hello, World
|
Welcome Hello, World
|
||||||
@@ -209,7 +211,7 @@ a b c d e
|
|||||||
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003
|
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003
|
||||||
connection master;
|
connection master;
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
@@ -218,13 +220,15 @@ t1 CREATE TABLE `t1` (
|
|||||||
`c` time DEFAULT NULL,
|
`c` time DEFAULT NULL,
|
||||||
`d` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
`d` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
`e` year(4) DEFAULT NULL
|
`e` year(4) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root&useSSL=false' `TABLE_TYPE`='JDBC'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
a b c d e
|
a b c d e
|
||||||
2003-05-27 2003-05-27 11:45:23 10:45:23 2003-05-27 10:45:23 2003
|
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
connection slave;
|
connection slave;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
connection master;
|
connection master;
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
|
@@ -3,7 +3,7 @@ command varchar(128) not null,
|
|||||||
number int(5) not null flag=1,
|
number int(5) not null flag=1,
|
||||||
message varchar(255) flag=2)
|
message varchar(255) flag=2)
|
||||||
ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01,Execsrc=1';
|
OPTION_LIST='User=system,Password=Biscote01,Execsrc=1';
|
||||||
SELECT * FROM t2 WHERE command = 'drop table employee';
|
SELECT * FROM t2 WHERE command = 'drop table employee';
|
||||||
command number message
|
command number message
|
||||||
drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
|
drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
|
||||||
@@ -23,14 +23,14 @@ Warnings:
|
|||||||
Warning 1105 Affected rows
|
Warning 1105 Affected rows
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
|
||||||
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01';
|
OPTION_LIST='User=system,Password=Biscote01';
|
||||||
SELECT * FROM t1 WHERE table_name='employee';
|
SELECT * FROM t1 WHERE table_name='employee';
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
NULL SYSTEM EMPLOYEE TABLE NULL
|
NULL SYSTEM EMPLOYEE TABLE NULL
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='EMPLOYEE' CATFUNC=columns
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='EMPLOYEE' CATFUNC=columns
|
||||||
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01';
|
OPTION_LIST='User=system,Password=Biscote01';
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL
|
NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL
|
||||||
@@ -42,7 +42,7 @@ CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OP
|
|||||||
HOST 'jdbc:oracle:thin:@localhost:1521:xe',
|
HOST 'jdbc:oracle:thin:@localhost:1521:xe',
|
||||||
DATABASE 'SYSTEM',
|
DATABASE 'SYSTEM',
|
||||||
USER 'system',
|
USER 'system',
|
||||||
PASSWORD 'Choupy01',
|
PASSWORD 'Biscote01',
|
||||||
PORT 0,
|
PORT 0,
|
||||||
SOCKET '',
|
SOCKET '',
|
||||||
OWNER 'SYSTEM');
|
OWNER 'SYSTEM');
|
||||||
|
@@ -10,7 +10,7 @@ SELECT * from t1 limit 3;
|
|||||||
Document
|
Document
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":"2014-03-03T00:00:00.000Z"},"grade":"A","score":2},{"date":{"$date":"2013-09-11T00:00:00.000Z"},"grade":"A","score":6},{"date":{"$date":"2013-01-24T00:00:00.000Z"},"grade":"A","score":10},{"date":{"$date":"2011-11-23T00:00:00.000Z"},"grade":"A","score":9},{"date":{"$date":"2011-03-10T00:00:00.000Z"},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":"2014-03-03T00:00:00.000Z"},"grade":"A","score":2},{"date":{"$date":"2013-09-11T00:00:00.000Z"},"grade":"A","score":6},{"date":{"$date":"2013-01-24T00:00:00.000Z"},"grade":"A","score":10},{"date":{"$date":"2011-11-23T00:00:00.000Z"},"grade":"A","score":9},{"date":{"$date":"2011-03-10T00:00:00.000Z"},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":"2014-12-30T00:00:00.000Z"},"grade":"A","score":8},{"date":{"$date":"2014-07-01T00:00:00.000Z"},"grade":"B","score":23},{"date":{"$date":"2013-04-30T00:00:00.000Z"},"grade":"A","score":12},{"date":{"$date":"2012-05-08T00:00:00.000Z"},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":"2014-12-30T00:00:00.000Z"},"grade":"A","score":8},{"date":{"$date":"2014-07-01T00:00:00.000Z"},"grade":"B","score":23},{"date":{"$date":"2013-04-30T00:00:00.000Z"},"grade":"A","score":12},{"date":{"$date":"2012-05-08T00:00:00.000Z"},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.98513559999999,40.7676919],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":"2014-09-06T00:00:00.000Z"},"grade":"A","score":2},{"date":{"$date":"2013-07-22T00:00:00.000Z"},"grade":"A","score":11},{"date":{"$date":"2012-07-31T00:00:00.000Z"},"grade":"A","score":12},{"date":{"$date":"2011-12-29T00:00:00.000Z"},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985136,40.767692],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":"2014-09-06T00:00:00.000Z"},"grade":"A","score":2},{"date":{"$date":"2013-07-22T00:00:00.000Z"},"grade":"A","score":11},{"date":{"$date":"2012-07-31T00:00:00.000Z"},"grade":"A","score":12},{"date":{"$date":"2011-12-29T00:00:00.000Z"},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Test catfunc
|
# Test catfunc
|
||||||
|
@@ -10,7 +10,7 @@ SELECT * from t1 limit 3;
|
|||||||
Document
|
Document
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000},"grade":"A","score":2},{"date":{"$date":1378857600000},"grade":"A","score":6},{"date":{"$date":1358985600000},"grade":"A","score":10},{"date":{"$date":1322006400000},"grade":"A","score":9},{"date":{"$date":1299715200000},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000},"grade":"A","score":2},{"date":{"$date":1378857600000},"grade":"A","score":6},{"date":{"$date":1358985600000},"grade":"A","score":10},{"date":{"$date":1322006400000},"grade":"A","score":9},{"date":{"$date":1299715200000},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000},"grade":"A","score":8},{"date":{"$date":1404172800000},"grade":"B","score":23},{"date":{"$date":1367280000000},"grade":"A","score":12},{"date":{"$date":1336435200000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000},"grade":"A","score":8},{"date":{"$date":1404172800000},"grade":"B","score":23},{"date":{"$date":1367280000000},"grade":"A","score":12},{"date":{"$date":1336435200000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.98513559999999,40.7676919],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000},"grade":"A","score":2},{"date":{"$date":1374451200000},"grade":"A","score":11},{"date":{"$date":1343692800000},"grade":"A","score":12},{"date":{"$date":1325116800000},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985136,40.767692],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000},"grade":"A","score":2},{"date":{"$date":1374451200000},"grade":"A","score":11},{"date":{"$date":1343692800000},"grade":"A","score":12},{"date":{"$date":1325116800000},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Test catfunc
|
# Test catfunc
|
||||||
|
@@ -8,9 +8,9 @@ ENGINE=CONNECT TABLE_TYPE=JSON TABNAME=restaurants CONNECTION='mongodb://localho
|
|||||||
OPTION_LIST='Driver=C,Version=0' DATA_CHARSET=utf8;
|
OPTION_LIST='Driver=C,Version=0' DATA_CHARSET=utf8;
|
||||||
SELECT * from t1 limit 3;
|
SELECT * from t1 limit 3;
|
||||||
Document
|
Document
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856076999999999089,40.848447000000000173],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000},"grade":"A","score":2},{"date":{"$date":1378857600000},"grade":"A","score":6},{"date":{"$date":1358985600000},"grade":"A","score":10},{"date":{"$date":1322006400000},"grade":"A","score":9},{"date":{"$date":1299715200000},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000},"grade":"A","score":2},{"date":{"$date":1378857600000},"grade":"A","score":6},{"date":{"$date":1358985600000},"grade":"A","score":10},{"date":{"$date":1322006400000},"grade":"A","score":9},{"date":{"$date":1299715200000},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.96170399999999745,40.66294200000000103],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000},"grade":"A","score":8},{"date":{"$date":1404172800000},"grade":"B","score":23},{"date":{"$date":1367280000000},"grade":"A","score":12},{"date":{"$date":1336435200000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000},"grade":"A","score":8},{"date":{"$date":1404172800000},"grade":"B","score":23},{"date":{"$date":1367280000000},"grade":"A","score":12},{"date":{"$date":1336435200000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985135599999992451,40.767691900000002647],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000},"grade":"A","score":2},{"date":{"$date":1374451200000},"grade":"A","score":11},{"date":{"$date":1343692800000},"grade":"A","score":12},{"date":{"$date":1325116800000},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985136,40.767692],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000},"grade":"A","score":2},{"date":{"$date":1374451200000},"grade":"A","score":11},{"date":{"$date":1343692800000},"grade":"A","score":12},{"date":{"$date":1325116800000},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Test catfunc
|
# Test catfunc
|
||||||
@@ -363,7 +363,7 @@ _id item prices_0 prices_1 prices_2 prices_3 prices_4
|
|||||||
1 journal 87 45 63 12 78
|
1 journal 87 45 63 12 78
|
||||||
2 notebook 123 456 789 NULL NULL
|
2 notebook 123 456 789 NULL NULL
|
||||||
3 paper 5 7 3 8 NULL
|
3 paper 5 7 3 8 NULL
|
||||||
4 planner 25 71 44 27 NULL
|
4 planner 25 71 NULL 44 27
|
||||||
5 postcard 5 7 3 8 NULL
|
5 postcard 5 7 3 8 NULL
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
|
@@ -8,9 +8,9 @@ ENGINE=CONNECT TABLE_TYPE=MONGO TABNAME=restaurants
|
|||||||
OPTION_LIST='Driver=C,Version=0' DATA_CHARSET=utf8;
|
OPTION_LIST='Driver=C,Version=0' DATA_CHARSET=utf8;
|
||||||
SELECT * from t1 limit 3;
|
SELECT * from t1 limit 3;
|
||||||
Document
|
Document
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856076999999999089,40.848447000000000173],"street":"Morris ParkAve", "zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000},"grade":"A","score":2},{"date":{"$date":1378857600000},"grade":"A","score":6},{"date":{"$date":1358985600000},"grade":"A","score":10},{"date":{"$date":1322006400000},"grade":"A","score":9},{"date":{"$date":1299715200000},"grade":"B","score":14}],"name":"Morris ParkBakeShop", "restaurant_id":"30075445"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51c"},"address":{"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"},"borough":"Bronx","cuisine":"Bakery","grades":[{"date":{"$date":1393804800000.000000},"grade":"A","score":2},{"date":{"$date":1378857600000.000000},"grade":"A","score":6},{"date":{"$date":1358985600000.000000},"grade":"A","score":10},{"date":{"$date":1322006400000.000000},"grade":"A","score":9},{"date":{"$date":1299715200000.000000},"grade":"B","score":14}],"name":"Morris Park Bake Shop","restaurant_id":"30075445"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.96170399999999745,40.66294200000000103],"street":"Flatbush Avenue", "zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000},"grade":"A","score":8},{"date":{"$date":1404172800000},"grade":"B","score":23},{"date":{"$date":1367280000000},"grade":"A","score":12},{"date":{"$date":1336435200000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51d"},"address":{"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"},"borough":"Brooklyn","cuisine":"Hamburgers","grades":[{"date":{"$date":1419897600000.000000},"grade":"A","score":8},{"date":{"$date":1404172800000.000000},"grade":"B","score":23},{"date":{"$date":1367280000000.000000},"grade":"A","score":12},{"date":{"$date":1336435200000.000000},"grade":"A","score":12}],"name":"Wendy'S","restaurant_id":"30112340"}
|
||||||
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985135599999992451,40.767691900000002647],"street":"West 57Street", "zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000},"grade":"A","score":2},{"date":{"$date":1374451200000},"grade":"A","score":11},{"date":{"$date":1343692800000},"grade":"A","score":12},{"date":{"$date":1325116800000},"grade":"A","score":12}],"name":"Dj ReynoldsPubAndRestaurant", "restaurant_id":"30191841"}
|
{"_id":{"$oid":"58ada47de5a51ddfcd5ed51e"},"address":{"building":"351","coord":[-73.985136,40.767692],"street":"West 57 Street","zipcode":"10019"},"borough":"Manhattan","cuisine":"Irish","grades":[{"date":{"$date":1409961600000.000000},"grade":"A","score":2},{"date":{"$date":1374451200000.000000},"grade":"A","score":11},{"date":{"$date":1343692800000.000000},"grade":"A","score":12},{"date":{"$date":1325116800000.000000},"grade":"A","score":12}],"name":"Dj Reynolds Pub And Restaurant","restaurant_id":"30191841"}
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Test catfunc
|
# Test catfunc
|
||||||
@@ -64,23 +64,23 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(10) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(10) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord` varchar(512) NOT NULL `FIELD_FORMAT`='address.coord',
|
`address_coord` varchar(512) NOT NULL `JPATH`='address.coord',
|
||||||
`address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(38) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`cuisine` char(64) NOT NULL,
|
`cuisine` char(64) NOT NULL,
|
||||||
`grades_0` varchar(512) DEFAULT NULL `FIELD_FORMAT`='grades.0',
|
`grades_0` varchar(512) DEFAULT NULL `JPATH`='grades.0',
|
||||||
`name` char(98) NOT NULL,
|
`name` char(98) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=C,Version=0' `DATA_CHARSET`='utf8'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=C,Version=0' `DATA_CHARSET`='utf8'
|
||||||
SELECT * FROM t1 LIMIT 5;
|
SELECT * FROM t1 LIMIT 5;
|
||||||
_id address_building address_coord address_street address_zipcode borough cuisine grades_0 name restaurant_id
|
_id address_building address_coord address_street address_zipcode borough cuisine grades_0 name restaurant_id
|
||||||
58ada47de5a51ddfcd5ed51c 1007 Morris Park Ave 10462 Bronx Bakery {"date":{"$date":1393804800000},"grade":"A","score":2} Morris Park Bake Shop 30075445
|
58ada47de5a51ddfcd5ed51c 1007 [-73.856077,40.848447] Morris Park Ave 10462 Bronx Bakery {"date":{"$date":1393804800000},"grade":"A","score":2} Morris Park Bake Shop 30075445
|
||||||
58ada47de5a51ddfcd5ed51d 469 Flatbush Avenue 11225 Brooklyn Hamburgers {"date":{"$date":1419897600000},"grade":"A","score":8} Wendy'S 30112340
|
58ada47de5a51ddfcd5ed51d 469 [-73.961704,40.662942] Flatbush Avenue 11225 Brooklyn Hamburgers {"date":{"$date":1419897600000},"grade":"A","score":8} Wendy'S 30112340
|
||||||
58ada47de5a51ddfcd5ed51e 351 West 57 Street 10019 Manhattan Irish {"date":{"$date":1409961600000},"grade":"A","score":2} Dj Reynolds Pub And Restaurant 30191841
|
58ada47de5a51ddfcd5ed51e 351 [-73.985136,40.767692] West 57 Street 10019 Manhattan Irish {"date":{"$date":1409961600000},"grade":"A","score":2} Dj Reynolds Pub And Restaurant 30191841
|
||||||
58ada47de5a51ddfcd5ed51f 2780 Stillwell Avenue 11224 Brooklyn American {"date":{"$date":1402358400000},"grade":"A","score":5} Riviera Caterer 40356018
|
58ada47de5a51ddfcd5ed51f 2780 [-73.982420,40.579505] Stillwell Avenue 11224 Brooklyn American {"date":{"$date":1402358400000},"grade":"A","score":5} Riviera Caterer 40356018
|
||||||
58ada47de5a51ddfcd5ed520 97-22 63 Road 11374 Queens Jewish/Kosher {"date":{"$date":1416787200000},"grade":"Z","score":20} Tov Kosher Kitchen 40356068
|
58ada47de5a51ddfcd5ed520 97-22 [-73.860115,40.731174] 63 Road 11374 Queens Jewish/Kosher {"date":{"$date":1416787200000},"grade":"Z","score":20} Tov Kosher Kitchen 40356068
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Dropping a column
|
# Dropping a column
|
||||||
@@ -89,16 +89,16 @@ CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MONGO TABNAME=restaurants DATA_CHARSET
|
|||||||
COLIST='{"projection":{"grades":0}}' OPTION_LIST='Driver=C,Version=0,level=0' ;
|
COLIST='{"projection":{"grades":0}}' OPTION_LIST='Driver=C,Version=0,level=0' ;
|
||||||
SELECT * FROM t1 LIMIT 10;
|
SELECT * FROM t1 LIMIT 10;
|
||||||
_id address borough cuisine name restaurant_id
|
_id address borough cuisine name restaurant_id
|
||||||
58ada47de5a51ddfcd5ed51c {"building":"1007","coord":[-73.856076999999999089,40.848447000000000173],"street":"Morris ParkAve", "zipcode":"10462"} Bronx Bakery Morris Park Bake Shop 30075445
|
58ada47de5a51ddfcd5ed51c {"building":"1007","coord":[-73.856077,40.848447],"street":"Morris Park Ave","zipcode":"10462"} Bronx Bakery Morris Park Bake Shop 30075445
|
||||||
58ada47de5a51ddfcd5ed51d {"building":"469","coord":[-73.96170399999999745,40.66294200000000103],"street":"Flatbush Avenue", "zipcode":"11225"} Brooklyn Hamburgers Wendy'S 30112340
|
58ada47de5a51ddfcd5ed51d {"building":"469","coord":[-73.961704,40.662942],"street":"Flatbush Avenue","zipcode":"11225"} Brooklyn Hamburgers Wendy'S 30112340
|
||||||
58ada47de5a51ddfcd5ed51e {"building":"351","coord":[-73.985135599999992451,40.767691900000002647],"street":"West 57Street", "zipcode":"10019"} Manhattan Irish Dj Reynolds Pub And Restaurant 30191841
|
58ada47de5a51ddfcd5ed51e {"building":"351","coord":[-73.985136,40.767692],"street":"West 57 Street","zipcode":"10019"} Manhattan Irish Dj Reynolds Pub And Restaurant 30191841
|
||||||
58ada47de5a51ddfcd5ed51f {"building":"2780","coord":[-73.982419999999990523,40.579504999999997494],"street":"Stillwell Avenue", "zipcode":"11224"} Brooklyn American Riviera Caterer 40356018
|
58ada47de5a51ddfcd5ed51f {"building":"2780","coord":[-73.982420,40.579505],"street":"Stillwell Avenue","zipcode":"11224"} Brooklyn American Riviera Caterer 40356018
|
||||||
58ada47de5a51ddfcd5ed520 {"building":"97-22","coord":[-73.860115199999995639,40.731173900000001709],"street":"63 Road", "zipcode":"11374"} Queens Jewish/Kosher Tov Kosher Kitchen 40356068
|
58ada47de5a51ddfcd5ed520 {"building":"97-22","coord":[-73.860115,40.731174],"street":"63 Road","zipcode":"11374"} Queens Jewish/Kosher Tov Kosher Kitchen 40356068
|
||||||
58ada47de5a51ddfcd5ed521 {"building":"8825","coord":[-73.880382699999998408,40.764312400000001446],"street":"Astoria Boulevard", "zipcode":"11369"} Queens American Brunos On The Boulevard 40356151
|
58ada47de5a51ddfcd5ed521 {"building":"8825","coord":[-73.880383,40.764312],"street":"Astoria Boulevard","zipcode":"11369"} Queens American Brunos On The Boulevard 40356151
|
||||||
58ada47de5a51ddfcd5ed522 {"building":"2206","coord":[-74.137728600000002643,40.611957199999999091],"street":"Victory Boulevard", "zipcode":"10314"} Staten Island Jewish/Kosher Kosher Island 40356442
|
58ada47de5a51ddfcd5ed522 {"building":"2206","coord":[-74.137729,40.611957],"street":"Victory Boulevard","zipcode":"10314"} Staten Island Jewish/Kosher Kosher Island 40356442
|
||||||
58ada47de5a51ddfcd5ed523 {"building":"7114","coord":[-73.906850599999998508,40.619903399999998328],"street":"Avenue U", "zipcode":"11234"} Brooklyn Delicatessen Wilken'S Fine Food 40356483
|
58ada47de5a51ddfcd5ed523 {"building":"7114","coord":[-73.906851,40.619903],"street":"Avenue U","zipcode":"11234"} Brooklyn Delicatessen Wilken'S Fine Food 40356483
|
||||||
58ada47de5a51ddfcd5ed524 {"building":"6409","coord":[-74.005288999999990551,40.628886000000001388],"street":"11 Avenue", "zipcode":"11219"} Brooklyn American Regina Caterers 40356649
|
58ada47de5a51ddfcd5ed524 {"building":"6409","coord":[-74.005289,40.628886],"street":"11 Avenue","zipcode":"11219"} Brooklyn American Regina Caterers 40356649
|
||||||
58ada47de5a51ddfcd5ed525 {"building":"1839","coord":[-73.948260899999993967,40.640827100000002758],"street":"Nostrand Avenue", "zipcode":"11226"} Brooklyn Ice Cream, Gelato, Yogurt, Ices Taste The Tropics Ice Cream 40356731
|
58ada47de5a51ddfcd5ed525 {"building":"1839","coord":[-73.948261,40.640827],"street":"Nostrand Avenue","zipcode":"11226"} Brooklyn Ice Cream, Gelato, Yogurt, Ices Taste The Tropics Ice Cream 40356731
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
# Specifying Jpath
|
# Specifying Jpath
|
||||||
@@ -249,14 +249,14 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(6) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(6) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord_0` double(12,6) NOT NULL `FIELD_FORMAT`='address.coord.0',
|
`address_coord_0` double(12,6) NOT NULL `JPATH`='address.coord.0',
|
||||||
`address_street` char(25) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(25) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`grades_0_date` datetime NOT NULL `FIELD_FORMAT`='grades.0.date',
|
`grades_0_date` datetime NOT NULL `JPATH`='grades.0.date',
|
||||||
`grades_0_grade` char(14) NOT NULL `FIELD_FORMAT`='grades.0.grade',
|
`grades_0_grade` char(14) NOT NULL `JPATH`='grades.0.grade',
|
||||||
`grades_0_score` int(11) NOT NULL `FIELD_FORMAT`='grades.0.score',
|
`grades_0_score` int(11) NOT NULL `JPATH`='grades.0.score',
|
||||||
`name` char(32) NOT NULL,
|
`name` char(32) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"projection":{"cuisine":0}}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=C,level=2,version=0'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"projection":{"cuisine":0}}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=C,level=2,version=0'
|
||||||
|
@@ -64,13 +64,13 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(10) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(10) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord` char(41) NOT NULL `FIELD_FORMAT`='address.coord',
|
`address_coord` char(41) NOT NULL `JPATH`='address.coord',
|
||||||
`address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(38) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`cuisine` char(64) NOT NULL,
|
`cuisine` char(64) NOT NULL,
|
||||||
`grades_0` char(99) DEFAULT NULL `FIELD_FORMAT`='grades.0',
|
`grades_0` char(99) DEFAULT NULL `JPATH`='grades.0',
|
||||||
`name` char(98) NOT NULL,
|
`name` char(98) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=Java,Version=2' `DATA_CHARSET`='utf8'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=Java,Version=2' `DATA_CHARSET`='utf8'
|
||||||
@@ -249,14 +249,14 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(6) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(6) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord_0` double(18,14) NOT NULL `FIELD_FORMAT`='address.coord.0',
|
`address_coord_0` double(18,14) NOT NULL `JPATH`='address.coord.0',
|
||||||
`address_street` char(25) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(25) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`grades_0_date` datetime NOT NULL `FIELD_FORMAT`='grades.0.date',
|
`grades_0_date` datetime NOT NULL `JPATH`='grades.0.date',
|
||||||
`grades_0_grade` char(14) NOT NULL `FIELD_FORMAT`='grades.0.grade',
|
`grades_0_grade` char(14) NOT NULL `JPATH`='grades.0.grade',
|
||||||
`grades_0_score` int(2) NOT NULL `FIELD_FORMAT`='grades.0.score',
|
`grades_0_score` int(2) NOT NULL `JPATH`='grades.0.score',
|
||||||
`name` char(32) NOT NULL,
|
`name` char(32) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"cuisine":0}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=Java,level=2,version=2'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"cuisine":0}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=Java,level=2,version=2'
|
||||||
|
@@ -64,13 +64,13 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(10) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(10) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord` char(39) NOT NULL `FIELD_FORMAT`='address.coord',
|
`address_coord` char(39) NOT NULL `JPATH`='address.coord',
|
||||||
`address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(38) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`cuisine` char(64) NOT NULL,
|
`cuisine` char(64) NOT NULL,
|
||||||
`grades_0` char(84) DEFAULT NULL `FIELD_FORMAT`='grades.0',
|
`grades_0` char(84) DEFAULT NULL `JPATH`='grades.0',
|
||||||
`name` char(98) NOT NULL,
|
`name` char(98) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=Java,Version=3' `DATA_CHARSET`='utf8'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=Java,Version=3' `DATA_CHARSET`='utf8'
|
||||||
@@ -249,14 +249,14 @@ SHOW CREATE TABLE t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`_id` char(24) NOT NULL,
|
`_id` char(24) NOT NULL,
|
||||||
`address_building` char(6) NOT NULL `FIELD_FORMAT`='address.building',
|
`address_building` char(6) NOT NULL `JPATH`='address.building',
|
||||||
`address_coord_0` double(18,14) NOT NULL `FIELD_FORMAT`='address.coord.0',
|
`address_coord_0` double(18,14) NOT NULL `JPATH`='address.coord.0',
|
||||||
`address_street` char(25) NOT NULL `FIELD_FORMAT`='address.street',
|
`address_street` char(25) NOT NULL `JPATH`='address.street',
|
||||||
`address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode',
|
`address_zipcode` char(5) NOT NULL `JPATH`='address.zipcode',
|
||||||
`borough` char(13) NOT NULL,
|
`borough` char(13) NOT NULL,
|
||||||
`grades_0_date` datetime NOT NULL `FIELD_FORMAT`='grades.0.date',
|
`grades_0_date` datetime NOT NULL `JPATH`='grades.0.date',
|
||||||
`grades_0_grade` char(14) NOT NULL `FIELD_FORMAT`='grades.0.grade',
|
`grades_0_grade` char(14) NOT NULL `JPATH`='grades.0.grade',
|
||||||
`grades_0_score` int(2) NOT NULL `FIELD_FORMAT`='grades.0.score',
|
`grades_0_score` int(2) NOT NULL `JPATH`='grades.0.score',
|
||||||
`name` char(32) NOT NULL,
|
`name` char(32) NOT NULL,
|
||||||
`restaurant_id` char(8) NOT NULL
|
`restaurant_id` char(8) NOT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"cuisine":0}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=Java,level=2,version=3'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MONGO' `TABNAME`='restaurants' `COLIST`='{"cuisine":0}' `FILTER`='{"cuisine":"French","borough":{"$ne":"Manhattan"}}' `OPTION_LIST`='Driver=Java,level=2,version=3'
|
||||||
|
@@ -10,7 +10,7 @@ SET NAMES utf8;
|
|||||||
|
|
||||||
# All tables in all schemas (filtered with WHERE)
|
# All tables in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables;
|
CATFUNC=Tables;
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -20,7 +20,7 @@ NULL MTR V1 VIEW NULL
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables in all schemas (filtered with WHERE)
|
# All tables in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='%.%';
|
CATFUNC=Tables TABNAME='%.%';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -30,7 +30,7 @@ NULL MTR V1 VIEW NULL
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables "T1" in all schemas (filtered with WHERE)
|
# All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='%.T1';
|
CATFUNC=Tables TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -38,7 +38,7 @@ NULL MTR T1 TABLE NULL
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables "T1" in all schemas (filtered with WHERE)
|
# All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='T1';
|
CATFUNC=Tables TABNAME='T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -46,7 +46,7 @@ NULL MTR T1 TABLE NULL
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# Table "T1" in the schema "MTR"
|
# Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='MTR.T1';
|
CATFUNC=Tables TABNAME='MTR.T1';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -54,7 +54,7 @@ NULL MTR T1 TABLE NULL
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables in the schema "MTR"
|
# All tables in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='MTR.%';
|
CATFUNC=Tables TABNAME='MTR.%';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Table_Type Remark
|
Table_Cat Table_Schema Table_Name Table_Type Remark
|
||||||
@@ -68,7 +68,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
# All columns in all schemas (limited with WHERE)
|
# All columns in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns;
|
CATFUNC=Columns;
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
@@ -80,7 +80,7 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All columns in all schemas (limited with WHERE)
|
# All columns in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='%.%';
|
CATFUNC=Columns TABNAME='%.%';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
@@ -91,7 +91,7 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
|
|||||||
MTR V1 B 6 NUMBER 38 40 NULL NULL 1
|
MTR V1 B 6 NUMBER 38 40 NULL NULL 1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables "T1" in all schemas (limited with WHERE)
|
# All tables "T1" in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' CATFUNC=Columns TABNAME='%.T1';
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' CATFUNC=Columns TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
MTR T1 A 3 DECIMAL 38 40 0 10 1
|
||||||
@@ -99,7 +99,7 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# Table "T1" in the schema "MTR"
|
# Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='MTR.T1';
|
CATFUNC=Columns TABNAME='MTR.T1';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
@@ -108,7 +108,7 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# All tables "T1" in all schemas (filtered with WHERE)
|
# All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='%.T1';
|
CATFUNC=Columns TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
|
||||||
@@ -121,14 +121,14 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
# Table "T1" in the default schema ("MTR")
|
# Table "T1" in the default schema ("MTR")
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='T1';
|
TABNAME='T1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`A` decimal(40,0) DEFAULT NULL,
|
`A` decimal(40,0) DEFAULT NULL,
|
||||||
`B` double DEFAULT NULL
|
`B` double DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' `TABLE_TYPE`='ODBC' `TABNAME`='T1'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' `TABLE_TYPE`='ODBC' `TABNAME`='T1'
|
||||||
SELECT * FROM t1 ORDER BY A;
|
SELECT * FROM t1 ORDER BY A;
|
||||||
A B
|
A B
|
||||||
10 1000000000
|
10 1000000000
|
||||||
@@ -157,14 +157,14 @@ DROP VIEW v1;
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# Table "T1" in the schema "MTR"
|
# Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.T1';
|
TABNAME='MTR.T1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`A` decimal(40,0) DEFAULT NULL,
|
`A` decimal(40,0) DEFAULT NULL,
|
||||||
`B` double DEFAULT NULL
|
`B` double DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.T1'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.T1'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
A B
|
A B
|
||||||
10 1000000000
|
10 1000000000
|
||||||
@@ -173,14 +173,14 @@ A B
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# View "V1" in the schema "MTR"
|
# View "V1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.V1';
|
TABNAME='MTR.V1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`A` decimal(40,0) DEFAULT NULL,
|
`A` decimal(40,0) DEFAULT NULL,
|
||||||
`B` double DEFAULT NULL
|
`B` double DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.V1'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.V1'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
A B
|
A B
|
||||||
10 1000000000
|
10 1000000000
|
||||||
@@ -209,13 +209,13 @@ DROP VIEW v1;
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# Table "T2" in the schema "MTR"
|
# Table "T2" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.T2';
|
TABNAME='MTR.T2';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`A` varchar(64) DEFAULT NULL
|
`A` varchar(64) DEFAULT NULL
|
||||||
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.T2'
|
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' `TABLE_TYPE`='ODBC' `TABNAME`='MTR.T2'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
A
|
A
|
||||||
test
|
test
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
-- source windows.inc
|
-- source windows.inc
|
||||||
-- source jdbconn.inc
|
-- source jdbconn.inc
|
||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
|
|
||||||
let $MYSQLD_DATADIR= `select @@datadir`;
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
||||||
--copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt
|
--copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt
|
||||||
@@ -27,7 +28,7 @@ SELECT * FROM t2;
|
|||||||
--echo #
|
--echo #
|
||||||
USE test;
|
USE test;
|
||||||
--replace_result $PORT PORT
|
--replace_result $PORT PORT
|
||||||
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=t2 CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root'
|
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=t2 CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root&useSSL=false'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
INSERT INTO t1 VALUES(786325481247, 'Hello!', '19:45:03', '1933-08-10', '1985-11-12 09:02:44', '2014-06-17 10:32:01');
|
INSERT INTO t1 VALUES(786325481247, 'Hello!', '19:45:03', '1933-08-10', '1985-11-12 09:02:44', '2014-06-17 10:32:01');
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -39,7 +40,7 @@ DROP TABLE t1;
|
|||||||
--echo # Testing JDBC view
|
--echo # Testing JDBC view
|
||||||
--echo #
|
--echo #
|
||||||
--replace_result $PORT PORT
|
--replace_result $PORT PORT
|
||||||
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC SRCDEF='select id, msg, tm, dt from t2' CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root'
|
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC SRCDEF='select id, msg, tm, dt from t2' CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root&useSSL=false'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
SELECT msg, dt FROM t1;
|
SELECT msg, dt FROM t1;
|
||||||
DROP TABLE t1, connect.t2;
|
DROP TABLE t1, connect.t2;
|
||||||
@@ -67,7 +68,7 @@ INSERT INTO t3 VALUES('Donald','Atlanta','1999-04-01','2016-03-31'),('Mick','New
|
|||||||
SELECT * FROM t3;
|
SELECT * FROM t3;
|
||||||
|
|
||||||
--replace_result $PORT PORT
|
--replace_result $PORT PORT
|
||||||
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=boys CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root' OPTION_LIST='scrollable=1'
|
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=boys CONNECTION='jdbc:mysql://localhost:$PORT/connect?user=root&useSSL=false' OPTION_LIST='scrollable=1'
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
UPDATE t1 SET city = 'Phoenix' WHERE name = 'Henry';
|
UPDATE t1 SET city = 'Phoenix' WHERE name = 'Henry';
|
||||||
INSERT INTO t1 SELECT * FROM t3;
|
INSERT INTO t1 SELECT * FROM t3;
|
||||||
@@ -145,4 +146,5 @@ DROP TABLE connect.tx1;
|
|||||||
DROP DATABASE connect;
|
DROP DATABASE connect;
|
||||||
--remove_file $MYSQLD_DATADIR/test/girls.txt
|
--remove_file $MYSQLD_DATADIR/test/girls.txt
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
-- source jdbconn_cleanup.inc
|
-- source jdbconn_cleanup.inc
|
||||||
|
@@ -9,7 +9,8 @@ connection master;
|
|||||||
-- source jdbconn.inc
|
-- source jdbconn.inc
|
||||||
|
|
||||||
connection slave;
|
connection slave;
|
||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
|
|
||||||
CREATE TABLE t1 (a int, b char(10));
|
CREATE TABLE t1 (a int, b char(10));
|
||||||
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
|
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
|
||||||
@@ -19,33 +20,34 @@ SELECT * FROM t1;
|
|||||||
--echo # Testing errors
|
--echo # Testing errors
|
||||||
--echo #
|
--echo #
|
||||||
connection master;
|
connection master;
|
||||||
SET GLOBAL time_zone='+1:00';
|
SET GLOBAL time_zone='+0:00';
|
||||||
|
SET time_zone='+0:00';
|
||||||
|
|
||||||
# Bad user name
|
# Bad user name
|
||||||
# Suppress "mysql_real_connect failed:" (printed in _DEBUG build)
|
# Suppress "mysql_real_connect failed:" (printed in _DEBUG build)
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
||||||
--error ER_UNKNOWN_ERROR
|
--error ER_UNKNOWN_ERROR
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=unknown';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=unknown&useSSL=false';
|
||||||
|
|
||||||
# Bad database name
|
# Bad database name
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
||||||
--error ER_UNKNOWN_ERROR
|
--error ER_UNKNOWN_ERROR
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/unknown?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/unknown?user=root&useSSL=false';
|
||||||
|
|
||||||
# Bad table name
|
# Bad table name
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
--error ER_UNKNOWN_ERROR
|
--error ER_UNKNOWN_ERROR
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='unknown'
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='unknown'
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--error ER_NO_SUCH_TABLE
|
--error ER_NO_SUCH_TABLE
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
|
|
||||||
# Bad column name
|
# Bad column name
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 (x int, y char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
--error ER_GET_ERRMSG
|
--error ER_GET_ERRMSG
|
||||||
@@ -55,7 +57,7 @@ DROP TABLE t1;
|
|||||||
# The remote table disappeared
|
# The remote table disappeared
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
|
|
||||||
connection slave;
|
connection slave;
|
||||||
ALTER TABLE t1 RENAME t1backup;
|
ALTER TABLE t1 RENAME t1backup;
|
||||||
@@ -77,7 +79,7 @@ DROP TABLE t1;
|
|||||||
# Automatic table structure
|
# Automatic table structure
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -86,7 +88,7 @@ DROP TABLE t1;
|
|||||||
# Explicit table structure
|
# Explicit table structure
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='t1'
|
eval CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='t1'
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -95,7 +97,7 @@ DROP TABLE t1;
|
|||||||
# Explicit table structure: remote NULL, local NOT NULL
|
# Explicit table structure: remote NULL, local NOT NULL
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 (a INT NOT NULL, b CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -104,7 +106,7 @@ DROP TABLE t1;
|
|||||||
# Explicit table structure with wrong column types
|
# Explicit table structure with wrong column types
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 (a char(10), b int) ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -125,7 +127,7 @@ INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.141592
|
|||||||
connection master;
|
connection master;
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -146,7 +148,7 @@ SELECT * FROM t1;
|
|||||||
connection master;
|
connection master;
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -167,7 +169,7 @@ SELECT * FROM t1;
|
|||||||
connection master;
|
connection master;
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root';
|
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=root&useSSL=false';
|
||||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -176,8 +178,10 @@ DROP TABLE t1;
|
|||||||
connection slave;
|
connection slave;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
|
|
||||||
connection master;
|
connection master;
|
||||||
SET GLOBAL time_zone=SYSTEM;
|
SET GLOBAL time_zone=SYSTEM;
|
||||||
|
SET time_zone=SYSTEM;
|
||||||
-- source jdbconn_cleanup.inc
|
-- source jdbconn_cleanup.inc
|
||||||
|
|
||||||
|
@@ -8,20 +8,20 @@ CREATE TABLE t2 (
|
|||||||
number int(5) not null flag=1,
|
number int(5) not null flag=1,
|
||||||
message varchar(255) flag=2)
|
message varchar(255) flag=2)
|
||||||
ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01,Execsrc=1';
|
OPTION_LIST='User=system,Password=Biscote01,Execsrc=1';
|
||||||
SELECT * FROM t2 WHERE command = 'drop table employee';
|
SELECT * FROM t2 WHERE command = 'drop table employee';
|
||||||
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))';
|
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))';
|
||||||
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
|
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
|
||||||
|
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
|
||||||
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01';
|
OPTION_LIST='User=system,Password=Biscote01';
|
||||||
SELECT * FROM t1 WHERE table_name='employee';
|
SELECT * FROM t1 WHERE table_name='employee';
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='EMPLOYEE' CATFUNC=columns
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='EMPLOYEE' CATFUNC=columns
|
||||||
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
|
||||||
OPTION_LIST='User=system,Password=Choupy01';
|
OPTION_LIST='User=system,Password=Biscote01';
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OP
|
|||||||
HOST 'jdbc:oracle:thin:@localhost:1521:xe',
|
HOST 'jdbc:oracle:thin:@localhost:1521:xe',
|
||||||
DATABASE 'SYSTEM',
|
DATABASE 'SYSTEM',
|
||||||
USER 'system',
|
USER 'system',
|
||||||
PASSWORD 'Choupy01',
|
PASSWORD 'Biscote01',
|
||||||
PORT 0,
|
PORT 0,
|
||||||
SOCKET '',
|
SOCKET '',
|
||||||
OWNER 'SYSTEM');
|
OWNER 'SYSTEM');
|
||||||
|
@@ -78,42 +78,42 @@ SET NAMES utf8;
|
|||||||
|
|
||||||
--echo # All tables in all schemas (filtered with WHERE)
|
--echo # All tables in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables;
|
CATFUNC=Tables;
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables in all schemas (filtered with WHERE)
|
--echo # All tables in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='%.%';
|
CATFUNC=Tables TABNAME='%.%';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='%.T1';
|
CATFUNC=Tables TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='T1';
|
CATFUNC=Tables TABNAME='T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # Table "T1" in the schema "MTR"
|
--echo # Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='MTR.T1';
|
CATFUNC=Tables TABNAME='MTR.T1';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables in the schema "MTR"
|
--echo # All tables in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Tables TABNAME='MTR.%';
|
CATFUNC=Tables TABNAME='MTR.%';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
@@ -127,7 +127,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # All columns in all schemas (limited with WHERE)
|
--echo # All columns in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns;
|
CATFUNC=Columns;
|
||||||
# Disable warnings to avoid "Result limited to 20000 lines"
|
# Disable warnings to avoid "Result limited to 20000 lines"
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
@@ -137,7 +137,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # All columns in all schemas (limited with WHERE)
|
--echo # All columns in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='%.%';
|
CATFUNC=Columns TABNAME='%.%';
|
||||||
# Disable warnings to avoid "Result limited to 20000 lines"
|
# Disable warnings to avoid "Result limited to 20000 lines"
|
||||||
--disable_warnings
|
--disable_warnings
|
||||||
@@ -146,20 +146,20 @@ SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables "T1" in all schemas (limited with WHERE)
|
--echo # All tables "T1" in all schemas (limited with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr' CATFUNC=Columns TABNAME='%.T1';
|
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew' CATFUNC=Columns TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # Table "T1" in the schema "MTR"
|
--echo # Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='MTR.T1';
|
CATFUNC=Columns TABNAME='MTR.T1';
|
||||||
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
--echo # All tables "T1" in all schemas (filtered with WHERE)
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
CATFUNC=Columns TABNAME='%.T1';
|
CATFUNC=Columns TABNAME='%.T1';
|
||||||
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
@@ -172,7 +172,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # Table "T1" in the default schema ("MTR")
|
--echo # Table "T1" in the default schema ("MTR")
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='T1';
|
TABNAME='T1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1 ORDER BY A;
|
SELECT * FROM t1 ORDER BY A;
|
||||||
@@ -189,7 +189,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # Table "T1" in the schema "MTR"
|
--echo # Table "T1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.T1';
|
TABNAME='MTR.T1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -197,7 +197,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # View "V1" in the schema "MTR"
|
--echo # View "V1" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.V1';
|
TABNAME='MTR.V1';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@@ -214,7 +214,7 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
--echo # Table "T2" in the schema "MTR"
|
--echo # Table "T2" in the schema "MTR"
|
||||||
CREATE TABLE t1 ENGINE=CONNECT
|
CREATE TABLE t1 ENGINE=CONNECT
|
||||||
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=newmtr'
|
TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtrnew'
|
||||||
TABNAME='MTR.T2';
|
TABNAME='MTR.T2';
|
||||||
SHOW CREATE TABLE t1;
|
SHOW CREATE TABLE t1;
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
|
@@ -13,11 +13,11 @@
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//nclude <io.h>
|
//nclude <io.h>
|
||||||
//nclude <fcntl.h>
|
//nclude <fcntl.h>
|
||||||
#include <direct.h> // for getcwd
|
#include <direct.h> // for getcwd
|
||||||
@@ -45,13 +45,13 @@
|
|||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* For dynamic load of ODBC32.DLL */
|
/* For dynamic load of ODBC32.DLL */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#pragma comment(lib, "odbc32.lib")
|
#pragma comment(lib, "odbc32.lib")
|
||||||
extern "C" HINSTANCE s_hModule; // Saved module handle
|
extern "C" HINSTANCE s_hModule; // Saved module handle
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
TYPCONV GetTypeConv();
|
TYPCONV GetTypeConv();
|
||||||
int GetConvSize();
|
int GetConvSize();
|
||||||
@@ -1280,15 +1280,15 @@ bool ODBConn::DriverConnect(DWORD Options)
|
|||||||
SWORD nResult;
|
SWORD nResult;
|
||||||
PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN);
|
PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN);
|
||||||
UWORD wConnectOption = SQL_DRIVER_COMPLETE;
|
UWORD wConnectOption = SQL_DRIVER_COMPLETE;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
HWND hWndTop = GetForegroundWindow();
|
HWND hWndTop = GetForegroundWindow();
|
||||||
HWND hWnd = GetParent(hWndTop);
|
HWND hWnd = GetParent(hWndTop);
|
||||||
|
|
||||||
if (hWnd == NULL)
|
if (hWnd == NULL)
|
||||||
hWnd = GetDesktopWindow();
|
hWnd = GetDesktopWindow();
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
HWND hWnd = (HWND)1;
|
HWND hWnd = (HWND)1;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
PGLOBAL& g = m_G;
|
PGLOBAL& g = m_G;
|
||||||
PDBUSER dup = PlgGetUser(g);
|
PDBUSER dup = PlgGetUser(g);
|
||||||
|
|
||||||
@@ -1301,10 +1301,10 @@ bool ODBConn::DriverConnect(DWORD Options)
|
|||||||
SQL_NTS, ConnOut, MAX_CONNECT_LEN,
|
SQL_NTS, ConnOut, MAX_CONNECT_LEN,
|
||||||
&nResult, wConnectOption);
|
&nResult, wConnectOption);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (hWndTop)
|
if (hWndTop)
|
||||||
EnableWindow(hWndTop, true);
|
EnableWindow(hWndTop, true);
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
// If user hit 'Cancel'
|
// If user hit 'Cancel'
|
||||||
if (rc == SQL_NO_DATA_FOUND) {
|
if (rc == SQL_NO_DATA_FOUND) {
|
||||||
|
@@ -29,9 +29,9 @@
|
|||||||
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
|
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
|
||||||
//efine DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
|
//efine DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
typedef unsigned char *PUCHAR;
|
typedef unsigned char *PUCHAR;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
// Field Flags, used to indicate status of fields
|
// Field Flags, used to indicate status of fields
|
||||||
//efine SQL_FIELD_FLAG_DIRTY 0x1
|
//efine SQL_FIELD_FLAG_DIRTY 0x1
|
||||||
|
@@ -16,19 +16,19 @@ typedef off_t off64_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
typedef __int64 BIGINT;
|
typedef __int64 BIGINT;
|
||||||
typedef _Null_terminated_ const char *PCSZ;
|
typedef _Null_terminated_ const char *PCSZ;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
typedef longlong BIGINT;
|
typedef longlong BIGINT;
|
||||||
#define FILE_BEGIN SEEK_SET
|
#define FILE_BEGIN SEEK_SET
|
||||||
#define FILE_CURRENT SEEK_CUR
|
#define FILE_CURRENT SEEK_CUR
|
||||||
#define FILE_END SEEK_END
|
#define FILE_END SEEK_END
|
||||||
typedef const char *PCSZ;
|
typedef const char *PCSZ;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
typedef const void *LPCVOID;
|
typedef const void *LPCVOID;
|
||||||
typedef const char *LPCTSTR;
|
typedef const char *LPCTSTR;
|
||||||
typedef const char *LPCSTR;
|
typedef const char *LPCSTR;
|
||||||
@@ -65,6 +65,6 @@ typedef int HANDLE;
|
|||||||
#define _MAX_EXT FN_EXTLEN
|
#define _MAX_EXT FN_EXTLEN
|
||||||
#define INVALID_HANDLE_VALUE (-1)
|
#define INVALID_HANDLE_VALUE (-1)
|
||||||
#define __stdcall
|
#define __stdcall
|
||||||
#endif /* !__WIN__ */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
#endif /* _OS_H_INCLUDED */
|
#endif /* _OS_H_INCLUDED */
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef _WIN32
|
||||||
my_bool CloseFileHandle(HANDLE h)
|
my_bool CloseFileHandle(HANDLE h)
|
||||||
{
|
{
|
||||||
return !CloseHandle(h);
|
return !CloseHandle(h);
|
||||||
|
@@ -581,11 +581,11 @@ typedef struct _colres {
|
|||||||
char Var; /* Type added information */
|
char Var; /* Type added information */
|
||||||
} COLRES;
|
} COLRES;
|
||||||
|
|
||||||
#if defined(__WIN__) && !defined(NOEX)
|
#if defined(_WIN32) && !defined(NOEX)
|
||||||
#define DllExport __declspec( dllexport )
|
#define DllExport __declspec( dllexport )
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#define DllExport
|
#define DllExport
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Utility routines. */
|
/* Utility routines. */
|
||||||
|
@@ -39,12 +39,12 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "my_pthread.h"
|
#include "my_pthread.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#define BIGMEM 1048576 // 1 Megabyte
|
#define BIGMEM 1048576 // 1 Megabyte
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
//#if defined(THREAD)
|
//#if defined(THREAD)
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
//#endif // THREAD
|
//#endif // THREAD
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#define BIGMEM 2147483647 // Max int value
|
#define BIGMEM 2147483647 // Max int value
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -89,11 +89,11 @@ extern "C" {
|
|||||||
extern char version[];
|
extern char version[];
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
//#if defined(__WIN__)
|
//#if defined(_WIN32)
|
||||||
//extern CRITICAL_SECTION parsec; // Used calling the Flex parser
|
//extern CRITICAL_SECTION parsec; // Used calling the Flex parser
|
||||||
//#else // !__WIN__
|
//#else // !_WIN32
|
||||||
extern pthread_mutex_t parmut;
|
extern pthread_mutex_t parmut;
|
||||||
//#endif // !__WIN__
|
//#endif // !_WIN32
|
||||||
|
|
||||||
// The debug trace used by the main thread
|
// The debug trace used by the main thread
|
||||||
FILE *pfile = NULL;
|
FILE *pfile = NULL;
|
||||||
@@ -386,11 +386,11 @@ char *SetPath(PGLOBAL g, const char *path)
|
|||||||
} // endif path
|
} // endif path
|
||||||
|
|
||||||
if (*path != '.') {
|
if (*path != '.') {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
const char *s = "\\";
|
const char *s = "\\";
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
const char *s = "/";
|
const char *s = "/";
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
|
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
|
||||||
} else
|
} else
|
||||||
strcpy(buf, path);
|
strcpy(buf, path);
|
||||||
@@ -409,7 +409,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
|
|||||||
char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
|
char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
|
||||||
|
|
||||||
switch (op) { // Determine which part to extract
|
switch (op) { // Determine which part to extract
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case OP_FDISK: drive = pBuff; break;
|
case OP_FDISK: drive = pBuff; break;
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
case OP_FPATH: direc = pBuff; break;
|
case OP_FPATH: direc = pBuff; break;
|
||||||
@@ -1249,7 +1249,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp)
|
|||||||
// For allocations greater than one fourth of remaining storage
|
// For allocations greater than one fourth of remaining storage
|
||||||
// in the area, do allocate from virtual storage.
|
// in the area, do allocate from virtual storage.
|
||||||
const char*v = "malloc";
|
const char*v = "malloc";
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (mp.Size >= BIGMEM) {
|
if (mp.Size >= BIGMEM) {
|
||||||
v = "VirtualAlloc";
|
v = "VirtualAlloc";
|
||||||
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
@@ -1352,7 +1352,7 @@ void PlgDBfree(MBLOCK& mp)
|
|||||||
{
|
{
|
||||||
if (!mp.Sub && mp.Memp) {
|
if (!mp.Sub && mp.Memp) {
|
||||||
const char*v = "free";
|
const char*v = "free";
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (mp.Size >= BIGMEM) {
|
if (mp.Size >= BIGMEM) {
|
||||||
v = "VirtualFree";
|
v = "VirtualFree";
|
||||||
VirtualFree(mp.Memp, 0, MEM_RELEASE);
|
VirtualFree(mp.Memp, 0, MEM_RELEASE);
|
||||||
@@ -1554,11 +1554,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
|
|||||||
bp[0] = buff1; bp[1] = buff2;
|
bp[0] = buff1; bp[1] = buff2;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY);
|
h[i]= global_open(g, MSGID_NONE, fn[i], _O_RDONLY | _O_BINARY);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY);
|
h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
if (h[i] == -1) {
|
if (h[i] == -1) {
|
||||||
// if (errno != ENOENT) {
|
// if (errno != ENOENT) {
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#if defined(UNIX) || defined(UNIV_LINUX)
|
#if defined(UNIX) || defined(UNIV_LINUX)
|
||||||
@@ -81,9 +81,9 @@
|
|||||||
#include "rcmsg.h"
|
#include "rcmsg.h"
|
||||||
#endif // NEWMSG
|
#endif // NEWMSG
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
extern HINSTANCE s_hModule; /* Saved module handle */
|
extern HINSTANCE s_hModule; /* Saved module handle */
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
#if defined(XMSG)
|
#if defined(XMSG)
|
||||||
extern char *msg_path;
|
extern char *msg_path;
|
||||||
@@ -205,7 +205,7 @@ PGLOBAL PlugExit(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
|
LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char drive[_MAX_DRIVE];
|
char drive[_MAX_DRIVE];
|
||||||
#else
|
#else
|
||||||
char *drive = NULL;
|
char *drive = NULL;
|
||||||
@@ -232,7 +232,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName)
|
|||||||
|
|
||||||
BOOL PlugIsAbsolutePath(LPCSTR path)
|
BOOL PlugIsAbsolutePath(LPCSTR path)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
return ((path[0] >= 'a' && path[0] <= 'z') ||
|
return ((path[0] >= 'a' && path[0] <= 'z') ||
|
||||||
(path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':';
|
(path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':';
|
||||||
#else
|
#else
|
||||||
@@ -250,7 +250,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
|
|||||||
char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR];
|
char direc[_MAX_DIR], defdir[_MAX_DIR], tmpdir[_MAX_DIR];
|
||||||
char fname[_MAX_FNAME];
|
char fname[_MAX_FNAME];
|
||||||
char ftype[_MAX_EXT];
|
char ftype[_MAX_EXT];
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE];
|
char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE];
|
||||||
#else
|
#else
|
||||||
char *drive = NULL, *defdrv = NULL;
|
char *drive = NULL, *defdrv = NULL;
|
||||||
@@ -270,7 +270,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
|
|||||||
return pBuff;
|
return pBuff;
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
if (*FileName == '~') {
|
if (*FileName == '~') {
|
||||||
if (_fullpath(pBuff, FileName, _MAX_PATH)) {
|
if (_fullpath(pBuff, FileName, _MAX_PATH)) {
|
||||||
if (trace(2))
|
if (trace(2))
|
||||||
@@ -281,7 +281,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
|
|||||||
return FileName; // Error, return unchanged name
|
return FileName; // Error, return unchanged name
|
||||||
|
|
||||||
} // endif FileName
|
} // endif FileName
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath))
|
if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath))
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
|
|||||||
|
|
||||||
if (trace(2)) {
|
if (trace(2)) {
|
||||||
htrc("after _splitpath: FileName=%s\n", FileName);
|
htrc("after _splitpath: FileName=%s\n", FileName);
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype);
|
htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype);
|
||||||
htrc("defdrv=%s defdir=%s\n", defdrv, defdir);
|
htrc("defdrv=%s defdir=%s\n", defdrv, defdir);
|
||||||
#else
|
#else
|
||||||
@@ -442,7 +442,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
|
|||||||
} // end of PlugGetMessage
|
} // end of PlugGetMessage
|
||||||
#endif // NEWMSG
|
#endif // NEWMSG
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Return the line length of the console screen buffer. */
|
/* Return the line length of the console screen buffer. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -454,7 +454,7 @@ short GetLineLength(PGLOBAL g)
|
|||||||
|
|
||||||
return (b) ? coninfo.dwSize.X : 0;
|
return (b) ? coninfo.dwSize.X : 0;
|
||||||
} // end of GetLineLength
|
} // end of GetLineLength
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Program for memory allocation of work and language areas. */
|
/* Program for memory allocation of work and language areas. */
|
||||||
@@ -464,7 +464,7 @@ bool AllocSarea(PGLOBAL g, size_t size)
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* This is the allocation routine for the WIN32/UNIX/AIX version. */
|
/* This is the allocation routine for the WIN32/UNIX/AIX version. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (size >= 1048576) // 1M
|
if (size >= 1048576) // 1M
|
||||||
g->Sarea = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
g->Sarea = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
else
|
else
|
||||||
@@ -500,7 +500,7 @@ bool AllocSarea(PGLOBAL g, size_t size)
|
|||||||
void FreeSarea(PGLOBAL g)
|
void FreeSarea(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (g->Sarea) {
|
if (g->Sarea) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (g->Sarea_Size >= 1048576) // 1M
|
if (g->Sarea_Size >= 1048576) // 1M
|
||||||
VirtualFree(g->Sarea, 0, MEM_RELEASE);
|
VirtualFree(g->Sarea, 0, MEM_RELEASE);
|
||||||
else
|
else
|
||||||
|
@@ -21,9 +21,9 @@
|
|||||||
#include "msgid.h"
|
#include "msgid.h"
|
||||||
#endif // NEWMSG
|
#endif // NEWMSG
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
char *msglang(void);
|
char *msglang(void);
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#else
|
#else
|
||||||
//#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
|
//#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
|
||||||
@@ -52,9 +52,9 @@
|
|||||||
#include "ha_connect.h"
|
#include "ha_connect.h"
|
||||||
#include "mycat.h"
|
#include "mycat.h"
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
extern handlerton *connect_hton;
|
extern handlerton *connect_hton;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* External function. */
|
/* External function. */
|
||||||
@@ -71,11 +71,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
typedef PQRYRES(__stdcall* XCOLDEF) (PGLOBAL, void*, char*, char*, bool);
|
typedef PQRYRES(__stdcall* XCOLDEF) (PGLOBAL, void*, char*, char*, bool);
|
||||||
const char* module, * subtype;
|
const char* module, * subtype;
|
||||||
char c, soname[_MAX_PATH], getname[40] = "Col";
|
char c, soname[_MAX_PATH], getname[40] = "Col";
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
HANDLE hdll; /* Handle to the external DLL */
|
HANDLE hdll; /* Handle to the external DLL */
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
void* hdll; /* Handle for the loaded shared library */
|
void* hdll; /* Handle for the loaded shared library */
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
XCOLDEF coldef = NULL;
|
XCOLDEF coldef = NULL;
|
||||||
PQRYRES qrp = NULL;
|
PQRYRES qrp = NULL;
|
||||||
|
|
||||||
@@ -93,8 +93,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
if (check_valid_path(module, strlen(module))) {
|
if (check_valid_path(module, strlen(module))) {
|
||||||
strcpy(g->Message, "Module cannot contain a path");
|
strcpy(g->Message, "Module cannot contain a path");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
PlugSetPath(soname, module, GetPluginDir());
|
PlugSetPath(soname, module, GetPluginDir());
|
||||||
|
|
||||||
// The exported name is always in uppercase
|
// The exported name is always in uppercase
|
||||||
@@ -104,7 +103,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
if (!c) break;
|
if (!c) break;
|
||||||
} // endfor i
|
} // endfor i
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// Load the Dll implementing the table
|
// Load the Dll implementing the table
|
||||||
if (!(hdll = LoadLibrary(soname))) {
|
if (!(hdll = LoadLibrary(soname))) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@@ -124,7 +123,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
FreeLibrary((HMODULE)hdll);
|
FreeLibrary((HMODULE)hdll);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif coldef
|
} // endif coldef
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
const char* error = NULL;
|
const char* error = NULL;
|
||||||
|
|
||||||
// Load the desired shared library
|
// Load the desired shared library
|
||||||
@@ -141,7 +140,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
dlclose(hdll);
|
dlclose(hdll);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif coldef
|
} // endif coldef
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
// Just in case the external Get function does not set error messages
|
// Just in case the external Get function does not set error messages
|
||||||
sprintf(g->Message, "Error getting column info from %s", subtype);
|
sprintf(g->Message, "Error getting column info from %s", subtype);
|
||||||
@@ -149,11 +148,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
|
|||||||
// Get the table column definition
|
// Get the table column definition
|
||||||
qrp = coldef(g, topt, tab, db, info);
|
qrp = coldef(g, topt, tab, db, info);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
FreeLibrary((HMODULE)hdll);
|
FreeLibrary((HMODULE)hdll);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
dlclose(hdll);
|
dlclose(hdll);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return qrp;
|
return qrp;
|
||||||
} // end of OEMColumns
|
} // end of OEMColumns
|
||||||
@@ -408,13 +407,13 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
|
|||||||
// Take care of the column definitions
|
// Take care of the column definitions
|
||||||
i= poff= nof= nlg= 0;
|
i= poff= nof= nlg= 0;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// Offsets of HTML and DIR tables start from 0, DBF at 1
|
// Offsets of HTML and DIR tables start from 0, DBF at 1
|
||||||
loff= (trf == RECFM_DBF) ? 1 : (trf == RECFM_XML || trf == RECFM_DIR) ? -1 : 0;
|
loff= (trf == RECFM_DBF) ? 1 : (trf == RECFM_XML || trf == RECFM_DIR) ? -1 : 0;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
// Offsets of HTML tables start from 0, DIR and DBF at 1
|
// Offsets of HTML tables start from 0, DIR and DBF at 1
|
||||||
loff = (trf == RECFM_DBF || trf == RECFM_DIR) ? 1 : (trf == RECFM_XML) ? -1 : 0;
|
loff = (trf == RECFM_DBF || trf == RECFM_DIR) ? 1 : (trf == RECFM_XML) ? -1 : 0;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Default Offset depends on table format
|
// Default Offset depends on table format
|
||||||
@@ -625,7 +624,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
|
|||||||
strncat(strcpy(soname, GetPluginDir()), Module,
|
strncat(strcpy(soname, GetPluginDir()), Module,
|
||||||
sizeof(soname) - strlen(soname) - 1);
|
sizeof(soname) - strlen(soname) - 1);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// Is the DLL already loaded?
|
// Is the DLL already loaded?
|
||||||
if (!Hdll && !(Hdll = GetModuleHandle(soname)))
|
if (!Hdll && !(Hdll = GetModuleHandle(soname)))
|
||||||
// No, load the Dll implementing the function
|
// No, load the Dll implementing the function
|
||||||
@@ -661,7 +660,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
|
|||||||
FreeLibrary((HMODULE)Hdll);
|
FreeLibrary((HMODULE)Hdll);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif getdef
|
} // endif getdef
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
|
|
||||||
#if 0 // Don't know what all this stuff does
|
#if 0 // Don't know what all this stuff does
|
||||||
@@ -703,7 +702,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
|
|||||||
dlclose(Hdll);
|
dlclose(Hdll);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif getdef
|
} // endif getdef
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
// Just in case the external Get function does not set error messages
|
// Just in case the external Get function does not set error messages
|
||||||
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
|
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
|
||||||
|
@@ -146,11 +146,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */
|
|||||||
PTABDEF GetXdef(PGLOBAL g);
|
PTABDEF GetXdef(PGLOBAL g);
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
HANDLE Hdll; /* Handle to the external DLL */
|
HANDLE Hdll; /* Handle to the external DLL */
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
void *Hdll; /* Handle for the loaded shared library */
|
void *Hdll; /* Handle for the loaded shared library */
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
|
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
|
||||||
char *Module; /* Path/Name of the DLL implenting it */
|
char *Module; /* Path/Name of the DLL implenting it */
|
||||||
char *Subtype; /* The name of the OEM table sub type */
|
char *Subtype; /* The name of the OEM table sub type */
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/************* tabbson C++ Program Source Code File (.CPP) *************/
|
/************* tabbson C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabbson Version 1.1 */
|
/* PROGRAM NAME: tabbson Version 1.2 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2020 - 2021 */
|
/* (C) Copyright to the author Olivier BERTRAND 2020 - 2021 */
|
||||||
/* This program are the BSON class DB execution routines. */
|
/* This program are the BSON class DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -53,6 +53,7 @@ USETEMP UseTemp(void);
|
|||||||
bool JsonAllPath(void);
|
bool JsonAllPath(void);
|
||||||
int GetDefaultDepth(void);
|
int GetDefaultDepth(void);
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* BSONColumns: construct the result blocks containing the description */
|
/* BSONColumns: construct the result blocks containing the description */
|
||||||
@@ -173,7 +174,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
||||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||||
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
||||||
limit = GetIntegerTableOption(g, topt, "Limit", 10);
|
limit = GetIntegerTableOption(g, topt, "Limit", 50);
|
||||||
strfy = GetStringTableOption(g, topt, "Stringify", NULL);
|
strfy = GetStringTableOption(g, topt, "Stringify", NULL);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -193,7 +194,11 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
if (!(tdp->Database = SetPath(g, db)))
|
if (!(tdp->Database = SetPath(g, db)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
if ((tdp->Objname = GetStringTableOption(g, topt, "Object", NULL))) {
|
||||||
|
if (*tdp->Objname == '$') tdp->Objname++;
|
||||||
|
if (*tdp->Objname == '.') tdp->Objname++;
|
||||||
|
} // endif Objname
|
||||||
|
|
||||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||||
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
||||||
tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL);
|
tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL);
|
||||||
@@ -218,8 +223,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
|
|
||||||
if (tdp->Uri) {
|
if (tdp->Uri) {
|
||||||
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
||||||
tdp->Collname = GetStringTableOption(g, topt, "Name", NULL);
|
tdp->Collname = GetStringTableOption(g, topt, "Tabname", NULL);
|
||||||
tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname);
|
|
||||||
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
||||||
tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all");
|
tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all");
|
||||||
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
||||||
@@ -433,7 +437,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
|
|||||||
jcol.Type = TYPE_UNKNOWN;
|
jcol.Type = TYPE_UNKNOWN;
|
||||||
jcol.Len = jcol.Scale = 0;
|
jcol.Len = jcol.Scale = 0;
|
||||||
jcol.Cbn = true;
|
jcol.Cbn = true;
|
||||||
} else if (j < lvl && !(strfy && !stricmp(strfy, colname))) {
|
} else if (j < lvl && !Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -504,7 +508,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
|
|||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
|
||||||
} else if (lvl >= 0) {
|
} else if (lvl >= 0) {
|
||||||
if (strfy && !stricmp(strfy, colname)) {
|
if (Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -604,33 +608,51 @@ void BSONDISC::AddColumn(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PBVAL BTUTIL::FindRow(PGLOBAL g)
|
PBVAL BTUTIL::FindRow(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *p, *objpath;
|
char *p, *objpath = PlugDup(g, Tp->Objname);
|
||||||
|
char *sep = (char*)(Tp->Sep == ':' ? ":[" : ".[");
|
||||||
|
bool bp = false, b = false;
|
||||||
PBVAL jsp = Tp->Row;
|
PBVAL jsp = Tp->Row;
|
||||||
PBVAL val = NULL;
|
PBVAL val = NULL;
|
||||||
|
|
||||||
for (objpath = PlugDup(g, Tp->Objname); jsp && objpath; objpath = p) {
|
for (; jsp && objpath; objpath = p, bp = b) {
|
||||||
if ((p = strchr(objpath, Tp->Sep)))
|
if ((p = strpbrk(objpath + 1, sep))) {
|
||||||
|
b = (*p == '[');
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
} // endif p
|
||||||
|
|
||||||
if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
if (!bp && *objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
||||||
val = (jsp->Type == TYPE_JOB) ?
|
val = (jsp->Type == TYPE_JOB) ?
|
||||||
GetKeyValue(jsp, objpath) : NULL;
|
GetKeyValue(jsp, objpath) : NULL;
|
||||||
} else {
|
} else {
|
||||||
if (*objpath == '[') {
|
if (bp || *objpath == '[') { // Old style
|
||||||
if (objpath[strlen(objpath) - 1] == ']')
|
if (objpath[strlen(objpath) - 1] != ']') {
|
||||||
objpath++;
|
sprintf(g->Message, "Invalid Table path %s", Tp->Objname);
|
||||||
else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif [
|
} else if (!bp)
|
||||||
|
objpath++;
|
||||||
|
|
||||||
|
} // endif bp
|
||||||
|
|
||||||
val = (jsp->Type == TYPE_JAR) ?
|
val = (jsp->Type == TYPE_JAR) ?
|
||||||
GetArrayValue(GetArray(jsp), atoi(objpath) - Tp->B) : NULL;
|
GetArrayValue(jsp, atoi(objpath) - Tp->B) : NULL;
|
||||||
} // endif objpath
|
} // endif objpath
|
||||||
|
|
||||||
// jsp = (val) ? val->GetJson() : NULL;
|
// jsp = (val) ? val->GetJson() : NULL;
|
||||||
jsp = val;
|
jsp = val;
|
||||||
} // endfor objpath
|
} // endfor objpath
|
||||||
|
|
||||||
|
if (jsp && jsp->Type != TYPE_JOB) {
|
||||||
|
if (jsp->Type == TYPE_JAR) {
|
||||||
|
jsp = GetArrayValue(jsp, Tp->B);
|
||||||
|
|
||||||
|
if (jsp->Type != TYPE_JOB)
|
||||||
|
jsp = NULL;
|
||||||
|
|
||||||
|
} else
|
||||||
|
jsp = NULL;
|
||||||
|
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
return jsp;
|
return jsp;
|
||||||
} // end of FindRow
|
} // end of FindRow
|
||||||
|
|
||||||
@@ -654,17 +676,22 @@ PBVAL BTUTIL::MakeTopTree(PGLOBAL g, int type)
|
|||||||
if (Tp->Objname) {
|
if (Tp->Objname) {
|
||||||
if (!Tp->Row) {
|
if (!Tp->Row) {
|
||||||
// Parse and allocate Objpath item(s)
|
// Parse and allocate Objpath item(s)
|
||||||
char* p;
|
char *p, *objpath = PlugDup(g, Tp->Objname);
|
||||||
char *objpath = PlugDup(g, Tp->Objname);
|
char *sep = (char*)(Tp->Sep == ':' ? ":[" : ".[");
|
||||||
int i;
|
int i;
|
||||||
|
bool bp = false, b = false;
|
||||||
PBVAL objp = NULL;
|
PBVAL objp = NULL;
|
||||||
PBVAL arp = NULL;
|
PBVAL arp = NULL;
|
||||||
|
|
||||||
for (; objpath; objpath = p) {
|
for (; objpath; objpath = p, bp = b) {
|
||||||
if ((p = strchr(objpath, Tp->Sep)))
|
if ((p = strpbrk(objpath + 1, sep))) {
|
||||||
|
b = (*p == '[');
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
} // endif p
|
||||||
|
|
||||||
if (*objpath != '[' && !IsNum(objpath)) {
|
|
||||||
|
if (!bp && *objpath != '[' && !IsNum(objpath)) {
|
||||||
|
// objpass is a key
|
||||||
objp = NewVal(TYPE_JOB);
|
objp = NewVal(TYPE_JOB);
|
||||||
|
|
||||||
if (!top)
|
if (!top)
|
||||||
@@ -676,15 +703,15 @@ PBVAL BTUTIL::MakeTopTree(PGLOBAL g, int type)
|
|||||||
val = NewVal();
|
val = NewVal();
|
||||||
SetKeyValue(objp, MOF(val), objpath);
|
SetKeyValue(objp, MOF(val), objpath);
|
||||||
} else {
|
} else {
|
||||||
if (*objpath == '[') {
|
if (bp || *objpath == '[') {
|
||||||
// Old style
|
// Old style
|
||||||
if (objpath[strlen(objpath) - 1] != ']') {
|
if (objpath[strlen(objpath) - 1] != ']') {
|
||||||
sprintf(g->Message, "Invalid Table path %s", Tp->Objname);
|
sprintf(g->Message, "Invalid Table path %s", Tp->Objname);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else if (!bp)
|
||||||
objpath++;
|
objpath++;
|
||||||
|
|
||||||
} // endif objpath
|
} // endif bp
|
||||||
|
|
||||||
if (!top)
|
if (!top)
|
||||||
top = NewVal(TYPE_JAR);
|
top = NewVal(TYPE_JAR);
|
||||||
@@ -756,10 +783,16 @@ void BCUTIL::SetJsonValue(PGLOBAL g, PVAL vp, PBVAL jvp)
|
|||||||
break;
|
break;
|
||||||
case TYPE_DATE:
|
case TYPE_DATE:
|
||||||
if (jvp->Type == TYPE_STRG) {
|
if (jvp->Type == TYPE_STRG) {
|
||||||
if (!((DTVAL*)vp)->IsFormatted())
|
PSZ dat = GetString(jvp);
|
||||||
((DTVAL*)vp)->SetFormat(g, "YYYY-MM-DDThh:mm:ssZ", 20, 0);
|
|
||||||
|
if (!IsNum(dat)) {
|
||||||
|
if (!((DTVAL*)vp)->IsFormatted())
|
||||||
|
((DTVAL*)vp)->SetFormat(g, "YYYY-MM-DDThh:mm:ssZ", 20, 0);
|
||||||
|
|
||||||
|
vp->SetValue_psz(dat);
|
||||||
|
} else
|
||||||
|
vp->SetValue(atoi(dat));
|
||||||
|
|
||||||
vp->SetValue_psz(GetString(jvp));
|
|
||||||
} else
|
} else
|
||||||
vp->SetValue(GetInteger(jvp));
|
vp->SetValue(GetInteger(jvp));
|
||||||
|
|
||||||
@@ -1157,10 +1190,15 @@ bool BSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
G = g;
|
G = g;
|
||||||
Schema = GetStringCatInfo(g, "DBname", Schema);
|
Schema = GetStringCatInfo(g, "DBname", Schema);
|
||||||
Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT);
|
Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT);
|
||||||
Objname = GetStringCatInfo(g, "Object", NULL);
|
|
||||||
|
if ((Objname = GetStringCatInfo(g, "Object", NULL))) {
|
||||||
|
if (*Objname == '$') Objname++;
|
||||||
|
if (*Objname == '.') Objname++;
|
||||||
|
} // endif Objname
|
||||||
|
|
||||||
Xcol = GetStringCatInfo(g, "Expand", NULL);
|
Xcol = GetStringCatInfo(g, "Expand", NULL);
|
||||||
Pretty = GetIntCatInfo("Pretty", 2);
|
Pretty = GetIntCatInfo("Pretty", 2);
|
||||||
Limit = GetIntCatInfo("Limit", 10);
|
Limit = GetIntCatInfo("Limit", 50);
|
||||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||||
Sep = *GetStringCatInfo(g, "Separator", ".");
|
Sep = *GetStringCatInfo(g, "Separator", ".");
|
||||||
Accept = GetBoolCatInfo("Accept", false);
|
Accept = GetBoolCatInfo("Accept", false);
|
||||||
@@ -1171,7 +1209,7 @@ bool BSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
Collname = GetStringCatInfo(g, "Name",
|
Collname = GetStringCatInfo(g, "Name",
|
||||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||||
Collname = GetStringCatInfo(g, "Tabname", Collname);
|
Collname = GetStringCatInfo(g, "Tabname", Collname);
|
||||||
Options = GetStringCatInfo(g, "Colist", NULL);
|
Options = GetStringCatInfo(g, "Colist", Xcol ? "all" : NULL);
|
||||||
Filter = GetStringCatInfo(g, "Filter", NULL);
|
Filter = GetStringCatInfo(g, "Filter", NULL);
|
||||||
Pipe = GetBoolCatInfo("Pipeline", false);
|
Pipe = GetBoolCatInfo("Pipeline", false);
|
||||||
Driver = GetStringCatInfo(g, "Driver", NULL);
|
Driver = GetStringCatInfo(g, "Driver", NULL);
|
||||||
@@ -1215,7 +1253,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
|
|
||||||
if (Lrecl) {
|
if (Lrecl) {
|
||||||
// Allocate the parse work memory
|
// Allocate the parse work memory
|
||||||
G = PlugInit(NULL, (size_t)Lrecl * (Pretty < 0 ? 2 : 4));
|
G = PlugInit(NULL, (size_t)Lrecl * (Pretty < 0 ? 3 : 5));
|
||||||
} else {
|
} else {
|
||||||
strcpy(g->Message, "LRECL is not defined");
|
strcpy(g->Message, "LRECL is not defined");
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1249,6 +1287,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
#endif // !MONGO_SUPPORT
|
#endif // !MONGO_SUPPORT
|
||||||
} // endif Driver
|
} // endif Driver
|
||||||
|
|
||||||
|
Pretty = 4; // Not a file
|
||||||
} else if (Zipped) {
|
} else if (Zipped) {
|
||||||
#if defined(ZIP_SUPPORT)
|
#if defined(ZIP_SUPPORT)
|
||||||
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
||||||
@@ -1454,7 +1493,7 @@ int TDBBSN::EstimatedLength(void)
|
|||||||
} // end of Estimated Length
|
} // end of Estimated Length
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OpenDB: Data Base open routine for JSN access method. */
|
/* OpenDB: Data Base open routine for BSN access method. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBBSN::OpenDB(PGLOBAL g)
|
bool TDBBSN::OpenDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
@@ -1676,6 +1715,7 @@ BSONCOL::BSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
Xpd = false;
|
Xpd = false;
|
||||||
Parsed = false;
|
Parsed = false;
|
||||||
Warned = false;
|
Warned = false;
|
||||||
|
Sgfy = false;
|
||||||
} // end of BSONCOL constructor
|
} // end of BSONCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1695,6 +1735,7 @@ BSONCOL::BSONCOL(BSONCOL* col1, PTDB tdbp) : DOSCOL(col1, tdbp)
|
|||||||
Xpd = col1->Xpd;
|
Xpd = col1->Xpd;
|
||||||
Parsed = col1->Parsed;
|
Parsed = col1->Parsed;
|
||||||
Warned = col1->Warned;
|
Warned = col1->Warned;
|
||||||
|
Sgfy = col1->Sgfy;
|
||||||
} // end of BSONCOL copy constructor
|
} // end of BSONCOL copy constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1933,6 +1974,10 @@ bool BSONCOL::ParseJpath(PGLOBAL g)
|
|||||||
// Analyse intermediate array processing
|
// Analyse intermediate array processing
|
||||||
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
|
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
|
||||||
return true;
|
return true;
|
||||||
|
else if (Xpd && Tbp->Mode == MODE_DELETE) {
|
||||||
|
strcpy(g->Message, "Cannot delete expanded columns");
|
||||||
|
return true;
|
||||||
|
} // endif Xpd
|
||||||
|
|
||||||
} else if (*p == '*') {
|
} else if (*p == '*') {
|
||||||
// Return JSON
|
// Return JSON
|
||||||
@@ -1966,8 +2011,10 @@ PSZ BSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
if (*p1 == '$') p1++;
|
if (*p1 == '$') p1++;
|
||||||
if (*p1 == '.') p1++;
|
if (*p1 == '.') p1++;
|
||||||
mgopath = PlugDup(g, p1);
|
mgopath = PlugDup(g, p1);
|
||||||
} else
|
} else {
|
||||||
|
Sgfy = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
} // endif
|
||||||
|
|
||||||
for (p1 = p2 = mgopath; *p1; p1++)
|
for (p1 = p2 = mgopath; *p1; p1++)
|
||||||
if (i) { // Inside []
|
if (i) { // Inside []
|
||||||
@@ -2005,6 +2052,7 @@ PSZ BSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
case '*':
|
case '*':
|
||||||
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
||||||
p2--; // Suppress last :*
|
p2--; // Suppress last :*
|
||||||
|
Sgfy = true;
|
||||||
break;
|
break;
|
||||||
} // endif p2
|
} // endif p2
|
||||||
|
|
||||||
@@ -2013,6 +2061,9 @@ PSZ BSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
break;
|
break;
|
||||||
} // endswitch p1;
|
} // endswitch p1;
|
||||||
|
|
||||||
|
if (*(p2 - 1) == '.')
|
||||||
|
p2--;
|
||||||
|
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
return mgopath;
|
return mgopath;
|
||||||
} else
|
} else
|
||||||
@@ -2229,8 +2280,6 @@ int TDBBSON::MakeDocument(PGLOBAL g)
|
|||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
if ((objpath = PlugDup(g, Objname))) {
|
if ((objpath = PlugDup(g, Objname))) {
|
||||||
if (*objpath == '$') objpath++;
|
|
||||||
if (*objpath == '.') objpath++;
|
|
||||||
p1 = (*objpath == '[') ? objpath++ : NULL;
|
p1 = (*objpath == '[') ? objpath++ : NULL;
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*************** tabbson H Declares Source Code File (.H) **************/
|
/*************** tabbson H Declares Source Code File (.H) **************/
|
||||||
/* Name: tabbson.h Version 1.0 */
|
/* Name: tabbson.h Version 1.1 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2020 */
|
/* (C) Copyright to the author Olivier BERTRAND 2020 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the BSON classes declares. */
|
/* This file contains the BSON classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -242,7 +242,8 @@ public:
|
|||||||
BSONCOL(BSONCOL* colp, PTDB tdbp); // Constructor used in copy process
|
BSONCOL(BSONCOL* colp, PTDB tdbp); // Constructor used in copy process
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) { return Tbp->GetAmType(); }
|
virtual int GetAmType(void) { return Tbp->GetAmType(); }
|
||||||
|
virtual bool Stringify(void) { return Sgfy; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||||
@@ -270,6 +271,7 @@ protected:
|
|||||||
bool Xpd; // True for expandable column
|
bool Xpd; // True for expandable column
|
||||||
bool Parsed; // True when parsed
|
bool Parsed; // True when parsed
|
||||||
bool Warned; // True when warning issued
|
bool Warned; // True when warning issued
|
||||||
|
bool Sgfy; // True if stringified
|
||||||
}; // end of class BSONCOL
|
}; // end of class BSONCOL
|
||||||
|
|
||||||
/* -------------------------- TDBBSON class -------------------------- */
|
/* -------------------------- TDBBSON class -------------------------- */
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/************** tabcmg C++ Program Source Code File (.CPP) *************/
|
/************** tabcmg C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabcmg Version 1.1 */
|
/* PROGRAM NAME: tabcmg Version 1.3 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
||||||
/* This program are the C MongoDB class DB execution routines. */
|
/* This program are the C MongoDB class DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
|
||||||
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/* -------------------------- Class CMGDISC -------------------------- */
|
/* -------------------------- Class CMGDISC -------------------------- */
|
||||||
|
|
||||||
@@ -84,69 +85,80 @@ bool CMGDISC::FindInDoc(PGLOBAL g, bson_iter_t *iter, const bson_t *doc,
|
|||||||
|
|
||||||
bcol.Cbn = false;
|
bcol.Cbn = false;
|
||||||
|
|
||||||
if (BSON_ITER_HOLDS_UTF8(iter)) {
|
switch (bson_iter_type(iter)) {
|
||||||
bcol.Type = TYPE_STRING;
|
case BSON_TYPE_UTF8:
|
||||||
bcol.Len = strlen(bson_iter_utf8(iter, NULL));
|
|
||||||
} else if (BSON_ITER_HOLDS_INT32(iter)) {
|
|
||||||
bcol.Type = TYPE_INT;
|
|
||||||
bcol.Len = 11; // bson_iter_int32(iter)
|
|
||||||
} else if (BSON_ITER_HOLDS_INT64(iter)) {
|
|
||||||
bcol.Type = TYPE_BIGINT;
|
|
||||||
bcol.Len = 22; // bson_iter_int64(iter)
|
|
||||||
} else if (BSON_ITER_HOLDS_DOUBLE(iter)) {
|
|
||||||
bcol.Type = TYPE_DOUBLE;
|
|
||||||
bcol.Len = 12;
|
|
||||||
bcol.Scale = 6; // bson_iter_double(iter)
|
|
||||||
} else if (BSON_ITER_HOLDS_DATE_TIME(iter)) {
|
|
||||||
bcol.Type = TYPE_DATE;
|
|
||||||
bcol.Len = 19; // bson_iter_date_time(iter)
|
|
||||||
} else if (BSON_ITER_HOLDS_BOOL(iter)) {
|
|
||||||
bcol.Type = TYPE_TINY;
|
|
||||||
bcol.Len = 1;
|
|
||||||
} else if (BSON_ITER_HOLDS_OID(iter)) {
|
|
||||||
bcol.Type = TYPE_STRING;
|
|
||||||
bcol.Len = 24; // bson_iter_oid(iter)
|
|
||||||
} else if (BSON_ITER_HOLDS_DECIMAL128(iter)) {
|
|
||||||
bcol.Type = TYPE_DECIM;
|
|
||||||
bcol.Len = 32; // bson_iter_decimal128(iter, &dec)
|
|
||||||
} else if (BSON_ITER_HOLDS_DOCUMENT(iter)) {
|
|
||||||
if (lvl < 0)
|
|
||||||
continue;
|
|
||||||
else if (lvl <= k) {
|
|
||||||
bcol.Type = TYPE_STRING;
|
bcol.Type = TYPE_STRING;
|
||||||
bcol.Len = 512;
|
bcol.Len = strlen(bson_iter_utf8(iter, NULL));
|
||||||
} else {
|
break;
|
||||||
bson_iter_t child;
|
case BSON_TYPE_INT32:
|
||||||
|
bcol.Type = TYPE_INT;
|
||||||
|
bcol.Len = 11; // bson_iter_int32(iter)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_INT64:
|
||||||
|
bcol.Type = TYPE_BIGINT;
|
||||||
|
bcol.Len = 22; // bson_iter_int64(iter)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DOUBLE:
|
||||||
|
bcol.Type = TYPE_DOUBLE;
|
||||||
|
bcol.Len = 12;
|
||||||
|
bcol.Scale = 6; // bson_iter_double(iter)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DATE_TIME:
|
||||||
|
bcol.Type = TYPE_DATE;
|
||||||
|
bcol.Len = 19; // bson_iter_date_time(iter)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_BOOL:
|
||||||
|
bcol.Type = TYPE_TINY;
|
||||||
|
bcol.Len = 1;
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_OID:
|
||||||
|
bcol.Type = TYPE_STRING;
|
||||||
|
bcol.Len = 24; // bson_iter_oid(iter)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DECIMAL128:
|
||||||
|
bcol.Type = TYPE_DECIM;
|
||||||
|
bcol.Len = 32; // bson_iter_decimal128(iter, &dec)
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_DOCUMENT:
|
||||||
|
if (lvl < 0)
|
||||||
|
continue;
|
||||||
|
else if (lvl <= k) {
|
||||||
|
bcol.Type = TYPE_STRING;
|
||||||
|
bcol.Len = 512;
|
||||||
|
} else {
|
||||||
|
bson_iter_t child;
|
||||||
|
|
||||||
if (bson_iter_recurse(iter, &child))
|
if (bson_iter_recurse(iter, &child))
|
||||||
if (FindInDoc(g, &child, NULL, colname, fmt, k + 1, false))
|
if (FindInDoc(g, &child, NULL, colname, fmt, k + 1, false))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
newcol = false;
|
||||||
|
} // endif lvl
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BSON_TYPE_ARRAY:
|
||||||
|
if (lvl < 0)
|
||||||
|
continue;
|
||||||
|
else if (lvl <= k) {
|
||||||
|
bcol.Type = TYPE_STRING;
|
||||||
|
bcol.Len = 512;
|
||||||
|
} else {
|
||||||
|
bson_t* arr;
|
||||||
|
bson_iter_t itar;
|
||||||
|
const uint8_t* data = NULL;
|
||||||
|
uint32_t len = 0;
|
||||||
|
|
||||||
|
bson_iter_array(iter, &len, &data);
|
||||||
|
arr = bson_new_from_data(data, len);
|
||||||
|
|
||||||
|
if (FindInDoc(g, &itar, arr, colname, fmt, k + 1, !all))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
newcol = false;
|
newcol = false;
|
||||||
} // endif lvl
|
} // endif lvl
|
||||||
|
|
||||||
} else if (BSON_ITER_HOLDS_ARRAY(iter)) {
|
break;
|
||||||
if (lvl < 0)
|
} // endswitch iter
|
||||||
continue;
|
|
||||||
else if (lvl <= k) {
|
|
||||||
bcol.Type = TYPE_STRING;
|
|
||||||
bcol.Len = 512;
|
|
||||||
} else {
|
|
||||||
bson_t *arr;
|
|
||||||
bson_iter_t itar;
|
|
||||||
const uint8_t *data = NULL;
|
|
||||||
uint32_t len = 0;
|
|
||||||
|
|
||||||
bson_iter_array(iter, &len, &data);
|
|
||||||
arr = bson_new_from_data(data, len);
|
|
||||||
|
|
||||||
if (FindInDoc(g, &itar, arr, colname, fmt, k + 1, !all))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
newcol = false;
|
|
||||||
} // endif lvl
|
|
||||||
|
|
||||||
} // endif's
|
|
||||||
|
|
||||||
if (newcol)
|
if (newcol)
|
||||||
AddColumn(g, colname, fmt, k);
|
AddColumn(g, colname, fmt, k);
|
||||||
@@ -178,15 +190,19 @@ TDBCMG::TDBCMG(MGODEF *tdp) : TDBEXT(tdp)
|
|||||||
Pcg.Coll_name = tdp->Tabname;
|
Pcg.Coll_name = tdp->Tabname;
|
||||||
Pcg.Options = tdp->Colist;
|
Pcg.Options = tdp->Colist;
|
||||||
Pcg.Filter = tdp->Filter;
|
Pcg.Filter = tdp->Filter;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = tdp->Pipe && tdp->Colist != NULL;
|
Pcg.Pipe = tdp->Pipe && tdp->Colist != NULL;
|
||||||
B = tdp->Base ? 1 : 0;
|
B = tdp->Base ? 1 : 0;
|
||||||
|
Strfy = tdp->Strfy;
|
||||||
} else {
|
} else {
|
||||||
Pcg.Uristr = NULL;
|
Pcg.Uristr = NULL;
|
||||||
Pcg.Db_name = NULL;
|
Pcg.Db_name = NULL;
|
||||||
Pcg.Coll_name = NULL;
|
Pcg.Coll_name = NULL;
|
||||||
Pcg.Options = NULL;
|
Pcg.Options = NULL;
|
||||||
Pcg.Filter = NULL;
|
Pcg.Filter = NULL;
|
||||||
|
Pcg.Line = NULL;
|
||||||
Pcg.Pipe = false;
|
Pcg.Pipe = false;
|
||||||
|
Strfy = NULL;
|
||||||
B = 0;
|
B = 0;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
|
|
||||||
@@ -200,6 +216,7 @@ TDBCMG::TDBCMG(TDBCMG *tdbp) : TDBEXT(tdbp)
|
|||||||
Cmgp = tdbp->Cmgp;
|
Cmgp = tdbp->Cmgp;
|
||||||
Cnd = tdbp->Cnd;
|
Cnd = tdbp->Cnd;
|
||||||
Pcg = tdbp->Pcg;
|
Pcg = tdbp->Pcg;
|
||||||
|
Strfy = tdbp->Strfy;
|
||||||
B = tdbp->B;
|
B = tdbp->B;
|
||||||
Fpos = tdbp->Fpos;
|
Fpos = tdbp->Fpos;
|
||||||
N = tdbp->N;
|
N = tdbp->N;
|
||||||
@@ -381,7 +398,21 @@ MGOCOL::MGOCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
||||||
{
|
{
|
||||||
Tmgp = (PTDBCMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
Tmgp = (PTDBCMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
||||||
Jpath = cdp->GetFmt() ? cdp->GetFmt() : cdp->GetName();
|
Sgfy = Stringified(Tmgp->Strfy, Name);
|
||||||
|
|
||||||
|
if ((Jpath = cdp->GetFmt())) {
|
||||||
|
int n = strlen(Jpath) - 1;
|
||||||
|
|
||||||
|
if (Jpath[n] == '*') {
|
||||||
|
Jpath = PlugDup(g, cdp->GetFmt());
|
||||||
|
if (Jpath[n - 1] == '.') n--;
|
||||||
|
Jpath[n] = 0;
|
||||||
|
Sgfy = true;
|
||||||
|
} // endif Jpath
|
||||||
|
|
||||||
|
} else
|
||||||
|
Jpath = cdp->GetName();
|
||||||
|
|
||||||
} // end of MGOCOL constructor
|
} // end of MGOCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -392,6 +423,7 @@ MGOCOL::MGOCOL(MGOCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
|||||||
{
|
{
|
||||||
Tmgp = col1->Tmgp;
|
Tmgp = col1->Tmgp;
|
||||||
Jpath = col1->Jpath;
|
Jpath = col1->Jpath;
|
||||||
|
Sgfy = col1->Sgfy;
|
||||||
} // end of MGOCOL copy constructor
|
} // end of MGOCOL copy constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -419,6 +451,9 @@ PSZ MGOCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
} else
|
} else
|
||||||
*p2++ = *p1;
|
*p2++ = *p1;
|
||||||
|
|
||||||
|
if (*(p2 - 1) == '.')
|
||||||
|
p2--;
|
||||||
|
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
return projpath;
|
return projpath;
|
||||||
} else
|
} else
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/**************** tabcmg H Declares Source Code File (.H) **************/
|
/**************** tabcmg H Declares Source Code File (.H) **************/
|
||||||
/* Name: tabcmg.h Version 1.2 */
|
/* Name: tabcmg.h Version 1.3 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the MongoDB classes declares. */
|
/* This file contains the MongoDB classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -75,6 +75,7 @@ protected:
|
|||||||
CMgoConn *Cmgp; // Points to a C Mongo connection class
|
CMgoConn *Cmgp; // Points to a C Mongo connection class
|
||||||
CMGOPARM Pcg; // Parms passed to Cmgp
|
CMGOPARM Pcg; // Parms passed to Cmgp
|
||||||
const Item *Cnd; // The first condition
|
const Item *Cnd; // The first condition
|
||||||
|
PCSZ Strfy; // The stringified columns
|
||||||
int Fpos; // The current row index
|
int Fpos; // The current row index
|
||||||
int N; // The current Rownum
|
int N; // The current Rownum
|
||||||
int B; // Array index base
|
int B; // Array index base
|
||||||
@@ -96,6 +97,7 @@ public:
|
|||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) { return Tmgp->GetAmType(); }
|
virtual int GetAmType(void) { return Tmgp->GetAmType(); }
|
||||||
|
virtual bool Stringify(void) { return Sgfy; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual PSZ GetJpath(PGLOBAL g, bool proj);
|
virtual PSZ GetJpath(PGLOBAL g, bool proj);
|
||||||
@@ -109,6 +111,7 @@ protected:
|
|||||||
// Members
|
// Members
|
||||||
TDBCMG *Tmgp; // To the MGO table block
|
TDBCMG *Tmgp; // To the MGO table block
|
||||||
char *Jpath; // The json path
|
char *Jpath; // The json path
|
||||||
|
bool Sgfy; // True if stringified
|
||||||
}; // end of class MGOCOL
|
}; // end of class MGOCOL
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <sys\timeb.h> // For testing only
|
#include <sys\timeb.h> // For testing only
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -233,11 +233,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g)
|
|||||||
|
|
||||||
// Delete any eventually ill formed non matching optimization file
|
// Delete any eventually ill formed non matching optimization file
|
||||||
if (!GetOptFileName(g, filename))
|
if (!GetOptFileName(g, filename))
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
DeleteFile(filename);
|
DeleteFile(filename);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
remove(filename);
|
remove(filename);
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
Optimized = 0;
|
Optimized = 0;
|
||||||
} // end of RemoveOptValues
|
} // end of RemoveOptValues
|
||||||
@@ -279,7 +279,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (sep) {
|
if (sep) {
|
||||||
// Indexes are save in separate files
|
// Indexes are save in separate files
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char drive[_MAX_DRIVE];
|
char drive[_MAX_DRIVE];
|
||||||
#else
|
#else
|
||||||
char *drive = NULL;
|
char *drive = NULL;
|
||||||
@@ -296,7 +296,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
|
|||||||
strcat(strcat(fname, "_"), pxdf->GetName());
|
strcat(strcat(fname, "_"), pxdf->GetName());
|
||||||
_makepath(filename, drive, direc, fname, ftype);
|
_makepath(filename, drive, direc, fname, ftype);
|
||||||
PlugSetPath(filename, filename, GetPath());
|
PlugSetPath(filename, filename, GetPath());
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (!DeleteFile(filename))
|
if (!DeleteFile(filename))
|
||||||
rc |= (GetLastError() != ERROR_FILE_NOT_FOUND);
|
rc |= (GetLastError() != ERROR_FILE_NOT_FOUND);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
@@ -313,7 +313,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
|
|||||||
// Drop all indexes, delete the common file
|
// Drop all indexes, delete the common file
|
||||||
PlugSetPath(filename, Ofn, GetPath());
|
PlugSetPath(filename, Ofn, GetPath());
|
||||||
strcat(PlugRemoveType(filename, filename), ftype);
|
strcat(PlugRemoveType(filename, filename), ftype);
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (!DeleteFile(filename))
|
if (!DeleteFile(filename))
|
||||||
rc = (GetLastError() != ERROR_FILE_NOT_FOUND);
|
rc = (GetLastError() != ERROR_FILE_NOT_FOUND);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
@@ -1026,7 +1026,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
|
|||||||
#if 0
|
#if 0
|
||||||
if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS)
|
if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS)
|
||||||
return false;
|
return false;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
if (defp->Optimized || !(dup->Check & CHK_OPT))
|
if (defp->Optimized || !(dup->Check & CHK_OPT))
|
||||||
return false; // Already done or to be redone
|
return false; // Already done or to be redone
|
||||||
@@ -2535,6 +2535,7 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
int field;
|
int field;
|
||||||
|
bool err = false;
|
||||||
double dval;
|
double dval;
|
||||||
PTDBDOS tdbp = (PTDBDOS)To_Tdb;
|
PTDBDOS tdbp = (PTDBDOS)To_Tdb;
|
||||||
|
|
||||||
@@ -2578,33 +2579,39 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
case TYPE_SHORT:
|
case TYPE_SHORT:
|
||||||
case TYPE_TINY:
|
case TYPE_TINY:
|
||||||
case TYPE_BIGINT:
|
case TYPE_BIGINT:
|
||||||
if (Value->SetValue_char(p, field - Dcm)) {
|
err = Value->SetValue_char(p, field - Dcm);
|
||||||
sprintf(g->Message, "Out of range value for column %s at row %d",
|
|
||||||
Name, tdbp->RowNumber(g));
|
|
||||||
PushWarning(g, tdbp);
|
|
||||||
} // endif SetValue_char
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
Value->SetValue_char(p, field);
|
if (!(err = Value->SetValue_char(p, field))) {
|
||||||
dval = Value->GetFloatValue();
|
dval = Value->GetFloatValue();
|
||||||
|
|
||||||
for (i = 0; i < Dcm; i++)
|
for (i = 0; i < Dcm; i++)
|
||||||
dval /= 10.0;
|
dval /= 10.0;
|
||||||
|
|
||||||
|
Value->SetValue(dval);
|
||||||
|
} // endif err
|
||||||
|
|
||||||
Value->SetValue(dval);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Value->SetValue_char(p, field);
|
err = Value->SetValue_char(p, field);
|
||||||
|
|
||||||
|
if (!err && Buf_Type == TYPE_DECIM) {
|
||||||
|
char* s = Value->GetCharValue();
|
||||||
|
|
||||||
|
if (!(err = ((i = strlen(s)) >= Value->GetClen()))) {
|
||||||
|
for (int d = Dcm + 1; d; i--, d--)
|
||||||
|
s[i + 1] = s[i];
|
||||||
|
|
||||||
|
s[i + 1] = '.';
|
||||||
|
} // endif err
|
||||||
|
|
||||||
|
} // endif DECIM
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} // endswitch Buf_Type
|
} // endswitch Buf_Type
|
||||||
|
|
||||||
else
|
else
|
||||||
if (Value->SetValue_char(p, field)) {
|
err = Value->SetValue_char(p, field);
|
||||||
sprintf(g->Message, "Out of range value for column %s at row %d",
|
|
||||||
Name, tdbp->RowNumber(g));
|
|
||||||
PushWarning(g, tdbp);
|
|
||||||
} // endif SetValue_char
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2612,6 +2619,12 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
throw 34;
|
throw 34;
|
||||||
} // endswitch Ftype
|
} // endswitch Ftype
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
sprintf(g->Message, "Out of range value for column %s at row %d",
|
||||||
|
Name, tdbp->RowNumber(g));
|
||||||
|
PushWarning(g, tdbp);
|
||||||
|
} // endif err
|
||||||
|
|
||||||
// Set null when applicable
|
// Set null when applicable
|
||||||
if (Nullable)
|
if (Nullable)
|
||||||
Value->SetNull(Value->IsZero());
|
Value->SetNull(Value->IsZero());
|
||||||
@@ -2702,7 +2715,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
|||||||
case TYPE_DECIM:
|
case TYPE_DECIM:
|
||||||
strcpy(fmt, (Ldz) ? "%0*.*lf" : "%*.*lf");
|
strcpy(fmt, (Ldz) ? "%0*.*lf" : "%*.*lf");
|
||||||
len = field + ((Nod && Dcm) ? 1 : 0);
|
len = field + ((Nod && Dcm) ? 1 : 0);
|
||||||
snprintf(Buf, len, fmt, len, Dcm, Value->GetFloatValue());
|
snprintf(Buf, len + 1, fmt, len, Dcm, Value->GetFloatValue());
|
||||||
len = strlen(Buf);
|
len = strlen(Buf);
|
||||||
|
|
||||||
if (Nod && Dcm)
|
if (Nod && Dcm)
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
#include "sql_servers.h"
|
#include "sql_servers.h"
|
||||||
#include "sql_string.h"
|
#include "sql_string.h"
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/* Include relevant section of system dependant header files. */
|
/* Include relevant section of system dependant header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -156,14 +156,14 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
|
|||||||
p = (char*)GetStringTableOption(g, topt, "Separator", ",");
|
p = (char*)GetStringTableOption(g, topt, "Separator", ",");
|
||||||
tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p;
|
tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (tdp->Sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
|
if (tdp->Sep == ',' || strnicmp(setlocale(LC_NUMERIC, NULL), "French", 6))
|
||||||
dechar = '.';
|
dechar = '.';
|
||||||
else
|
else
|
||||||
dechar = ',';
|
dechar = ',';
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
dechar = '.';
|
dechar = '.';
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
sep = tdp->Sep;
|
sep = tdp->Sep;
|
||||||
tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1);
|
tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1);
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
#include "sql_servers.h"
|
#include "sql_servers.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@@ -188,6 +188,9 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b)
|
|||||||
} else // host is a URL
|
} else // host is a URL
|
||||||
Url = PlugDup(g, server->host);
|
Url = PlugDup(g, server->host);
|
||||||
|
|
||||||
|
if (!Tabschema && server->db)
|
||||||
|
Tabschema = PlugDup(g, server->db);
|
||||||
|
|
||||||
if (!Username && server->username)
|
if (!Username && server->username)
|
||||||
Username = PlugDup(g, server->username);
|
Username = PlugDup(g, server->username);
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/************** tabjmg C++ Program Source Code File (.CPP) *************/
|
/************** tabjmg C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabjmg Version 1.2 */
|
/* PROGRAM NAME: tabjmg Version 1.3 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2021 */
|
||||||
/* This file contains the MongoDB classes using the Java Driver. */
|
/* This file contains the MongoDB classes using the Java Driver. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
|
|
||||||
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/* -------------------------- Class JMGDISC -------------------------- */
|
/* -------------------------- Class JMGDISC -------------------------- */
|
||||||
|
|
||||||
@@ -166,6 +167,7 @@ TDBJMG::TDBJMG(PMGODEF tdp) : TDBEXT(tdp)
|
|||||||
Coll_name = tdp->Tabname;
|
Coll_name = tdp->Tabname;
|
||||||
Options = tdp->Colist;
|
Options = tdp->Colist;
|
||||||
Filter = tdp->Filter;
|
Filter = tdp->Filter;
|
||||||
|
Strfy = tdp->Strfy;
|
||||||
B = tdp->Base ? 1 : 0;
|
B = tdp->Base ? 1 : 0;
|
||||||
Pipe = tdp->Pipe && Options != NULL;
|
Pipe = tdp->Pipe && Options != NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -177,6 +179,7 @@ TDBJMG::TDBJMG(PMGODEF tdp) : TDBEXT(tdp)
|
|||||||
Coll_name = NULL;
|
Coll_name = NULL;
|
||||||
Options = NULL;
|
Options = NULL;
|
||||||
Filter = NULL;
|
Filter = NULL;
|
||||||
|
Strfy = NULL;
|
||||||
B = 0;
|
B = 0;
|
||||||
Pipe = false;
|
Pipe = false;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
@@ -197,6 +200,7 @@ TDBJMG::TDBJMG(TDBJMG *tdbp) : TDBEXT(tdbp)
|
|||||||
Coll_name = tdbp->Coll_name;
|
Coll_name = tdbp->Coll_name;
|
||||||
Options = tdbp->Options;
|
Options = tdbp->Options;
|
||||||
Filter = tdbp->Filter;
|
Filter = tdbp->Filter;
|
||||||
|
Strfy = tdbp->Strfy;
|
||||||
B = tdbp->B;
|
B = tdbp->B;
|
||||||
Fpos = tdbp->Fpos;
|
Fpos = tdbp->Fpos;
|
||||||
N = tdbp->N;
|
N = tdbp->N;
|
||||||
@@ -384,7 +388,7 @@ int TDBJMG::WriteDB(PGLOBAL g)
|
|||||||
int rc = RC_OK;
|
int rc = RC_OK;
|
||||||
|
|
||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
rc = Jcp->DocWrite(g);
|
rc = Jcp->DocWrite(g, NULL);
|
||||||
} else if (Mode == MODE_DELETE) {
|
} else if (Mode == MODE_DELETE) {
|
||||||
rc = Jcp->DocDelete(g, false);
|
rc = Jcp->DocDelete(g, false);
|
||||||
} else if (Mode == MODE_UPDATE) {
|
} else if (Mode == MODE_UPDATE) {
|
||||||
@@ -420,8 +424,25 @@ JMGCOL::JMGCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
||||||
{
|
{
|
||||||
Tmgp = (PTDBJMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
Tmgp = (PTDBJMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
||||||
Jpath = cdp->GetFmt() ? cdp->GetFmt() : cdp->GetName();
|
Sgfy = Stringified(Tmgp->Strfy, Name);
|
||||||
//Mbuf = NULL;
|
|
||||||
|
if ((Jpath = cdp->GetFmt())) {
|
||||||
|
int n = strlen(Jpath);
|
||||||
|
|
||||||
|
if (n && Jpath[n - 1] == '*') {
|
||||||
|
Jpath = PlugDup(g, cdp->GetFmt());
|
||||||
|
|
||||||
|
if (--n) {
|
||||||
|
if (Jpath[n - 1] == '.') n--;
|
||||||
|
Jpath[n] = 0;
|
||||||
|
} // endif n
|
||||||
|
|
||||||
|
Sgfy = true;
|
||||||
|
} // endif Jpath
|
||||||
|
|
||||||
|
} else
|
||||||
|
Jpath = cdp->GetName();
|
||||||
|
|
||||||
} // end of JMGCOL constructor
|
} // end of JMGCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -432,7 +453,7 @@ JMGCOL::JMGCOL(JMGCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
|||||||
{
|
{
|
||||||
Tmgp = col1->Tmgp;
|
Tmgp = col1->Tmgp;
|
||||||
Jpath = col1->Jpath;
|
Jpath = col1->Jpath;
|
||||||
//Mbuf = col1->Mbuf;
|
Sgfy = col1->Sgfy;
|
||||||
} // end of JMGCOL copy constructor
|
} // end of JMGCOL copy constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -442,7 +463,7 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
{
|
{
|
||||||
if (Jpath) {
|
if (Jpath) {
|
||||||
if (proj) {
|
if (proj) {
|
||||||
char *p1, *p2, *projpath = PlugDup(g, Jpath);
|
char* p1, * p2, * projpath = PlugDup(g, Jpath);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (p1 = p2 = projpath; *p1; p1++)
|
for (p1 = p2 = projpath; *p1; p1++)
|
||||||
@@ -460,6 +481,9 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
} else
|
} else
|
||||||
*p2++ = *p1;
|
*p2++ = *p1;
|
||||||
|
|
||||||
|
if (*(p2 - 1) == '.')
|
||||||
|
p2--;
|
||||||
|
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
return projpath;
|
return projpath;
|
||||||
} else
|
} else
|
||||||
@@ -489,6 +513,7 @@ char *JMGCOL::Mini(PGLOBAL g, const bson_t *bson, bool b)
|
|||||||
switch (s[i]) {
|
switch (s[i]) {
|
||||||
case ' ':
|
case ' ':
|
||||||
if (ok) continue;
|
if (ok) continue;
|
||||||
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
ok = !ok;
|
ok = !ok;
|
||||||
default:
|
default:
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/**************** tabjmg H Declares Source Code File (.H) **************/
|
/**************** tabjmg H Declares Source Code File (.H) **************/
|
||||||
/* Name: tabjmg.h Version 1.1 */
|
/* Name: tabjmg.h Version 1.3 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the MongoDB classes using the Java Driver. */
|
/* This file contains the MongoDB classes using the Java Driver. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -83,6 +83,7 @@ protected:
|
|||||||
PCSZ Coll_name;
|
PCSZ Coll_name;
|
||||||
PCSZ Options; // The MongoDB options
|
PCSZ Options; // The MongoDB options
|
||||||
PCSZ Filter; // The filtering query
|
PCSZ Filter; // The filtering query
|
||||||
|
PCSZ Strfy; // The stringified columns
|
||||||
PSZ Wrapname; // Java wrapper name
|
PSZ Wrapname; // Java wrapper name
|
||||||
int Fpos; // The current row index
|
int Fpos; // The current row index
|
||||||
int N; // The current Rownum
|
int N; // The current Rownum
|
||||||
@@ -106,6 +107,7 @@ public:
|
|||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) {return Tmgp->GetAmType();}
|
virtual int GetAmType(void) {return Tmgp->GetAmType();}
|
||||||
|
virtual bool Stringify(void) { return Sgfy; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||||
@@ -123,7 +125,7 @@ protected:
|
|||||||
// Members
|
// Members
|
||||||
TDBJMG *Tmgp; // To the MGO table block
|
TDBJMG *Tmgp; // To the MGO table block
|
||||||
char *Jpath; // The json path
|
char *Jpath; // The json path
|
||||||
//char *Mbuf; // The Mini buffer
|
bool Sgfy; // True if stringified
|
||||||
}; // end of class JMGCOL
|
}; // end of class JMGCOL
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabjson Version 1.8 */
|
/* PROGRAM NAME: tabjson Version 1.9 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2021 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2021 */
|
||||||
/* This program are the JSON class DB execution routines. */
|
/* This program are the JSON class DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -58,6 +58,7 @@ USETEMP UseTemp(void);
|
|||||||
bool JsonAllPath(void);
|
bool JsonAllPath(void);
|
||||||
int GetDefaultDepth(void);
|
int GetDefaultDepth(void);
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* JSONColumns: construct the result blocks containing the description */
|
/* JSONColumns: construct the result blocks containing the description */
|
||||||
@@ -178,8 +179,8 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
||||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||||
strfy = GetStringTableOption(g, topt, "Stringify", NULL);
|
strfy = GetStringTableOption(g, topt, "Stringify", NULL);
|
||||||
sz = GetIntegerTableOption(g, topt, "Jsize", 250);
|
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
||||||
limit = GetIntegerTableOption(g, topt, "Limit", 10);
|
limit = GetIntegerTableOption(g, topt, "Limit", 50);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Open the input file. */
|
/* Open the input file. */
|
||||||
@@ -191,13 +192,19 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
#endif // ZIP_SUPPORT
|
#endif // ZIP_SUPPORT
|
||||||
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||||
|
|
||||||
if (!tdp->Fn && topt->http)
|
if (!tdp->Fn && topt->http) {
|
||||||
tdp->Fn = GetStringTableOption(g, topt, "Subtype", NULL);
|
tdp->Fn = GetStringTableOption(g, topt, "Subtype", NULL);
|
||||||
|
topt->subtype = NULL;
|
||||||
|
} // endif fn
|
||||||
|
|
||||||
if (!(tdp->Database = SetPath(g, db)))
|
if (!(tdp->Database = SetPath(g, db)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
if ((tdp->Objname = GetStringTableOption(g, topt, "Object", NULL))) {
|
||||||
|
if (*tdp->Objname == '$') tdp->Objname++;
|
||||||
|
if (*tdp->Objname == '.') tdp->Objname++;
|
||||||
|
} // endif Objname
|
||||||
|
|
||||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||||
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
||||||
tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL);
|
tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL);
|
||||||
@@ -222,8 +229,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
|
|
||||||
if (tdp->Uri) {
|
if (tdp->Uri) {
|
||||||
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
||||||
tdp->Collname = GetStringTableOption(g, topt, "Name", NULL);
|
tdp->Collname = GetStringTableOption(g, topt, "Tabname", NULL);
|
||||||
tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname);
|
|
||||||
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test");
|
||||||
tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all");
|
tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all");
|
||||||
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false);
|
||||||
@@ -442,7 +448,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||||||
jcol.Type = TYPE_UNKNOWN;
|
jcol.Type = TYPE_UNKNOWN;
|
||||||
jcol.Len = jcol.Scale = 0;
|
jcol.Len = jcol.Scale = 0;
|
||||||
jcol.Cbn = true;
|
jcol.Cbn = true;
|
||||||
} else if (j < lvl && !(strfy && !stricmp(strfy, colname))) {
|
} else if (j < lvl && !Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -512,7 +518,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
|
||||||
} else if (lvl >= 0) {
|
} else if (lvl >= 0) {
|
||||||
if (strfy && !stricmp(strfy, colname)) {
|
if (Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -633,10 +639,15 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
{
|
{
|
||||||
Schema = GetStringCatInfo(g, "DBname", Schema);
|
Schema = GetStringCatInfo(g, "DBname", Schema);
|
||||||
Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT);
|
Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT);
|
||||||
Objname = GetStringCatInfo(g, "Object", NULL);
|
|
||||||
|
if ((Objname = GetStringCatInfo(g, "Object", NULL))) {
|
||||||
|
if (*Objname == '$') Objname++;
|
||||||
|
if (*Objname == '.') Objname++;
|
||||||
|
} // endif Objname
|
||||||
|
|
||||||
Xcol = GetStringCatInfo(g, "Expand", NULL);
|
Xcol = GetStringCatInfo(g, "Expand", NULL);
|
||||||
Pretty = GetIntCatInfo("Pretty", 2);
|
Pretty = GetIntCatInfo("Pretty", 2);
|
||||||
Limit = GetIntCatInfo("Limit", 10);
|
Limit = GetIntCatInfo("Limit", 50);
|
||||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||||
Sep = *GetStringCatInfo(g, "Separator", ".");
|
Sep = *GetStringCatInfo(g, "Separator", ".");
|
||||||
Accept = GetBoolCatInfo("Accept", false);
|
Accept = GetBoolCatInfo("Accept", false);
|
||||||
@@ -647,7 +658,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
Collname = GetStringCatInfo(g, "Name",
|
Collname = GetStringCatInfo(g, "Name",
|
||||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||||
Collname = GetStringCatInfo(g, "Tabname", Collname);
|
Collname = GetStringCatInfo(g, "Tabname", Collname);
|
||||||
Options = GetStringCatInfo(g, "Colist", NULL);
|
Options = GetStringCatInfo(g, "Colist", Xcol ? "all" : NULL);
|
||||||
Filter = GetStringCatInfo(g, "Filter", NULL);
|
Filter = GetStringCatInfo(g, "Filter", NULL);
|
||||||
Pipe = GetBoolCatInfo("Pipeline", false);
|
Pipe = GetBoolCatInfo("Pipeline", false);
|
||||||
Driver = GetStringCatInfo(g, "Driver", NULL);
|
Driver = GetStringCatInfo(g, "Driver", NULL);
|
||||||
@@ -716,6 +727,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
#endif // !MONGO_SUPPORT
|
#endif // !MONGO_SUPPORT
|
||||||
} // endif Driver
|
} // endif Driver
|
||||||
|
|
||||||
|
Pretty = 4; // Not a file
|
||||||
} else if (Zipped) {
|
} else if (Zipped) {
|
||||||
#if defined(ZIP_SUPPORT)
|
#if defined(ZIP_SUPPORT)
|
||||||
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
||||||
@@ -761,7 +773,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
G->jump_level = 0;
|
G->jump_level = 0;
|
||||||
((TDBJSN*)tdbp)->G = G;
|
((TDBJSN*)tdbp)->G = G;
|
||||||
#endif // 0
|
#endif // 0
|
||||||
((TDBJSN*)tdbp)->G = PlugInit(NULL, (size_t)Lrecl * (Pretty >= 0 ? 10 : 2));
|
((TDBJSN*)tdbp)->G = PlugInit(NULL, (size_t)Lrecl * (Pretty >= 0 ? 12 : 4));
|
||||||
} else {
|
} else {
|
||||||
strcpy(g->Message, "LRECL is not defined");
|
strcpy(g->Message, "LRECL is not defined");
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -950,23 +962,29 @@ int TDBJSN::EstimatedLength(void)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PJSON TDBJSN::FindRow(PGLOBAL g)
|
PJSON TDBJSN::FindRow(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *p, *objpath;
|
char *p, *objpath = PlugDup(g, Objname);
|
||||||
|
char *sep = (char*)(Sep == ':' ? ":[" : ".[");
|
||||||
|
bool bp = false, b = false;
|
||||||
PJSON jsp = Row;
|
PJSON jsp = Row;
|
||||||
PJVAL val = NULL;
|
PJVAL val = NULL;
|
||||||
|
|
||||||
for (objpath = PlugDup(g, Objname); jsp && objpath; objpath = p) {
|
for (; jsp && objpath; objpath = p, bp = b) {
|
||||||
if ((p = strchr(objpath, Sep)))
|
if ((p = strpbrk(objpath + 1, sep))) {
|
||||||
|
b = (*p == '[');
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
} // endif p
|
||||||
|
|
||||||
if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
if (!bp && *objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
||||||
val = (jsp->GetType() == TYPE_JOB) ?
|
val = (jsp->GetType() == TYPE_JOB) ?
|
||||||
jsp->GetObject()->GetKeyValue(objpath) : NULL;
|
jsp->GetObject()->GetKeyValue(objpath) : NULL;
|
||||||
} else {
|
} else {
|
||||||
if (*objpath == '[') {
|
if (bp || *objpath == '[') {
|
||||||
if (objpath[strlen(objpath) - 1] == ']')
|
if (objpath[strlen(objpath) - 1] != ']') {
|
||||||
objpath++;
|
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||||
else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
} else if (!bp)
|
||||||
|
objpath++;
|
||||||
|
|
||||||
} // endif [
|
} // endif [
|
||||||
|
|
||||||
val = (jsp->GetType() == TYPE_JAR) ?
|
val = (jsp->GetType() == TYPE_JAR) ?
|
||||||
@@ -976,6 +994,18 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
|
|||||||
jsp = (val) ? val->GetJson() : NULL;
|
jsp = (val) ? val->GetJson() : NULL;
|
||||||
} // endfor objpath
|
} // endfor objpath
|
||||||
|
|
||||||
|
if (jsp && jsp->GetType() != TYPE_JOB) {
|
||||||
|
if (jsp->GetType() == TYPE_JAR) {
|
||||||
|
jsp = jsp->GetArray()->GetArrayValue(B);
|
||||||
|
|
||||||
|
if (jsp->GetType() != TYPE_JOB)
|
||||||
|
jsp = NULL;
|
||||||
|
|
||||||
|
} else
|
||||||
|
jsp = NULL;
|
||||||
|
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
return jsp;
|
return jsp;
|
||||||
} // end of FindRow
|
} // end of FindRow
|
||||||
|
|
||||||
@@ -1144,25 +1174,28 @@ int TDBJSN::ReadDB(PGLOBAL g) {
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Make the top tree from the object path. */
|
/* Make the top tree from the object path. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
bool TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
||||||
{
|
{
|
||||||
if (Objname) {
|
if (Objname) {
|
||||||
if (!Val) {
|
if (!Val) {
|
||||||
// Parse and allocate Objname item(s)
|
// Parse and allocate Objname item(s)
|
||||||
char *p;
|
char *p, *objpath = PlugDup(g, Objname);
|
||||||
char *objpath = PlugDup(g, Objname);
|
char *sep = (char*)(Sep == ':' ? ":[" : ".[");
|
||||||
int i;
|
int i;
|
||||||
|
bool bp = false, b = false;
|
||||||
PJOB objp;
|
PJOB objp;
|
||||||
PJAR arp;
|
PJAR arp;
|
||||||
PJVAL val = NULL;
|
PJVAL val = NULL;
|
||||||
|
|
||||||
Top = NULL;
|
Top = NULL;
|
||||||
|
|
||||||
for (; objpath; objpath = p) {
|
for (; objpath; objpath = p, bp = b) {
|
||||||
if ((p = strchr(objpath, Sep)))
|
if ((p = strpbrk(objpath + 1, sep))) {
|
||||||
|
b = (*p == '[');
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
} // endif p
|
||||||
|
|
||||||
if (*objpath != '[' && !IsNum(objpath)) {
|
if (!bp && *objpath != '[' && !IsNum(objpath)) {
|
||||||
objp = new(g) JOBJECT;
|
objp = new(g) JOBJECT;
|
||||||
|
|
||||||
if (!Top)
|
if (!Top)
|
||||||
@@ -1174,15 +1207,15 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
|||||||
val = new(g) JVALUE;
|
val = new(g) JVALUE;
|
||||||
objp->SetKeyValue(g, val, objpath);
|
objp->SetKeyValue(g, val, objpath);
|
||||||
} else {
|
} else {
|
||||||
if (*objpath == '[') {
|
if (bp || *objpath == '[') {
|
||||||
// Old style
|
// Old style
|
||||||
if (objpath[strlen(objpath) - 1] != ']') {
|
if (objpath[strlen(objpath) - 1] != ']') {
|
||||||
sprintf(g->Message, "Invalid Table path %s", Objname);
|
sprintf(g->Message, "Invalid Table path %s", Objname);
|
||||||
return RC_FX;
|
return true;
|
||||||
} else
|
} else if (!bp)
|
||||||
objpath++;
|
objpath++;
|
||||||
|
|
||||||
} // endif objpath
|
} // endif bp
|
||||||
|
|
||||||
arp = new(g) JARRAY;
|
arp = new(g) JARRAY;
|
||||||
|
|
||||||
@@ -1207,7 +1240,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
|||||||
} else
|
} else
|
||||||
Top = jsp;
|
Top = jsp;
|
||||||
|
|
||||||
return RC_OK;
|
return false;
|
||||||
} // end of MakeTopTree
|
} // end of MakeTopTree
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1277,6 +1310,7 @@ JSONCOL::JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
Xpd = false;
|
Xpd = false;
|
||||||
Parsed = false;
|
Parsed = false;
|
||||||
Warned = false;
|
Warned = false;
|
||||||
|
Sgfy = false;
|
||||||
} // end of JSONCOL constructor
|
} // end of JSONCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1296,6 +1330,7 @@ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
|
|||||||
Xpd = col1->Xpd;
|
Xpd = col1->Xpd;
|
||||||
Parsed = col1->Parsed;
|
Parsed = col1->Parsed;
|
||||||
Warned = col1->Warned;
|
Warned = col1->Warned;
|
||||||
|
Sgfy = col1->Sgfy;
|
||||||
} // end of JSONCOL copy constructor
|
} // end of JSONCOL copy constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1535,6 +1570,10 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
|
|||||||
// Analyse intermediate array processing
|
// Analyse intermediate array processing
|
||||||
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
|
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
|
||||||
return true;
|
return true;
|
||||||
|
else if (Xpd && Tjp->Mode == MODE_DELETE) {
|
||||||
|
strcpy(g->Message, "Cannot delete expanded columns");
|
||||||
|
return true;
|
||||||
|
} // endif Xpd
|
||||||
|
|
||||||
} else if (*p == '*') {
|
} else if (*p == '*') {
|
||||||
// Return JSON
|
// Return JSON
|
||||||
@@ -1568,8 +1607,10 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
if (*p1 == '$') p1++;
|
if (*p1 == '$') p1++;
|
||||||
if (*p1 == '.') p1++;
|
if (*p1 == '.') p1++;
|
||||||
mgopath = PlugDup(g, p1);
|
mgopath = PlugDup(g, p1);
|
||||||
} else
|
} else {
|
||||||
|
Sgfy = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
} // endif
|
||||||
|
|
||||||
for (p1 = p2 = mgopath; *p1; p1++)
|
for (p1 = p2 = mgopath; *p1; p1++)
|
||||||
if (i) { // Inside []
|
if (i) { // Inside []
|
||||||
@@ -1607,6 +1648,7 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
case '*':
|
case '*':
|
||||||
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
||||||
p2--; // Suppress last :*
|
p2--; // Suppress last :*
|
||||||
|
Sgfy = true;
|
||||||
break;
|
break;
|
||||||
} // endif p2
|
} // endif p2
|
||||||
|
|
||||||
@@ -1615,6 +1657,9 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
|||||||
break;
|
break;
|
||||||
} // endswitch p1;
|
} // endswitch p1;
|
||||||
|
|
||||||
|
if (*(p2 - 1) == '.')
|
||||||
|
p2--;
|
||||||
|
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
return mgopath;
|
return mgopath;
|
||||||
} else
|
} else
|
||||||
@@ -1744,10 +1789,16 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL jvp)
|
|||||||
break;
|
break;
|
||||||
case TYPE_DATE:
|
case TYPE_DATE:
|
||||||
if (jvp->GetValType() == TYPE_STRG) {
|
if (jvp->GetValType() == TYPE_STRG) {
|
||||||
if (!((DTVAL*)vp)->IsFormatted())
|
PSZ dat = jvp->GetString(g);
|
||||||
((DTVAL*)vp)->SetFormat(g, "YYYY-MM-DDThh:mm:ssZ", 20, 0);
|
|
||||||
|
if (!IsNum(dat)) {
|
||||||
|
if (!((DTVAL*)vp)->IsFormatted())
|
||||||
|
((DTVAL*)vp)->SetFormat(g, "YYYY-MM-DDThh:mm:ssZ", 20, 0);
|
||||||
|
|
||||||
|
vp->SetValue_psz(dat);
|
||||||
|
} else
|
||||||
|
vp->SetValue(atoi(dat));
|
||||||
|
|
||||||
vp->SetValue_psz(jvp->GetString(g));
|
|
||||||
} else
|
} else
|
||||||
vp->SetValue(jvp->GetInteger());
|
vp->SetValue(jvp->GetInteger());
|
||||||
|
|
||||||
@@ -2127,10 +2178,14 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||||||
if (Nodes[Nod-1].Op == OP_XX) {
|
if (Nodes[Nod-1].Op == OP_XX) {
|
||||||
s = Value->GetCharValue();
|
s = Value->GetCharValue();
|
||||||
|
|
||||||
if (!(jsp = ParseJson(G, s, strlen(s)))) {
|
if (s && *s) {
|
||||||
strcpy(g->Message, s);
|
if (!(jsp = ParseJson(G, s, strlen(s)))) {
|
||||||
throw 666;
|
strcpy(g->Message, s);
|
||||||
} // endif jsp
|
throw 666;
|
||||||
|
} // endif jsp
|
||||||
|
|
||||||
|
} else
|
||||||
|
jsp = NULL;
|
||||||
|
|
||||||
if (arp) {
|
if (arp) {
|
||||||
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
||||||
@@ -2560,8 +2615,8 @@ int TDBJSON::WriteDB(PGLOBAL g)
|
|||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
Doc->AddArrayValue(g, vp);
|
Doc->AddArrayValue(g, vp);
|
||||||
Row = new(g) JOBJECT;
|
Row = new(g) JOBJECT;
|
||||||
} else if (Doc->SetArrayValue(g, vp, Fpos))
|
} else
|
||||||
return RC_FX;
|
Doc->SetArrayValue(g, vp, Fpos);
|
||||||
|
|
||||||
} else if (Jmode == MODE_ARRAY) {
|
} else if (Jmode == MODE_ARRAY) {
|
||||||
PJVAL vp = new(g) JVALUE(Row);
|
PJVAL vp = new(g) JVALUE(Row);
|
||||||
@@ -2569,15 +2624,15 @@ int TDBJSON::WriteDB(PGLOBAL g)
|
|||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
Doc->AddArrayValue(g, vp);
|
Doc->AddArrayValue(g, vp);
|
||||||
Row = new(g) JARRAY;
|
Row = new(g) JARRAY;
|
||||||
} else if (Doc->SetArrayValue(g, vp, Fpos))
|
} else
|
||||||
return RC_FX;
|
Doc->SetArrayValue(g, vp, Fpos);
|
||||||
|
|
||||||
} else { // if (Jmode == MODE_VALUE)
|
} else { // if (Jmode == MODE_VALUE)
|
||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
Doc->AddArrayValue(g, (PJVAL)Row);
|
Doc->AddArrayValue(g, (PJVAL)Row);
|
||||||
Row = new(g) JVALUE;
|
Row = new(g) JVALUE;
|
||||||
} else if (Doc->SetArrayValue(g, (PJVAL)Row, Fpos))
|
} else
|
||||||
return RC_FX;
|
Doc->SetArrayValue(g, (PJVAL)Row, Fpos);
|
||||||
|
|
||||||
} // endif Jmode
|
} // endif Jmode
|
||||||
|
|
||||||
|
@@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
PJSON FindRow(PGLOBAL g);
|
PJSON FindRow(PGLOBAL g);
|
||||||
int MakeTopTree(PGLOBAL g, PJSON jsp);
|
bool MakeTopTree(PGLOBAL g, PJSON jsp);
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
PGLOBAL G; // Support of parse memory
|
PGLOBAL G; // Support of parse memory
|
||||||
@@ -216,7 +216,8 @@ public:
|
|||||||
JSONCOL(JSONCOL *colp, PTDB tdbp); // Constructor used in copy process
|
JSONCOL(JSONCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) {return Tjp->GetAmType();}
|
virtual int GetAmType(void) {return Tjp->GetAmType();}
|
||||||
|
virtual bool Stringify(void) { return Sgfy; }
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||||
@@ -251,6 +252,7 @@ public:
|
|||||||
bool Xpd; // True for expandable column
|
bool Xpd; // True for expandable column
|
||||||
bool Parsed; // True when parsed
|
bool Parsed; // True when parsed
|
||||||
bool Warned; // True when warning issued
|
bool Warned; // True when warning issued
|
||||||
|
bool Sgfy; // True if stringified
|
||||||
}; // end of class JSONCOL
|
}; // end of class JSONCOL
|
||||||
|
|
||||||
/* -------------------------- TDBJSON class -------------------------- */
|
/* -------------------------- TDBJSON class -------------------------- */
|
||||||
|
@@ -3,12 +3,12 @@
|
|||||||
/* From the article and sample code by Khalid Shaikh. */
|
/* From the article and sample code by Khalid Shaikh. */
|
||||||
/* TABMAC: virtual table to get the list of MAC addresses. */
|
/* TABMAC: virtual table to get the list of MAC addresses. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
//#include <iphlpapi.h>
|
//#include <iphlpapi.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#error This is a WINDOWS only table type
|
#error This is a WINDOWS only table type
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
//#include "catalog.h"
|
//#include "catalog.h"
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
// TABMAC.H Olivier Bertrand 2011-2012
|
// TABMAC.H Olivier Bertrand 2011-2012
|
||||||
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
|
// MAC: virtual table to Get Mac Addresses via GetAdaptersInfo
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#error This is a WINDOWS only table TYPE
|
#error This is a WINDOWS only table TYPE
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Definitions. */
|
/* Definitions. */
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
/* Include relevant section of system dependant header files. */
|
/* Include relevant section of system dependant header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@@ -166,11 +166,11 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
if ((rc = dirp->ReadDB(g)) == RC_OK) {
|
if ((rc = dirp->ReadDB(g)) == RC_OK) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
strcat(strcpy(filename, dirp->Drive), dirp->Direc);
|
strcat(strcpy(filename, dirp->Drive), dirp->Direc);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
strcpy(filename, dirp->Direc);
|
strcpy(filename, dirp->Direc);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
strcat(strcat(filename, dirp->Fname), dirp->Ftype);
|
strcat(strcat(filename, dirp->Fname), dirp->Ftype);
|
||||||
pfn[n++] = PlugDup(g, filename);
|
pfn[n++] = PlugDup(g, filename);
|
||||||
} else
|
} else
|
||||||
@@ -199,7 +199,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
|
|||||||
|
|
||||||
p = filename + strlen(filename) - 1;
|
p = filename + strlen(filename) - 1;
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
// Data files can be imported from Windows (having CRLF)
|
// Data files can be imported from Windows (having CRLF)
|
||||||
if (*p == '\n' || *p == '\r') {
|
if (*p == '\n' || *p == '\r') {
|
||||||
// is this enough for Unix ???
|
// is this enough for Unix ???
|
||||||
@@ -566,11 +566,11 @@ bool TDBMSD::InitFileNames(PGLOBAL g)
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
if ((rc = dirp->ReadDB(g)) == RC_OK) {
|
if ((rc = dirp->ReadDB(g)) == RC_OK) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
strcat(strcpy(filename, dirp->Drive), dirp->Direc);
|
strcat(strcpy(filename, dirp->Drive), dirp->Direc);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
strcpy(filename, dirp->Direc);
|
strcpy(filename, dirp->Direc);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
strcat(strcat(filename, dirp->Fname), dirp->Ftype);
|
strcat(strcat(filename, dirp->Fname), dirp->Ftype);
|
||||||
pfn[n++] = PlugDup(g, filename);
|
pfn[n++] = PlugDup(g, filename);
|
||||||
} else
|
} else
|
||||||
@@ -634,18 +634,18 @@ PTDB DIRDEF::GetTable(PGLOBAL g, MODE)
|
|||||||
void TDBDIR::Init(void)
|
void TDBDIR::Init(void)
|
||||||
{
|
{
|
||||||
iFile = 0;
|
iFile = 0;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
Dvalp = NULL;
|
Dvalp = NULL;
|
||||||
memset(&FileData, 0, sizeof(_finddata_t));
|
memset(&FileData, 0, sizeof(_finddata_t));
|
||||||
hSearch = INVALID_HANDLE_VALUE;
|
hSearch = INVALID_HANDLE_VALUE;
|
||||||
*Drive = '\0';
|
*Drive = '\0';
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
memset(&Fileinfo, 0, sizeof(struct stat));
|
memset(&Fileinfo, 0, sizeof(struct stat));
|
||||||
Entry = NULL;
|
Entry = NULL;
|
||||||
Dir = NULL;
|
Dir = NULL;
|
||||||
Done = false;
|
Done = false;
|
||||||
*Pattern = '\0';
|
*Pattern = '\0';
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
*Fpath = '\0';
|
*Fpath = '\0';
|
||||||
*Direc = '\0';
|
*Direc = '\0';
|
||||||
*Fname = '\0';
|
*Fname = '\0';
|
||||||
@@ -674,7 +674,7 @@ char* TDBDIR::Path(PGLOBAL g)
|
|||||||
PCATLG cat = PlgGetCatalog(g);
|
PCATLG cat = PlgGetCatalog(g);
|
||||||
PTABDEF defp = (PTABDEF)To_Def;
|
PTABDEF defp = (PTABDEF)To_Def;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
if (!*Drive) {
|
if (!*Drive) {
|
||||||
PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL);
|
PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL);
|
||||||
_splitpath(Fpath, Drive, Direc, Fname, Ftype);
|
_splitpath(Fpath, Drive, Direc, Fname, Ftype);
|
||||||
@@ -682,7 +682,7 @@ char* TDBDIR::Path(PGLOBAL g)
|
|||||||
_makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull for TDBSDR
|
_makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull for TDBSDR
|
||||||
|
|
||||||
return Fpath;
|
return Fpath;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
if (!Done) {
|
if (!Done) {
|
||||||
PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL);
|
PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL);
|
||||||
_splitpath(Fpath, NULL, Direc, Fname, Ftype);
|
_splitpath(Fpath, NULL, Direc, Fname, Ftype);
|
||||||
@@ -691,7 +691,7 @@ char* TDBDIR::Path(PGLOBAL g)
|
|||||||
} // endif Done
|
} // endif Done
|
||||||
|
|
||||||
return Pattern;
|
return Pattern;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} // end of Path
|
} // end of Path
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -709,7 +709,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
if (MaxSize < 0) {
|
if (MaxSize < 0) {
|
||||||
int rc, n = -1;
|
int rc, n = -1;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
// Start searching files in the target directory.
|
// Start searching files in the target directory.
|
||||||
hSearch = FindFirstFile(Path(g), &FileData);
|
hSearch = FindFirstFile(Path(g), &FileData);
|
||||||
@@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
|
|||||||
|
|
||||||
// Close the search handle.
|
// Close the search handle.
|
||||||
FindClose(hSearch);
|
FindClose(hSearch);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
Path(g);
|
Path(g);
|
||||||
|
|
||||||
// Start searching files in the target directory.
|
// Start searching files in the target directory.
|
||||||
@@ -774,7 +774,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g)
|
|||||||
|
|
||||||
// Close the DIR handle.
|
// Close the DIR handle.
|
||||||
closedir(Dir);
|
closedir(Dir);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
MaxSize = n;
|
MaxSize = n;
|
||||||
} // endif MaxSize
|
} // endif MaxSize
|
||||||
|
|
||||||
@@ -800,10 +800,10 @@ bool TDBDIR::OpenDB(PGLOBAL g)
|
|||||||
} // endif use
|
} // endif use
|
||||||
|
|
||||||
Use = USE_OPEN;
|
Use = USE_OPEN;
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
Path(g); // Be sure it is done
|
Path(g); // Be sure it is done
|
||||||
Dir = NULL; // For ReadDB
|
Dir = NULL; // For ReadDB
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
return false;
|
return false;
|
||||||
} // end of OpenDB
|
} // end of OpenDB
|
||||||
|
|
||||||
@@ -814,7 +814,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
int rc = RC_OK;
|
int rc = RC_OK;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
do {
|
do {
|
||||||
if (hSearch == INVALID_HANDLE_VALUE) {
|
if (hSearch == INVALID_HANDLE_VALUE) {
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
@@ -877,7 +877,7 @@ int TDBDIR::ReadDB(PGLOBAL g)
|
|||||||
rc = RC_EF;
|
rc = RC_EF;
|
||||||
} // endif Entry
|
} // endif Entry
|
||||||
|
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of ReadDB
|
} // end of ReadDB
|
||||||
@@ -905,17 +905,17 @@ int TDBDIR::DeleteDB(PGLOBAL g, int)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void TDBDIR::CloseDB(PGLOBAL)
|
void TDBDIR::CloseDB(PGLOBAL)
|
||||||
{
|
{
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
// Close the search handle.
|
// Close the search handle.
|
||||||
FindClose(hSearch);
|
FindClose(hSearch);
|
||||||
hSearch = INVALID_HANDLE_VALUE;
|
hSearch = INVALID_HANDLE_VALUE;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
// Close the DIR handle
|
// Close the DIR handle
|
||||||
if (Dir) {
|
if (Dir) {
|
||||||
closedir(Dir);
|
closedir(Dir);
|
||||||
Dir = NULL;
|
Dir = NULL;
|
||||||
} // endif dir
|
} // endif dir
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
iFile = 0;
|
iFile = 0;
|
||||||
} // end of CloseDB
|
} // end of CloseDB
|
||||||
|
|
||||||
@@ -950,7 +950,7 @@ DIRCOL::DIRCOL(DIRCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp)
|
|||||||
N = col1->N;
|
N = col1->N;
|
||||||
} // end of DIRCOL copy constructor
|
} // end of DIRCOL copy constructor
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Retrieve time information from FileData. */
|
/* Retrieve time information from FileData. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -977,7 +977,7 @@ void DIRCOL::SetTimeValue(PGLOBAL g, FILETIME& ftime)
|
|||||||
Value->Reset();
|
Value->Reset();
|
||||||
|
|
||||||
} // end of SetTimeValue
|
} // end of SetTimeValue
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ReadColumn: what this routine does is to access the information */
|
/* ReadColumn: what this routine does is to access the information */
|
||||||
@@ -993,19 +993,19 @@ void DIRCOL::ReadColumn(PGLOBAL g)
|
|||||||
/* Retrieve the information corresponding to the column number. */
|
/* Retrieve the information corresponding to the column number. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
switch (N) {
|
switch (N) {
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case 0: Value->SetValue_psz(Tdbp->Drive); break;
|
case 0: Value->SetValue_psz(Tdbp->Drive); break;
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
case 1: Value->SetValue_psz(Tdbp->Direc); break;
|
case 1: Value->SetValue_psz(Tdbp->Direc); break;
|
||||||
case 2: Value->SetValue_psz(Tdbp->Fname); break;
|
case 2: Value->SetValue_psz(Tdbp->Fname); break;
|
||||||
case 3: Value->SetValue_psz(Tdbp->Ftype); break;
|
case 3: Value->SetValue_psz(Tdbp->Ftype); break;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
case 4: Value->SetValue((int)Tdbp->FileData.dwFileAttributes); break;
|
case 4: Value->SetValue((int)Tdbp->FileData.dwFileAttributes); break;
|
||||||
case 5: Value->SetValue((int)Tdbp->FileData.nFileSizeLow); break;
|
case 5: Value->SetValue((int)Tdbp->FileData.nFileSizeLow); break;
|
||||||
case 6: SetTimeValue(g, Tdbp->FileData.ftLastWriteTime); break;
|
case 6: SetTimeValue(g, Tdbp->FileData.ftLastWriteTime); break;
|
||||||
case 7: SetTimeValue(g, Tdbp->FileData.ftCreationTime); break;
|
case 7: SetTimeValue(g, Tdbp->FileData.ftCreationTime); break;
|
||||||
case 8: SetTimeValue(g, Tdbp->FileData.ftLastAccessTime); break;
|
case 8: SetTimeValue(g, Tdbp->FileData.ftLastAccessTime); break;
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
case 4: Value->SetValue((int)Tdbp->Fileinfo.st_mode); break;
|
case 4: Value->SetValue((int)Tdbp->Fileinfo.st_mode); break;
|
||||||
case 5: Value->SetValue((int)Tdbp->Fileinfo.st_size); break;
|
case 5: Value->SetValue((int)Tdbp->Fileinfo.st_size); break;
|
||||||
case 6: Value->SetValue((int)Tdbp->Fileinfo.st_mtime); break;
|
case 6: Value->SetValue((int)Tdbp->Fileinfo.st_mtime); break;
|
||||||
@@ -1013,7 +1013,7 @@ void DIRCOL::ReadColumn(PGLOBAL g)
|
|||||||
case 8: Value->SetValue((int)Tdbp->Fileinfo.st_atime); break;
|
case 8: Value->SetValue((int)Tdbp->Fileinfo.st_atime); break;
|
||||||
case 9: Value->SetValue((int)Tdbp->Fileinfo.st_uid); break;
|
case 9: Value->SetValue((int)Tdbp->Fileinfo.st_uid); break;
|
||||||
case 10: Value->SetValue((int)Tdbp->Fileinfo.st_gid); break;
|
case 10: Value->SetValue((int)Tdbp->Fileinfo.st_gid); break;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
||||||
throw GetAmType();
|
throw GetAmType();
|
||||||
@@ -1045,7 +1045,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
|
|||||||
size_t m = strlen(Direc);
|
size_t m = strlen(Direc);
|
||||||
|
|
||||||
// Start searching files in the target directory.
|
// Start searching files in the target directory.
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
#if defined(PATHMATCHSPEC)
|
#if defined(PATHMATCHSPEC)
|
||||||
@@ -1155,7 +1155,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
|
|||||||
|
|
||||||
// Close the search handle.
|
// Close the search handle.
|
||||||
FindClose(h);
|
FindClose(h);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
int k;
|
int k;
|
||||||
DIR *dir = opendir(Direc);
|
DIR *dir = opendir(Direc);
|
||||||
|
|
||||||
@@ -1189,7 +1189,7 @@ int TDBSDR::FindInDir(PGLOBAL g)
|
|||||||
|
|
||||||
// Close the DIR handle.
|
// Close the DIR handle.
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // end of FindInDir
|
} // end of FindInDir
|
||||||
@@ -1205,13 +1205,13 @@ bool TDBSDR::OpenDB(PGLOBAL g)
|
|||||||
Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR));
|
Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR));
|
||||||
Sub->Next = NULL;
|
Sub->Next = NULL;
|
||||||
Sub->Prev = NULL;
|
Sub->Prev = NULL;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
Sub->H = INVALID_HANDLE_VALUE;
|
Sub->H = INVALID_HANDLE_VALUE;
|
||||||
Sub->Len = strlen(Direc);
|
Sub->Len = strlen(Direc);
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
Sub->D = NULL;
|
Sub->D = NULL;
|
||||||
Sub->Len = 0;
|
Sub->Len = 0;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} // endif To_Sub
|
} // endif To_Sub
|
||||||
|
|
||||||
return TDBDIR::OpenDB(g);
|
return TDBDIR::OpenDB(g);
|
||||||
@@ -1224,7 +1224,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
again:
|
again:
|
||||||
rc = TDBDIR::ReadDB(g);
|
rc = TDBDIR::ReadDB(g);
|
||||||
|
|
||||||
@@ -1280,7 +1280,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
|
|||||||
} // endif H
|
} // endif H
|
||||||
|
|
||||||
} // endif rc
|
} // endif rc
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
rc = RC_NF;
|
rc = RC_NF;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
@@ -1338,7 +1338,7 @@ int TDBSDR::ReadDB(PGLOBAL g)
|
|||||||
|
|
||||||
} // endif Entry
|
} // endif Entry
|
||||||
|
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of ReadDB
|
} // end of ReadDB
|
||||||
|
@@ -6,14 +6,14 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file contains the TDBMUL and TDBDIR classes declares. */
|
/* This file contains the TDBMUL and TDBDIR classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
//#include "osutil.h"
|
//#include "osutil.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
|
|
||||||
@@ -160,18 +160,18 @@ public:
|
|||||||
// Members
|
// Members
|
||||||
PSZ To_File; // Points to file search pathname
|
PSZ To_File; // Points to file search pathname
|
||||||
int iFile; // Index of currently retrieved file
|
int iFile; // Index of currently retrieved file
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
PVAL Dvalp; // Used to retrieve file date values
|
PVAL Dvalp; // Used to retrieve file date values
|
||||||
WIN32_FIND_DATA FileData; // Find data structure
|
WIN32_FIND_DATA FileData; // Find data structure
|
||||||
HANDLE hSearch; // Search handle
|
HANDLE hSearch; // Search handle
|
||||||
char Drive[_MAX_DRIVE]; // Drive name
|
char Drive[_MAX_DRIVE]; // Drive name
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
struct stat Fileinfo; // File info structure
|
struct stat Fileinfo; // File info structure
|
||||||
struct dirent *Entry; // Point to directory entry structure
|
struct dirent *Entry; // Point to directory entry structure
|
||||||
DIR *Dir; // To searched directory structure
|
DIR *Dir; // To searched directory structure
|
||||||
bool Done; // true when _splipath is done
|
bool Done; // true when _splipath is done
|
||||||
char Pattern[_MAX_FNAME+_MAX_EXT];
|
char Pattern[_MAX_FNAME+_MAX_EXT];
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
char Fpath[_MAX_PATH]; // Absolute file search pattern
|
char Fpath[_MAX_PATH]; // Absolute file search pattern
|
||||||
char Direc[_MAX_DIR]; // Search path
|
char Direc[_MAX_DIR]; // Search path
|
||||||
char Fname[_MAX_FNAME]; // File name
|
char Fname[_MAX_FNAME]; // File name
|
||||||
@@ -207,11 +207,11 @@ class TDBSDR : public TDBDIR {
|
|||||||
typedef struct _Sub_Dir {
|
typedef struct _Sub_Dir {
|
||||||
struct _Sub_Dir *Next;
|
struct _Sub_Dir *Next;
|
||||||
struct _Sub_Dir *Prev;
|
struct _Sub_Dir *Prev;
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
HANDLE H; // Search handle
|
HANDLE H; // Search handle
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
DIR *D;
|
DIR *D;
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
size_t Len; // Initial directory name length
|
size_t Len; // Initial directory name length
|
||||||
} SUBDIR, *PSUBDIR;
|
} SUBDIR, *PSUBDIR;
|
||||||
|
|
||||||
@@ -238,9 +238,9 @@ class DIRCOL : public COLBLK {
|
|||||||
protected:
|
protected:
|
||||||
// Default constructor not to be used
|
// Default constructor not to be used
|
||||||
DIRCOL(void) {}
|
DIRCOL(void) {}
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
void SetTimeValue(PGLOBAL g, FILETIME& ftime);
|
void SetTimeValue(PGLOBAL g, FILETIME& ftime);
|
||||||
#endif // __WIN__
|
#endif // _WIN32
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
PTDBDIR Tdbp; // To DIR table
|
PTDBDIR Tdbp; // To DIR table
|
||||||
|
@@ -35,9 +35,9 @@
|
|||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
#include "sql_servers.h"
|
#include "sql_servers.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
//#include <fnmatch.h>
|
//#include <fnmatch.h>
|
||||||
//#include <errno.h>
|
//#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
//#include <io.h>
|
//#include <io.h>
|
||||||
//#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ TabOccur CPP Declares Source Code File (.CPP) ************/
|
/************ TabOccur CPP Declares Source Code File (.CPP) ************/
|
||||||
/* Name: TABOCCUR.CPP Version 1.2 */
|
/* Name: TABOCCUR.CPP Version 1.2 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* OCCUR: Table that provides a view of a source table where the */
|
/* OCCUR: Table that provides a view of a source table where the */
|
||||||
/* contain of several columns of the source table is placed in only */
|
/* contain of several columns of the source table is placed in only */
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "table.h" // MySQL table definitions
|
#include "table.h" // MySQL table definitions
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@@ -49,11 +49,13 @@
|
|||||||
#include "tabmysql.h"
|
#include "tabmysql.h"
|
||||||
#include "ha_connect.h"
|
#include "ha_connect.h"
|
||||||
|
|
||||||
|
int PrepareColist(char *colist);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Prepare and count columns in the column list. */
|
/* Prepare and count columns in the column list. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
static int PrepareColist(char *colist)
|
int PrepareColist(char *colist)
|
||||||
{
|
{
|
||||||
char *p, *pn;
|
char *p, *pn;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ static int PrepareColist(char *colist)
|
|||||||
} // endif p
|
} // endif p
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // end of PrepareColist
|
} // end of PrepareColist
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* OcrColumns: constructs the result blocks containing all the columns */
|
/* OcrColumns: constructs the result blocks containing all the columns */
|
||||||
@@ -79,7 +81,7 @@ static int PrepareColist(char *colist)
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
||||||
const char *ocr, const char *rank)
|
const char *ocr, const char *rank)
|
||||||
{
|
{
|
||||||
char *pn, *colist;
|
char *pn, *colist;
|
||||||
int i, k, m, n = 0, c = 0, j = qrp->Nblin;
|
int i, k, m, n = 0, c = 0, j = qrp->Nblin;
|
||||||
bool rk, b = false;
|
bool rk, b = false;
|
||||||
@@ -168,7 +170,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
qrp->Nblin = j;
|
qrp->Nblin = j;
|
||||||
return false;
|
return false;
|
||||||
} // end of OcrColumns
|
} // end of OcrColumns
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* OcrSrcCols: constructs the result blocks containing all the columns */
|
/* OcrSrcCols: constructs the result blocks containing all the columns */
|
||||||
@@ -176,7 +178,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
||||||
const char *ocr, const char *rank)
|
const char *ocr, const char *rank)
|
||||||
{
|
{
|
||||||
char *pn, *colist;
|
char *pn, *colist;
|
||||||
int i, k, m, n = 0, c = 0;
|
int i, k, m, n = 0, c = 0;
|
||||||
bool rk, b = false;
|
bool rk, b = false;
|
||||||
@@ -249,7 +251,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
qrp->Nblin = i;
|
qrp->Nblin = i;
|
||||||
return false;
|
return false;
|
||||||
} // end of OcrSrcCols
|
} // end of OcrSrcCols
|
||||||
|
|
||||||
/* -------------- Implementation of the OCCUR classes ---------------- */
|
/* -------------- Implementation of the OCCUR classes ---------------- */
|
||||||
|
|
||||||
@@ -257,24 +259,24 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/* DefineAM: define specific AM block values from OCCUR table. */
|
/* DefineAM: define specific AM block values from OCCUR table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||||
{
|
{
|
||||||
Rcol = GetStringCatInfo(g, "RankCol", "");
|
Rcol = GetStringCatInfo(g, "RankCol", "");
|
||||||
Colist = GetStringCatInfo(g, "Colist", "");
|
Colist = GetStringCatInfo(g, "Colist", "");
|
||||||
Xcol = GetStringCatInfo(g, "OccurCol", Colist);
|
Xcol = GetStringCatInfo(g, "OccurCol", Colist);
|
||||||
return PRXDEF::DefineAM(g, am, poff);
|
return PRXDEF::DefineAM(g, am, poff);
|
||||||
} // end of DefineAM
|
} // end of DefineAM
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* GetTable: makes a new TDB of the proper type. */
|
/* GetTable: makes a new TDB of the proper type. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
||||||
{
|
{
|
||||||
if (Catfunc != FNC_COL)
|
if (Catfunc != FNC_COL)
|
||||||
return new(g) TDBOCCUR(this);
|
return new(g) TDBOCCUR(this);
|
||||||
else
|
else
|
||||||
return new(g) TDBTBC(this);
|
return new(g) TDBTBC(this);
|
||||||
|
|
||||||
} // end of GetTable
|
} // end of GetTable
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -282,7 +284,7 @@ PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
|||||||
/* Implementation of the TDBOCCUR class. */
|
/* Implementation of the TDBOCCUR class. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
||||||
{
|
{
|
||||||
//Tdbp = NULL; // Source table (in TDBPRX)
|
//Tdbp = NULL; // Source table (in TDBPRX)
|
||||||
Tabname = tdp->Tablep->GetName(); // Name of source table
|
Tabname = tdp->Tablep->GetName(); // Name of source table
|
||||||
Colist = tdp->Colist; // List of source columns
|
Colist = tdp->Colist; // List of source columns
|
||||||
@@ -294,13 +296,13 @@ TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
|||||||
N = 0; // The current table index
|
N = 0; // The current table index
|
||||||
M = 0; // The occurence rank
|
M = 0; // The occurence rank
|
||||||
RowFlag = 0; // 0: Ok, 1: Same, 2: Skip
|
RowFlag = 0; // 0: Ok, 1: Same, 2: Skip
|
||||||
} // end of TDBOCCUR constructor
|
} // end of TDBOCCUR constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR/SRC column description block. */
|
/* Allocate OCCUR/SRC column description block. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
||||||
{
|
{
|
||||||
PCOL colp = NULL;
|
PCOL colp = NULL;
|
||||||
|
|
||||||
if (!stricmp(cdp->GetName(), Rcolumn)) {
|
if (!stricmp(cdp->GetName(), Rcolumn)) {
|
||||||
@@ -321,13 +323,13 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
|||||||
} // endif cprec
|
} // endif cprec
|
||||||
|
|
||||||
return colp;
|
return colp;
|
||||||
} // end of MakeCol
|
} // end of MakeCol
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Initializes the table. */
|
/* Initializes the table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::InitTable(PGLOBAL g)
|
bool TDBOCCUR::InitTable(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (!Tdbp)
|
if (!Tdbp)
|
||||||
// Get the table description block of this table
|
// Get the table description block of this table
|
||||||
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
||||||
@@ -338,13 +340,13 @@ bool TDBOCCUR::InitTable(PGLOBAL g)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} // end of InitTable
|
} // end of InitTable
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR column description block. */
|
/* Allocate OCCUR column description block. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *pn;
|
char *pn;
|
||||||
int i;
|
int i;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
@@ -371,13 +373,13 @@ bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
|||||||
} // endfor i
|
} // endfor i
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of MakeColumnList
|
} // end of MakeColumnList
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR column description block for a view. */
|
/* Allocate OCCUR column description block for a view. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *pn;
|
char *pn;
|
||||||
int i;
|
int i;
|
||||||
PCOL colp, cp;
|
PCOL colp, cp;
|
||||||
@@ -412,13 +414,13 @@ bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
|||||||
} // endif Col
|
} // endif Col
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of ViewColumnList
|
} // end of ViewColumnList
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OCCUR GetMaxSize: returns the maximum number of rows in the table. */
|
/* OCCUR GetMaxSize: returns the maximum number of rows in the table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (MaxSize < 0) {
|
if (MaxSize < 0) {
|
||||||
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -427,22 +429,22 @@ int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
|||||||
} // endif MaxSize
|
} // endif MaxSize
|
||||||
|
|
||||||
return MaxSize;
|
return MaxSize;
|
||||||
} // end of GetMaxSize
|
} // end of GetMaxSize
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* In this sample, ROWID will be the (virtual) row number, */
|
/* In this sample, ROWID will be the (virtual) row number, */
|
||||||
/* while ROWNUM will be the occurence rank in the multiple column. */
|
/* while ROWNUM will be the occurence rank in the multiple column. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::RowNumber(PGLOBAL, bool b)
|
int TDBOCCUR::RowNumber(PGLOBAL, bool b)
|
||||||
{
|
{
|
||||||
return (b) ? M : N;
|
return (b) ? M : N;
|
||||||
} // end of RowNumber
|
} // end of RowNumber
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OCCUR Access Method opening routine. */
|
/* OCCUR Access Method opening routine. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::OpenDB(PGLOBAL g)
|
bool TDBOCCUR::OpenDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (Use == USE_OPEN) {
|
if (Use == USE_OPEN) {
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* Table already open, just replace it at its beginning. */
|
/* Table already open, just replace it at its beginning. */
|
||||||
@@ -491,13 +493,13 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
|
|||||||
|
|
||||||
Use = USE_OPEN;
|
Use = USE_OPEN;
|
||||||
return ViewColumnList(g);
|
return ViewColumnList(g);
|
||||||
} // end of OpenDB
|
} // end of OpenDB
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Data Base read routine for OCCUR access method. */
|
/* Data Base read routine for OCCUR access method. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::ReadDB(PGLOBAL g)
|
int TDBOCCUR::ReadDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
int rc = RC_OK;
|
int rc = RC_OK;
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -518,7 +520,7 @@ int TDBOCCUR::ReadDB(PGLOBAL g)
|
|||||||
|
|
||||||
N++;
|
N++;
|
||||||
return rc;
|
return rc;
|
||||||
} // end of ReadDB
|
} // end of ReadDB
|
||||||
|
|
||||||
// ------------------------ OCCURCOL functions ----------------------------
|
// ------------------------ OCCURCOL functions ----------------------------
|
||||||
|
|
||||||
@@ -527,17 +529,17 @@ int TDBOCCUR::ReadDB(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
OCCURCOL::OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n)
|
OCCURCOL::OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n)
|
||||||
: COLBLK(cdp, tdbp, n)
|
: COLBLK(cdp, tdbp, n)
|
||||||
{
|
{
|
||||||
// Set additional OCCUR access method information for column.
|
// Set additional OCCUR access method information for column.
|
||||||
I = 0;
|
I = 0;
|
||||||
} // end of OCCURCOL constructor
|
} // end of OCCURCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ReadColumn: what this routine does is to access the columns of */
|
/* ReadColumn: what this routine does is to access the columns of */
|
||||||
/* list, extract their value and convert it to buffer type. */
|
/* list, extract their value and convert it to buffer type. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void OCCURCOL::ReadColumn(PGLOBAL g)
|
void OCCURCOL::ReadColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
||||||
PCOL *col = tdbp->Col;
|
PCOL *col = tdbp->Col;
|
||||||
|
|
||||||
@@ -559,7 +561,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g)
|
|||||||
// Set the OCCUR column value from the Ith source column value
|
// Set the OCCUR column value from the Ith source column value
|
||||||
Value->SetValue_pval(col[I++]->GetValue());
|
Value->SetValue_pval(col[I++]->GetValue());
|
||||||
tdbp->RowFlag = 1;
|
tdbp->RowFlag = 1;
|
||||||
} // end of ReadColumn
|
} // end of ReadColumn
|
||||||
|
|
||||||
|
|
||||||
// ------------------------ RANKCOL functions ---------------------------
|
// ------------------------ RANKCOL functions ---------------------------
|
||||||
@@ -569,7 +571,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g)
|
|||||||
/* list, extract its name and set to it the rank column value. */
|
/* list, extract its name and set to it the rank column value. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void RANKCOL::ReadColumn(PGLOBAL)
|
void RANKCOL::ReadColumn(PGLOBAL)
|
||||||
{
|
{
|
||||||
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
||||||
PCOL *col = tdbp->Col;
|
PCOL *col = tdbp->Col;
|
||||||
|
|
||||||
@@ -584,4 +586,4 @@ void RANKCOL::ReadColumn(PGLOBAL)
|
|||||||
|
|
||||||
} // endelse
|
} // endelse
|
||||||
|
|
||||||
} // end of ReadColumn
|
} // end of ReadColumn
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "table.h" // MySQL table definitions
|
#include "table.h" // MySQL table definitions
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/************** tabrest C++ Program Source Code File (.CPP) ************/
|
/************** tabrest C++ Program Source Code File (.CPP) ************/
|
||||||
/* PROGRAM NAME: tabrest Version 2.0 */
|
/* PROGRAM NAME: tabrest Version 2.1 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2021 */
|
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2021 */
|
||||||
/* This program is the REST Web API support for MariaDB. */
|
/* This program is the REST Web API support for MariaDB. */
|
||||||
/* The way Connect handles NOSQL data returned by REST queries is */
|
/* The way Connect handles NOSQL data returned by REST queries is */
|
||||||
@@ -13,10 +13,10 @@
|
|||||||
#include <my_global.h> // All MariaDB stuff
|
#include <my_global.h> // All MariaDB stuff
|
||||||
#include <mysqld.h>
|
#include <mysqld.h>
|
||||||
#include <sql_error.h>
|
#include <sql_error.h>
|
||||||
#if !defined(__WIN__) && !defined(_WINDOWS)
|
#if !defined(_WIN32) && !defined(_WINDOWS)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif // !__WIN__ && !_WINDOWS
|
#endif // !_WIN32 && !_WINDOWS
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
#include "tabrest.h"
|
#include "tabrest.h"
|
||||||
|
|
||||||
#if defined(connect_EXPORTS)
|
#if defined(connect_EXPORTS)
|
||||||
#define PUSH_WARNING(M) push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, M)
|
#define PUSH_WARNING(M) push_warning(current_thd, Sql_condition::WARN_LEVEL_NOTE, 0, M)
|
||||||
#else
|
#else
|
||||||
#define PUSH_WARNING(M) htrc(M)
|
#define PUSH_WARNING(M) htrc(M)
|
||||||
#endif
|
#endif
|
||||||
@@ -65,9 +65,9 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
|
|||||||
my_snprintf(buf, sizeof(buf)-1, "%s/%s", Http, Uri);
|
my_snprintf(buf, sizeof(buf)-1, "%s/%s", Http, Uri);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
my_snprintf(buf, sizeof(buf)-1, "%s", Http);
|
my_snprintf(buf, sizeof(buf)-1, "%s", Http);
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
@@ -90,7 +90,7 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
|
|||||||
sprintf(g->Message, "CreateProcess curl failed (%d)", GetLastError());
|
sprintf(g->Message, "CreateProcess curl failed (%d)", GetLastError());
|
||||||
rc = 1;
|
rc = 1;
|
||||||
} // endif CreateProcess
|
} // endif CreateProcess
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
char fn[600];
|
char fn[600];
|
||||||
pid_t pID;
|
pid_t pID;
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
|
|||||||
// Parent process
|
// Parent process
|
||||||
wait(NULL); // Wait for the child to terminate
|
wait(NULL); // Wait for the child to terminate
|
||||||
} // endif pID
|
} // endif pID
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of Xcurl
|
} // end of Xcurl
|
||||||
@@ -147,7 +147,7 @@ XGETREST GetRestFunction(PGLOBAL g)
|
|||||||
if (trace(515))
|
if (trace(515))
|
||||||
htrc("Looking for GetRest library\n");
|
htrc("Looking for GetRest library\n");
|
||||||
|
|
||||||
#if defined(__WIN__) || defined(_WINDOWS)
|
#if defined(_WIN32) || defined(_WINDOWS)
|
||||||
HANDLE Hdll;
|
HANDLE Hdll;
|
||||||
const char* soname = "GetRest.dll"; // Module name
|
const char* soname = "GetRest.dll"; // Module name
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ XGETREST GetRestFunction(PGLOBAL g)
|
|||||||
FreeLibrary((HMODULE)Hdll);
|
FreeLibrary((HMODULE)Hdll);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif getRestFnc
|
} // endif getRestFnc
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
void* Hso;
|
void* Hso;
|
||||||
const char* error = NULL;
|
const char* error = NULL;
|
||||||
const char* soname = "GetRest.so"; // Module name
|
const char* soname = "GetRest.so"; // Module name
|
||||||
@@ -195,7 +195,7 @@ XGETREST GetRestFunction(PGLOBAL g)
|
|||||||
dlclose(Hso);
|
dlclose(Hso);
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif getdef
|
} // endif getdef
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#else // REST_SOURCE
|
#else // REST_SOURCE
|
||||||
getRestFnc = restGetFile;
|
getRestFnc = restGetFile;
|
||||||
#endif // REST_SOURCE
|
#endif // REST_SOURCE
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
static PCSZ slash = "\\";
|
static PCSZ slash = "\\";
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
static PCSZ slash = "/";
|
static PCSZ slash = "/";
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
typedef int(__stdcall* XGETREST) (char*, bool, PCSZ, PCSZ, PCSZ);
|
typedef int(__stdcall* XGETREST) (char*, bool, PCSZ, PCSZ, PCSZ);
|
||||||
|
|
||||||
|
@@ -12,12 +12,12 @@
|
|||||||
/* Include relevant sections of the System header files. */
|
/* Include relevant sections of the System header files. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define __MFC_COMPAT__ // To define min/max as macro
|
#define __MFC_COMPAT__ // To define min/max as macro
|
||||||
#endif // __BORLANDC__
|
#endif // __BORLANDC__
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif // !UNIX
|
#endif // !UNIX
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include application header files: */
|
/* Include application header files: */
|
||||||
@@ -36,9 +36,9 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
#include "reldef.h"
|
#include "reldef.h"
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
#include "osutil.h"
|
#include "osutil.h"
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
#include "filamtxt.h"
|
#include "filamtxt.h"
|
||||||
#include "tabdos.h"
|
#include "tabdos.h"
|
||||||
#include "tabsys.h"
|
#include "tabsys.h"
|
||||||
@@ -48,10 +48,10 @@
|
|||||||
#define CSZ 36 // Column section name length
|
#define CSZ 36 // Column section name length
|
||||||
#define CDZ 256 // Column definition length
|
#define CDZ 256 // Column definition length
|
||||||
|
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
#define GetPrivateProfileSectionNames(S,L,I) \
|
#define GetPrivateProfileSectionNames(S,L,I) \
|
||||||
GetPrivateProfileString(NULL,NULL,"",S,L,I)
|
GetPrivateProfileString(NULL,NULL,"",S,L,I)
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
/* -------------- Implementation of the INI classes ------------------ */
|
/* -------------- Implementation of the INI classes ------------------ */
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g)
|
|||||||
// Delete the INI table file if not protected
|
// Delete the INI table file if not protected
|
||||||
if (!IsReadOnly()) {
|
if (!IsReadOnly()) {
|
||||||
PlugSetPath(filename, Fn, GetPath());
|
PlugSetPath(filename, Fn, GetPath());
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
rc = !DeleteFile(filename);
|
rc = !DeleteFile(filename);
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
rc = remove(filename);
|
rc = remove(filename);
|
||||||
@@ -345,9 +345,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void TDBINI::CloseDB(PGLOBAL)
|
void TDBINI::CloseDB(PGLOBAL)
|
||||||
{
|
{
|
||||||
#if !defined(__WIN__)
|
#if !defined(_WIN32)
|
||||||
PROFILE_Close(Ifile);
|
PROFILE_Close(Ifile);
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
} // end of CloseDB
|
} // end of CloseDB
|
||||||
|
|
||||||
// ------------------------ INICOL functions ----------------------------
|
// ------------------------ INICOL functions ----------------------------
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
//#include "sql_base.h"
|
//#include "sql_base.h"
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "table.h" // MySQL table definitions
|
#include "table.h" // MySQL table definitions
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@@ -71,15 +71,15 @@
|
|||||||
#include "tabmysql.h"
|
#include "tabmysql.h"
|
||||||
#include "ha_connect.h"
|
#include "ha_connect.h"
|
||||||
|
|
||||||
#if defined(__WIN__)
|
#if defined(_WIN32)
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#define SYSEXIT void _USERENTRY
|
#define SYSEXIT void _USERENTRY
|
||||||
#else
|
#else
|
||||||
#define SYSEXIT void
|
#define SYSEXIT void
|
||||||
#endif
|
#endif
|
||||||
#else // !__WIN__
|
#else // !_WIN32
|
||||||
#define SYSEXIT void *
|
#define SYSEXIT void *
|
||||||
#endif // !__WIN__
|
#endif // !_WIN32
|
||||||
|
|
||||||
extern pthread_mutex_t tblmut;
|
extern pthread_mutex_t tblmut;
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user