From 829cfdecfa0b7b6169d197db8ceda12417384919 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 5 May 2022 14:15:44 +0800 Subject: [PATCH] [CP] fix table location generate wrong key_exprs --- src/sql/optimizer/ob_table_location.cpp | 28 ++++++++------ tools/docker/standalone/Dockerfile | 6 +-- tools/docker/standalone/boot/_boot | 45 +++++++--------------- tools/docker/standalone/boot/boot-tmp.yaml | 2 - 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/src/sql/optimizer/ob_table_location.cpp b/src/sql/optimizer/ob_table_location.cpp index 266536ab2f..57df62d746 100644 --- a/src/sql/optimizer/ob_table_location.cpp +++ b/src/sql/optimizer/ob_table_location.cpp @@ -4594,12 +4594,6 @@ int ObTableLocation::record_insert_part_info(ObInsertStmt& insert_stmt, ObSQLSes const ObIArray* value_vector = NULL; const int64_t part_column_count = partition_columns.count(); - if (NULL != table_columns && table_columns->count() > 1) { - if (0 == table_columns->at(0)->get_table_name().case_compare("sg1")) { - LOG_DEBUG("shaoge table"); - } - } - ObSEArray value_desc_heap_table; ObSEArray value_vector_heap_table; if (insert_stmt.get_part_generated_col_dep_cols().count() == 0) { @@ -4628,11 +4622,23 @@ int ObTableLocation::record_insert_part_info(ObInsertStmt& insert_stmt, ObSQLSes } } else { for (int64_t value_idx = 0; OB_SUCC(ret) && value_idx < value_desc_count; ++value_idx) { - if (OB_ISNULL(value_desc->at(value_idx))) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("value desc expr is null"); - } else { - if (OB_FAIL(value_need_idx.push_back(value_idx))) { + // Value with subquery can't be calculated, remove it from value_need_idx. + // Previous code already guarantee that part key not contain subquery. + bool has_subquery = false; + for (int64_t j = value_idx; OB_SUCC(ret) && !has_subquery && j < value_count; j += value_desc_count) { + ObRawExpr *expr = value_vector->at(j); + if (OB_ISNULL(expr)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get null expr", K(ret), K(j)); + } else if (expr->has_flag(CNT_SUB_QUERY) || expr->has_flag(CNT_EXEC_PARAM)) { + has_subquery = true; + } + } + if (OB_SUCC(ret) && !has_subquery) { + if (OB_ISNULL(value_desc->at(value_idx))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("value desc expr is null"); + } else if (OB_FAIL(value_need_idx.push_back(value_idx))) { LOG_WARN("Failed to add value idx", K(ret)); } } diff --git a/tools/docker/standalone/Dockerfile b/tools/docker/standalone/Dockerfile index 3fc92da7c3..45d449c599 100644 --- a/tools/docker/standalone/Dockerfile +++ b/tools/docker/standalone/Dockerfile @@ -1,10 +1,10 @@ FROM oceanbase/centos7:latest RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \ - yum install -y ob-deploy-1.2.1 obclient ob-sysbench wget libaio && \ + yum install -y ob-deploy obclient ob-sysbench wget libaio && \ mkdir /root/pkg && \ cd /root/pkg && \ - wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-3.1.3-10000292022032916.el7.x86_64.rpm -q && \ - wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-3.1.3-10000292022032916.el7.x86_64.rpm -q && \ + wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm -q && \ + wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm -q && \ rm -rf /usr/obd/mirror/remote/* && \ obd mirror clone *.rpm && \ obd mirror list local && \ diff --git a/tools/docker/standalone/boot/_boot b/tools/docker/standalone/boot/_boot index dcea2a7ff6..3402c3ed93 100755 --- a/tools/docker/standalone/boot/_boot +++ b/tools/docker/standalone/boot/_boot @@ -5,49 +5,32 @@ source _env STAMP="$(date +%s)" -# return 0 if mini_mode is nil or 'no'/'false'/0 -# 0 means true and 1 for false in bash -function is_mini_mode() { - if test -z ${MINI_MODE} - then - return 1 - fi - - # convert MINI_MODE to upper case string(can work in bash 4.x) - mini_mode=${MINI_MODE^^} - if [ "x${mini_mode}" == "xNO" ] || [ "x${mini_mode}" == "xFALSE" ] || [ "x${mini_mode}" == "x0" ]; then - return 1 - fi - return 0 -} - [[ -f boot.yaml ]] && echo "find boot.yaml, skip configuring..." || { echo "generate boot.yaml ..." TMPFILE="boot.${STAMP}.yaml" - - if is_mini_mode + if [[ $MINI_MODE == 1 ]] then - echo "oceanbase-ce docker in mini mode" - cp -f boot-mini-tmp.yaml $TMPFILE + cp -f boot-mini-tmp.yaml $TMPFILE else - cp -f boot-tmp.yaml $TMPFILE + cp -f boot-tmp.yaml $TMPFILE fi - sed -i "s|@OB_HOME_PATH@|${OB_HOME_PATH}|g" $TMPFILE sed -i "s|@OB_MYSQL_PORT@|${OB_MYSQL_PORT}|g" $TMPFILE sed -i "s|@OB_RPC_PORT@|${OB_RPC_PORT}|g" $TMPFILE sed -i "s|@OB_ROOT_PASSWORD@|${OB_ROOT_PASSWORD}|g" $TMPFILE - [ "${OB_DATA_DIR}" ] && echo " data_dir: ${OB_DATA_DIR}" >> $TMPFILE [ "${OB_REDO_DIR}" ] && echo " redo_dir: ${OB_REDO_DIR}" >> $TMPFILE echo "create boot dirs and deploy ob cluster ..." mkdir -p $OB_HOME_PATH - - obd cluster autodeploy "${OB_CLUSTER_NAME}" -c $TMPFILE \ - && obd cluster tenant create "${OB_CLUSTER_NAME}" -n ${OB_TENANT_NAME} \ - && obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql \ - && mv -f $TMPFILE boot.yaml \ - && echo "start ob cluster ..." \ - && echo "boot success!" \ - && exec /sbin/init + if [[ $MINI_MODE == 1 ]] + then + obd cluster deploy "${OB_CLUSTER_NAME}" -c $TMPFILE && obd cluster tenant create "${OB_CLUSTER_NAME}" -n ${OB_TENANT_NAME} && obd cluster start "${OB_CLUSTER_NAME}" && obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql && mv -f $TMPFILE boot.yaml + else + obd cluster autodeploy "${OB_CLUSTER_NAME}" -c $TMPFILE && obd cluster tenant create "${OB_CLUSTER_NAME}" -n ${OB_TENANT_NAME} && obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql && mv -f $TMPFILE boot.yaml + fi } + +[[ -f boot.yaml ]] && { + echo "start ob cluster ..." + obd cluster start $OB_CLUSTER_NAME +} && echo "boot success!" && exec /sbin/init diff --git a/tools/docker/standalone/boot/boot-tmp.yaml b/tools/docker/standalone/boot/boot-tmp.yaml index d435718087..86d834c64c 100644 --- a/tools/docker/standalone/boot/boot-tmp.yaml +++ b/tools/docker/standalone/boot/boot-tmp.yaml @@ -7,5 +7,3 @@ oceanbase-ce: mysql_port: @OB_MYSQL_PORT@ # default: 2881 rpc_port: @OB_RPC_PORT@ # default: 2882 root_password: @OB_ROOT_PASSWORD@ # default: null - datafile_size: 10G - clog_disk_usage_limit_percentage: 98 # default: 80 -- GitLab