Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPorl-0000eq-0t for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Mar 2014 07:55:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WPork-0006IN-Cg for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Mar 2014 07:55:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPori-0006H9-Bc for pgsql-bugs@postgresql.org; Tue, 18 Mar 2014 07:55:14 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPorX-0005X8-R4 for pgsql-bugs@postgresql.org; Tue, 18 Mar 2014 07:55:11 +0000 MIME-Version: 1.0 Subject: BUG #9616: Materialized view with indexes unable to load from pg_dump To: pgsql-bugs@postgresql.org From: jesse.denardo@myfarms.com Date: Tue, 18 Mar 2014 07:54:27 +0000 Message-ID: <20140318075427.20722.65161@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 9616 Logged by: Jesse Denardo Email address: jesse.denardo@myfarms.com PostgreSQL version: 9.3.3 Operating system: Arch Linux Description: Linux: Linux hostname 3.13.5-1-ARCH #1 SMP PREEMPT Sun Feb 23 00:25:24 CET 2014 x86_64 GNU/Linux PostgreSQL: PostgreSQL 9.3.3 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.2 20140206 (prerelease), 64-bit I have created several materialized views on one database. To copy data to a new database, I dump the schema(s) of choice using pg_dump and pipe the result to psql. The exact command looks like: $ pg_dump -b -n -O -x -h localhost -U | psql -h -d -U The materialized views get copied and restored just fine with one exception: The one mat view that has indexes. Here is the result of \d on this mat view: # \d example_mat_view; Materialized view "example_mat_view" Column | Type | Modifiers --------------+-------------------+----------- f_id | integer | f_name | character varying | collate C s_z | integer[] | c_id | integer | Indexes: "example_mat_view_c_id" btree (c_id) "example_mat_view_f_id" btree (f_id) Analyzing the output of pg_dump shows the following: -- -- Name: example_mat_view; Type: TABLE; Schema: ; Owner: -; Tablespace:~ -- CREATE TABLE example_mat_view ( f_id integer, f_name character varying COLLATE pg_catalog."C", s_z integer[], c_id integer ); -- -- Name: example_mat_view_c_id; Type: INDEX; Schema: ; Owner: -; Tablespace:~ -- CREATE INDEX example_mat_view_c_id ON example_mat_view USING btree (c_id); -- -- Name: example_mat_view_f_id; Type: INDEX; Schema: ; Owner: -; Tablespace:~ -- CREATE INDEX example_mat_view_f_id ON example_mat_view USING btree (f_id); -- -- Name: _RETURN; Type: RULE; Schema: ; Owner: - -- CREATE RULE "_RETURN" AS ON SELECT TO example_mat_view DO INSTEAD ; -- -- Name: example_mat_view; Type: MATERIALIZED VIEW DATA; Schema: ; Owner: - -- REFRESH MATERIALIZED VIEW example_mat_view; Attempting to restore this dump via psql gives the following errors: ERROR: could not convert table "example_mat_view" to a view because it has indexes ERROR: "example_mat_view" is not a materialized view My independent testing showed that pg_dump usually dumps materialized views using CREATE MATERIALIZED VIEW, not tables that are later converted into mat views. I confirmed that the mat view was created normally with CREATE MATERIALIZED VIEW example_mat_view AS ; -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs