Skip to content
Permalink
Browse files
[BUG] fix information_schema.columns results not correctly on vec eng…
…ine (#9612)

* VSchemaScanNode get_next bugfix

* add regression-test case for VSchemaScanNode

Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
  • Loading branch information
cambyzju and cambyzju committed May 17, 2022
1 parent b6f5c89 commit bfb1ab059d73fed59e391f1a82a40eb80a82d6b5
Showing 5 changed files with 132 additions and 3 deletions.
@@ -46,6 +46,7 @@ Status VMysqlScanNode::get_next(RuntimeState* state, vectorized::Block* block, b
bool mysql_eos = false;

do {
columns.resize(_slot_num);
for (int i = 0; i < _slot_num; ++i) {
if (mem_reuse) {
columns[i] = std::move(*block->get_by_position(i).column).mutate();
@@ -58,6 +58,7 @@ Status VOdbcScanNode::get_next(RuntimeState* state, Block* block, bool* eos) {
do {
RETURN_IF_CANCELLED(state);

columns.resize(column_size);
for (auto i = 0; i < column_size; i++) {
if (mem_reuse) {
columns[i] = std::move(*block->get_by_position(i).column).mutate();
@@ -69,12 +69,14 @@ Status VSchemaScanNode::get_next(RuntimeState* state, vectorized::Block* block,
if (!_is_init) return Status::InternalError("used before initialize.");
RETURN_IF_ERROR(exec_debug_action(TExecNodePhase::GETNEXT));
RETURN_IF_CANCELLED(state);
bool mem_reuse = block->mem_reuse();
DCHECK(block->rows() == 0);
std::vector<vectorized::MutableColumnPtr> columns(_slot_num);
bool schema_eos = false;

do {
bool mem_reuse = block->mem_reuse();
DCHECK(block->rows() == 0);

columns.resize(_slot_num);
for (int i = 0; i < _slot_num; ++i) {
if (mem_reuse) {
columns[i] = std::move(*block->get_by_position(i).column).mutate();
@@ -88,7 +90,6 @@ Status VSchemaScanNode::get_next(RuntimeState* state, vectorized::Block* block,
// get all slots from schema table.
RETURN_IF_ERROR(_schema_scanner->get_next_row(_src_single_tuple, _tuple_pool.get(),
&schema_eos));

if (schema_eos) {
*eos = true;
break;
@@ -0,0 +1,31 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
612

-- !sql --
578

-- !sql --
544

-- !sql --
510

-- !sql --
476

-- !sql --
612

-- !sql --
578

-- !sql --
544

-- !sql --
510

-- !sql --
476

@@ -0,0 +1,95 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
suite("test_information_schema", "columns") {
def dbPrefix = "db_test_schema_"
def tablePrefix = "tb_test_schema_"

// create lots of dbs and tables to make rows in `information_schema.columns` more than 1024
for (int i = 1; i <= 5; i++) {
def dbName = dbPrefix + i.toString()
sql "CREATE DATABASE IF NOT EXISTS `${dbName}`"
sql "USE `${dbName}`"
for (int j = i; j <= 18; j++) {
def tableName = tablePrefix + j.toString();
sql """
CREATE TABLE IF NOT EXISTS `${tableName}` (
`aaa` varchar(170) NOT NULL COMMENT "",
`bbb` varchar(100) NOT NULL COMMENT "",
`ccc` varchar(170) NULL COMMENT "",
`ddd` varchar(120) NULL COMMENT "",
`eee` varchar(120) NULL COMMENT "",
`fff` varchar(130) NULL COMMENT "",
`ggg` varchar(170) NULL COMMENT "",
`hhh` varchar(170) NULL COMMENT "",
`jjj` varchar(170) NULL COMMENT "",
`kkk` varchar(170) NULL COMMENT "",
`lll` varchar(170) NULL COMMENT "",
`mmm` varchar(170) NULL COMMENT "",
`nnn` varchar(70) NULL COMMENT "",
`ooo` varchar(140) NULL COMMENT "",
`ppp` varchar(70) NULL COMMENT "",
`qqq` varchar(130) NULL COMMENT "",
`rrr` bigint(20) NULL COMMENT "",
`sss` bigint(20) NULL COMMENT "",
`ttt` decimal(24, 2) NULL COMMENT "",
`uuu` decimal(24, 2) NULL COMMENT "",
`vvv` decimal(24, 2) NULL COMMENT "",
`www` varchar(50) NULL COMMENT "",
`xxx` varchar(190) NULL COMMENT "",
`yyy` varchar(190) NULL COMMENT "",
`zzz` varchar(100) NULL COMMENT "",
`aa` bigint(20) NULL COMMENT "",
`bb` bigint(20) NULL COMMENT "",
`cc` bigint(20) NULL COMMENT "",
`dd` varchar(60) NULL COMMENT "",
`ee` varchar(60) NULL COMMENT "",
`ff` varchar(60) NULL COMMENT "",
`gg` varchar(50) NULL COMMENT "",
`hh` bigint(20) NULL COMMENT "",
`ii` bigint(20) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`aaa`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`aaa`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
)
"""
}
}

sql "set enable_vectorized_engine=true"
for (int i = 1; i <= 5; i++) {
def dbName = dbPrefix + i.toString()
sql "USE information_schema"
qt_sql "SELECT COUNT(*) FROM `columns` WHERE TABLE_SCHEMA='${dbName}'"
}

sql "set enable_vectorized_engine=false"
for (int i = 1; i <= 5; i++) {
def dbName = dbPrefix + i.toString()
sql "USE information_schema"
qt_sql "SELECT COUNT(*) FROM `columns` WHERE TABLE_SCHEMA='${dbName}'"
}

for (int i = 1; i <= 5; i++) {
def dbName = dbPrefix + i.toString()
sql "DROP DATABASE `${dbName}`"
}
}

0 comments on commit bfb1ab0

Please sign in to comment.