Changeset: 5970f9e88c5e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5970f9e88c5e
Modified Files:
clients/odbc/driver/ODBCUtil.c
clients/odbc/driver/SQLExecDirect.c
clients/odbc/driver/SQLNativeSql.c
clients/odbc/driver/SQLPrepare.c
Branch: escape-sequences
Log Message:
better way of pass through escape sequences
diffs (110 lines):
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -892,6 +892,9 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
* plenty long enough */
char buf[128], buf2[128];
+ if (dbc->minor >= 46)
+ noscan = SQL_NOSCAN_ON;
+
if (noscan != SQL_NOSCAN_ON) {
char *nquery;
bool quoted = false, rawstring = false, dquoted = false;
diff --git a/clients/odbc/driver/SQLExecDirect.c
b/clients/odbc/driver/SQLExecDirect.c
--- a/clients/odbc/driver/SQLExecDirect.c
+++ b/clients/odbc/driver/SQLExecDirect.c
@@ -56,14 +56,8 @@ ODBCExecDirect(ODBCStmt *stmt, const SQL
stmt->Dbc->qtimeout = stmt->qtimeout;
}
- if (stmt->Dbc->minor >= 46)
- query = (char *) StatementText;
- else
- query = ODBCTranslateSQL(
- stmt->Dbc,
- StatementText,
- (size_t) TextLength,
- stmt->noScan);
+ query = ODBCTranslateSQL(stmt->Dbc, StatementText, (size_t) TextLength,
+ stmt->noScan);
if (query == NULL) {
/* Memory allocation error */
addStmtError(stmt, "HY001", NULL, 0);
@@ -89,8 +83,7 @@ ODBCExecDirect(ODBCStmt *stmt, const SQL
stmt->Dbc->cachelimit = 100;
}
ret = mapi_query_handle(hdl, query);
- if (query != (char *) StatementText)
- free(query);
+ free(query);
switch (ret) {
case MOK:
break;
diff --git a/clients/odbc/driver/SQLNativeSql.c
b/clients/odbc/driver/SQLNativeSql.c
--- a/clients/odbc/driver/SQLNativeSql.c
+++ b/clients/odbc/driver/SQLNativeSql.c
@@ -50,13 +50,9 @@ MNDBNativeSql(ODBCDbc *dbc,
#ifdef ODBCDEBUG
ODBCLOG("\"%.*s\"\n", (int) TextLength1, (char *) InStatementText);
#endif
- if (dbc->minor >= 46)
- query = (char *) InStatementText;
- else
- query = ODBCTranslateSQL(dbc,
- InStatementText,
- (size_t) TextLength1,
- SQL_NOSCAN_OFF);
+
+ query = ODBCTranslateSQL(dbc, InStatementText, (size_t) TextLength1,
+ SQL_NOSCAN_OFF);
if (query == NULL) {
/* Memory allocation error */
addDbcError(dbc, "HY001", NULL, 0);
@@ -65,8 +61,7 @@ MNDBNativeSql(ODBCDbc *dbc,
copyString(query, strlen(query), OutStatementText, BufferLength,
TextLength2Ptr, SQLINTEGER, addDbcError, dbc,
free(query); return SQL_ERROR);
- if (query != (char *) InStatementText)
- free(query);
+ free(query);
return dbc->Error ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
}
diff --git a/clients/odbc/driver/SQLPrepare.c b/clients/odbc/driver/SQLPrepare.c
--- a/clients/odbc/driver/SQLPrepare.c
+++ b/clients/odbc/driver/SQLPrepare.c
@@ -74,13 +74,8 @@ MNDBPrepare(ODBCStmt *stmt,
}
fixODBCstring(StatementText, TextLength, SQLINTEGER, addStmtError,
stmt, return SQL_ERROR);
- if (stmt->Dbc->minor >= 46)
- query = (char *) StatementText;
- else
- query = ODBCTranslateSQL(stmt->Dbc,
- StatementText,
- (size_t) TextLength,
- stmt->noScan);
+ query = ODBCTranslateSQL(stmt->Dbc, StatementText, (size_t) TextLength,
+ stmt->noScan);
if (query == NULL) {
/* Memory allocation error */
addStmtError(stmt, "HY001", NULL, 0);
@@ -92,15 +87,13 @@ MNDBPrepare(ODBCStmt *stmt,
size_t querylen = strlen(query) + 9;
s = malloc(querylen);
if (s == NULL) {
- if (query != (char *) StatementText)
- free(query);
+ free(query);
/* Memory allocation error */
addStmtError(stmt, "HY001", NULL, 0);
return SQL_ERROR;
}
strconcat_len(s, querylen, "prepare ", query, NULL);
- if (query != (char *) StatementText)
- free(query);
+ free(query);
ODBCResetStmt(stmt);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]