Refrain from creating tables in “data only” operations.

We forgot that rule in the case of creating the target tables for the
materializing views commands, which led to surprising and wrong behavior.

Fix #721, and add a new test case while at it.
This commit is contained in:
Dimitri Fontaine 2018-01-25 23:32:31 +01:00
parent 5ba42edb0c
commit 7b08b6e3d3
4 changed files with 170 additions and 1 deletions

View File

@ -102,7 +102,7 @@
(set-table-oids catalog)))
;; We might have to MATERIALIZE VIEWS
(when materialize-views
(when (and create-tables materialize-views)
(with-stats-collection ("Create MatViews Tables" :section :pre
:use-result-as-read t
:use-result-as-rows t)

21
test/mysql/f1db-data.load Normal file
View File

@ -0,0 +1,21 @@
load database
from mysql://root@localhost/f1db
into pgsql:///plop
-- with data only, truncate
WITH disable triggers, data only, no truncate,
include no drop, create no tables, create indexes,
reset sequences, no foreign keys,
downcase identifiers, uniquify index names
excluding table names matching ~/./
materialize views circuit as
$$
select circuitid, circuitref, name, location, country,
concat('(', lng, ',', lat, ')') as position,
alt, url
from circuits;
$$;

59
test/mysql/f1db.circuits.my.sql vendored Normal file

File diff suppressed because one or more lines are too long

89
test/mysql/f1db.circuits.pg.sql vendored Normal file
View File

@ -0,0 +1,89 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.1
-- Dumped by pg_dump version 10.1
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = f1db, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE SCHEMA f1db;
--
-- Name: circuits; Type: TABLE; Schema: f1db; Owner: dim
--
CREATE TABLE circuits (
circuitid bigint NOT NULL,
circuitref character varying(255) DEFAULT ''::character varying NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL,
location character varying(255) DEFAULT NULL::character varying,
country character varying(255) DEFAULT NULL::character varying,
position point,
alt bigint,
url character varying(255) DEFAULT ''::character varying NOT NULL
);
ALTER TABLE circuits OWNER TO dim;
--
-- Name: circuits_circuitid_seq; Type: SEQUENCE; Schema: f1db; Owner: dim
--
CREATE SEQUENCE circuits_circuitid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE circuits_circuitid_seq OWNER TO dim;
--
-- Name: circuits_circuitid_seq; Type: SEQUENCE OWNED BY; Schema: f1db; Owner: dim
--
ALTER SEQUENCE circuits_circuitid_seq OWNED BY circuits.circuitid;
--
-- Name: circuits circuitid; Type: DEFAULT; Schema: f1db; Owner: dim
--
ALTER TABLE ONLY circuits ALTER COLUMN circuitid SET DEFAULT nextval('circuits_circuitid_seq'::regclass);
--
-- Name: circuits idx_61484_primary; Type: CONSTRAINT; Schema: f1db; Owner: dim
--
ALTER TABLE ONLY circuits
ADD CONSTRAINT idx_61484_primary PRIMARY KEY (circuitid);
--
-- Name: idx_61484_url; Type: INDEX; Schema: f1db; Owner: dim
--
CREATE UNIQUE INDEX idx_61484_url ON circuits USING btree (url);
--
-- PostgreSQL database dump complete
--