diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2021-06-08 17:44:43 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2021-06-08 17:44:43 +0200 |
commit | 5f64276fb2bd4a400927105cf5d536b82e01fbd2 (patch) | |
tree | c75c109d21d8d758b3f14b6859ae3b8e1e21fb0c | |
parent | be7e41db96b0a05b4896be875b8797089100b7b6 (diff) | |
download | mariadb-git-5f64276fb2bd4a400927105cf5d536b82e01fbd2.tar.gz |
- Fix MDEV-25863 : Replace __WIN__ by _WIN32
modified: storage/connect/array.cpp
modified: storage/connect/blkfil.cpp
modified: storage/connect/block.h
modified: storage/connect/bson.cpp
modified: storage/connect/cmgoconn.cpp
modified: storage/connect/colblk.cpp
modified: storage/connect/domdoc.cpp
modified: storage/connect/filamap.cpp
modified: storage/connect/filamdbf.cpp
modified: storage/connect/filamfix.cpp
modified: storage/connect/filamgz.cpp
modified: storage/connect/filamtxt.cpp
modified: storage/connect/filamvct.cpp
modified: storage/connect/filamzip.cpp
modified: storage/connect/filter.cpp
modified: storage/connect/filter.h
modified: storage/connect/fmdlex.c
modified: storage/connect/global.h
modified: storage/connect/ha_connect.cc
modified: storage/connect/javaconn.cpp
modified: storage/connect/javaconn.h
modified: storage/connect/jdbconn.cpp
modified: storage/connect/jmgfam.cpp
modified: storage/connect/json.cpp
modified: storage/connect/macutil.cpp
modified: storage/connect/macutil.h
modified: storage/connect/maputil.cpp
modified: storage/connect/mycat.cc
modified: storage/connect/myconn.cpp
modified: storage/connect/myconn.h
modified: storage/connect/myutil.cpp
modified: storage/connect/odbconn.cpp
modified: storage/connect/odbconn.h
modified: storage/connect/os.h
modified: storage/connect/osutil.c
modified: storage/connect/plgdbsem.h
modified: storage/connect/plgdbutl.cpp
modified: storage/connect/plugutil.cpp
modified: storage/connect/rcmsg.c
modified: storage/connect/reldef.cpp
modified: storage/connect/reldef.h
modified: storage/connect/tabdos.cpp
modified: storage/connect/tabext.cpp
modified: storage/connect/tabfix.cpp
modified: storage/connect/tabfmt.cpp
modified: storage/connect/tabjdbc.cpp
modified: storage/connect/tabmac.cpp
modified: storage/connect/tabmac.h
modified: storage/connect/tabmul.cpp
modified: storage/connect/tabmul.h
modified: storage/connect/tabmysql.cpp
modified: storage/connect/taboccur.cpp
modified: storage/connect/tabodbc.cpp
modified: storage/connect/tabpivot.cpp
modified: storage/connect/tabrest.cpp
modified: storage/connect/tabrest.h
modified: storage/connect/tabsys.cpp
modified: storage/connect/tabtbl.cpp
modified: storage/connect/tabutil.cpp
modified: storage/connect/tabvct.cpp
modified: storage/connect/tabwmi.cpp
modified: storage/connect/tabxcl.cpp
modified: storage/connect/tabxml.cpp
modified: storage/connect/valblk.cpp
modified: storage/connect/value.cpp
modified: storage/connect/xindex.cpp
modified: storage/connect/xindex.h
- Fix Date errors and SSL warnings
modified: storage/connect/mysql-test/connect/r/jdbc.result
modified: storage/connect/mysql-test/connect/r/jdbc_new.result
modified: storage/connect/mysql-test/connect/t/jdbc.test
modified: storage/connect/mysql-test/connect/t/jdbc_new.test
- Update java source files
modified: storage/connect/Mongo2Interface.java
modified: storage/connect/Mongo3Interface.java
added: storage/connect/Client2.java
added: storage/connect/Client3.java
added: storage/connect/TestInsert2.java
added: storage/connect/TestInsert3.java
77 files changed, 1317 insertions, 551 deletions
diff --git a/storage/connect/Client2.java b/storage/connect/Client2.java new file mode 100644 index 00000000000..6dbf4188032 --- /dev/null +++ b/storage/connect/Client2.java @@ -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 diff --git a/storage/connect/Client3.java b/storage/connect/Client3.java new file mode 100644 index 00000000000..0d3914cdd0d --- /dev/null +++ b/storage/connect/Client3.java @@ -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 diff --git a/storage/connect/Mongo2Interface.java b/storage/connect/Mongo2Interface.java index 106dd4a4d63..5d27fe467d6 100644 --- a/storage/connect/Mongo2Interface.java +++ b/storage/connect/Mongo2Interface.java @@ -21,6 +21,7 @@ import com.mongodb.util.JSON; public class Mongo2Interface { boolean DEBUG = false; String Errmsg = "No error"; + String ovalName = null; Set<String> Colnames = null; Cursor cursor = null; MongoClient client = null; @@ -220,7 +221,7 @@ public class Mongo2Interface { System.out.println("Class doc = " + doc.getClass()); Colnames = doc.keySet(); - return 1; + return Colnames.size(); } else return 0; @@ -253,30 +254,106 @@ public class Mongo2Interface { } // end of GetColumns - public String ColumnDesc(int n, int[] val) { - // if (rsmd == null) { - // System.out.println("No result metadata"); - // return null; - // } else try { - // 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 + public Object ColumnDesc(Object obj, int n, int[] val, int lvl) { + Object ret = null; + Object oval = ((obj != null) ? obj : doc); + BasicDBObject dob = (oval instanceof BasicDBObject) ? (BasicDBObject) oval : null; + BasicDBList ary = (oval instanceof BasicDBList) ? (BasicDBList) oval : null; + 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; } // end of ColumnDesc + public String ColDescName() { + return ovalName; + } // end of ColDescName + protected Object GetFieldObject(String path) { Object o = null; BasicDBObject dob = null; BasicDBList lst = null; String[] names = null; - if (path == null || path.equals("*")) + if (path == null || path.equals("") || path.equals("*")) return doc; else if (doc instanceof BasicDBObject) dob = doc; @@ -325,9 +402,10 @@ public class Mongo2Interface { if (o != null) { if (o instanceof Date) { - Integer TS = (int) (((Date) o).getTime() / 1000); + Long TS = (((Date) o).getTime() / 1000); return TS.toString(); - } // endif Date + } else if (o instanceof Boolean) + return (Boolean) o ? "1" : "0"; return o.toString(); } else @@ -335,13 +413,25 @@ public class Mongo2Interface { } // 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() { return new BasicDBObject(); } // end of MakeDocument - public boolean DocAdd(Object bdc, String key, Object val) { + public boolean DocAdd(Object bdc, String key, Object val, int json) { 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) { SetErrmsg(me); return true; @@ -354,9 +444,13 @@ public class Mongo2Interface { return new BasicDBList(); } // end of MakeArray - public boolean ArrayAdd(Object bar, int n, Object val) { + public boolean ArrayAdd(Object bar, int n, Object val, int json) { 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) { SetErrmsg(me); return true; diff --git a/storage/connect/Mongo3Interface.java b/storage/connect/Mongo3Interface.java index f587c01b391..73175e13aa3 100644 --- a/storage/connect/Mongo3Interface.java +++ b/storage/connect/Mongo3Interface.java @@ -1,5 +1,6 @@ package wrappers; +//import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Date; @@ -9,6 +10,7 @@ import java.util.Set; import org.bson.BsonArray; import org.bson.BsonBoolean; import org.bson.BsonDateTime; +//import org.bson.BsonDecimal128; import org.bson.BsonDocument; import org.bson.BsonDouble; import org.bson.BsonInt32; @@ -18,6 +20,7 @@ import org.bson.BsonString; import org.bson.BsonValue; import org.bson.Document; import org.bson.conversions.Bson; +//import org.bson.types.Decimal128; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; @@ -34,6 +37,7 @@ import com.mongodb.client.result.UpdateResult; public class Mongo3Interface { boolean DEBUG = false; String Errmsg = "No error"; + String bvalName = null; Set<String> Colnames = null; MongoClient client = null; MongoDatabase db = null; @@ -167,7 +171,7 @@ public class Mongo3Interface { try { if (query != null) { - Bson dbq = Document.parse((query != null) ? query : "{}"); + Bson dbq = Document.parse(query); finditer = coll.find(dbq); } else finditer = coll.find(); @@ -218,17 +222,23 @@ public class Mongo3Interface { } // end of Rewind public int ReadNext() { - if (cursor.hasNext()) { - doc = cursor.next(); + try { + if (cursor.hasNext()) { + doc = cursor.next(); - if (DEBUG) - System.out.println("Class doc = " + doc.getClass()); + if (DEBUG) + System.out.println("Class doc = " + doc.getClass()); - Colnames = doc.keySet(); - return 1; - } else - return 0; + Colnames = doc.keySet(); + return Colnames.size(); + } else + return 0; + } catch (MongoException mx) { + SetErrmsg(mx); + } // end try/catch + + return -1; } // end of ReadNext public boolean Fetch(int row) { @@ -254,13 +264,11 @@ public class Mongo3Interface { } // end of GetColumns public String ColumnName(int n) { - int i = 1; - - for (String name : Colnames) - if (i++ == n) - return name; + if (n < Colnames.size()) + return (String) Colnames.toArray()[n]; + else + return null; - return null; } // end of ColumnName public int ColumnType(int n, String name) { @@ -278,30 +286,111 @@ public class Mongo3Interface { return 666; // Not a type } // end of ColumnType - public String ColumnDesc(int n, int[] val) { - // if (rsmd == null) { - // System.out.println("No result metadata"); - // return null; - // } else try { - // 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 + public Object ColumnDesc(Object obj, int n, int[] val, int lvl) { + Object ret = null; + BsonValue bval = (BsonValue) ((obj != null) ? obj : doc); + BsonDocument dob = (bval instanceof BsonDocument) ? (BsonDocument) bval : null; + BsonArray ary = (bval instanceof BsonArray) ? (BsonArray) bval : null; + + 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; } // end of ColumnDesc + public String ColDescName() { + return bvalName; + } // end of ColDescName + protected BsonValue GetFieldObject(String path) { BsonValue o = doc; BsonDocument dob = null; BsonArray ary = null; String[] names = null; - if (path == null || path.equals("*")) + if (path == null || path.equals("") || path.equals("*")) return doc; else if (o instanceof BsonDocument) dob = doc; @@ -362,6 +451,8 @@ public class Mongo3Interface { return TS.toString(); } else if (o.isDouble()) { return Double.toString(o.asDouble().getValue()); + } else if (o.isBoolean()) { + return o.asBoolean().getValue() ? "1" : "0"; } else if (o.isDocument()) { return o.asDocument().toJson(); } else if (o.isArray()) { @@ -370,6 +461,8 @@ public class Mongo3Interface { int i1 = s.indexOf('['); int i2 = s.lastIndexOf(']'); return s.substring(i1, i2 + 1); + } else if (o.isDecimal128()) { + return o.asDecimal128().toString(); } else if (o.isNull()) { return null; } else @@ -380,14 +473,33 @@ public class Mongo3Interface { } // 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; if (val == null) bval = bsonull; - else if (val.getClass() == String.class) - bval = new BsonString((String) val); - else if (val.getClass() == Integer.class) + else if (val.getClass() == String.class) { + if (json == 1) + 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); else if (val.getClass() == Double.class) bval = new BsonDouble((double) val); @@ -401,6 +513,8 @@ public class Mongo3Interface { bval = (BsonDocument) val; else if (val.getClass() == BsonArray.class) bval = (BsonArray) val; + // else if (val.getClass() == BigDecimal.class) + // bval = new BsonDecimal128((BigDecimal) val); return bval; } // end of ObjToBson @@ -409,9 +523,9 @@ public class Mongo3Interface { return new BsonDocument(); } // end of MakeDocument - public boolean DocAdd(Object bdc, String key, Object val) { + public boolean DocAdd(Object bdc, String key, Object val, int json) { try { - ((BsonDocument) bdc).append(key, ObjToBson(val)); + ((BsonDocument) bdc).append(key, ObjToBson(val, json)); } catch (MongoException me) { SetErrmsg(me); return true; @@ -424,12 +538,12 @@ public class Mongo3Interface { return new BsonArray(); } // end of MakeArray - public boolean ArrayAdd(Object bar, int n, Object val) { + public boolean ArrayAdd(Object bar, int n, Object val, int json) { try { for (int i = ((BsonArray) bar).size(); i < n; i++) ((BsonArray) bar).add(bsonull); - ((BsonArray) bar).add(ObjToBson(val)); + ((BsonArray) bar).add(ObjToBson(val, json)); } catch (MongoException me) { SetErrmsg(me); return true; @@ -501,4 +615,4 @@ public class Mongo3Interface { return n; } // end of CollDelete -} // end of class MongoInterface +} // end of class Mongo3Interface diff --git a/storage/connect/TestInsert2.java b/storage/connect/TestInsert2.java new file mode 100644 index 00000000000..e1a7cb4f98b --- /dev/null +++ b/storage/connect/TestInsert2.java @@ -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 + +} diff --git a/storage/connect/TestInsert3.java b/storage/connect/TestInsert3.java new file mode 100644 index 00000000000..a56a361e7aa --- /dev/null +++ b/storage/connect/TestInsert3.java @@ -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 + +} diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 84a686cc145..0e7e3ffc701 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -19,14 +19,14 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <stdint.h> // for uintprt_h -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include required application header files */ diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp index 76c9d09ac93..93ae5a5ef0c 100644 --- a/storage/connect/blkfil.cpp +++ b/storage/connect/blkfil.cpp @@ -20,13 +20,13 @@ #include "sql_class.h" //#include "sql_time.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/block.h b/storage/connect/block.h index c10fc4761ac..e8871277d48 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -24,11 +24,11 @@ #if !defined(BLOCK_DEFINED) #define BLOCK_DEFINED -#if defined(__WIN__) && !defined(NOEX) +#if defined(_WIN32) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !__WIN__ +#else // !_WIN32 #define DllExport -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Definition of class BLOCK with its method function new. */ diff --git a/storage/connect/bson.cpp b/storage/connect/bson.cpp index 060e8b1e394..bf03f47a10d 100644 --- a/storage/connect/bson.cpp +++ b/storage/connect/bson.cpp @@ -30,7 +30,7 @@ #define CheckType(X,Y) #endif -#if defined(__WIN__) +#if defined(_WIN32) #define EL "\r\n" #else #define EL "\n" diff --git a/storage/connect/cmgoconn.cpp b/storage/connect/cmgoconn.cpp index 6ab9e781994..f3fc30fa9e2 100644 --- a/storage/connect/cmgoconn.cpp +++ b/storage/connect/cmgoconn.cpp @@ -161,16 +161,16 @@ bool CMgoConn::Connect(PGLOBAL g) } // endif name if (!IsInit) -#if defined(__WIN__) +#if defined(_WIN32) __try { mongo_init(true); } __except (EXCEPTION_EXECUTE_HANDLER) { strcpy(g->Message, "Cannot load MongoDB C driver"); return true; } // end try/except -#else // !__WIN__ +#else // !_WIN32 mongo_init(true); -#endif // !__WIN__ +#endif // !_WIN32 Uri = mongoc_uri_new_with_error(Pcg->Uristr, &Error); diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index a9cf43f3d96..7bbebaaa889 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -297,9 +297,9 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op) Buf_Type = TYPE_STRING; *Format.Type = 'C'; Format.Length = Long; -#if defined(__WIN__) +#if defined(_WIN32) Format.Prec = 1; // Case insensitive -#endif // __WIN__ +#endif // _WIN32 Constant = (!To_Tdb->GetDef()->GetMultiple() && To_Tdb->GetAmType() != TYPE_AM_PLG && To_Tdb->GetAmType() != TYPE_AM_PLM); diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp index 9ae34a3b9ef..9da73bdc770 100644 --- a/storage/connect/domdoc.cpp +++ b/storage/connect/domdoc.cpp @@ -4,7 +4,7 @@ /******************************************************************/ #include "my_global.h" #include <stdio.h> -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> #if defined(MSX2) #import "msxml2.dll" //Does not exist on Vista diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 18ba0b1018f..9f873e4f180 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -17,12 +17,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -30,7 +30,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -197,11 +197,11 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) return true; } // endif Memory -#if defined(__WIN__) +#if defined(_WIN32) if (mode != MODE_DELETE) { -#else // !__WIN__ +#else // !_WIN32 if (mode == MODE_READ) { -#endif // !__WIN__ +#endif // !_WIN32 CloseFileHandle(hFile); // Not used anymore hFile = INVALID_HANDLE_VALUE; // For Fblock } // endif Mode @@ -468,7 +468,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = (int)(Tpos - Memory); -#if defined(__WIN__) +#if defined(_WIN32) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -498,7 +498,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) #endif // UNIX } // endif Abort -#if defined(__WIN__) +#if defined(_WIN32) CloseHandle(fp->Handle); #else // UNIX close(fp->Handle); diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index 542159fd172..a93fba52a50 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -22,12 +22,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> //#include <errno.h> //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -35,7 +35,7 @@ //#include <io.h> #endif // !UNIX //#include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 #include <ctype.h> #include <stdio.h> #include <string.h> @@ -649,7 +649,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); if (mode == MODE_INSERT) { -#if defined(__WIN__) +#if defined(_WIN32) /************************************************************************/ /* 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 */ @@ -659,7 +659,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) sprintf(g->Message, MSG(BIN_MODE_FAIL), strerror(errno)); return true; } // endif setmode -#endif // __WIN__ +#endif // _WIN32 /************************************************************************/ /* If this is a new file, the header must be generated. */ diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index 0a98ec5b54a..e0002f6f784 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #endif // !UNIX #include <sys/stat.h> #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -338,7 +338,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #else 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) { -#if defined(__WIN__) +#if defined(_WIN32) char buf[256]; DWORD drc; 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); return true; } // endif -#else // !__WIN__ +#else // !_WIN32 if (lseek64(h, pos, org) < 0) { // sprintf(g->Message, MSG(ERROR_IN_LSK), errno); sprintf(g->Message, "lseek64: %s", strerror(errno)); printf("%s\n", g->Message); return true; } // endif -#endif // !__WIN__ +#endif // !_WIN32 return false; } // end of BigSeek @@ -714,7 +714,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), { int rc; -#if defined(__WIN__) +#if defined(_WIN32) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); @@ -736,12 +736,12 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), rc = -1; } else rc = (int)nbr; -#else // !__WIN__ +#else // !_WIN32 size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); rc = (int)nbr; -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of BigRead @@ -753,7 +753,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(__WIN__) +#if defined(_WIN32) DWORD nbw, drc, len = (DWORD)req; 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; } // endif brc || nbw -#else // !__WIN__ +#else // !_WIN32 size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -796,7 +796,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of BigWrite @@ -831,7 +831,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) if (trace(1)) htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode); -#if defined(__WIN__) +#if defined(_WIN32) DWORD rc, access, creation, share = 0; /*********************************************************************/ @@ -989,7 +989,7 @@ int BGXFAM::Cardinality(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); -#if defined(__WIN__) // OB +#if defined(_WIN32) // OB LARGE_INTEGER len; DWORD rc = 0; @@ -1348,7 +1348,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) if (BigSeek(g, Hfile, (BIGINT)Tpos * (BIGINT)Lrecl)) return RC_FX; @@ -1358,12 +1358,12 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !__WIN__ +#else // !_WIN32 if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !__WIN__ +#endif // !_WIN32 } // endif UseTemp @@ -1388,7 +1388,7 @@ bool BGXFAM::OpenTempFile(PGLOBAL g) strcat(PlugRemoveType(tempname, tempname), ".t"); remove(tempname); // Be sure it does not exist yet -#if defined(__WIN__) +#if defined(_WIN32) Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); @@ -1528,7 +1528,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort) void BGXFAM::Rewind(void) { #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); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamgz.cpp b/storage/connect/filamgz.cpp index 880db54c91d..1f785fc73ac 100644 --- a/storage/connect/filamgz.cpp +++ b/storage/connect/filamgz.cpp @@ -17,21 +17,21 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #else // !UNIX #include <io.h> #endif #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -89,11 +89,11 @@ int GZFAM::Zerror(PGLOBAL g) strcpy(g->Message, gzerror(Zfile, &errnum)); if (errnum == Z_ERRNO) -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(NULL)); -#else // !__WIN__ +#else // !_WIN32 sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); -#endif // !__WIN__ +#endif // !_WIN32 return (errnum == Z_STREAM_END) ? RC_EF : RC_FX; } // end of Zerror @@ -764,9 +764,9 @@ bool GZXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() < 2) // if not binary, the file is physically a text file for (int len = Lrecl; len <= Buflen; len += Lrecl) { -#if defined(__WIN__) +#if defined(_WIN32) To_Buf[len - 2] = '\r'; -#endif // __WIN__ +#endif // _WIN32 To_Buf[len - 1] = '\n'; } // endfor len diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index 30ce19a5d37..13779858d48 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) || defined(UNIV_LINUX) #include <errno.h> #include <unistd.h> @@ -36,7 +36,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -82,7 +82,7 @@ TXTFAM::TXTFAM(PDOSDEF tdp) To_File = NULL; Lrecl = 0; Eof = false; -#if defined(__WIN__) +#if defined(_WIN32) Ending = 2; #else Ending = 1; @@ -731,7 +731,7 @@ int DOSFAM::SkipRecord(PGLOBAL g, bool header) if (feof(Stream)) return RC_EF; -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #else sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); @@ -814,7 +814,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g) if (trace(2)) htrc(" Read: To_Buf=%p p=%c\n", To_Buf, p); -#if defined(__WIN__) +#if defined(_WIN32) if (Bin) { // Data file is read in binary so CRLF remains #else @@ -848,7 +848,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #else sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); @@ -1043,7 +1043,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) if (chsize(h, Tpos)) { sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); close(h); @@ -1482,7 +1482,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #else sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); @@ -1567,11 +1567,11 @@ int BLKFAM::WriteBuffer(PGLOBAL g) Spos = GetNextPos(); // New start position // Prepare the output buffer -#if defined(__WIN__) +#if defined(_WIN32) crlf = "\r\n"; #else crlf = "\n"; -#endif // __WIN__ +#endif // _WIN32 strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf); len = strlen(OutBuf); } else { @@ -1871,7 +1871,7 @@ int BINFAM::ReadBuffer(PGLOBAL g) } else if (feof(Stream)) { rc = RC_EF; } else { -#if defined(__WIN__) +#if defined(_WIN32) sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #else sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); @@ -2065,7 +2065,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) if (chsize(h, Tpos)) { sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno)); close(h); diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index 5a3e025cd55..7a3c43e507f 100644 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -21,7 +21,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -29,7 +29,7 @@ #endif // __BORLAND__ //#include <windows.h> #include <sys/stat.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -40,7 +40,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -371,11 +371,11 @@ bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn) int h, n; 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); -#else // !__WIN__ +#else // !_WIN32 h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE); -#endif // !__WIN__ +#endif // !_WIN32 if (h == -1) return true; @@ -1672,7 +1672,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) // Remove extra blocks n = Block * Blksize; -#if defined(__WIN__) +#if defined(_WIN32) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -2579,11 +2579,11 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) char fn[_MAX_PATH]; sprintf(fn, Colfn, colp->Index); -#if defined(__WIN__) +#if defined(_WIN32) if (feof(Streams[i])) -#else // !__WIN__ +#else // !_WIN32 if (errno == NO_ERROR) -#endif // !__WIN__ +#endif // !_WIN32 sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn); else sprintf(g->Message, MSG(READ_ERROR), @@ -2979,7 +2979,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ n = Tpos * Clens[i]; -#if defined(__WIN__) +#if defined(_WIN32) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { @@ -3059,7 +3059,7 @@ BGVFAM::BGVFAM(PBGVFAM txfp) : VCTFAM(txfp) /***********************************************************************/ bool BGVFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b) { -#if defined(__WIN__) +#if defined(_WIN32) char buf[256]; DWORD drc, m = (b) ? FILE_END : FILE_BEGIN; 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); return true; } // endif -#else // !__WIN__ +#else // !_WIN32 if (lseek64(h, pos, (b) ? SEEK_END : SEEK_SET) < 0) { sprintf(g->Message, MSG(ERROR_IN_LSK), errno); return true; } // endif -#endif // !__WIN__ +#endif // !_WIN32 return false; } // end of BigSeek @@ -3092,7 +3092,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(__WIN__) +#if defined(_WIN32) DWORD nbr, drc, len = (DWORD)req; 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; } // endif brc || nbr -#else // !__WIN__ +#else // !_WIN32 size_t len = (size_t)req; ssize_t nbr = read(h, inbuf, len); @@ -3133,7 +3133,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of BigRead @@ -3145,7 +3145,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) { bool rc = false; -#if defined(__WIN__) +#if defined(_WIN32) DWORD nbw, drc, len = (DWORD)req; 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; } // endif brc || nbw -#else // !__WIN__ +#else // !_WIN32 size_t len = (size_t)req; ssize_t nbw = write(h, inbuf, len); @@ -3188,7 +3188,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) rc = true; } // endif nbr -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of BigWrite @@ -3214,7 +3214,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) if (Header == 2) strcat(PlugRemoveType(filename, filename), ".blk"); -#if defined(__WIN__) +#if defined(_WIN32) LARGE_INTEGER len; h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -3226,11 +3226,11 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) } // endif h if (h == INVALID_HANDLE_VALUE || !len.QuadPart) { -#else // !__WIN__ +#else // !_WIN32 h = open64(filename, O_RDONLY, 0); if (h == INVALID_HANDLE_VALUE || !_filelength(h)) { -#endif // !__WIN__ +#endif // !_WIN32 // Consider this is a void table if (trace(1)) htrc("Void table h=%d\n", h); @@ -3291,17 +3291,17 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) strcat(PlugRemoveType(filename, filename), ".blk"); if (h == INVALID_HANDLE_VALUE) { -#if defined(__WIN__) +#if defined(_WIN32) DWORD creation = (b) ? OPEN_EXISTING : TRUNCATE_EXISTING; h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL); -#else // !__WIN__ +#else // !_WIN32 int oflag = (b) ? O_RDWR : O_RDWR | O_TRUNC; h = open64(filename, oflag, 0); -#endif // !__WIN__ +#endif // !_WIN32 if (h == INVALID_HANDLE_VALUE) { 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()); -#if defined(__WIN__) +#if defined(_WIN32) PCSZ p; DWORD rc; bool brc; @@ -3391,7 +3391,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn) CloseHandle(h); return true; -#else // !__WIN__ +#else // !_WIN32 int h; BIGINT pos; @@ -3420,7 +3420,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn) sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno)); close(h); return true; -#endif // !__WIN__ +#endif // !_WIN32 } // end of MakeEmptyFile /***********************************************************************/ @@ -3451,7 +3451,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) htrc("OpenTableFile: filename=%s mode=%d Last=%d\n", filename, mode, Last); -#if defined(__WIN__) +#if defined(_WIN32) DWORD access, creation, share = 0, rc = 0; /*********************************************************************/ @@ -3779,7 +3779,7 @@ int BGVFAM::WriteBuffer(PGLOBAL g) if (!Closing && !MaxBlk) { // Close the VCT file and reopen it in mode Insert -//#if defined(__WIN__) //OB +//#if defined(_WIN32) //OB // CloseHandle(Hfile); //#else // UNIX // close(Hfile); @@ -3906,7 +3906,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) /***************************************************************/ /* Remove extra records. */ /***************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) BIGINT pos = (BIGINT)Block * (BIGINT)Blksize; if (BigSeek(g, Hfile, pos)) @@ -3918,12 +3918,12 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) sprintf(g->Message, MSG(SETEOF_ERROR), drc); return RC_FX; } // endif error -#else // !__WIN__ +#else // !_WIN32 if (ftruncate64(Hfile, (BIGINT)(Tpos * Lrecl))) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); return RC_FX; } // endif -#endif // !__WIN__ +#endif // !_WIN32 } else // MaxBlk // Clean the unused space in the file, this is required when // inserting again with a partial column list. @@ -3960,7 +3960,7 @@ bool BGVFAM::OpenTempFile(PGLOBAL g) else if (MakeEmptyFile(g, tempname)) return true; -#if defined(__WIN__) +#if defined(_WIN32) DWORD access = (MaxBlk) ? OPEN_EXISTING : CREATE_NEW; Tfile = CreateFile(tempname, GENERIC_WRITE, 0, NULL, @@ -4231,7 +4231,7 @@ void BGVFAM::Rewind(void) CurNum = Nrec - 1; #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); #else // UNIX lseek64(Hfile, 0, SEEK_SET); diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index eeb23e1f053..3d576e97ebb 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if !defined(__WIN__) +#if !defined(_WIN32) #if defined(UNIX) #include <fnmatch.h> #include <errno.h> @@ -27,7 +27,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 #include <time.h> /***********************************************************************/ @@ -154,7 +154,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) /*********************************************************************/ strcpy(filename, pat); -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE], direc[_MAX_DIR]; WIN32_FIND_DATA FileData; HANDLE hSearch; @@ -210,7 +210,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) return true; } // endif FindClose -#else // !__WIN__ +#else // !_WIN32 struct stat fileinfo; char fn[FN_REFLEN], direc[FN_REFLEN], pattern[FN_HEADLEN], ftype[FN_EXTLEN]; DIR *dir; @@ -251,7 +251,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) // Close the dir handle. closedir(dir); -#endif // !__WIN__ +#endif // !_WIN32 return false; } // 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 char* p = strrchr((char*)fn, '/'); -#if defined(__WIN__) +#if defined(_WIN32) if (!p) p = strrchr((char*)fn, '\\'); -#endif // __WIN__ +#endif // _WIN32 entp = (p) ? p + 1 : entry; } else entp = entry; @@ -467,7 +467,7 @@ UNZIPUTL::UNZIPUTL(PCSZ tgt, PCSZ pw, bool mul) memset(fn, 0, sizeof(fn)); // Init the case mapping table. -#if defined(__WIN__) +#if defined(_WIN32) for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i); #else for (int i = 0; i < 256; ++i) mapCaseTable[i] = i; @@ -487,7 +487,7 @@ UNZIPUTL::UNZIPUTL(PDOSDEF tdp) memset(fn, 0, sizeof(fn)); // Init the case mapping table. -#if defined(__WIN__) +#if defined(_WIN32) for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i); #else for (int i = 0; i < 256; ++i) mapCaseTable[i] = i; diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 7082b082c67..afcd2adfab0 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -13,13 +13,13 @@ //#include "sql_class.h" //#include "sql_time.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ diff --git a/storage/connect/filter.h b/storage/connect/filter.h index c6ab8fddd35..12ac3a169c1 100644 --- a/storage/connect/filter.h +++ b/storage/connect/filter.h @@ -106,7 +106,7 @@ class FILTERX : public FILTER { // Fake operator new used to change a filter into a derived filter 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 void operator delete(void *, PFIL) {} #else diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 729b1b883c1..1fb2b3fee65 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -22,12 +22,12 @@ */ #define FLEX_SCANNER -#ifdef __WIN__ +#ifdef _WIN32 #define __STDC__ 1 #define isatty _isatty #endif #include <stdio.h> -#ifndef __WIN__ +#ifndef _WIN32 #include <unistd.h> #endif diff --git a/storage/connect/global.h b/storage/connect/global.h index 8774285e54b..eb3d4106477 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -14,11 +14,11 @@ #include <time.h> /* time_t type declaration */ #include <setjmp.h> /* Long jump declarations */ -#if defined(__WIN__) && !defined(NOEX) +#if defined(_WIN32) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !__WIN__ +#else // !_WIN32 #define DllExport -#endif // !__WIN__ +#endif // !_WIN32 #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #define XML_SUPPORT 1 @@ -43,11 +43,11 @@ #define STEP(I) MSG_##I #endif // !XMSG and !NEWMSG -#if defined(__WIN__) +#if defined(_WIN32) #define CRLF 2 -#else // !__WIN__ +#else // !_WIN32 #define CRLF 1 -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Define access to the thread based trace value. */ @@ -204,9 +204,9 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *); #elif defined(NEWMSG) DllExport char *PlugGetMessage(PGLOBAL, int); #endif // XMSG || NEWMSG -#if defined(__WIN__) +#if defined(_WIN32) DllExport short GetLineLength(PGLOBAL); // Console line length -#endif // __WIN__ +#endif // _WIN32 DllExport PGLOBAL PlugInit(LPCSTR, size_t); // Plug global initialization DllExport PGLOBAL PlugExit(PGLOBAL); // Plug global termination DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 416bbb5d071..01fe7a6d2b3 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -139,10 +139,10 @@ //#include "reldef.h" #include "tabcol.h" #include "xindex.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include "tabwmi.h" -#endif // __WIN__ +#endif // _WIN32 #include "connect.h" #include "user_connect.h" #include "ha_connect.h" @@ -170,13 +170,13 @@ #define JSONMAX 50 // JSON Default max grp size extern "C" { - char version[]= "Version 1.07.0003 May 22, 2021"; -#if defined(__WIN__) + char version[]= "Version 1.07.0003 June 06, 2021"; +#if defined(_WIN32) char compver[]= "Version 1.07.0003 " __DATE__ " " __TIME__; char slash= '\\'; -#else // !__WIN__ +#else // !_WIN32 char slash= '/'; -#endif // !__WIN__ +#endif // !_WIN32 } // extern "C" #if MYSQL_VERSION_ID > 100200 @@ -802,11 +802,11 @@ static int connect_init_func(void *p) } #endif // 0 (LINUX) -#if defined(__WIN__) +#if defined(_WIN32) sql_print_information("CONNECT: %s", compver); -#else // !__WIN__ +#else // !_WIN32 sql_print_information("CONNECT: %s", version); -#endif // !__WIN__ +#endif // !_WIN32 pthread_mutex_init(&parmut, NULL); pthread_mutex_init(&usrmut, NULL); pthread_mutex_init(&tblmut, NULL); @@ -865,9 +865,9 @@ static int connect_done_func(void *) JAVAConn::ResetJVM(); #endif // JAVA_SUPPORT -#if !defined(__WIN__) +#if !defined(_WIN32) PROFILE_End(); -#endif // !__WIN__ +#endif // !_WIN32 pthread_mutex_lock(&usrmut); for (pc= user_connect::to_users; pc; pc= pn) { @@ -941,11 +941,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) xp= (table) ? GetUser(ha_thd(), NULL) : NULL; if (xp) xp->SetHandler(this); -#if defined(__WIN__) +#if defined(_WIN32) datapath= ".\\"; -#else // !__WIN__ +#else // !_WIN32 datapath= "./"; -#endif // !__WIN__ +#endif // !_WIN32 tdbp= NULL; sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL; sdvalout= NULL; @@ -4549,11 +4549,11 @@ static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options, strcpy(dbpath, mysql_real_data_home); if (db) -#if defined(__WIN__) +#if defined(_WIN32) strcat(strcat(dbpath, db), "\\"); -#else // !__WIN__ +#else // !_WIN32 strcat(strcat(dbpath, db), "/"); -#endif // !__WIN__ +#endif // !_WIN32 (void)fn_format(path, options->filename, dbpath, "", MY_RELATIVE_PATH | MY_UNPACK_FILENAME); @@ -5607,9 +5607,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd, PCSZ user, fn, db, host, pwd, sep, tbl, src; PCSZ col, ocl, rnk, pic, fcl, skc, zfn; char *tab, *dsn, *shm, *dpath, *url; -#if defined(__WIN__) +#if defined(_WIN32) PCSZ nsp= NULL, cls= NULL; -#endif // __WIN__ +#endif // _WIN32 //int hdr, mxe; int port= 0, mxr= 0, rc= 0, mul= 0, lrecl= 0; //PCSZ tabtyp= NULL; @@ -5670,10 +5670,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd, skc= GetListOption(g, "skipcol", topt->oplist, NULL); rnk= GetListOption(g, "rankcol", topt->oplist, NULL); pwd= GetListOption(g, "password", topt->oplist); -#if defined(__WIN__) +#if defined(_WIN32) nsp= GetListOption(g, "namespace", topt->oplist); cls= GetListOption(g, "class", topt->oplist); -#endif // __WIN__ +#endif // _WIN32 port= atoi(GetListOption(g, "port", topt->oplist, "0")); #if defined(ODBC_SUPPORT) // tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL); @@ -5904,11 +5904,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ok= false; break; -#if defined(__WIN__) +#if defined(_WIN32) case TAB_WMI: ok= true; break; -#endif // __WIN__ +#endif // _WIN32 case TAB_PIVOT: supfnc= FNC_NO; case TAB_PRX: @@ -6072,11 +6072,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd, case TAB_CSV: qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL); break; -#if defined(__WIN__) +#if defined(_WIN32) case TAB_WMI: qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); break; -#endif // __WIN__ +#endif // _WIN32 case TAB_PRX: case TAB_TBL: case TAB_XCL: @@ -6606,11 +6606,11 @@ int ha_connect::create(const char *name, TABLE *table_arg, // on Windows and libxml2 otherwise switch (toupper(*xsup)) { case '*': -#if defined(__WIN__) +#if defined(_WIN32) dom= true; -#else // !__WIN__ +#else // !_WIN32 dom= false; -#endif // !__WIN__ +#endif // !_WIN32 break; case 'M': case 'D': @@ -6993,11 +6993,11 @@ bool ha_connect::FileExists(const char *fn, bool bf) int n; struct stat info; -#if defined(__WIN__) +#if defined(_WIN32) s= "\\"; -#else // !__WIN__ +#else // !_WIN32 s= "/"; -#endif // !__WIN__ +#endif // !_WIN32 if (IsPartitioned()) { sprintf(tfn, fn, GetPartName()); diff --git a/storage/connect/javaconn.cpp b/storage/connect/javaconn.cpp index 34b844f59b0..2b288e3cdc6 100644 --- a/storage/connect/javaconn.cpp +++ b/storage/connect/javaconn.cpp @@ -6,24 +6,24 @@ /* This file contains the JAVA connection classes functions. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) // This is needed for RegGetValue #define _WINVER 0x0601 #undef _WIN32_WINNT #define _WIN32_WINNT 0x0601 -#endif // __WIN__ +#endif // _WIN32 /***********************************************************************/ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include <my_global.h> //#include <m_string.h> -#if defined(__WIN__) +#if defined(_WIN32) #include <direct.h> // for getcwd #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #else // !UNIX @@ -31,7 +31,7 @@ #include <stdio.h> #include <stdlib.h> // for getenv #define NODW -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Required objects includes. */ @@ -47,9 +47,9 @@ #include "valblk.h" #include "osutil.h" -#if defined(__WIN__) +#if defined(_WIN32) extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // __WIN__ +#endif // _WIN32 #define nullptr 0 //TYPCONV GetTypeConv(); @@ -200,11 +200,11 @@ int JAVAConn::GetMaxValue(int n) void JAVAConn::ResetJVM(void) { if (LibJvm) { -#if defined(__WIN__) +#if defined(_WIN32) FreeLibrary((HMODULE)LibJvm); -#else // !__WIN__ +#else // !_WIN32 dlclose(LibJvm); -#endif // !__WIN__ +#endif // !_WIN32 LibJvm = NULL; CreateJavaVM = NULL; GetCreatedJavaVMs = NULL; @@ -227,7 +227,7 @@ bool JAVAConn::GetJVM(PGLOBAL g) if (!LibJvm) { char soname[512]; -#if defined(__WIN__) +#if defined(_WIN32) for (ntry = 0; !LibJvm && ntry < 3; ntry++) { if (!ntry && JvmPath) { strcat(strcpy(soname, JvmPath), "\\jvm.dll"); @@ -295,7 +295,7 @@ bool JAVAConn::GetJVM(PGLOBAL g) LibJvm = NULL; #endif // _DEBUG } // endif LibJvm -#else // !__WIN__ +#else // !_WIN32 const char *error = NULL; for (ntry = 0; !LibJvm && ntry < 2; ntry++) { @@ -336,7 +336,7 @@ bool JAVAConn::GetJVM(PGLOBAL g) LibJvm = NULL; #endif // _DEBUG } // endif LibJvm -#endif // !__WIN__ +#endif // !_WIN32 } // endif LibJvm @@ -378,7 +378,7 @@ bool JAVAConn::Open(PGLOBAL g) char *cp = NULL; char sep; -#if defined(__WIN__) +#if defined(_WIN32) sep = ';'; #define N 1 //#define N 2 diff --git a/storage/connect/javaconn.h b/storage/connect/javaconn.h index 73812f6ab3b..963b8c1a6ac 100644 --- a/storage/connect/javaconn.h +++ b/storage/connect/javaconn.h @@ -27,9 +27,9 @@ //efine MAX_CURSOR_NAME 18 // Max size of a cursor name //efine DEFAULT_FIELD_TYPE 0 // TYPE_NULL -#if !defined(__WIN__) +#if !defined(_WIN32) typedef unsigned char *PUCHAR; -#endif // !__WIN__ +#endif // !_WIN32 enum JCATINFO { JCAT_TAB = 1, // JDBC Tables @@ -104,11 +104,11 @@ public: protected: // Members -#if defined(__WIN__) +#if defined(_WIN32) static HANDLE LibJvm; // Handle to the jvm DLL -#else // !__WIN__ +#else // !_WIN32 static void *LibJvm; // Handle for the jvm shared library -#endif // !__WIN__ +#endif // !_WIN32 static CRTJVM CreateJavaVM; static GETJVM GetCreatedJavaVMs; #if defined(_DEBUG) diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index 2cb75e0adc1..20918745316 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -6,19 +6,19 @@ /* This file contains the JDBC connection classes functions. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) // This is needed for RegGetValue #define _WINVER 0x0601 #undef _WIN32_WINNT #define _WIN32_WINNT 0x0601 -#endif // __WIN__ +#endif // _WIN32 /***********************************************************************/ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include <my_global.h> #include <m_string.h> -#if defined(__WIN__) +#if defined(_WIN32) //nclude <io.h> //nclude <fcntl.h> #include <direct.h> // for getcwd @@ -26,7 +26,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #else // !UNIX @@ -36,7 +36,7 @@ #include <stdlib.h> // for getenv //nclude <fcntl.h> #define NODW -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Required objects includes. */ @@ -53,9 +53,9 @@ #include "osutil.h" -//#if defined(__WIN__) +//#if defined(_WIN32) //extern "C" HINSTANCE s_hModule; // Saved module handle -//#endif // __WIN__ +//#endif // _WIN32 #define nullptr 0 TYPCONV GetTypeConv(); diff --git a/storage/connect/jmgfam.cpp b/storage/connect/jmgfam.cpp index d7f469cf4fe..670781da6f5 100644 --- a/storage/connect/jmgfam.cpp +++ b/storage/connect/jmgfam.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <io.h> //#include <fcntl.h> //#include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) || defined(UNIV_LINUX) //#include <errno.h> #include <unistd.h> @@ -36,7 +36,7 @@ //#include <io.h> #endif // !UNIX //#include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index b376a8c5c27..9b7145bb498 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -23,7 +23,7 @@ #define ARGS MY_MIN(24,(int)len-i),s+MY_MAX(i-3,0) -#if defined(__WIN__) +#if defined(_WIN32) #define EL "\r\n" #else #define EL "\n" diff --git a/storage/connect/macutil.cpp b/storage/connect/macutil.cpp index f95f3adcc6e..93cd0bcb5e1 100644 --- a/storage/connect/macutil.cpp +++ b/storage/connect/macutil.cpp @@ -2,11 +2,11 @@ /* MACUTIL: Author Olivier Bertrand -- 2008-2012 */ /* From the article and sample code by Khalid Shaikh. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) #include "my_global.h" -#else // !__WIN__ +#else // !_WIN32 #error This is WINDOWS only DLL -#endif // !__WIN__ +#endif // !_WIN32 #include "global.h" #include "plgdbsem.h" #include "macutil.h" diff --git a/storage/connect/macutil.h b/storage/connect/macutil.h index c80bd58e20a..69a785dc9da 100644 --- a/storage/connect/macutil.h +++ b/storage/connect/macutil.h @@ -1,10 +1,10 @@ // MACUTIL.H Olivier Bertrand 2008-2012 // Get Mac Addresses via GetAdaptersInfo -#if defined(__WIN__) +#if defined(_WIN32) #include <iphlpapi.h> -#else // !__WIN__ +#else // !_WIN32 #error This is WINDOWS only -#endif // !__WIN__ +#endif // !_WIN32 #include "block.h" typedef class MACINFO *MACIP; diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp index 87263b3adf6..e4ad70f5032 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -14,7 +14,7 @@ #include "plgdbsem.h" #include "maputil.h" -#ifdef __WIN__ +#ifdef _WIN32 /***********************************************************************/ /* In Insert mode, just open the file for append. Otherwise */ /* create the mapping file object. The map handle can be released */ diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 4a7e65eb01f..d4b182b4c64 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -62,10 +62,10 @@ #include "tabvct.h" #endif // VCT_SUPPORT #include "tabsys.h" -#if defined(__WIN__) +#if defined(_WIN32) #include "tabmac.h" #include "tabwmi.h" -#endif // __WIN__ +#endif // _WIN32 //#include "tabtbl.h" #include "tabxcl.h" #include "tabtbl.h" @@ -105,9 +105,9 @@ /***********************************************************************/ /* Extern static variables. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // !__WIN__ +#endif // !_WIN32 #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) bool MongoEnabled(void); #endif // JAVA_SUPPORT || CMGO_SUPPORT @@ -161,10 +161,10 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "DIR")) ? TAB_DIR -#if defined(__WIN__) +#if defined(_WIN32) : (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "WMI")) ? TAB_WMI -#endif // __WIN__ +#endif // _WIN32 : (!stricmp(type, "TBL")) ? TAB_TBL : (!stricmp(type, "XCOL")) ? TAB_XCL : (!stricmp(type, "OCCUR")) ? TAB_OCCUR @@ -383,11 +383,11 @@ uint GetFuncID(const char *func) /***********************************************************************/ CATALOG::CATALOG(void) { -#if defined(__WIN__) +#if defined(_WIN32) //DataPath= ".\\"; -#else // !__WIN__ +#else // !_WIN32 //DataPath= "./"; -#endif // !__WIN__ +#endif // !_WIN32 memset(&Ctb, 0, sizeof(CURTAB)); Cbuf= NULL; Cblen= 0; @@ -481,10 +481,10 @@ PTABDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) #if defined(JAVA_SUPPORT) case TAB_JDBC: tdp= new(g) JDBCDEF; break; #endif // JAVA_SUPPORT -#if defined(__WIN__) +#if defined(_WIN32) case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break; -#endif // __WIN__ +#endif // _WIN32 case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 4303a9e191b..945c4e698be 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -35,11 +35,11 @@ #include "my_sys.h" #include "mysqld_error.h" #endif // !MYSQL_PREPARED_STATEMENTS -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include "osutil.h" -#endif // !__WIN__ +#endif // !_WIN32 #include "global.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_WRITE_TIMEOUT, ...); -#if defined(__WIN__) +#if defined(_WIN32) if (!strcmp(host, ".")) { mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL); pipe = mysqld_unix_port; } // endif host -#else // !__WIN__ +#else // !_WIN32 if (!strcmp(host, "localhost")) pipe = mysqld_unix_port; -#endif // !__WIN__ +#endif // !_WIN32 #if 0 if (pwd && !strcmp(pwd, "*")) { diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 9ebd37527a6..5f64f933878 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -7,24 +7,24 @@ /* DO NOT define DLL_EXPORT in your application so these items are */ /* declared are imported from the Myconn DLL. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) #include <winsock.h> -#else // !__WIN__ +#else // !_WIN32 #include <sys/socket.h> -#endif // !__WIN__ +#endif // !_WIN32 #include <mysql.h> #include <errmsg.h> #include "myutil.h" -#if defined(__WIN__) && defined(MYCONN_EXPORTS) +#if defined(_WIN32) && defined(MYCONN_EXPORTS) #if defined(DLL_EXPORT) #define DllItem _declspec(dllexport) #else // !DLL_EXPORT #define DllItem _declspec(dllimport) #endif // !DLL_EXPORT -#else // !__WIN__ || !MYCONN_EXPORTS +#else // !_WIN32 || !MYCONN_EXPORTS #define DllItem -#endif // !__WIN__ +#endif // !_WIN32 #define MYSQL_ENABLED 0x00000001 #define MYSQL_LOGON 0x00000002 diff --git a/storage/connect/mysql-test/connect/r/jdbc.result b/storage/connect/mysql-test/connect/r/jdbc.result index 0dbdf851860..b42311b8136 100644 --- a/storage/connect/mysql-test/connect/r/jdbc.result +++ b/storage/connect/mysql-test/connect/r/jdbc.result @@ -1,4 +1,5 @@ -SET GLOBAL time_zone='+1:00'; +SET GLOBAL time_zone='+0:00'; +SET time_zone='+0:00'; CREATE DATABASE connect; USE connect; CREATE TABLE t2 ( @@ -16,7 +17,7 @@ id msg tm dt dtm ts # Testing JDBC connection to MySQL driver # 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; 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 @@ -26,7 +27,7 @@ Note 1105 t2: 1 affected rows SELECT * FROM t1; 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 -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!'; Warnings: Note 1105 t2: 1 affected rows @@ -37,7 +38,7 @@ DROP TABLE t1; # # 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; id msg tm dt 455000000000 A very big number 18:10:25 2016-03-16 @@ -74,7 +75,7 @@ SELECT * FROM t3; name city birth hired Donald Atlanta 1999-04-01 2016-03-31 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; name city birth hired 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 James Dallas 1992-05-13 2009-12-14 Bill Boston 1986-09-11 2008-02-10 -Donald Atlanta 1999-03-31 2016-03-30 -Mick New York 1980-01-20 2002-09-10 -Tom Seatle 2002-03-15 1970-01-01 +Donald Atlanta 1999-04-01 2016-03-31 +Mick New York 1980-01-20 2002-09-11 +Tom Seatle 2002-03-15 NULL DROP TABLE t3; # # Testing JDBC join operations @@ -280,3 +281,4 @@ DROP TABLE t1; DROP TABLE connect.tx1; DROP DATABASE connect; SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; diff --git a/storage/connect/mysql-test/connect/r/jdbc_new.result b/storage/connect/mysql-test/connect/r/jdbc_new.result index 33d8bd3b7d8..a47fb9ccaf9 100644 --- a/storage/connect/mysql-test/connect/r/jdbc_new.result +++ b/storage/connect/mysql-test/connect/r/jdbc_new.result @@ -2,7 +2,8 @@ connect master,127.0.0.1,root,,test,$MASTER_MYPORT,; connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,; connection master; 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)); INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); SELECT * FROM t1; @@ -16,31 +17,32 @@ NULL NULL # Testing errors # 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 -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 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 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 SHOW CREATE TABLE t1; ERROR 42S02: Table 'test.t1' doesn't exist 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; Table Create Table t1 CREATE TABLE `t1` ( `x` int(11) 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; ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT DROP TABLE t1; 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; ALTER TABLE t1 RENAME t1backup; connection master; @@ -54,13 +56,13 @@ DROP TABLE t1; # Testing SELECT, etc. # 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; Table Create Table t1 CREATE TABLE `t1` ( `a` int(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; a b NULL NULL @@ -70,13 +72,13 @@ NULL NULL 3 test03 DROP TABLE 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; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) 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; a b NULL NULL @@ -86,13 +88,13 @@ NULL NULL 3 test03 DROP TABLE t1; 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; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) 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; a b 0 @@ -102,13 +104,13 @@ a b 3 test03 DROP TABLE t1; 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; Table Create Table t1 CREATE TABLE `t1` ( `a` char(10) 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; a b 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); connection master; 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; Table Create Table t1 CREATE TABLE `t1` ( @@ -150,7 +152,7 @@ t1 CREATE TABLE `t1` ( `f` double(14,0) DEFAULT NULL, `g` double(24,0) 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; a b c d e f g h 100 3333 41235 1234567890 235000000000 3 3 3141.59265 @@ -173,13 +175,13 @@ a b Welcome Hello, World connection master; 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; Table Create Table t1 CREATE TABLE `t1` ( `a` char(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; a b 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 connection master; 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; Table Create Table t1 CREATE TABLE `t1` ( @@ -218,13 +220,15 @@ t1 CREATE TABLE `t1` ( `c` time DEFAULT NULL, `d` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `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; 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; connection slave; DROP TABLE t1; SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; connection master; SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; diff --git a/storage/connect/mysql-test/connect/t/jdbc.test b/storage/connect/mysql-test/connect/t/jdbc.test index 58a527a3e6b..79809f4eaf3 100644 --- a/storage/connect/mysql-test/connect/t/jdbc.test +++ b/storage/connect/mysql-test/connect/t/jdbc.test @@ -1,6 +1,7 @@ -- source windows.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`; --copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt @@ -27,7 +28,7 @@ SELECT * FROM t2; --echo # USE test; --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; 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; @@ -39,7 +40,7 @@ DROP TABLE t1; --echo # Testing JDBC view --echo # --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 msg, dt FROM t1; 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; --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; UPDATE t1 SET city = 'Phoenix' WHERE name = 'Henry'; INSERT INTO t1 SELECT * FROM t3; @@ -145,4 +146,5 @@ DROP TABLE connect.tx1; DROP DATABASE connect; --remove_file $MYSQLD_DATADIR/test/girls.txt SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; -- source jdbconn_cleanup.inc diff --git a/storage/connect/mysql-test/connect/t/jdbc_new.test b/storage/connect/mysql-test/connect/t/jdbc_new.test index 36e8f36ced0..1eaafdfbf43 100644 --- a/storage/connect/mysql-test/connect/t/jdbc_new.test +++ b/storage/connect/mysql-test/connect/t/jdbc_new.test @@ -9,7 +9,8 @@ connection master; -- source jdbconn.inc 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)); 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 # connection master; -SET GLOBAL time_zone='+1:00'; +SET GLOBAL time_zone='+0:00'; +SET time_zone='+0:00'; # Bad user name # Suppress "mysql_real_connect failed:" (printed in _DEBUG build) --replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " "" --error ER_UNKNOWN_ERROR 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 --replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " "" --error ER_UNKNOWN_ERROR 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 --replace_result $SLAVE_MYPORT SLAVE_PORT --error ER_UNKNOWN_ERROR 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 SHOW CREATE TABLE t1; # Bad column name --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; --error ER_GET_ERRMSG @@ -55,7 +57,7 @@ DROP TABLE t1; # The remote table disappeared --replace_result $SLAVE_MYPORT SLAVE_PORT 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; ALTER TABLE t1 RENAME t1backup; @@ -77,7 +79,7 @@ DROP TABLE t1; # Automatic table structure --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -86,7 +88,7 @@ DROP TABLE t1; # Explicit table structure --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -95,7 +97,7 @@ DROP TABLE t1; # Explicit table structure: remote NULL, local NOT NULL --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -104,7 +106,7 @@ DROP TABLE t1; # Explicit table structure with wrong column types --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -125,7 +127,7 @@ INSERT INTO t1 VALUES(100,3333,41235,1234567890,235000000000,3.14159265,3.141592 connection master; --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -146,7 +148,7 @@ SELECT * FROM t1; connection master; --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -167,7 +169,7 @@ SELECT * FROM t1; connection master; --replace_result $SLAVE_MYPORT SLAVE_PORT 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 SHOW CREATE TABLE t1; SELECT * FROM t1; @@ -176,8 +178,10 @@ DROP TABLE t1; connection slave; DROP TABLE t1; SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; connection master; SET GLOBAL time_zone=SYSTEM; +SET time_zone=SYSTEM; -- source jdbconn_cleanup.inc diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index ed25abc4bc5..1c73ded5e05 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -13,11 +13,11 @@ /************************************************************************/ #include "my_global.h" #include <mysql.h> -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include "osutil.h" -#endif // !__WIN__ +#endif // !_WIN32 #include "global.h" #include "plgdbsem.h" diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index d08c6d1b7a5..5b20b33e240 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -11,7 +11,7 @@ /***********************************************************************/ #include <my_global.h> #include <m_string.h> -#if defined(__WIN__) +#if defined(_WIN32) //nclude <io.h> //nclude <fcntl.h> #include <direct.h> // for getcwd @@ -45,13 +45,13 @@ #include "osutil.h" -#if defined(__WIN__) +#if defined(_WIN32) /***********************************************************************/ /* For dynamic load of ODBC32.DLL */ /***********************************************************************/ #pragma comment(lib, "odbc32.lib") extern "C" HINSTANCE s_hModule; // Saved module handle -#endif // __WIN__ +#endif // _WIN32 TYPCONV GetTypeConv(); int GetConvSize(); @@ -1280,15 +1280,15 @@ bool ODBConn::DriverConnect(DWORD Options) SWORD nResult; PUCHAR ConnOut = (PUCHAR)PlugSubAlloc(m_G, NULL, MAX_CONNECT_LEN); UWORD wConnectOption = SQL_DRIVER_COMPLETE; -#if defined(__WIN__) +#if defined(_WIN32) HWND hWndTop = GetForegroundWindow(); HWND hWnd = GetParent(hWndTop); if (hWnd == NULL) hWnd = GetDesktopWindow(); -#else // !__WIN__ +#else // !_WIN32 HWND hWnd = (HWND)1; -#endif // !__WIN__ +#endif // !_WIN32 PGLOBAL& g = m_G; PDBUSER dup = PlgGetUser(g); @@ -1301,10 +1301,10 @@ bool ODBConn::DriverConnect(DWORD Options) SQL_NTS, ConnOut, MAX_CONNECT_LEN, &nResult, wConnectOption); -#if defined(__WIN__) +#if defined(_WIN32) if (hWndTop) EnableWindow(hWndTop, true); -#endif // __WIN__ +#endif // _WIN32 // If user hit 'Cancel' if (rc == SQL_NO_DATA_FOUND) { diff --git a/storage/connect/odbconn.h b/storage/connect/odbconn.h index f98c67bd12f..7038f06e5f3 100644 --- a/storage/connect/odbconn.h +++ b/storage/connect/odbconn.h @@ -29,9 +29,9 @@ //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 -#if !defined(__WIN__) +#if !defined(_WIN32) typedef unsigned char *PUCHAR; -#endif // !__WIN__ +#endif // !_WIN32 // Field Flags, used to indicate status of fields //efine SQL_FIELD_FLAG_DIRTY 0x1 diff --git a/storage/connect/os.h b/storage/connect/os.h index 797692d47b2..7d0d5cabbb6 100644 --- a/storage/connect/os.h +++ b/storage/connect/os.h @@ -16,19 +16,19 @@ typedef off_t off64_t; #endif #endif -#if defined(__WIN__) +#if defined(_WIN32) typedef __int64 BIGINT; typedef _Null_terminated_ const char *PCSZ; -#else // !__WIN__ +#else // !_WIN32 typedef longlong BIGINT; #define FILE_BEGIN SEEK_SET #define FILE_CURRENT SEEK_CUR #define FILE_END SEEK_END typedef const char *PCSZ; -#endif // !__WIN__ +#endif // !_WIN32 -#if !defined(__WIN__) +#if !defined(_WIN32) typedef const void *LPCVOID; typedef const char *LPCTSTR; typedef const char *LPCSTR; @@ -65,6 +65,6 @@ typedef int HANDLE; #define _MAX_EXT FN_EXTLEN #define INVALID_HANDLE_VALUE (-1) #define __stdcall -#endif /* !__WIN__ */ +#endif /* !_WIN32 */ #endif /* _OS_H_INCLUDED */ diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c index da896fec50e..278023f55a2 100644 --- a/storage/connect/osutil.c +++ b/storage/connect/osutil.c @@ -5,7 +5,7 @@ #include <stdio.h> #include "osutil.h" -#ifdef __WIN__ +#ifdef _WIN32 my_bool CloseFileHandle(HANDLE h) { return !CloseHandle(h); diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index dd204d065ed..370bf69ffa0 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -581,11 +581,11 @@ typedef struct _colres { char Var; /* Type added information */ } COLRES; -#if defined(__WIN__) && !defined(NOEX) +#if defined(_WIN32) && !defined(NOEX) #define DllExport __declspec( dllexport ) -#else // !__WIN__ +#else // !_WIN32 #define DllExport -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Utility routines. */ diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 7bc7c5f592b..6c1ce4ad6d3 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -39,12 +39,12 @@ /***********************************************************************/ #include "my_global.h" #include "my_pthread.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> #define BIGMEM 1048576 // 1 Megabyte -#else // !__WIN__ +#else // !_WIN32 #include <unistd.h> #include <fcntl.h> //#if defined(THREAD) @@ -52,7 +52,7 @@ //#endif // THREAD #include <stdarg.h> #define BIGMEM 2147483647 // Max int value -#endif // !__WIN__ +#endif // !_WIN32 #include <locale.h> /***********************************************************************/ @@ -89,11 +89,11 @@ extern "C" { extern char version[]; } // extern "C" -//#if defined(__WIN__) +//#if defined(_WIN32) //extern CRITICAL_SECTION parsec; // Used calling the Flex parser -//#else // !__WIN__ +//#else // !_WIN32 extern pthread_mutex_t parmut; -//#endif // !__WIN__ +//#endif // !_WIN32 // The debug trace used by the main thread FILE *pfile = NULL; @@ -386,11 +386,11 @@ char *SetPath(PGLOBAL g, const char *path) } // endif path if (*path != '.') { -#if defined(__WIN__) +#if defined(_WIN32) const char *s = "\\"; -#else // !__WIN__ +#else // !_WIN32 const char *s = "/"; -#endif // !__WIN__ +#endif // !_WIN32 strcat(strcat(strcat(strcpy(buf, "."), s), path), s); } else 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; switch (op) { // Determine which part to extract -#if defined(__WIN__) +#if defined(_WIN32) case OP_FDISK: drive = pBuff; break; #endif // !UNIX 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 // in the area, do allocate from virtual storage. const char*v = "malloc"; -#if defined(__WIN__) +#if defined(_WIN32) if (mp.Size >= BIGMEM) { v = "VirtualAlloc"; 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) { const char*v = "free"; -#if defined(__WIN__) +#if defined(_WIN32) if (mp.Size >= BIGMEM) { v = "VirtualFree"; VirtualFree(mp.Memp, 0, MEM_RELEASE); @@ -1554,11 +1554,11 @@ int FileComp(PGLOBAL g, char *file1, char *file2) bp[0] = buff1; bp[1] = buff2; 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); -#else // !__WIN__ +#else // !_WIN32 h[i]= global_open(g, MSGOD_NONE, fn[i], O_RDONLY); -#endif // !__WIN__ +#endif // !_WIN32 if (h[i] == -1) { // if (errno != ENOENT) { diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp index 9e1f006d605..4aecbadfc6a 100644 --- a/storage/connect/plugutil.cpp +++ b/storage/connect/plugutil.cpp @@ -44,7 +44,7 @@ /* */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> #else #if defined(UNIX) || defined(UNIV_LINUX) @@ -81,9 +81,9 @@ #include "rcmsg.h" #endif // NEWMSG -#if defined(__WIN__) +#if defined(_WIN32) extern HINSTANCE s_hModule; /* Saved module handle */ -#endif // __WIN__ +#endif // _WIN32 #if defined(XMSG) extern char *msg_path; @@ -205,7 +205,7 @@ PGLOBAL PlugExit(PGLOBAL g) /***********************************************************************/ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) { -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -232,7 +232,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) BOOL PlugIsAbsolutePath(LPCSTR path) { -#if defined(__WIN__) +#if defined(_WIN32) return ((path[0] >= 'a' && path[0] <= 'z') || (path[0] >= 'A' && path[0] <= 'Z')) && path[1] == ':'; #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 fname[_MAX_FNAME]; char ftype[_MAX_EXT]; -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE], defdrv[_MAX_DRIVE]; #else char *drive = NULL, *defdrv = NULL; @@ -270,7 +270,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return pBuff; } // endif -#if !defined(__WIN__) +#if !defined(_WIN32) if (*FileName == '~') { if (_fullpath(pBuff, FileName, _MAX_PATH)) { if (trace(2)) @@ -281,7 +281,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) return FileName; // Error, return unchanged name } // endif FileName -#endif // !__WIN__ +#endif // !_WIN32 if (prefix && strcmp(prefix, ".") && !PlugIsAbsolutePath(defpath)) { @@ -310,7 +310,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) if (trace(2)) { 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("defdrv=%s defdir=%s\n", defdrv, defdir); #else @@ -442,7 +442,7 @@ char *PlugGetMessage(PGLOBAL g, int mid) } // end of PlugGetMessage #endif // NEWMSG -#if defined(__WIN__) +#if defined(_WIN32) /***********************************************************************/ /* Return the line length of the console screen buffer. */ /***********************************************************************/ @@ -454,7 +454,7 @@ short GetLineLength(PGLOBAL g) return (b) ? coninfo.dwSize.X : 0; } // end of GetLineLength -#endif // __WIN__ +#endif // _WIN32 /***********************************************************************/ /* 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. */ /*********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) if (size >= 1048576) // 1M g->Sarea = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); else @@ -500,7 +500,7 @@ bool AllocSarea(PGLOBAL g, size_t size) void FreeSarea(PGLOBAL g) { if (g->Sarea) { -#if defined(__WIN__) +#if defined(_WIN32) if (g->Sarea_Size >= 1048576) // 1M VirtualFree(g->Sarea, 0, MEM_RELEASE); else diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c index 895f8f5862b..4cd443d88bb 100644 --- a/storage/connect/rcmsg.c +++ b/storage/connect/rcmsg.c @@ -21,9 +21,9 @@ #include "msgid.h" #endif // NEWMSG -#if !defined(__WIN__) +#if !defined(_WIN32) #define stricmp strcasecmp -#endif // !__WIN__ +#endif // !_WIN32 char *msglang(void); diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index bb25d4803d9..d7715a2ea9f 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -17,7 +17,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <sqlext.h> #else //#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ... @@ -52,9 +52,9 @@ #include "ha_connect.h" #include "mycat.h" -#if !defined(__WIN__) +#if !defined(_WIN32) extern handlerton *connect_hton; -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* 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); const char* module, * subtype; char c, soname[_MAX_PATH], getname[40] = "Col"; -#if defined(__WIN__) +#if defined(_WIN32) HANDLE hdll; /* Handle to the external DLL */ -#else // !__WIN__ +#else // !_WIN32 void* hdll; /* Handle for the loaded shared library */ -#endif // !__WIN__ +#endif // !_WIN32 XCOLDEF coldef = NULL; PQRYRES qrp = NULL; @@ -103,7 +103,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info) if (!c) break; } // endfor i -#if defined(__WIN__) +#if defined(_WIN32) // Load the Dll implementing the table if (!(hdll = LoadLibrary(soname))) { char buf[256]; @@ -123,7 +123,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info) FreeLibrary((HMODULE)hdll); return NULL; } // endif coldef -#else // !__WIN__ +#else // !_WIN32 const char* error = NULL; // Load the desired shared library @@ -140,7 +140,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info) dlclose(hdll); return NULL; } // endif coldef -#endif // !__WIN__ +#endif // !_WIN32 // Just in case the external Get function does not set error messages sprintf(g->Message, "Error getting column info from %s", subtype); @@ -148,11 +148,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info) // Get the table column definition qrp = coldef(g, topt, tab, db, info); -#if defined(__WIN__) +#if defined(_WIN32) FreeLibrary((HMODULE)hdll); -#else // !__WIN__ +#else // !_WIN32 dlclose(hdll); -#endif // !__WIN__ +#endif // !_WIN32 return qrp; } // end of OEMColumns @@ -407,13 +407,13 @@ int TABDEF::GetColCatInfo(PGLOBAL g) // Take care of the column definitions i= poff= nof= nlg= 0; -#if defined(__WIN__) +#if defined(_WIN32) // 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; -#else // !__WIN__ +#else // !_WIN32 // 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; -#endif // !__WIN__ +#endif // !_WIN32 while (true) { // Default Offset depends on table format @@ -624,7 +624,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) strncat(strcpy(soname, GetPluginDir()), Module, sizeof(soname) - strlen(soname) - 1); -#if defined(__WIN__) +#if defined(_WIN32) // Is the DLL already loaded? if (!Hdll && !(Hdll = GetModuleHandle(soname))) // No, load the Dll implementing the function @@ -660,7 +660,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef -#else // !__WIN__ +#else // !_WIN32 const char *error = NULL; #if 0 // Don't know what all this stuff does @@ -702,7 +702,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) dlclose(Hdll); return NULL; } // endif getdef -#endif // !__WIN__ +#endif // !_WIN32 // Just in case the external Get function does not set error messages sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h index 73e178ed51c..1b81ae9e3b3 100644 --- a/storage/connect/reldef.h +++ b/storage/connect/reldef.h @@ -146,11 +146,11 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */ PTABDEF GetXdef(PGLOBAL g); // Members -#if defined(__WIN__) +#if defined(_WIN32) HANDLE Hdll; /* Handle to the external DLL */ -#else // !__WIN__ +#else // !_WIN32 void *Hdll; /* Handle for the loaded shared library */ -#endif // !__WIN__ +#endif // !_WIN32 PTABDEF Pxdef; /* Pointer to the external TABDEF class */ char *Module; /* Path/Name of the DLL implenting it */ char *Subtype; /* The name of the OEM table sub type */ diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 6c42ab2c810..d2485bdc8ac 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -17,7 +17,7 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <sys\timeb.h> // For testing only #include <fcntl.h> @@ -26,7 +26,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -34,7 +34,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -233,11 +233,11 @@ void DOSDEF::RemoveOptValues(PGLOBAL g) // Delete any eventually ill formed non matching optimization file if (!GetOptFileName(g, filename)) -#if defined(__WIN__) +#if defined(_WIN32) DeleteFile(filename); #else // UNIX remove(filename); -#endif // __WIN__ +#endif // _WIN32 Optimized = 0; } // end of RemoveOptValues @@ -279,7 +279,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) /*********************************************************************/ if (sep) { // Indexes are save in separate files -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -296,7 +296,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) strcat(strcat(fname, "_"), pxdf->GetName()); _makepath(filename, drive, direc, fname, ftype); PlugSetPath(filename, filename, GetPath()); -#if defined(__WIN__) +#if defined(_WIN32) if (!DeleteFile(filename)) rc |= (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -313,7 +313,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf) // Drop all indexes, delete the common file PlugSetPath(filename, Ofn, GetPath()); strcat(PlugRemoveType(filename, filename), ftype); -#if defined(__WIN__) +#if defined(_WIN32) if (!DeleteFile(filename)) rc = (GetLastError() != ERROR_FILE_NOT_FOUND); #else // UNIX @@ -1026,7 +1026,7 @@ bool TDBDOS::GetBlockValues(PGLOBAL g) #if 0 if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS) return false; -#endif // __WIN__ +#endif // _WIN32 if (defp->Optimized || !(dup->Check & CHK_OPT)) return false; // Already done or to be redone diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp index e9c7b2490d8..698f792b1f4 100644 --- a/storage/connect/tabext.cpp +++ b/storage/connect/tabext.cpp @@ -14,7 +14,7 @@ #include "sql_class.h" #include "sql_servers.h" #include "sql_string.h" -#if !defined(__WIN__) +#if !defined(_WIN32) #include "osutil.h" #endif diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index 4a0a75460cd..5deb5fd0d40 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -17,7 +17,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -25,7 +25,7 @@ #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -35,7 +35,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 9a1e43dd798..cc49fdf9db7 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -20,7 +20,7 @@ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> @@ -156,14 +156,14 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) p = (char*)GetStringTableOption(g, topt, "Separator", ","); 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)) dechar = '.'; else dechar = ','; -#else // !__WIN__ +#else // !_WIN32 dechar = '.'; -#endif // !__WIN__ +#endif // !_WIN32 sep = tdp->Sep; tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1); diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp index 06b6b3a9730..7a8eedad12b 100644 --- a/storage/connect/tabjdbc.cpp +++ b/storage/connect/tabjdbc.cpp @@ -38,7 +38,7 @@ #include "my_global.h" #include "sql_class.h" #include "sql_servers.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) diff --git a/storage/connect/tabmac.cpp b/storage/connect/tabmac.cpp index 8260ab65391..ed161ac4be1 100644 --- a/storage/connect/tabmac.cpp +++ b/storage/connect/tabmac.cpp @@ -3,12 +3,12 @@ /* From the article and sample code by Khalid Shaikh. */ /* TABMAC: virtual table to get the list of MAC addresses. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) #include "my_global.h" //#include <iphlpapi.h> -#else // !__WIN__ +#else // !_WIN32 #error This is a WINDOWS only table type -#endif // !__WIN__ +#endif // !_WIN32 #include "global.h" #include "plgdbsem.h" //#include "catalog.h" diff --git a/storage/connect/tabmac.h b/storage/connect/tabmac.h index 47565bb2541..68135edb95f 100644 --- a/storage/connect/tabmac.h +++ b/storage/connect/tabmac.h @@ -1,11 +1,11 @@ // TABMAC.H Olivier Bertrand 2011-2012 // MAC: virtual table to Get Mac Addresses via GetAdaptersInfo -#if defined(__WIN__) +#if defined(_WIN32) #include <windows.h> #include <iphlpapi.h> -#else // !__WIN__ +#else // !_WIN32 #error This is a WINDOWS only table TYPE -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Definitions. */ diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 649fc6706c6..d10f3cfab67 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -37,7 +37,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -166,11 +166,11 @@ bool TDBMUL::InitFileNames(PGLOBAL g) while (true) if ((rc = dirp->ReadDB(g)) == RC_OK) { -#if defined(__WIN__) +#if defined(_WIN32) strcat(strcpy(filename, dirp->Drive), dirp->Direc); -#else // !__WIN__ +#else // !_WIN32 strcpy(filename, dirp->Direc); -#endif // !__WIN__ +#endif // !_WIN32 strcat(strcat(filename, dirp->Fname), dirp->Ftype); pfn[n++] = PlugDup(g, filename); } else @@ -199,7 +199,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) p = filename + strlen(filename) - 1; -#if !defined(__WIN__) +#if !defined(_WIN32) // Data files can be imported from Windows (having CRLF) if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? @@ -566,11 +566,11 @@ bool TDBMSD::InitFileNames(PGLOBAL g) while (true) if ((rc = dirp->ReadDB(g)) == RC_OK) { -#if defined(__WIN__) +#if defined(_WIN32) strcat(strcpy(filename, dirp->Drive), dirp->Direc); -#else // !__WIN__ +#else // !_WIN32 strcpy(filename, dirp->Direc); -#endif // !__WIN__ +#endif // !_WIN32 strcat(strcat(filename, dirp->Fname), dirp->Ftype); pfn[n++] = PlugDup(g, filename); } else @@ -634,18 +634,18 @@ PTDB DIRDEF::GetTable(PGLOBAL g, MODE) void TDBDIR::Init(void) { iFile = 0; -#if defined(__WIN__) +#if defined(_WIN32) Dvalp = NULL; memset(&FileData, 0, sizeof(_finddata_t)); hSearch = INVALID_HANDLE_VALUE; *Drive = '\0'; -#else // !__WIN__ +#else // !_WIN32 memset(&Fileinfo, 0, sizeof(struct stat)); Entry = NULL; Dir = NULL; Done = false; *Pattern = '\0'; -#endif // !__WIN__ +#endif // !_WIN32 *Fpath = '\0'; *Direc = '\0'; *Fname = '\0'; @@ -674,7 +674,7 @@ char* TDBDIR::Path(PGLOBAL g) PCATLG cat = PlgGetCatalog(g); PTABDEF defp = (PTABDEF)To_Def; -#if defined(__WIN__) +#if defined(_WIN32) if (!*Drive) { PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL); _splitpath(Fpath, Drive, Direc, Fname, Ftype); @@ -682,7 +682,7 @@ char* TDBDIR::Path(PGLOBAL g) _makepath(Fpath, Drive, Direc, Fname, Ftype); // Usefull for TDBSDR return Fpath; -#else // !__WIN__ +#else // !_WIN32 if (!Done) { PlugSetPath(Fpath, To_File, defp ? defp->GetPath() : NULL); _splitpath(Fpath, NULL, Direc, Fname, Ftype); @@ -691,7 +691,7 @@ char* TDBDIR::Path(PGLOBAL g) } // endif Done return Pattern; -#endif // !__WIN__ +#endif // !_WIN32 } // end of Path /***********************************************************************/ @@ -709,7 +709,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { int rc, n = -1; -#if defined(__WIN__) +#if defined(_WIN32) // Start searching files in the target directory. hSearch = FindFirstFile(Path(g), &FileData); @@ -750,7 +750,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) // Close the search handle. FindClose(hSearch); -#else // !__WIN__ +#else // !_WIN32 Path(g); // Start searching files in the target directory. @@ -774,7 +774,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) // Close the DIR handle. closedir(Dir); -#endif // !__WIN__ +#endif // !_WIN32 MaxSize = n; } // endif MaxSize @@ -800,10 +800,10 @@ bool TDBDIR::OpenDB(PGLOBAL g) } // endif use Use = USE_OPEN; -#if !defined(__WIN__) +#if !defined(_WIN32) Path(g); // Be sure it is done Dir = NULL; // For ReadDB -#endif // !__WIN__ +#endif // !_WIN32 return false; } // end of OpenDB @@ -814,7 +814,7 @@ int TDBDIR::ReadDB(PGLOBAL g) { int rc = RC_OK; -#if defined(__WIN__) +#if defined(_WIN32) do { if (hSearch == INVALID_HANDLE_VALUE) { /*****************************************************************/ @@ -877,7 +877,7 @@ int TDBDIR::ReadDB(PGLOBAL g) rc = RC_EF; } // endif Entry -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of ReadDB @@ -905,17 +905,17 @@ int TDBDIR::DeleteDB(PGLOBAL g, int) /***********************************************************************/ void TDBDIR::CloseDB(PGLOBAL) { -#if defined(__WIN__) +#if defined(_WIN32) // Close the search handle. FindClose(hSearch); hSearch = INVALID_HANDLE_VALUE; -#else // !__WIN__ +#else // !_WIN32 // Close the DIR handle if (Dir) { closedir(Dir); Dir = NULL; } // endif dir -#endif // !__WIN__ +#endif // !_WIN32 iFile = 0; } // end of CloseDB @@ -950,7 +950,7 @@ DIRCOL::DIRCOL(DIRCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp) N = col1->N; } // end of DIRCOL copy constructor -#if defined(__WIN__) +#if defined(_WIN32) /***********************************************************************/ /* Retrieve time information from FileData. */ /***********************************************************************/ @@ -977,7 +977,7 @@ void DIRCOL::SetTimeValue(PGLOBAL g, FILETIME& ftime) Value->Reset(); } // end of SetTimeValue -#endif // __WIN__ +#endif // _WIN32 /***********************************************************************/ /* 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. */ /*********************************************************************/ switch (N) { -#if defined(__WIN__) +#if defined(_WIN32) case 0: Value->SetValue_psz(Tdbp->Drive); break; -#endif // __WIN__ +#endif // _WIN32 case 1: Value->SetValue_psz(Tdbp->Direc); break; case 2: Value->SetValue_psz(Tdbp->Fname); 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 5: Value->SetValue((int)Tdbp->FileData.nFileSizeLow); break; case 6: SetTimeValue(g, Tdbp->FileData.ftLastWriteTime); break; case 7: SetTimeValue(g, Tdbp->FileData.ftCreationTime); break; case 8: SetTimeValue(g, Tdbp->FileData.ftLastAccessTime); break; -#else // !__WIN__ +#else // !_WIN32 case 4: Value->SetValue((int)Tdbp->Fileinfo.st_mode); break; case 5: Value->SetValue((int)Tdbp->Fileinfo.st_size); 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 9: Value->SetValue((int)Tdbp->Fileinfo.st_uid); break; case 10: Value->SetValue((int)Tdbp->Fileinfo.st_gid); break; -#endif // !__WIN__ +#endif // !_WIN32 default: sprintf(g->Message, MSG(INV_DIRCOL_OFST), N); throw GetAmType(); @@ -1045,7 +1045,7 @@ int TDBSDR::FindInDir(PGLOBAL g) size_t m = strlen(Direc); // Start searching files in the target directory. -#if defined(__WIN__) +#if defined(_WIN32) HANDLE h; #if defined(PATHMATCHSPEC) @@ -1155,7 +1155,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the search handle. FindClose(h); -#else // !__WIN__ +#else // !_WIN32 int k; DIR *dir = opendir(Direc); @@ -1189,7 +1189,7 @@ int TDBSDR::FindInDir(PGLOBAL g) // Close the DIR handle. closedir(dir); -#endif // !__WIN__ +#endif // !_WIN32 return n; } // end of FindInDir @@ -1205,13 +1205,13 @@ bool TDBSDR::OpenDB(PGLOBAL g) Sub = (PSUBDIR)PlugSubAlloc(g, NULL, sizeof(SUBDIR)); Sub->Next = NULL; Sub->Prev = NULL; -#if defined(__WIN__) +#if defined(_WIN32) Sub->H = INVALID_HANDLE_VALUE; Sub->Len = strlen(Direc); -#else // !__WIN__ +#else // !_WIN32 Sub->D = NULL; Sub->Len = 0; -#endif // !__WIN__ +#endif // !_WIN32 } // endif To_Sub return TDBDIR::OpenDB(g); @@ -1224,7 +1224,7 @@ int TDBSDR::ReadDB(PGLOBAL g) { int rc; -#if defined(__WIN__) +#if defined(_WIN32) again: rc = TDBDIR::ReadDB(g); @@ -1280,7 +1280,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif H } // endif rc -#else // !__WIN__ +#else // !_WIN32 rc = RC_NF; again: @@ -1338,7 +1338,7 @@ int TDBSDR::ReadDB(PGLOBAL g) } // endif Entry -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of ReadDB diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h index 8a95a772c41..a9d3f88cc44 100644 --- a/storage/connect/tabmul.h +++ b/storage/connect/tabmul.h @@ -6,14 +6,14 @@ /* */ /* This file contains the TDBMUL and TDBDIR classes declares. */ /***********************************************************************/ -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> -#else // !__WIN__ +#else // !_WIN32 #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> -#endif // !__WIN__ +#endif // !_WIN32 //#include "osutil.h" #include "block.h" @@ -160,18 +160,18 @@ public: // Members PSZ To_File; // Points to file search pathname int iFile; // Index of currently retrieved file -#if defined(__WIN__) +#if defined(_WIN32) PVAL Dvalp; // Used to retrieve file date values WIN32_FIND_DATA FileData; // Find data structure HANDLE hSearch; // Search handle char Drive[_MAX_DRIVE]; // Drive name -#else // !__WIN__ +#else // !_WIN32 struct stat Fileinfo; // File info structure struct dirent *Entry; // Point to directory entry structure DIR *Dir; // To searched directory structure bool Done; // true when _splipath is done char Pattern[_MAX_FNAME+_MAX_EXT]; -#endif // !__WIN__ +#endif // !_WIN32 char Fpath[_MAX_PATH]; // Absolute file search pattern char Direc[_MAX_DIR]; // Search path char Fname[_MAX_FNAME]; // File name @@ -207,11 +207,11 @@ class TDBSDR : public TDBDIR { typedef struct _Sub_Dir { struct _Sub_Dir *Next; struct _Sub_Dir *Prev; -#if defined(__WIN__) +#if defined(_WIN32) HANDLE H; // Search handle -#else // !__WIN__ +#else // !_WIN32 DIR *D; -#endif // !__WIN__ +#endif // !_WIN32 size_t Len; // Initial directory name length } SUBDIR, *PSUBDIR; @@ -238,9 +238,9 @@ class DIRCOL : public COLBLK { protected: // Default constructor not to be used DIRCOL(void) {} -#if defined(__WIN__) +#if defined(_WIN32) void SetTimeValue(PGLOBAL g, FILETIME& ftime); -#endif // __WIN__ +#endif // _WIN32 // Members PTDBDIR Tdbp; // To DIR table diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 7e165fb5a80..f8f995f211e 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -35,9 +35,9 @@ #include "my_global.h" #include "sql_class.h" #include "sql_servers.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 //#include <fnmatch.h> //#include <errno.h> #include <stdlib.h> @@ -46,7 +46,7 @@ #include "osutil.h" //#include <io.h> //#include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 07272d1b298..6bf2bd2b47f 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -13,7 +13,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(__WIN__) +#if defined(_WIN32) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index ba5c65e2c94..bede19f7344 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -36,7 +36,7 @@ /***********************************************************************/ #include "my_global.h" #include "sql_class.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 9121a0453e5..2dab1cba981 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(__WIN__) +#if defined(_WIN32) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index 4b6bb6a9e62..3b89d5232b7 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -13,10 +13,10 @@ #include <my_global.h> // All MariaDB stuff #include <mysqld.h> #include <sql_error.h> -#if !defined(__WIN__) && !defined(_WINDOWS) +#if !defined(_WIN32) && !defined(_WINDOWS) #include <sys/types.h> #include <sys/wait.h> -#endif // !__WIN__ && !_WINDOWS +#endif // !_WIN32 && !_WINDOWS /***********************************************************************/ /* Include application header files: */ @@ -67,7 +67,7 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) } else strcpy(buf, Http); -#if defined(__WIN__) +#if defined(_WIN32) char cmd[1024]; STARTUPINFO si; 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()); rc = 1; } // endif CreateProcess -#else // !__WIN__ +#else // !_WIN32 char fn[600]; pid_t pID; @@ -130,7 +130,7 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) // Parent process wait(NULL); // Wait for the child to terminate } // endif pID -#endif // !__WIN__ +#endif // !_WIN32 return rc; } // end of Xcurl @@ -147,7 +147,7 @@ XGETREST GetRestFunction(PGLOBAL g) if (trace(515)) htrc("Looking for GetRest library\n"); -#if defined(__WIN__) || defined(_WINDOWS) +#if defined(_WIN32) || defined(_WINDOWS) HANDLE Hdll; const char* soname = "GetRest.dll"; // Module name @@ -176,7 +176,7 @@ XGETREST GetRestFunction(PGLOBAL g) FreeLibrary((HMODULE)Hdll); return NULL; } // endif getRestFnc -#else // !__WIN__ +#else // !_WIN32 void* Hso; const char* error = NULL; const char* soname = "GetRest.so"; // Module name @@ -195,7 +195,7 @@ XGETREST GetRestFunction(PGLOBAL g) dlclose(Hso); return NULL; } // endif getdef -#endif // !__WIN__ +#endif // !_WIN32 #else // REST_SOURCE getRestFnc = restGetFile; #endif // REST_SOURCE diff --git a/storage/connect/tabrest.h b/storage/connect/tabrest.h index 9cf2d10a6b8..9066a89b306 100644 --- a/storage/connect/tabrest.h +++ b/storage/connect/tabrest.h @@ -5,12 +5,12 @@ /***********************************************************************/ #pragma once -#if defined(__WIN__) +#if defined(_WIN32) static PCSZ slash = "\\"; -#else // !__WIN__ +#else // !_WIN32 static PCSZ slash = "/"; #define stricmp strcasecmp -#endif // !__WIN__ +#endif // !_WIN32 typedef int(__stdcall* XGETREST) (char*, bool, PCSZ, PCSZ, PCSZ); diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index f73a2b6578d..9a8e4a9c562 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -12,12 +12,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif // __BORLANDC__ //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <errno.h> #include <unistd.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include application header files: */ @@ -36,9 +36,9 @@ #include "global.h" #include "plgdbsem.h" #include "reldef.h" -#if !defined(__WIN__) +#if !defined(_WIN32) #include "osutil.h" -#endif // !__WIN__ +#endif // !_WIN32 #include "filamtxt.h" #include "tabdos.h" #include "tabsys.h" @@ -48,10 +48,10 @@ #define CSZ 36 // Column section name length #define CDZ 256 // Column definition length -#if !defined(__WIN__) +#if !defined(_WIN32) #define GetPrivateProfileSectionNames(S,L,I) \ GetPrivateProfileString(NULL,NULL,"",S,L,I) -#endif // !__WIN__ +#endif // !_WIN32 /* -------------- Implementation of the INI classes ------------------ */ @@ -123,7 +123,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g) // Delete the INI table file if not protected if (!IsReadOnly()) { PlugSetPath(filename, Fn, GetPath()); -#if defined(__WIN__) +#if defined(_WIN32) rc = !DeleteFile(filename); #else // UNIX rc = remove(filename); @@ -345,9 +345,9 @@ int TDBINI::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ void TDBINI::CloseDB(PGLOBAL) { -#if !defined(__WIN__) +#if !defined(_WIN32) PROFILE_Close(Ifile); -#endif // !__WIN__ +#endif // !_WIN32 } // end of CloseDB // ------------------------ INICOL functions ---------------------------- diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 1150824464f..b6277088bac 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -36,7 +36,7 @@ //#include "sql_base.h" #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(__WIN__) +#if defined(_WIN32) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) @@ -71,15 +71,15 @@ #include "tabmysql.h" #include "ha_connect.h" -#if defined(__WIN__) +#if defined(_WIN32) #if defined(__BORLANDC__) #define SYSEXIT void _USERENTRY #else #define SYSEXIT void #endif -#else // !__WIN__ +#else // !_WIN32 #define SYSEXIT void * -#endif // !__WIN__ +#endif // !_WIN32 extern pthread_mutex_t tblmut; diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index e187e6eaec5..47a882e11b1 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -14,7 +14,7 @@ #include "sql_class.h" #include "table.h" #include "field.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 0ed466f6ffb..9cf5f41d1fe 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -35,7 +35,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #if defined(__BORLANDC__) @@ -149,7 +149,7 @@ bool VCTDEF::Erase(char *filename) for (i = 1, cdp = To_Cols; cdp; i++, cdp = cdp->GetNext()) { sprintf(filename, fpat, i); -//#if defined(__WIN__) +//#if defined(_WIN32) // rc |= !DeleteFile(filename); //#else // UNIX rc |= remove(filename); @@ -178,7 +178,7 @@ bool VCTDEF::Erase(char *filename) int VCTDEF::MakeFnPattern(char *fpat) { char pat[16]; -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index 8a8e1bcbcb6..a6aab7d2563 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -2,9 +2,9 @@ /* TABWMI: Author Olivier Bertrand -- PlugDB -- 2012 - 2017 */ /* TABWMI: Virtual table to get WMI information. */ /***********************************************************************/ -#if !defined(__WIN__) +#if !defined(_WIN32) #error This is a WINDOWS only table type -#endif // !__WIN__ +#endif // !_WIN32 #include "my_global.h" #include <stdio.h> diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 93a24accc3c..87fa799d87e 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -17,7 +17,7 @@ /***********************************************************************/ #include "my_global.h" #include "table.h" // MySQL table definitions -#if defined(__WIN__) +#if defined(_WIN32) #include <stdlib.h> #include <stdio.h> #if defined(__BORLANDC__) diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index d7f199a8092..cb428f5a94c 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -15,12 +15,12 @@ #include <stdio.h> #include <fcntl.h> #include <errno.h> -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <winsock2.h> //#include <windows.h> #include <comdef.h> -#else // !__WIN__ +#else // !_WIN32 #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -28,7 +28,7 @@ //#include <ctype.h> #include "osutil.h" #define _O_RDONLY O_RDONLY -#endif // !__WIN__ +#endif // !_WIN32 #include "resource.h" // for IDS_COLUMNS #define INCLUDE_TDBXML @@ -53,11 +53,11 @@ extern "C" char version[]; -#if defined(__WIN__) && defined(DOMDOC_SUPPORT) +#if defined(_WIN32) && defined(DOMDOC_SUPPORT) #define XMLSUP "MS-DOM" -#else // !__WIN__ +#else // !_WIN32 #define XMLSUP "libxml2" -#endif // !__WIN__ +#endif // !_WIN32 #define TYPE_UNKNOWN 12 /* Must be greater than other types */ #define XLEN(M) sizeof(M) - strlen(M) - 1 /* To avoid overflow*/ @@ -180,11 +180,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) tdp->Skip = GetBooleanTableOption(g, topt, "Skipnull", false); if (!(op = GetStringTableOption(g, topt, "Xmlsup", NULL))) -#if defined(__WIN__) +#if defined(_WIN32) tdp->Usedom = true; -#else // !__WIN__ +#else // !_WIN32 tdp->Usedom = false; -#endif // !__WIN__ +#endif // !_WIN32 else tdp->Usedom = (toupper(*op) == 'M' || toupper(*op) == 'D'); @@ -533,11 +533,11 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) // Note that if no support is specified, the default is MS-DOM // on Windows and libxml2 otherwise if (*buf == '*') -#if defined(__WIN__) +#if defined(_WIN32) Usedom = true; -#else // !__WIN__ +#else // !_WIN32 Usedom = false; -#endif // !__WIN__ +#endif // !_WIN32 else Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D'); @@ -970,7 +970,7 @@ bool TDBXML::Initialize(PGLOBAL g) Docp->SetNofree(true); // For libxml2 -#if defined(__WIN__) +#if defined(_WIN32) } catch (_com_error e) { // We come here if a DOM command threw an error char buf[128]; @@ -984,7 +984,7 @@ bool TDBXML::Initialize(PGLOBAL g) sprintf(g->Message, "%s hr=%x", MSG(COM_ERROR), e.Error()); goto error; -#endif // __WIN__ +#endif // _WIN32 #if !defined(UNIX) } catch(...) { // Other errors diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index b7c8c704e65..a993c1371c2 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -23,7 +23,7 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> #else #include "osutil.h" diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index e710fefc624..1366362dac0 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -30,11 +30,11 @@ #include "sql_class.h" #include "sql_time.h" -#if defined(__WIN__) +#if defined(_WIN32) //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #include <string.h> -#endif // !__WIN__ +#endif // !_WIN32 #include <math.h> @@ -77,12 +77,12 @@ int DTVAL::Shift = 0; /***********************************************************************/ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); -#if !defined(__WIN__) +#if !defined(_WIN32) extern "C" { PSZ strupr(PSZ s); PSZ strlwr(PSZ s); } -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Get a long long number from its character representation. */ @@ -1648,10 +1648,10 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp) else n = strcmp(Strp, vp->GetCharValue()); -#if defined(__WIN__) +#if defined(_WIN32) if (n == _NLSCMPERROR) return n; // Here we should raise an error -#endif // __WIN__ +#endif // _WIN32 return (n > 0) ? 1 : (n < 0) ? -1 : 0; } // end of CompareValue diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 95f038d494c..84a730788e2 100644 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -10,12 +10,12 @@ /* Include relevant sections of the System header files. */ /***********************************************************************/ #include "my_global.h" -#if defined(__WIN__) +#if defined(_WIN32) #include <io.h> #include <fcntl.h> #include <errno.h> //#include <windows.h> -#else // !__WIN__ +#else // !_WIN32 #if defined(UNIX) #include <sys/types.h> #include <sys/stat.h> @@ -25,7 +25,7 @@ #include <io.h> #endif // !UNIX #include <fcntl.h> -#endif // !__WIN__ +#endif // !_WIN32 /***********************************************************************/ /* Include required application header files */ @@ -846,7 +846,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) if ((sep = defp->GetBoolCatInfo("SepIndex", false))) { // Index is saved in a separate file -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1000,7 +1000,7 @@ bool XINDEX::Init(PGLOBAL g) if (defp->SepIndex()) { // Index was saved in a separate file -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1254,7 +1254,7 @@ bool XINDEX::MapInit(PGLOBAL g) if (defp->SepIndex()) { // Index was save in a separate file -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -1469,7 +1469,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) if (defp->SepIndex()) { // Index was saved in a separate file -#if defined(__WIN__) +#if defined(_WIN32) char drive[_MAX_DRIVE]; #else char *drive = NULL; @@ -2517,7 +2517,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) if (trace(1)) htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode); -#if defined(__WIN__) +#if defined(_WIN32) LONG high = 0; DWORD rc, drc, access, share, creation; @@ -2693,7 +2693,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) /***********************************************************************/ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin) { -#if defined(__WIN__) +#if defined(_WIN32) LONG hi = high; DWORD rc = SetFilePointer(Hfile, low, &hi, origin); @@ -2729,7 +2729,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) { bool rc = false; -#if defined(__WIN__) +#if defined(_WIN32) bool brc; DWORD nbr, count = (DWORD)(n * size); @@ -2775,7 +2775,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) /***********************************************************************/ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) { -#if defined(__WIN__) +#if defined(_WIN32) bool brc; DWORD nbw, count = (DWORD)n * (DWORD) size; @@ -2817,7 +2817,7 @@ void XHUGE::Close(char *fn, int id) if (trace(1)) htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val); -#if defined(__WIN__) +#if defined(_WIN32) if (id >= 0 && fn) { CloseFileHandle(Hfile); Hfile = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL, @@ -2832,7 +2832,7 @@ void XHUGE::Close(char *fn, int id) } // endif SetFilePointer } // endif id -#else // !__WIN__ +#else // !_WIN32 if (id >= 0 && fn) { if (Hfile != INVALID_HANDLE_VALUE) { if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) { @@ -2848,7 +2848,7 @@ void XHUGE::Close(char *fn, int id) htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno)); } // endif id -#endif // !__WIN__ +#endif // !_WIN32 XLOAD::Close(); } // end of Close diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index 339d7e68b75..ce62f0591c1 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -350,7 +350,7 @@ class DllExport XLOAD : public BLOCK { protected: // Members -#if defined(__WIN__) +#if defined(_WIN32) HANDLE Hfile; // Handle to file or map #else // UNIX int Hfile; // Descriptor to file or map |