Merge pull request #701 from taosdata/feature/liaohj
[TBASE-1099] fix bug referred in issue #699, refactor some codes
This commit is contained in:
commit
41c28f7a13
|
@ -479,6 +479,7 @@ void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
|
||||||
void tscKillMetricQuery(SSqlObj *pSql);
|
void tscKillMetricQuery(SSqlObj *pSql);
|
||||||
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
|
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
|
||||||
int32_t tscBuildResultsForEmptyRetrieval(SSqlObj *pSql);
|
int32_t tscBuildResultsForEmptyRetrieval(SSqlObj *pSql);
|
||||||
|
bool tscIsUpdateQuery(STscObj *pObj);
|
||||||
|
|
||||||
// transfer SSqlInfo to SqlCmd struct
|
// transfer SSqlInfo to SqlCmd struct
|
||||||
int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
|
int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
|
||||||
|
|
|
@ -289,15 +289,17 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
|
||||||
return JNI_CONNECTION_NULL;
|
return JNI_CONNECTION_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_fields = taos_field_count(tscon);
|
jlong ret = 0;
|
||||||
if (num_fields != 0) {
|
|
||||||
jlong ret = (jlong)taos_use_result(tscon);
|
if (tscIsUpdateQuery(tscon)) {
|
||||||
jniTrace("jobj:%p, taos:%p, get resultset:%p", jobj, tscon, (void *)ret);
|
ret = 0; // for update query, no result pointer
|
||||||
return ret;
|
jniTrace("jobj:%p, taos:%p, no result", jobj, tscon);
|
||||||
|
} else {
|
||||||
|
ret = (jlong) taos_use_result(tscon);
|
||||||
|
jniTrace("jobj:%p, taos:%p, get resultset:%p", jobj, tscon, (void *) ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
jniTrace("jobj:%p, taos:%p, no resultset", jobj, tscon);
|
return ret;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(JNIEnv *env, jobject jobj, jlong con,
|
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(JNIEnv *env, jobject jobj, jlong con,
|
||||||
|
|
|
@ -255,8 +255,7 @@ static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, cha
|
||||||
|
|
||||||
t0 = tStrGetToken(str, i, false, 0, NULL);
|
t0 = tStrGetToken(str, i, false, 0, NULL);
|
||||||
if (t0.n == 0 || t0.type == TK_RP) {
|
if (t0.n == 0 || t0.type == TK_RP) {
|
||||||
if (pLeft->nodeType != TSQL_NODE_EXPR) {
|
if (pLeft->nodeType != TSQL_NODE_EXPR) { // if left is not the expr, it is not a legal expr
|
||||||
// if left is not the expr, it is not a legal expr
|
|
||||||
tSQLSyntaxNodeDestroy(pLeft, NULL);
|
tSQLSyntaxNodeDestroy(pLeft, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -320,13 +319,13 @@ static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, cha
|
||||||
pn->colId = -1;
|
pn->colId = -1;
|
||||||
return pn;
|
return pn;
|
||||||
} else {
|
} else {
|
||||||
int32_t optr = getBinaryExprOptr(&t0);
|
uint8_t localOptr = getBinaryExprOptr(&t0);
|
||||||
if (optr <= 0) {
|
if (localOptr <= 0) {
|
||||||
pError("not support binary operator:%d", t0.type);
|
pError("not support binary operator:%d", t0.type);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseRemainStr(str, pBinExpr, pSchema, optr, numOfCols, i);
|
return parseRemainStr(str, pBinExpr, pSchema, localOptr, numOfCols, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1817,3 +1817,17 @@ int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid) {
|
||||||
return pTagCond->joinInfo.right.tagCol;
|
return pTagCond->joinInfo.right.tagCol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tscIsUpdateQuery(STscObj* pObj) {
|
||||||
|
if (pObj == NULL || pObj->signature != pObj) {
|
||||||
|
globalCode = TSDB_CODE_DISCONNECTED;
|
||||||
|
return TSDB_CODE_DISCONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSqlCmd* pCmd = &(pObj->pSql->cmd);
|
||||||
|
if (pCmd->command >= TSDB_SQL_INSERT && pCmd->command <= TSDB_SQL_DROP_DNODE) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class TSDBJNIConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try retrieving result set for the executed SQLusing the current connection pointer. If the executed
|
// Try retrieving result set for the executed SQL using the current connection pointer. If the executed
|
||||||
// SQL is a DML/DDL which doesn't return a result set, then taosResultSetPointer should be 0L. Otherwise,
|
// SQL is a DML/DDL which doesn't return a result set, then taosResultSetPointer should be 0L. Otherwise,
|
||||||
// taosResultSetPointer should be a non-zero value.
|
// taosResultSetPointer should be a non-zero value.
|
||||||
taosResultSetPointer = this.getResultSetImp(this.taos);
|
taosResultSetPointer = this.getResultSetImp(this.taos);
|
||||||
|
|
|
@ -122,9 +122,6 @@ void taos_close_stream(TAOS_STREAM *tstr);
|
||||||
|
|
||||||
int taos_load_table_info(TAOS *taos, const char* tableNameList);
|
int taos_load_table_info(TAOS *taos, const char* tableNameList);
|
||||||
|
|
||||||
// TODO: `configDir` should not be declared here
|
|
||||||
extern char configDir[]; // the path to global configuration
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,7 +89,7 @@ extern "C" {
|
||||||
} else { \
|
} else { \
|
||||||
return (x) < (y) ? -1 : 1; \
|
return (x) < (y) ? -1 : 1; \
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0)
|
||||||
|
|
||||||
#define GET_INT8_VAL(x) (*(int8_t *)(x))
|
#define GET_INT8_VAL(x) (*(int8_t *)(x))
|
||||||
#define GET_INT16_VAL(x) (*(int16_t *)(x))
|
#define GET_INT16_VAL(x) (*(int16_t *)(x))
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||||
SAcctObj * pAcct = NULL;
|
SAcctObj * pAcct = NULL;
|
||||||
SUserObj * pUser = NULL;
|
SUserObj * pUser = NULL;
|
||||||
SDbObj * pDb = NULL;
|
SDbObj * pDb = NULL;
|
||||||
char dbName[TSDB_METER_ID_LEN];
|
char dbName[256] = {0};
|
||||||
|
|
||||||
pConnectMsg = (SConnectMsg *)pMsg;
|
pConnectMsg = (SConnectMsg *)pMsg;
|
||||||
|
|
||||||
|
@ -1158,7 +1158,6 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) {
|
||||||
pAcct = mgmtGetAcct(pUser->acct);
|
pAcct = mgmtGetAcct(pUser->acct);
|
||||||
|
|
||||||
if (pConnectMsg->db[0]) {
|
if (pConnectMsg->db[0]) {
|
||||||
memset(dbName, 0, sizeof(dbName));
|
|
||||||
sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
|
sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
|
||||||
pDb = mgmtGetDb(dbName);
|
pDb = mgmtGetDb(dbName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue