mirror of https://github.com/citusdata/citus.git
Move rest of the schema changes to 10.2-1
parent
07117b0454
commit
18fe0311c0
|
@ -20,34 +20,3 @@ END$proc$;
|
|||
-- since we dropped pg11 support, we don't need to worry about missing
|
||||
-- columnar objects when upgrading postgres
|
||||
DROP FUNCTION citus_internal.columnar_ensure_objects_exist();
|
||||
|
||||
-- For a proper mapping between tid & (stripe, row_num), add a new column to
|
||||
-- columnar.stripe and define a BTREE index on this column.
|
||||
-- Also include storage_id column for per-relation scans.
|
||||
ALTER TABLE columnar.stripe ADD COLUMN first_row_number bigint;
|
||||
CREATE INDEX stripe_first_row_number_idx ON columnar.stripe USING BTREE(storage_id, first_row_number);
|
||||
|
||||
-- Populate first_row_number column of columnar.stripe table.
|
||||
--
|
||||
-- For simplicity, we calculate MAX(row_count) value across all the stripes
|
||||
-- of all the columanar tables and then use it to populate first_row_number
|
||||
-- column. This would introduce some gaps however we are okay with that since
|
||||
-- it's already the case with regular INSERT/COPY's.
|
||||
DO $$
|
||||
DECLARE
|
||||
max_row_count bigint;
|
||||
-- this should be equal to columnar_storage.h/COLUMNAR_FIRST_ROW_NUMBER
|
||||
COLUMNAR_FIRST_ROW_NUMBER constant bigint := 1;
|
||||
BEGIN
|
||||
SELECT MAX(row_count) INTO max_row_count FROM columnar.stripe;
|
||||
UPDATE columnar.stripe SET first_row_number = COLUMNAR_FIRST_ROW_NUMBER +
|
||||
(stripe_num - 1) * max_row_count;
|
||||
END;
|
||||
$$;
|
||||
|
||||
#include "udfs/upgrade_columnar_storage/10.1-1.sql"
|
||||
#include "udfs/downgrade_columnar_storage/10.1-1.sql"
|
||||
|
||||
-- upgrade storage for all columnar relations
|
||||
SELECT citus_internal.upgrade_columnar_storage(c.oid) FROM pg_class c, pg_am a
|
||||
WHERE c.relam = a.oid AND amname = 'columnar';
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* columnar--10.1-1--10.2-1.sql */
|
||||
|
||||
-- For a proper mapping between tid & (stripe, row_num), add a new column to
|
||||
-- columnar.stripe and define a BTREE index on this column.
|
||||
-- Also include storage_id column for per-relation scans.
|
||||
ALTER TABLE columnar.stripe ADD COLUMN first_row_number bigint;
|
||||
CREATE INDEX stripe_first_row_number_idx ON columnar.stripe USING BTREE(storage_id, first_row_number);
|
||||
|
||||
-- Populate first_row_number column of columnar.stripe table.
|
||||
--
|
||||
-- For simplicity, we calculate MAX(row_count) value across all the stripes
|
||||
-- of all the columanar tables and then use it to populate first_row_number
|
||||
-- column. This would introduce some gaps however we are okay with that since
|
||||
-- it's already the case with regular INSERT/COPY's.
|
||||
DO $$
|
||||
DECLARE
|
||||
max_row_count bigint;
|
||||
-- this should be equal to columnar_storage.h/COLUMNAR_FIRST_ROW_NUMBER
|
||||
COLUMNAR_FIRST_ROW_NUMBER constant bigint := 1;
|
||||
BEGIN
|
||||
SELECT MAX(row_count) INTO max_row_count FROM columnar.stripe;
|
||||
UPDATE columnar.stripe SET first_row_number = COLUMNAR_FIRST_ROW_NUMBER +
|
||||
(stripe_num - 1) * max_row_count;
|
||||
END;
|
||||
$$;
|
||||
|
||||
#include "udfs/upgrade_columnar_storage/10.2-1.sql"
|
||||
#include "udfs/downgrade_columnar_storage/10.2-1.sql"
|
||||
|
||||
-- upgrade storage for all columnar relations
|
||||
SELECT citus_internal.upgrade_columnar_storage(c.oid) FROM pg_class c, pg_am a
|
||||
WHERE c.relam = a.oid AND amname = 'columnar';
|
|
@ -11,14 +11,3 @@ REFERENCES columnar.stripe(storage_id, stripe_num) ON DELETE CASCADE;
|
|||
|
||||
-- define columnar_ensure_objects_exist again
|
||||
#include "../udfs/columnar_ensure_objects_exist/10.0-1.sql"
|
||||
|
||||
-- downgrade storage for all columnar relations
|
||||
SELECT citus_internal.downgrade_columnar_storage(c.oid) FROM pg_class c, pg_am a
|
||||
WHERE c.relam = a.oid AND amname = 'columnar';
|
||||
|
||||
DROP FUNCTION citus_internal.upgrade_columnar_storage(regclass);
|
||||
DROP FUNCTION citus_internal.downgrade_columnar_storage(regclass);
|
||||
|
||||
-- drop "first_row_number" column and the index defined on it
|
||||
DROP INDEX columnar.stripe_first_row_number_idx;
|
||||
ALTER TABLE columnar.stripe DROP COLUMN first_row_number;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/* columnar--10.2-1--10.1-1.sql */
|
||||
|
||||
-- downgrade storage for all columnar relations
|
||||
SELECT citus_internal.downgrade_columnar_storage(c.oid) FROM pg_class c, pg_am a
|
||||
WHERE c.relam = a.oid AND amname = 'columnar';
|
||||
|
||||
DROP FUNCTION citus_internal.upgrade_columnar_storage(regclass);
|
||||
DROP FUNCTION citus_internal.downgrade_columnar_storage(regclass);
|
||||
|
||||
-- drop "first_row_number" column and the index defined on it
|
||||
DROP INDEX columnar.stripe_first_row_number_idx;
|
||||
ALTER TABLE columnar.stripe DROP COLUMN first_row_number;
|
|
@ -1,4 +1,3 @@
|
|||
-- citus--10.1-1--10.2-1
|
||||
|
||||
-- bump version to 10.2-1
|
||||
|
||||
#include "../../columnar/sql/columnar--10.1-1--10.2-1.sql"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
-- citus--10.2-1--10.1-1
|
||||
-- this is an empty downgrade path since citus--10.1-1--10.2-1.sql is empty for now
|
||||
|
||||
#include "../../../columnar/sql/downgrades/columnar--10.2-1--10.1-1.sql"
|
||||
|
|
|
@ -595,9 +595,11 @@ SELECT * FROM print_extension_changes();
|
|||
-- Snapshot of state at 10.2-1
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-1';
|
||||
SELECT * FROM print_extension_changes();
|
||||
previous_object | current_object
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
| function citus_internal.downgrade_columnar_storage(regclass) void
|
||||
| function citus_internal.upgrade_columnar_storage(regclass) void
|
||||
(2 rows)
|
||||
|
||||
DROP TABLE prev_objects, extension_diff;
|
||||
-- show running version
|
||||
|
|
Loading…
Reference in New Issue