When a relation is moved to another tablespace, we can't assume that we can
[PostgreSQL.git] / src / tools / find_static
blobda1c02893c0aabe4487ab9c5d8df41c415ffd833
1 #!/bin/sh
3 # $PostgreSQL$
5 trap "rm -f /tmp/$$" 0 1 2 3 15
7 # This script finds functions that are either never called, or
8 # should be static.
9 # Some functions, like library functions and debug_print functions,
10 # should remain unchanged.
12 # Run on a compiled source tree, from the top of the source tree
14 # My nm utility has 9 characters of address which I strip, then a 'type'
15 # character, with T as a text function, and U as an undefined function
16 # symbol, then the function name.
18 find . -name '[a-z]*.o' -type f -print | while read FILE
20 nm $FILE | cut -c10-100 |awk '{printf "%s\t%s\t%s\n", "'"$FILE"'",$1,$2}'
21 done >/tmp/$$
22 dropdb debug
23 createdb debug
24 echo "
25 create table debug (file text, scope char, func text);
27 copy debug from '/tmp/"$$"';
29 select *
30 into table debug2
31 from debug;
33 create index idebug on debug(scope,func);
34 create index idebug2 on debug2(func,scope);
35 vacuum debug;
36 vacuum debug2;
38 update debug2
39 set scope = '_'
40 from debug
41 where debug2.func = debug.func and
42 debug2.scope = 'T' and debug.scope = 'U';
44 delete from debug2
45 where scope = '_';
47 select *
48 from debug2
49 where scope = 'T' and func != 'main'
50 order by file, func;
51 " |psql debug