timescaledb/tsl/test/sql/deparse.sql
niksa 4368fcff3c Add function to reconstruct the creating command for a table
Deparse a table into a set of SQL commands that can be used to
reconstruct it. Together with column definiton it deparses
constraints, indexes, triggers and rules as well. There are some table
types that are not supported: temporary, partitioned, foreign,
inherited and a table that uses options.  Row security is also not
supported.
2020-05-27 17:31:09 +02:00

31 lines
804 B
SQL

-- This file and its contents are licensed under the Timescale License.
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
-- We compare information(\d+) about manually created tables with the ones that were recreated using deparse_table command.
-- There should be no diff.
\set ECHO errors
\ir include/deparse_func.sql
SELECT format('%s/results/deparse_create.out', :'TEST_OUTPUT_DIR') AS "CREATE_OUT",
format('%s/results/deparse_recreate.out', :'TEST_OUTPUT_DIR') AS "RECREATE_OUT"
\gset
SELECT format('\! diff %s %s', :'CREATE_OUT', :'RECREATE_OUT') as "DIFF_CMD"
\gset
\ir include/deparse_create.sql
\o :CREATE_OUT
\d+ "public".*
\ir include/deparse_recreate.sql
\o :RECREATE_OUT
\d+ "public".*
\o
:DIFF_CMD
SELECT 'DONE'