sqlc generate sometimes silently fails and sometimes segfaults. I managed to isolate the issue to this nested query
-- name: GetAnsweredTasksWithQuestionText :many
SELECT * FROM (
SELECT room_tasks.*, cards.question FROM room_tasks
JOIN cards ON room_tasks.card_id = cards.id
WHERE room_id = $1 AND answer_submitted_at IS NOT NULL AND room_tasks.deleted_at IS NULL AND cards IS NULL ORDER BY order_in_attempt DESC -- TODO: LIMIT 1000
) ORDER BY order_in_attempt ASC;
if you add the LIMIT 1000, it seems to segfault always
There is a mistake in the cards IS NULL part of the nested query, nevertheless, it should not segfault.
-- Card
CREATE TABLE IF NOT EXISTS cards (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at TIMESTAMP DEFAULT NULL,
question VARCHAR NOT NULL
);
-- RoomTasks
CREATE TABLE IF NOT EXISTS room_tasks (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at TIMESTAMP DEFAULT NULL,
answer_submitted_at TIMESTAMP DEFAULT NULL,
order_in_attempt INT NOT NULL,
room_id INT NOT NULL,
card_id INT NOT NULL,
answer TEXT DEFAULT '' NOT NULL,
FOREIGN KEY (card_id) REFERENCES cards (id)
);
SQL queries
-- name: GetAnsweredTasksWithQuestionText :many
SELECT FROM (
SELECT room_tasks., cards.question FROM room_tasks
JOIN cards ON room_tasks.card_id = cards.id
WHERE room_id = $1 AND answer_submitted_at IS NOT NULL AND room_tasks.deleted_at IS NULL AND cards IS NULL ORDER BY order_in_attempt DESC
) ORDER BY order_in_attempt ASC;
Version
1.27.0
What happened?
sqlc generate
sometimes silently fails and sometimes segfaults. I managed to isolate the issue to this nested queryThere is a mistake in the
cards IS NULL
part of the nested query, nevertheless, it should not segfault.Relevant log output
Database schema
SQL queries
-- name: GetAnsweredTasksWithQuestionText :many SELECT FROM ( SELECT room_tasks., cards.question FROM room_tasks JOIN cards ON room_tasks.card_id = cards.id WHERE room_id = $1 AND answer_submitted_at IS NOT NULL AND room_tasks.deleted_at IS NULL AND cards IS NULL ORDER BY order_in_attempt DESC ) ORDER BY order_in_attempt ASC;
Configuration
No response
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go