diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 97f2058e7556c786d91ef6301c495437262528f5..1114bccff3f6c7bdd8284ff0a223a376f734f3d4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5266,10 +5266,6 @@ static int32_t validateSQLExprItemOperatorExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, S pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH || pExpr->tokenId == TK_CONTAINS || pExpr->tokenId == TK_IN) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "unsupported filtering operations"); - } else if (pExpr->tokenId == TK_LSHIFT || pExpr->tokenId == TK_RSHIFT) { - if (rightType != SQLEXPR_TYPE_VALUE) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "non numeric right operand"); - } } } else { *type = SQLEXPR_TYPE_SCALAR; diff --git a/src/common/src/tarithoperator.c b/src/common/src/tarithoperator.c index 6c97c3427ac7854cff35d56ea8f1099a0702b27e..ca5d247dd60eb0865c2a02b5d0e911185280f0fa 100644 --- a/src/common/src/tarithoperator.c +++ b/src/common/src/tarithoperator.c @@ -738,98 +738,266 @@ void vectorBitnot(void *left, int32_t len1, int32_t _left_type, void *right, int void vectorLshift(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; + char *output = (char *)out; + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); + _arithmetic_getVectorBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(_left_type); + _arithmetic_getVectorBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(_right_type); - // the right operand is a number - if (len2 != 1) { - return; - } + if ((len1) == (len2)) { + for (; i < (len2) && i >= 0; i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - char *output = (char *) out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } - for (; i < (len1) && i >= 0; i += step) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type)) { switch (_left_type) { case TSDB_DATA_TYPE_BOOL: - *(bool *) output = TSDB_DATA_BOOL_NULL; + *(bool *)output = 0; output += sizeof(bool); break; case TSDB_DATA_TYPE_TINYINT: - *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + *(int8_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int8_t); break; case TSDB_DATA_TYPE_SMALLINT: - *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + *(int16_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int16_t); break; case TSDB_DATA_TYPE_INT: - *(int32_t *) output = TSDB_DATA_INT_NULL; + *(int32_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int32_t); break; case TSDB_DATA_TYPE_BIGINT: - *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + *(int64_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int64_t); break; case TSDB_DATA_TYPE_UTINYINT: - *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + *(uint8_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int8_t); break; case TSDB_DATA_TYPE_USMALLINT: - *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + *(uint16_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int16_t); break; case TSDB_DATA_TYPE_UINT: - *(uint32_t *) output = TSDB_DATA_UINT_NULL; + *(uint32_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int32_t); break; case TSDB_DATA_TYPE_UBIGINT: - *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + *(uint64_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, i); output += sizeof(int64_t); break; } + } + } else if ((len1) == 1) { + for (; i >= 0 && i < (len2); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, 0), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - continue; + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } + + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *)output = 0; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = getVectorBigintValueFnLeft(left, 0) << getVectorBigintValueFnRight(right, i); + output += sizeof(int64_t); + break; + } } + } else if ((len2) == 1) { + for (; i >= 0 && i < (len1); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, 0), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - switch (_left_type) { - case TSDB_DATA_TYPE_BOOL: - *(bool *)output = 0; - output += sizeof(bool); - break; - case TSDB_DATA_TYPE_TINYINT: - *(int8_t *) output = *((int8_t *) left + i) << *(int8_t *) right; - output += sizeof(int8_t); - break; - case TSDB_DATA_TYPE_SMALLINT: - *(int16_t *) output = *((int16_t *) left + i) << *(int16_t *) right; - output += sizeof(int16_t); - break; - case TSDB_DATA_TYPE_INT: - *(int32_t *) output = *((int32_t *) left + i) << *(int32_t *) right; - output += sizeof(int32_t); - break; - case TSDB_DATA_TYPE_BIGINT: - *(int64_t *) output = *((int64_t *) left + i) << *(int64_t *) right; - output += sizeof(int64_t); - break; + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } - case TSDB_DATA_TYPE_UTINYINT: - *(uint8_t *) output = *((uint8_t *) left + i) << *(uint8_t *) right; - output += sizeof(int8_t); - break; - case TSDB_DATA_TYPE_USMALLINT: - *(uint16_t *) output = *((uint16_t *) left + i) << *(uint16_t *) right; - output += sizeof(int16_t); - break; - case TSDB_DATA_TYPE_UINT: - *(uint32_t *) output = *((uint32_t *) left + i) << *(uint32_t *) right; - output += sizeof(int32_t); - break; - case TSDB_DATA_TYPE_UBIGINT: - *(uint64_t *) output = *((uint64_t *) left + i) << *(uint64_t *) right; - output += sizeof(int64_t); - break; + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *)output = 0; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = getVectorBigintValueFnLeft(left, i) << getVectorBigintValueFnRight(right, 0); + output += sizeof(int64_t); + break; + } } } } @@ -837,98 +1005,266 @@ void vectorLshift(void *left, int32_t len1, int32_t _left_type, void *right, int void vectorRshift(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; + char *output = (char *)out; + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); + _arithmetic_getVectorBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(_left_type); + _arithmetic_getVectorBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(_right_type); - // the right operand is a number - if (len2 != 1) { - return; - } + if ((len1) == (len2)) { + for (; i < (len2) && i >= 0; i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - char *output = (char *) out; - _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } - for (; i < (len1) && i >= 0; i += step) { - if (isNull(getVectorValueAddrFnLeft(left,i), _left_type)) { switch (_left_type) { case TSDB_DATA_TYPE_BOOL: - *(bool *) output = TSDB_DATA_BOOL_NULL; + *(bool *)output = 0; output += sizeof(bool); break; case TSDB_DATA_TYPE_TINYINT: - *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + *(int8_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int8_t); break; case TSDB_DATA_TYPE_SMALLINT: - *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + *(int16_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int16_t); break; case TSDB_DATA_TYPE_INT: - *(int32_t *) output = TSDB_DATA_INT_NULL; + *(int32_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int32_t); break; case TSDB_DATA_TYPE_BIGINT: - *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + *(int64_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int64_t); break; case TSDB_DATA_TYPE_UTINYINT: - *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + *(uint8_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int8_t); break; case TSDB_DATA_TYPE_USMALLINT: - *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + *(uint16_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int16_t); break; case TSDB_DATA_TYPE_UINT: - *(uint32_t *) output = TSDB_DATA_UINT_NULL; + *(uint32_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int32_t); break; case TSDB_DATA_TYPE_UBIGINT: - *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + *(uint64_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, i); output += sizeof(int64_t); break; } + } + } else if ((len1) == 1) { + for (; i >= 0 && i < (len2); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, 0), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - continue; + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } + + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *)output = 0; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = getVectorBigintValueFnLeft(left, 0) >> getVectorBigintValueFnRight(right, i); + output += sizeof(int64_t); + break; + } } + } else if ((len2) == 1) { + for (; i >= 0 && i < (len1); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, 0), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; - switch (_left_type) { - case TSDB_DATA_TYPE_BOOL: - *(bool *)output = 0; - output += sizeof(bool); - break; - case TSDB_DATA_TYPE_TINYINT: - *(int8_t *) output = *((int8_t *) left + i) >> *(int8_t *) right; - output += sizeof(int8_t); - break; - case TSDB_DATA_TYPE_SMALLINT: - *(int16_t *) output = *((int16_t *) left + i) >> *(int16_t *) right; - output += sizeof(int16_t); - break; - case TSDB_DATA_TYPE_INT: - *(int32_t *) output = *((int32_t *) left + i) >> *(int32_t *) right; - output += sizeof(int32_t); - break; - case TSDB_DATA_TYPE_BIGINT: - *(int64_t *) output = *((int64_t *) left + i) >> *(int64_t *) right; - output += sizeof(int64_t); - break; + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } - case TSDB_DATA_TYPE_UTINYINT: - *(uint8_t *) output = *((uint8_t *) left + i) >> *(uint8_t *) right; - output += sizeof(int8_t); - break; - case TSDB_DATA_TYPE_USMALLINT: - *(uint16_t *) output = *((uint16_t *) left + i) >> *(uint16_t *) right; - output += sizeof(int16_t); - break; - case TSDB_DATA_TYPE_UINT: - *(uint32_t *) output = *((uint32_t *) left + i) >> *(uint32_t *) right; - output += sizeof(int32_t); - break; - case TSDB_DATA_TYPE_UBIGINT: - *(uint64_t *) output = *((uint64_t *) left + i) >> *(uint64_t *) right; - output += sizeof(int64_t); - break; + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *)output = 0; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = getVectorBigintValueFnLeft(left, i) >> getVectorBigintValueFnRight(right, 0); + output += sizeof(int64_t); + break; + } } } } diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 60cf4a4ea685e58b303bf89ed8fa61729110f999..d7705f9c0cd4f630166ac5eee4b512ef01f301f2 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -261,10 +261,10 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { if (sptr != NULL) { // select ... where col >> n op m ...; - match = regex_match(sptr + 2, "^\\s*[0-9]{1,}\\s*[\\>|\\<|\\<=|\\>=|=|!=]\\s*.*;\\s*$", REG_EXTENDED | REG_ICASE); + match = regex_match(sptr + 2, "^\\s*.{1,}\\s*[\\>|\\<|\\<=|\\>=|=|!=]\\s*.{1,};\\s*$", REG_EXTENDED | REG_ICASE); if (match == 0) { // select col >> n from ...; - match = regex_match(sptr + 2, "^\\s*[0-9]{1,}\\s*.*;\\s*$", REG_EXTENDED | REG_ICASE); + match = regex_match(sptr + 2, "^\\s*.{1,}\\s{1,}.{1,};\\s*$", REG_EXTENDED | REG_ICASE); if (match == 0) { cptr = tstrstr(command, ";", true); if (cptr != NULL) {