1\set ON_ERROR_STOP true
2
3SELECT set_config('search_path','partman, public',false);
4
5SELECT plan(11);
6
7SELECT is_empty('SELECT * FROM partman_test.id_taptest_table_source LIMIT 1', 'Check that source table is empty');
8SELECT results_eq('SELECT count(*)::int FROM partman_test.id_taptest_table', ARRAY[1000000], 'Check count from parent table');
9SELECT results_eq('SELECT count(*)::int FROM partman_test.id_taptest_table_p0', ARRAY[99999], 'Check count from id_taptest_table_p0');
10
11SELECT has_table('partman_test', 'id_taptest_table_p500000', 'Check id_taptest_table_p500000 exists');
12SELECT has_table('partman_test', 'id_taptest_table_p600000', 'Check id_taptest_table_p600000 exists');
13SELECT has_table('partman_test', 'id_taptest_table_p700000', 'Check id_taptest_table_p700000 exists');
14SELECT has_table('partman_test', 'id_taptest_table_p800000', 'Check id_taptest_table_p800000 exists');
15SELECT has_table('partman_test', 'id_taptest_table_p900000', 'Check id_taptest_table_p900000 exists');
16SELECT has_table('partman_test', 'id_taptest_table_p1000000', 'Check id_taptest_table_p1000000 exists');
17SELECT hasnt_table('partman_test', 'id_taptest_table_p1100000', 'Check id_taptest_table_p1100000 doesn''t exists yet');
18
19-- Check for duped indexes since it was created on both the parent and the template
20SELECT is_empty($$SELECT key
21    FROM (SELECT indexrelid::regclass AS idx
22            , (indrelid::text ||E'\n'|| indclass::text ||E'\n'|| indkey::text ||E'\n'|| coalesce(indexprs::text,'')||E'\n' || coalesce(indpred::text,'')) AS KEY FROM pg_index
23                WHERE indrelid = 'partman_test.id_taptest_table_p500000'::regclass) sub
24            GROUP BY key
25            HAVING count(*)>1$$
26    , 'Check that table id_taptest_table_p500000 does not have duped index');
27
28
29SELECT diag('!!! In separate psql terminal, please run the following (adjusting schema if needed): "CALL partman.run_maintenance_proc();".');
30SELECT diag('!!! After that, run part3 of this script to check result !!!');
31
32
33SELECT * FROM finish();
34