Backport #71679 to 24.3: Fix LOGICAL_ERROR when doing ALTER with empty tuple

This commit is contained in:
robot-clickhouse 2024-11-13 16:11:02 +00:00
parent cfa4e62b77
commit d871da5418
4 changed files with 18 additions and 0 deletions

View File

@ -1048,6 +1048,9 @@ private:
size_t tuple_size, size_t tuple_size,
size_t input_rows_count) const size_t input_rows_count) const
{ {
if (0 == tuple_size)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Comparison of zero-sized tuples is not implemented");
ColumnsWithTypeAndName less_columns(tuple_size); ColumnsWithTypeAndName less_columns(tuple_size);
ColumnsWithTypeAndName equal_columns(tuple_size - 1); ColumnsWithTypeAndName equal_columns(tuple_size - 1);
ColumnsWithTypeAndName tmp_columns(2); ColumnsWithTypeAndName tmp_columns(2);

View File

@ -760,6 +760,9 @@ private:
temporary_columns[0] = arguments[0]; temporary_columns[0] = arguments[0];
size_t tuple_size = type1.getElements().size(); size_t tuple_size = type1.getElements().size();
if (tuple_size == 0)
return ColumnTuple::create(input_rows_count);
Columns tuple_columns(tuple_size); Columns tuple_columns(tuple_size);
for (size_t i = 0; i < tuple_size; ++i) for (size_t i = 0; i < tuple_size; ++i)

View File

@ -0,0 +1 @@
() 2

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS t0;
CREATE TABLE t0 (c0 Tuple(), c1 int) ENGINE = Memory();
INSERT INTO t0 VALUES ((), 1);
ALTER TABLE t0 UPDATE c0 = (), c1 = 2 WHERE EXISTS (SELECT 1);
SELECT * FROM t0;
DROP TABLE t0;