mirror of https://github.com/citusdata/citus.git
Give nicer error message when using alter_table_set_access_method on a view (#6553)
DESCRIPTION: Fixes alter_table_set_access_method error for views. Fixes #6001pull/6555/head
parent
1ad1a0a336
commit
3f091e3493
|
@ -477,6 +477,11 @@ AlterTableSetAccessMethod(TableConversionParameters *params)
|
|||
ereport(ERROR, (errmsg("you cannot alter access method of a partitioned table")));
|
||||
}
|
||||
|
||||
if (get_rel_relkind(params->relationId) == RELKIND_VIEW)
|
||||
{
|
||||
ereport(ERROR, (errmsg("you cannot alter access method of a view")));
|
||||
}
|
||||
|
||||
if (PartitionTable(params->relationId) &&
|
||||
IsCitusTableType(params->relationId, DISTRIBUTED_TABLE))
|
||||
{
|
||||
|
|
|
@ -299,7 +299,7 @@ CREATE INDEX idx1 ON index_table (a);
|
|||
-- also create an index with statistics
|
||||
CREATE INDEX idx2 ON index_table ((a+1));
|
||||
ALTER INDEX idx2 ALTER COLUMN 1 SET STATISTICS 300;
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table';
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table' order by indexname;
|
||||
indexname
|
||||
---------------------------------------------------------------------
|
||||
idx1
|
||||
|
@ -322,7 +322,7 @@ NOTICE: renaming the new table to alter_table_set_access_method.index_table
|
|||
|
||||
(1 row)
|
||||
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table';
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table' order by indexname;
|
||||
indexname
|
||||
---------------------------------------------------------------------
|
||||
idx1
|
||||
|
@ -792,6 +792,19 @@ NOTICE: renaming the new table to alter_table_set_access_method.events
|
|||
(1 row)
|
||||
|
||||
COMMIT;
|
||||
--create the view to test alter table set access method on it
|
||||
CREATE TABLE view_test_table (id int, val int, flag bool, kind int);
|
||||
SELECT create_distributed_table('view_test_table','id');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO view_test_table VALUES (1, 1, true, 99), (2, 2, false, 99), (2, 3, true, 88);
|
||||
CREATE VIEW view_test_view AS SELECT * FROM view_test_table;
|
||||
-- error out when attempting to set access method of a view.
|
||||
select alter_table_set_access_method('view_test_view','columnar');
|
||||
ERROR: you cannot alter access method of a view
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA alter_table_set_access_method CASCADE;
|
||||
SELECT 1 FROM master_remove_node('localhost', :master_port);
|
||||
|
|
|
@ -99,10 +99,10 @@ CREATE INDEX idx1 ON index_table (a);
|
|||
-- also create an index with statistics
|
||||
CREATE INDEX idx2 ON index_table ((a+1));
|
||||
ALTER INDEX idx2 ALTER COLUMN 1 SET STATISTICS 300;
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table';
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table' order by indexname;
|
||||
SELECT a.amname FROM pg_class c, pg_am a where c.relname = 'index_table' AND c.relnamespace = 'alter_table_set_access_method'::regnamespace AND c.relam = a.oid;
|
||||
SELECT alter_table_set_access_method('index_table', 'columnar');
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table';
|
||||
SELECT indexname FROM pg_indexes WHERE schemaname = 'alter_table_set_access_method' AND tablename = 'index_table' order by indexname;
|
||||
SELECT a.amname FROM pg_class c, pg_am a where c.relname = 'index_table' AND c.relnamespace = 'alter_table_set_access_method'::regnamespace AND c.relam = a.oid;
|
||||
|
||||
CREATE TABLE "heap_\'tbl" (
|
||||
|
@ -271,6 +271,15 @@ BEGIN;
|
|||
select alter_table_set_access_method('events', 'columnar');
|
||||
COMMIT;
|
||||
|
||||
--create the view to test alter table set access method on it
|
||||
CREATE TABLE view_test_table (id int, val int, flag bool, kind int);
|
||||
SELECT create_distributed_table('view_test_table','id');
|
||||
INSERT INTO view_test_table VALUES (1, 1, true, 99), (2, 2, false, 99), (2, 3, true, 88);
|
||||
CREATE VIEW view_test_view AS SELECT * FROM view_test_table;
|
||||
|
||||
-- error out when attempting to set access method of a view.
|
||||
select alter_table_set_access_method('view_test_view','columnar');
|
||||
|
||||
SET client_min_messages TO WARNING;
|
||||
DROP SCHEMA alter_table_set_access_method CASCADE;
|
||||
SELECT 1 FROM master_remove_node('localhost', :master_port);
|
||||
|
|
Loading…
Reference in New Issue