cartodb-postgresql/test/CDB_RegenerateTable_expect
2020-11-23 16:17:54 +01:00

187 lines
9.2 KiB
Plaintext

## Setup
CREATE TABLE
INSERT 0 3
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||||plain||
c4|integer||||plain||
1|2|3|4|5
2|3|4|5|6
3|4|5|6|7
SELECT 1
CREATE FUNCTION
## Run cartodb.CDB_RegenerateTable and confirm the data and columns are the same
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||||plain||
c4|integer||||plain||
1|2|3|4|5
2|3|4|5|6
3|4|5|6|7
## The table oid must have changed since the table itself changed
SELECT 1
f
## Check adding an index
CREATE INDEX
testtable|testtable_stable_idx|CREATE INDEX testtable_stable_idx ON public.testtable USING btree (stable NULLS FIRST) WITH (fillfactor='80', vacuum_cleanup_index_scale_factor='0.11')
testtable|testtable_stable_idx|CREATE INDEX testtable_stable_idx ON public.testtable USING btree (stable NULLS FIRST) WITH (fillfactor='80', vacuum_cleanup_index_scale_factor='0.11')
## Check column properties
ALTER TABLE
ALTER TABLE
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||not null||plain||
c4|integer||||plain||
testtable|testtable_c2_key|CREATE UNIQUE INDEX testtable_c2_key ON public.testtable USING btree (c2)
testtable|testtable_stable_idx|CREATE INDEX testtable_stable_idx ON public.testtable USING btree (stable NULLS FIRST) WITH (fillfactor='80', vacuum_cleanup_index_scale_factor='0.11')
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||not null||plain||
c4|integer||||plain||
testtable|testtable_c2_key|CREATE UNIQUE INDEX testtable_c2_key ON public.testtable USING btree (c2)
testtable|testtable_stable_idx|CREATE INDEX testtable_stable_idx ON public.testtable USING btree (stable NULLS FIRST) WITH (fillfactor='80', vacuum_cleanup_index_scale_factor='0.11')
## Check triggers
CREATE FUNCTION
CREATE TRIGGER
public|testtable|public|testtable_trigger_example
public|testtable|public|testtable_trigger_example
## Check Cartodbfycation
DROP INDEX
DROP TRIGGER
{"ALTER TABLE public.testtable OWNER TO postgres","ALTER TABLE ONLY public.testtable ADD CONSTRAINT testtable_c2_key UNIQUE (c2)"}
{"ALTER TABLE public.testtable OWNER TO postgres","ALTER TABLE ONLY public.testtable ADD CONSTRAINT testtable_c2_key UNIQUE (c2)"}
0
testtable
{"ALTER TABLE public.testtable OWNER TO postgres","CREATE SEQUENCE public.testtable_cartodb_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1","ALTER TABLE public.testtable_cartodb_id_seq OWNER TO postgres","ALTER SEQUENCE public.testtable_cartodb_id_seq OWNED BY public.testtable.cartodb_id","ALTER TABLE ONLY public.testtable ALTER COLUMN cartodb_id SET DEFAULT nextval('public.testtable_cartodb_id_seq'::regclass)","ALTER TABLE ONLY public.testtable ADD CONSTRAINT testtable_pkey PRIMARY KEY (cartodb_id)","CREATE INDEX testtable_the_geom_idx ON public.testtable USING gist (the_geom)","CREATE INDEX testtable_the_geom_webmercator_idx ON public.testtable USING gist (the_geom_webmercator)","CREATE TRIGGER test_quota BEFORE INSERT OR UPDATE ON public.testtable FOR EACH STATEMENT EXECUTE FUNCTION cartodb.cdb_checkquota('0.1', '-1', 'public')","CREATE TRIGGER test_quota_per_row BEFORE INSERT OR UPDATE ON public.testtable FOR EACH ROW EXECUTE FUNCTION cartodb.cdb_checkquota('0.001', '-1', 'public')","CREATE TRIGGER track_updates AFTER INSERT OR DELETE OR UPDATE OR TRUNCATE ON public.testtable FOR EACH STATEMENT EXECUTE FUNCTION cartodb.cdb_tablemetadata_trigger()","CREATE TRIGGER update_the_geom_webmercator_trigger BEFORE INSERT OR UPDATE OF the_geom ON public.testtable FOR EACH ROW EXECUTE FUNCTION cartodb._cdb_update_the_geom_webmercator()"}
{"ALTER TABLE public.testtable OWNER TO postgres"}
cartodb_id|bigint||not null|nextval('testtable_cartodb_id_seq'::regclass)|plain||
the_geom|geometry(Geometry,4326)||||main||
the_geom_webmercator|geometry(Geometry,3857)||||main||
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||||plain||
c4|integer||||plain||
testtable|testtable_pkey|CREATE UNIQUE INDEX testtable_pkey ON public.testtable USING btree (cartodb_id)
testtable|testtable_the_geom_idx|CREATE INDEX testtable_the_geom_idx ON public.testtable USING gist (the_geom)
testtable|testtable_the_geom_webmercator_idx|CREATE INDEX testtable_the_geom_webmercator_idx ON public.testtable USING gist (the_geom_webmercator)
public|testtable|public|test_quota
public|testtable|public|test_quota_per_row
public|testtable|public|track_updates
public|testtable|public|update_the_geom_webmercator_trigger
{"ALTER TABLE public.testtable OWNER TO postgres","CREATE SEQUENCE public.testtable_cartodb_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1","ALTER TABLE public.testtable_cartodb_id_seq OWNER TO postgres","ALTER SEQUENCE public.testtable_cartodb_id_seq OWNED BY public.testtable.cartodb_id","ALTER TABLE ONLY public.testtable ALTER COLUMN cartodb_id SET DEFAULT nextval('public.testtable_cartodb_id_seq'::regclass)","ALTER TABLE ONLY public.testtable ADD CONSTRAINT testtable_pkey PRIMARY KEY (cartodb_id)","CREATE INDEX testtable_the_geom_idx ON public.testtable USING gist (the_geom)","CREATE INDEX testtable_the_geom_webmercator_idx ON public.testtable USING gist (the_geom_webmercator)","CREATE TRIGGER test_quota BEFORE INSERT OR UPDATE ON public.testtable FOR EACH STATEMENT EXECUTE FUNCTION cartodb.cdb_checkquota('0.1', '-1', 'public')","CREATE TRIGGER test_quota_per_row BEFORE INSERT OR UPDATE ON public.testtable FOR EACH ROW EXECUTE FUNCTION cartodb.cdb_checkquota('0.001', '-1', 'public')","CREATE TRIGGER track_updates AFTER INSERT OR DELETE OR UPDATE OR TRUNCATE ON public.testtable FOR EACH STATEMENT EXECUTE FUNCTION cartodb.cdb_tablemetadata_trigger()","CREATE TRIGGER update_the_geom_webmercator_trigger BEFORE INSERT OR UPDATE OF the_geom ON public.testtable FOR EACH ROW EXECUTE FUNCTION cartodb._cdb_update_the_geom_webmercator()"}
{"ALTER TABLE public.testtable OWNER TO postgres"}
cartodb_id|bigint||not null|nextval('testtable_cartodb_id_seq'::regclass)|plain||
the_geom|geometry(Geometry,4326)||||main||
the_geom_webmercator|geometry(Geometry,3857)||||main||
stable|integer||||plain||
c1|integer||||plain||
c2|integer||||plain||
c3|integer||||plain||
c4|integer||||plain||
testtable|testtable_pkey|CREATE UNIQUE INDEX testtable_pkey ON public.testtable USING btree (cartodb_id)
testtable|testtable_the_geom_idx|CREATE INDEX testtable_the_geom_idx ON public.testtable USING gist (the_geom)
testtable|testtable_the_geom_webmercator_idx|CREATE INDEX testtable_the_geom_webmercator_idx ON public.testtable USING gist (the_geom_webmercator)
public|testtable|public|test_quota
public|testtable|public|test_quota_per_row
public|testtable|public|track_updates
public|testtable|public|update_the_geom_webmercator_trigger
## Test view / matview dependencies: It will not work but data will be the same
CREATE VIEW
1|||1|2|3|4|5
2|||2|3|4|5|6
3|||3|4|5|6|7
cartodb_id|bigint||not null|nextval('testtable_cartodb_id_seq'::regclass)
the_geom|geometry(Geometry,4326)|||
the_geom_webmercator|geometry(Geometry,3857)|||
stable|integer|||
c1|integer|||
c2|integer|||
c3|integer|||
c4|integer|||
ERROR: cannot drop table testtable because other objects depend on it
DROP VIEW
SELECT 3
1|||1|2|3|4|5
2|||2|3|4|5|6
3|||3|4|5|6|7
ERROR: cannot drop table testtable because other objects depend on it
DROP MATERIALIZED VIEW
cartodb_id|bigint||not null|nextval('testtable_cartodb_id_seq'::regclass)
the_geom|geometry(Geometry,4326)|||
the_geom_webmercator|geometry(Geometry,3857)|||
stable|integer|||
c1|integer|||
c2|integer|||
c3|integer|||
c4|integer|||
## Test role access
CREATE ROLE
GRANT
GRANT
You are now connected to database "contrib_regression" as user "cdb_regenerate_tester".
3|||3|4|5|6|7
2|||2|3|4|5|6
1|||1|2|3|4|5
You are now connected to database "contrib_regression" as user "postgres".
You are now connected to database "contrib_regression" as user "cdb_regenerate_tester".
3|||3|4|5|6|7
2|||2|3|4|5|6
1|||1|2|3|4|5
You are now connected to database "contrib_regression" as user "postgres".
## Test calling with read only access (should fail)
You are now connected to database "contrib_regression" as user "cdb_regenerate_tester".
ERROR: must be owner of table testtable
You are now connected to database "contrib_regression" as user "postgres".
## Test partitioned table
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
city_id|integer||not null|
logdate|date||not null|
peaktemp|integer|||
unitsales|integer|||
measurement_y2006m02|FOR VALUES FROM ('02-01-2006') TO ('03-01-2006')|p
measurement_y2006m03|FOR VALUES FROM ('03-01-2006') TO ('04-01-2006')|r
city_id|integer||not null|
logdate|date||not null|
peaktemp|integer|||
unitsales|integer|||
city_id|integer||not null|
logdate|date||not null|
peaktemp|integer|||
unitsales|integer|||
ERROR: CDB_RegenerateTable does not support the parent of partitioned tables
measurement_y2006m02|FOR VALUES FROM ('02-01-2006') TO ('03-01-2006')|p
measurement_y2006m03|FOR VALUES FROM ('03-01-2006') TO ('04-01-2006')|r
city_id|integer||not null|
logdate|date||not null|
peaktemp|integer|||
unitsales|integer|||
city_id|integer||not null|
logdate|date||not null|
peaktemp|integer|||
unitsales|integer|||
ERROR: CDB_GetTableQueries does not support the parent of partitioned tables
## teardown
DROP TABLE
DROP TABLE
REVOKE
DROP ROLE
DROP FUNCTION