#!/usr/bin/perl # pg_restore must be in the path # # we use pg_restore to get the toc (requires the backup be made with pg_dump -Fc) from a backup # create a newtoc with all the things that look like tsearch2 stuff stripped out # so you can pg_restore -Fc -L newtoc ... # syntax: xtract dumpfile.bak > newtoc use strict; my %list = ('gtsq' => 1, 'gtsq_in' => 1, 'gtsq_out' => 1, 'gtsvector' => 1, 'gtsvector_in' => 1, 'gtsvector_out' => 1, 'tsquery' => 1, 'tsquery_in' => 1, 'tsquery_out' => 1, 'tsvector' => 1, 'tsvector_in' => 1, 'tsvector_out' => 1, 'statinfo' => 1, 'tokenout' => 1, 'tokentype' => 1, 'tsdebug' => 1, '_get_parser_from_curcfg' => 1, 'concat' => 1, 'dex_init' => 1, 'dex_lexize' => 1, 'exectsq' => 1, 'get_covers' => 1, 'gin_extract_tsquery' => 1, 'gin_extract_tsvector' => 1, 'gin_ts_consistent' => 1, 'gtsq_compress' => 1, 'gtsq_consistent' => 1, 'gtsq_decompress' => 1, 'gtsq_penalty' => 1, 'gtsq_picksplit' => 1, 'gtsq_same' => 1, 'gtsq_union' => 1, 'gtsvector_compress' => 1, 'gtsvector_consistent' => 1, 'gtsvector_decompress' => 1, 'gtsvector_penalty' => 1, 'gtsvector_picksplit' => 1, 'gtsvector_same' => 1, 'gtsvector_union' => 1, 'headline' => 1, 'length' => 1, 'lexize' => 1, 'numnode' => 1, 'parse' => 1, 'plainto_tsquery' => 1, 'prsd_end' => 1, 'prsd_getlexeme' => 1, 'prsd_headline' => 1, 'prsd_lextype' => 1, 'prsd_start' => 1, 'querytree' => 1, 'rank' => 1, 'rank_cd' => 1, 'reset_tsearch' => 1, 'rewrite' => 1, 'rewrite_accum' => 1, 'rewrite_finish' => 1, 'rexectsq' => 1, 'set_curcfg' => 1, 'set_curdict' => 1, 'set_curprs' => 1, 'setweight' => 1, 'show_curcfg' => 1, 'snb_en_init' => 1, 'snb_lexize' => 1, 'snb_ru_init_koi8' => 1, 'snb_ru_init_utf8' => 1, 'spell_init' => 1, 'spell_lexize' => 1, 'stat' => 1, 'strip' => 1, 'syn_init' => 1, 'syn_lexize' => 1, 'thesaurus_init' => 1, 'thesaurus_lexize' => 1, 'to_tsquery' => 1, 'to_tsvector' => 1, 'token_type' => 1, 'ts_debug' => 1, 'tsearch2' => 1, 'tsq_mcontained' => 1, 'tsq_mcontains' => 1, 'tsquery_and' => 1, 'tsquery_cmp' => 1, 'tsquery_eq' => 1, 'tsquery_ge' => 1, 'tsquery_gt' => 1, 'tsquery_le' => 1, 'tsquery_lt' => 1, 'tsquery_ne' => 1, 'tsquery_not' => 1, 'tsquery_or' => 1, 'tsvector_cmp' => 1, 'tsvector_eq' => 1, 'tsvector_ge' => 1, 'tsvector_gt' => 1, 'tsvector_le' => 1, 'tsvector_lt' => 1, 'tsvector_ne' => 1, 'rewrite' => 1, 'gin_tsvector_ops' => 1, 'gist_tp_tsquery_ops' => 1, 'gist_tsvector_ops' => 1, 'tsquery_ops' => 1, 'tsvector_ops' => 1, 'pg_ts_cfg' => 1, 'pg_ts_cfg_pkey' => 1, 'pg_ts_cfgmap' => 1, 'pg_ts_cfgmap_pkey' => 1, 'pg_ts_dict' => 1, 'pg_ts_dict_pkey' => 1, 'pg_ts_parser' => 1, 'pg_ts_parser_pkey' => 1 ); my @list = qx/pg_restore -Fc --list $ARGV[0]/; #open(F,'>tmp') or die; #print F @list; #close(F); foreach (@list) { if (/(FUNCTION|AGGREGATE)\s+(public\s+)?(.*)\(/) { #print "$1 | $2 | $3"; if (!exists($list{$3})) { print; } } elsif (/(TYPE|ACL|CONSTRAINT|TABLE|TABLE DATA|OPERATOR CLASS)\s+(public)?\s+(.*?)\s/) { #print "$1 | $2 | $3"; if (!exists($list{$3})) { print; } } elsif (/(OPERATOR)\s+(public)?\s+(.*?)\s/) { #print "$1 | $2 | $3"; open(F, '>item.tmp') or die; print F $_; close(F); my $buff = qx/pg_restore -Fc -L item.tmp $ARGV[0]/; unlink('item.tmp'); #open(F, '>item.txt') or die; #print F $buff; #close(F); if ($buff =~ /PROCEDURE = (\w+)/) { if (!exists($list{$1})) { print; } } else { print STDERR "cannot find PROCEDURE\n"; } } else { print; } }