oceanbase / oceanbase/oceanbase

[Bug]: Row Size Too Large Error When Creating an Empty Table Using HAVING 1=0 from a Wide View in OceanBase

Open
#2,267 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
C++
Stars
10.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
This is a common scenario in practice—wanting to quickly create an empty table from an existing view or table using a query like the one below. Especially when there are many columns, manually recreating the table structure can be very time-consuming.

use oceanbase;
CREATE TABLE empty_table1 AS SELECT * FROM CDB_TAB_COLS HAVING 1=0;
Query OK, 0 rows affected (2.619 sec)
CREATE TABLE empty_table2 AS SELECT * FROM __all_column HAVING 1=0;
ERROR 1118 (42000): Row size too large
[172.17.0.5:2882] [2025-05-09 13:43:38.720075] [YB42AC110005-0006338932A093C4-0-0]

The condition HAVING 1=0 is always false, so these SQL statements create a table with the same column definitions as the source view or table, but without copying any data. However, the second statement fails because the underlying view __all_column contains too many columns or data fields, causing the resulting row size to exceed the database's maximum row size limit.

Environment
Linux ubuntu 6.5.0-18-generic #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 11:40:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

5.7.25-OceanBase_CE-v4.2.1.10

Fast Reproduce Steps(Required)
Steps to reproduce the behavior:

use oceanbase;
CREATE TABLE empty_table1 AS SELECT * FROM CDB_TAB_COLS HAVING 1=0;
Query OK, 0 rows affected (2.619 sec)
CREATE TABLE empty_table2 AS SELECT * FROM __all_column HAVING 1=0;
ERROR 1118 (42000): Row size too large
[172.17.0.5:2882] [2025-05-09 13:43:38.720075] [YB42AC110005-0006338932A093C4-0-0]

Expected behavior

CREATE TABLE empty_table2 AS SELECT * FROM __all_column HAVING 1=0;
Query OK, 0 rows affected (x.xxx sec)

Actual Behavior

CREATE TABLE empty_table2 AS SELECT * FROM __all_column HAVING 1=0;
ERROR 1118 (42000): Row size too large
[172.17.0.5:2882] [2025-05-09 13:43:38.720075] [YB42AC110005-0006338932A093C4-0-0]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two CREATE TABLE ... AS SELECT statements against OceanBase 4.2.1.10, especially the query using __all_column and HAVING 1=0. Compare the successful CDB_TAB_COLS case with the Row size too large failure; done means the __all_column statement creates an empty table with the source column definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
database
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.