Create table from another database results in errors and segfault
- Dominant language
- C
- Stars
- 291
- Forks
- 45
- Avg merge
- 10h 13m
- Merged PRs (30d)
- 18
Description
### What happens?
I tried to use duckdb to copy data from PostgreSQL to SQLite, and this results in "Not implemented error" and finally a segfault with some commands. Before the segfault, the commands would sometimes succeed, seemingly non-deterministically.
```
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
[... TRUNCATED]
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
zsh: segmentation fault duckdb
```
### To Reproduce
I managed to reproduce this with two SQLite databases as well as the original PostgreSQL + SQLite. SQLite version here:
1. Create the SQLite database
```zsh
sqlite3 db1.db
```
```sql
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
age INTEGER,
email TEXT UNIQUE NOT NULL
);
INSERT INTO users (name, age, email) VALUES
('Alice', 25, 'alice@example.com'),
('Bob', 30, 'bob@example.com'),
('Charlie', 22, 'charlie@example.com');
```
2. Use duckdb to create table in another SQLite database from this table:
```
duckdb
```
```
ATTACH 'db1.db' (TYPE SQLITE);
ATTACH 'db2.db' (TYPE SQLITE);
CREATE TABLE db2.users AS SELECT * FROM db1.users;
USE db2;
SHOW TABLES;
```
output (as expected):
```
D use db2;
D show tables;
┌─────────┐
│ name │
│ varchar │
├─────────┤
│ users │
└─────────┘
```
3. Reproducing the bug:
Run the command:
```
show all;
```
multiple times. It should fail some of the time, succeed some of the time, and finally result in a segfault:
```
[... TRUNCATED]
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
┌──────────┬─────────┬─────────────────┬────────────────────────┬────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼────────────────────────┼────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db1 │ main │ users │ [id, name, age, email] │ [BIGINT, VARCHAR, BIGINT, VARCHAR] │ false │
│ db2 │ main │ users │ [id, name, age, email] │ [BIGINT, VARCHAR, BIGINT, VARCHAR] │ false │
└──────────┴─────────┴─────────────────┴────────────────────────┴────────────────────────────────────┴───────────┘
D show all;
┌──────────┬─────────┬─────────────────┬──────────────────────┬─────────────────────────────────────────────────────────────┬───────────┐
│ database │ schema │ name │ column_names │ column_types │ temporary │
│ varchar │ varchar │ varchar │ varchar[] │ varchar[] │ boolean │
├──────────┼─────────┼─────────────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼───────────┤
│ db1 │ main │ sqlite_sequence │ [name, seq] │ [BLOB, BLOB] │ false │
│ db2 │ main │ users │ [id, id, name, nam… │ [BIGINT, BIGINT, VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHA… │ false │
└──────────┴─────────┴─────────────────┴──────────────────────┴─────────────────────────────────────────────────────────────┴───────────┘
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
Not implemented Error:
Unsupported catalog type for duckdb_columns
D show all;
zsh: segmentation fault duckdb
```
### OS:
macOS Ventura 13.7.2 (arm64)
### DuckDB Version:
v1.2.0 5f5512b827 (from homebrew)
### DuckDB Client:
CLI
### Hardware:
_No response_
### Full Name:
Sakari Cajanus
### Affiliation:
Taiste Oy
### 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?
- [x] Yes, I have
### Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- [x] Yes, I have
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.