1#!/bin/sh
2
3## currently, this script makes a lot of assumptions:
4## in postgresql.conf.sample:
5##   1) the valid config settings may be preceded by a '#', but NOT '# '
6##      (we use this to skip comments)
7##   2) the valid config settings will be followed immediately by  ' ='
8##      (at least one space preceding the '=')
9## in guc.c:
10##   3) the options have PGC_ on the same line as the option
11##   4) the options have '{' on the same line as the option
12
13##  Problems
14## 1) Don't know what to do with TRANSACTION ISOLATION LEVEL
15
16## if an option is valid but shows up in only one file (guc.c but not
17## postgresql.conf.sample), it should be listed here so that it
18## can be ignored
19INTENTIONALLY_NOT_INCLUDED="debug_deadlocks \
20is_superuser lc_collate lc_ctype lc_messages lc_monetary lc_numeric lc_time \
21pre_auth_delay role seed server_encoding server_version server_version_int \
22session_authorization trace_lock_oidmin trace_lock_table trace_locks trace_lwlocks \
23trace_notify trace_userlocks transaction_isolation transaction_read_only \
24zero_damaged_pages"
25
26### What options are listed in postgresql.conf.sample, but don't appear
27### in guc.c?
28
29# grab everything that looks like a setting and convert it to lower case
30SETTINGS=`grep ' =' postgresql.conf.sample |
31grep -v '^# ' | # strip comments
32sed -e 's/^#//' |
33awk '{print $1}'`
34
35SETTINGS=`echo "$SETTINGS" | tr 'A-Z' 'a-z'`
36
37for i in $SETTINGS ; do
38  hidden=0
39  ## it sure would be nice to replace this with an sql "not in" statement
40  ## it doesn't seem to make sense to have things in .sample and not in guc.c
41#  for hidethis in $INTENTIONALLY_NOT_INCLUDED ; do
42#    if [ "$hidethis" = "$i" ] ; then
43#      hidden=1
44#    fi
45#  done
46  if [ "$hidden" -eq 0 ] ; then
47    grep -i '"'$i'"' guc.c > /dev/null
48    if [ $? -ne 0 ] ; then
49      echo "$i seems to be missing from guc.c";
50    fi;
51  fi
52done
53
54### What options are listed in guc.c, but don't appear
55### in postgresql.conf.sample?
56
57# grab everything that looks like a setting and convert it to lower case
58
59SETTINGS=`grep '{.* PGC_' guc.c | awk '{print $1}' | \
60          sed -e 's/{//g' -e 's/"//g' -e 's/,//'`
61
62SETTINGS=`echo "$SETTINGS" | tr 'A-Z' 'a-z'`
63
64for i in $SETTINGS ; do
65  hidden=0
66  ## it sure would be nice to replace this with an sql "not in" statement
67  for hidethis in $INTENTIONALLY_NOT_INCLUDED ; do
68    if [ "$hidethis" = "$i" ] ; then
69      hidden=1
70    fi
71  done
72  if [ "$hidden" -eq 0 ] ; then
73    grep -i '#'$i' ' postgresql.conf.sample > /dev/null
74    if [ $? -ne 0 ] ; then
75      echo "$i seems to be missing from postgresql.conf.sample";
76    fi
77  fi
78done
79