Skip to content

DuckDB SEGV when running ill-formed CREATE VIEW statement #14699

@SteveLeungYL

Description

@SteveLeungYL

What happens?

The latest version of the DuckDB (v1.1.3 1986445 and latest main: v1.1.3-dev165 1986445) crashes when running the following SQL statement:

CREATE VIEW any_view_name AS ( SHOW ALL TABLES );

Here is the stack trace from v1.1.3-dev165 1986445:

(gdb) bt
#0  0x0000aaaadba322f0 in duckdb::Transformer::TransformPivotStatement (this=0xffffe4d4e090, select=...) at /home/duckdb/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp:138
#1  0x0000aaaadba37da4 in duckdb::Transformer::TransformSelectNodeInternal (this=this@entry=0xffffe4d4e090, select=..., is_select=is_select@entry=false) at /home/duckdb/duckdb/src/parser/transform/statement/transform_select.cpp:31
#2  0x0000aaaadba39e4c in duckdb::Transformer::TransformSelectStmt (this=this@entry=0xffffe4d4e090, select=..., is_select=is_select@entry=false) at ../../src/include/duckdb/common/unique_ptr.hpp:39
#3  0x0000aaaadba3a018 in duckdb::Transformer::TransformCreateView (this=this@entry=0xffffe4d4e090, stmt=...) at ../../src/include/duckdb/common/optional_ptr.hpp:42
#4  0x0000aaaadb210e8c in duckdb::Transformer::TransformStatementInternal (this=this@entry=0xffffe4d4e090, stmt=...) at /home/duckdb/duckdb/src/parser/transformer.cpp:153
#5  0x0000aaaadb211130 in duckdb::Transformer::TransformStatement (this=this@entry=0xffffe4d4e090, stmt=...) at /home/duckdb/duckdb/src/parser/transformer.cpp:59
#6  0x0000aaaadb211038 in duckdb::Transformer::TransformStatementInternal (this=this@entry=0xffffe4d4e090, stmt=...) at /home/duckdb/duckdb/src/parser/transformer.cpp:139
#7  0x0000aaaadb211130 in duckdb::Transformer::TransformStatement (this=this@entry=0xffffe4d4e090, stmt=...) at /home/duckdb/duckdb/src/parser/transformer.cpp:59
#8  0x0000aaaadb211224 in duckdb::Transformer::TransformParseTree (this=this@entry=0xffffe4d4e090, tree=<optimized out>, statements=...) at ../../src/include/duckdb/common/optional_ptr.hpp:42
#9  0x0000aaaadb215648 in duckdb::Parser::ParseQuery (this=this@entry=0xffffe4d4e3f8, query="CREATE VIEW any_view_name AS ( SHOW ALL TABLES );") at /home/duckdb/duckdb/src/parser/parser.cpp:219
#10 0x0000aaaadb1f4ecc in duckdb_shell_sqlite3_prepare_v2 (db=0xaaaae503c8c0, zSql=0xaaaae503a290 "CREATE VIEW any_view_name AS ( SHOW ALL TABLES );", nByte=<optimized out>, ppStmt=0xffffe4d4e620, pzTail=0xffffe4d4e628)
    at ../../tools/sqlite3_api_wrapper/sqlite3_api_wrapper.cpp:176
#11 0x0000aaaadb1e0f68 in shell_exec (pArg=0xffffe4d4e8b0, zSql=0xaaaae503a290 "CREATE VIEW any_view_name AS ( SHOW ALL TABLES );", pzErrMsg=<optimized out>) at ../../tools/shell/shell.c:12993
#12 0x0000aaaadb1e2a28 in runOneSqlLine (p=0xffffe4d4e8b0, zSql=0xaaaae503a290 "CREATE VIEW any_view_name AS ( SHOW ALL TABLES );", startline=<optimized out>, in=<optimized out>) at ../../tools/shell/shell.c:19273
#13 0x0000aaaadb1e9bc0 in process_input (p=0xffffe4d4e8b0) at ../../tools/shell/shell.c:19384
#14 0x0000aaaadb1bfb90 in main (argc=<optimized out>, argv=0xffffe4d4fc18) at ../../tools/shell/shell.c:20206

To Reproduce

  1. Clone the DuckDB Git from the official repo.
  2. Checkout to either the latest main (1986445) or release version: 1.1.3 (1986445).
  3. Compile the DuckDB binary by using either make reldebug or make debug.
  4. Run the compiled DuckDB and input the following SQL:
CREATE VIEW any_view_name AS ( SHOW ALL TABLES );

OS:

Ubuntu 20.04 LTS

DuckDB Version:

1.1.3

DuckDB Client:

cli

Hardware:

No response

Full Name:

Yu Liang

Affiliation:

Pennsylvania State University

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions