Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions regress/expected/drop.out
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,83 @@ DROP SCHEMA IF EXISTS ag_catalog CASCADE;
RESET client_min_messages;
CREATE SCHEMA _regress_drop;
DROP SCHEMA _regress_drop; -- should'n produce the ERROR
-- A loaded library must not inspect AGE catalogs before installation.
CREATE TABLE public._regress_utility (id int);
CREATE INDEX _regress_utility_idx ON public._regress_utility (id);
INSERT INTO public._regress_utility VALUES (2), (1), (2), (NULL);
VACUUM FULL public._regress_utility;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'VACUUM FULL did not preserve the ordinary table data';
END IF;
END
$$;
CLUSTER public._regress_utility USING _regress_utility_idx;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'CLUSTER did not preserve the ordinary table data';
END IF;
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_index
WHERE indexrelid = 'public._regress_utility_idx'::regclass
AND indisclustered
) THEN
RAISE EXCEPTION 'CLUSTER did not mark the specified index';
END IF;
END
$$;
TRUNCATE public._regress_utility;
DO $$
BEGIN
IF EXISTS (SELECT FROM public._regress_utility) THEN
RAISE EXCEPTION 'TRUNCATE did not empty the ordinary table';
END IF;
END
$$;
-- An empty schema is not an installed extension.
CREATE SCHEMA ag_catalog;
-- Clear the previous CLUSTER marker so this case tests it independently.
ALTER TABLE public._regress_utility SET WITHOUT CLUSTER;
INSERT INTO public._regress_utility VALUES (2), (1), (2), (NULL);
VACUUM FULL public._regress_utility;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'VACUUM FULL did not preserve the ordinary table data';
END IF;
END
$$;
CLUSTER public._regress_utility USING _regress_utility_idx;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'CLUSTER did not preserve the ordinary table data';
END IF;
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_index
WHERE indexrelid = 'public._regress_utility_idx'::regclass
AND indisclustered
) THEN
RAISE EXCEPTION 'CLUSTER did not mark the specified index';
END IF;
END
$$;
TRUNCATE public._regress_utility;
DO $$
BEGIN
IF EXISTS (SELECT FROM public._regress_utility) THEN
RAISE EXCEPTION 'TRUNCATE did not empty the ordinary table';
END IF;
END
$$;
DROP TABLE public._regress_utility;
DROP SCHEMA ag_catalog;
-- Recreate the extension and validate we can recreate a graph
CREATE EXTENSION age;
SELECT create_graph('drop');
Expand Down
78 changes: 78 additions & 0 deletions regress/sql/drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,84 @@ RESET client_min_messages;
CREATE SCHEMA _regress_drop;
DROP SCHEMA _regress_drop; -- should'n produce the ERROR

-- A loaded library must not inspect AGE catalogs before installation.
CREATE TABLE public._regress_utility (id int);
CREATE INDEX _regress_utility_idx ON public._regress_utility (id);
INSERT INTO public._regress_utility VALUES (2), (1), (2), (NULL);
VACUUM FULL public._regress_utility;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'VACUUM FULL did not preserve the ordinary table data';
END IF;
END
$$;
CLUSTER public._regress_utility USING _regress_utility_idx;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'CLUSTER did not preserve the ordinary table data';
END IF;
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_index
WHERE indexrelid = 'public._regress_utility_idx'::regclass
AND indisclustered
) THEN
RAISE EXCEPTION 'CLUSTER did not mark the specified index';
END IF;
END
$$;
TRUNCATE public._regress_utility;
DO $$
BEGIN
IF EXISTS (SELECT FROM public._regress_utility) THEN
RAISE EXCEPTION 'TRUNCATE did not empty the ordinary table';
END IF;
END
$$;
-- An empty schema is not an installed extension.
CREATE SCHEMA ag_catalog;
-- Clear the previous CLUSTER marker so this case tests it independently.
ALTER TABLE public._regress_utility SET WITHOUT CLUSTER;
INSERT INTO public._regress_utility VALUES (2), (1), (2), (NULL);
VACUUM FULL public._regress_utility;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'VACUUM FULL did not preserve the ordinary table data';
END IF;
END
$$;
CLUSTER public._regress_utility USING _regress_utility_idx;
DO $$
BEGIN
IF (SELECT array_agg(id ORDER BY id) FROM public._regress_utility)
IS DISTINCT FROM ARRAY[1, 2, 2, NULL] THEN
RAISE EXCEPTION 'CLUSTER did not preserve the ordinary table data';
END IF;
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_index
WHERE indexrelid = 'public._regress_utility_idx'::regclass
AND indisclustered
) THEN
RAISE EXCEPTION 'CLUSTER did not mark the specified index';
END IF;
END
$$;
TRUNCATE public._regress_utility;
DO $$
BEGIN
IF EXISTS (SELECT FROM public._regress_utility) THEN
RAISE EXCEPTION 'TRUNCATE did not empty the ordinary table';
END IF;
END
$$;
DROP TABLE public._regress_utility;
DROP SCHEMA ag_catalog;

-- Recreate the extension and validate we can recreate a graph
CREATE EXTENSION age;

Expand Down
15 changes: 15 additions & 0 deletions src/backend/catalog/ag_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString,
TruncateStmt *tstmt = (TruncateStmt *) parsetree;
ListCell *lc;

if (!is_age_extension_exists())
{
break;
}

foreach(lc, tstmt->relations)
{
RangeVar *rv = (RangeVar *) lfirst(lc);
Expand Down Expand Up @@ -268,6 +273,11 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString,
*/
VacuumStmt *vstmt = (VacuumStmt *) parsetree;

if (!is_age_extension_exists())
{
break;
}

if (vacuum_rewrites_heap(vstmt))
{
if (vstmt->rels == NIL)
Expand All @@ -294,6 +304,11 @@ void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString,
/* CLUSTER rewrites the heap for the same reason. */
ClusterStmt *cstmt = (ClusterStmt *) parsetree;

if (!is_age_extension_exists())
{
break;
}

if (cstmt->relation == NULL)
{
increment_all_graph_versions();
Expand Down