Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault after second ANALYZE #5054

Merged
merged 1 commit into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@
`psql` with the `-X` flag to prevent any `.psqlrc` commands from
accidentally triggering the load of a previous DB version.**

**Bugfixes**
* #5054 Fix segfault after second ANALYZE

**Thanks**
* @kyrias for reporting a crash when ANALYZE is executed on extended query protocol mode with extension loaded.

## 2.9.0
This release adds major new features since the 2.8.1 release.
We deem it moderate priority for upgrading.
Expand Down
8 changes: 8 additions & 0 deletions src/process_utility.c
Expand Up @@ -906,6 +906,8 @@ process_vacuum(ProcessUtilityArgs *args)
Hypertable *ht;
List *vacuum_rels = NIL;
bool is_vacuumcmd;
/* save original VacuumRelation list */
List *saved_stmt_rels = stmt->rels;

is_vacuumcmd = stmt->is_vacuumcmd;

Expand Down Expand Up @@ -975,6 +977,12 @@ process_vacuum(ProcessUtilityArgs *args)
cp->compressed_relid);
}
}
/*
Restore original list. stmt->rels which has references to
VacuumRelation list is freed up, however VacuumStmt is not
cleaned up because of which there is a crash.
*/
stmt->rels = saved_stmt_rels;
return DDL_DONE;
}

Expand Down
14 changes: 14 additions & 0 deletions test/expected/size_utils.out
Expand Up @@ -744,3 +744,17 @@ SELECT * FROM hypertable_index_size('hypersize_time_idx');
24576
(1 row)

-- github issue #4857
-- below procedure should not crash
SET client_min_messages = ERROR;
do
$$
DECLARE
o INT;
BEGIN
FOR c IN 1..20 LOOP
ANALYZE;
END LOOP;
END;
$$;
RESET client_min_messages;
15 changes: 15 additions & 0 deletions test/sql/size_utils.sql
Expand Up @@ -273,3 +273,18 @@ SELECT * FROM chunks_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM chunk_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_index_size('hypersize_time_idx');

-- github issue #4857
-- below procedure should not crash
SET client_min_messages = ERROR;
do
$$
DECLARE
o INT;
BEGIN
FOR c IN 1..20 LOOP
ANALYZE;
END LOOP;
END;
$$;
RESET client_min_messages;