/[rserv]/bin/InitRservTest
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /bin/InitRservTest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Aug 5 09:20:08 2003 UTC (20 years, 9 months ago) by dpavlin
Branch: MAIN
CVS Tags: before_onlytables, before_multmaster, r_0_3, debian, HEAD
Changes since 1.1: +3 -3 lines
change paths to support Debian

1 dpavlin 1.1 #!/bin/sh
2     # InitRservTest
3     # erServer demonstration implementation
4     # (c) 2000 Vadim Mikheev, PostgreSQL Inc.
5    
6 dpavlin 1.2 [ -n "$RSERV_PERL" ] || RSERV_PERL=/usr/share/postgresql/contrib
7     [ -n "$RSERV_SQL" ] || RSERV_SQL=/usr/share/postgresql/contrib
8     [ -n "$RSERV_BIN" ] || RSERV_BIN=/usr/lib/postgresql/bin
9 dpavlin 1.1 export RSERV_PERL
10     export RSERV_SQL
11     export RSERV_BIN
12    
13     pargs=
14    
15     while [[ $1 == -* ]]; do
16     case "$1" in
17     --user)
18     shift
19     pargs="$pargs -U $1"
20     ;;
21     --host)
22     shift
23     pargs="$pargs -h $1"
24     ;;
25     *)
26     echo "Usage: $0 --user name --host name masterdb slavedb"
27     exit 1
28     ;;
29     esac
30     shift
31     done
32    
33     masterdb=$1
34     slavedb=$2
35    
36     [ "${masterdb}" != "" ] || masterdb=master
37     [ "${slavedb}" != "" ] || slavedb=slave
38    
39     echo "Master -> $masterdb"
40     echo "Slave -> $slavedb"
41    
42     ############################################################################
43    
44     fill()
45     {
46     table="create table test (i text, k int, l int);
47     copy test from stdin;
48     Line: 1 1 1
49     Line: 2 2 2
50     Line: 3 3 3
51     Line: 4 4 4
52     Line: 5 5 5
53     Line: 6 6 6
54     Line: 7 7 7
55     Line: 8 8 8
56     Line: 9 9 9
57     Line: 10 10 10
58     Line: 11 11 11
59     Line: 12 12 12
60     Line: 13 13 13
61     Line: 14 14 14
62     Line: 15 15 15
63     Line: 16 16 16
64     Line: 17 17 17
65     Line: 18 18 18
66     Line: 19 19 19
67     Line: 20 20 20
68     Line: 21 21 21
69     Line: 22 22 22
70     Line: 23 23 23
71     Line: 24 24 24
72     Line: 25 25 25
73     Line: 26 26 26
74     Line: 27 27 27
75     Line: 28 28 28
76     Line: 29 29 29
77     Line: 30 30 30
78     Line: 31 31 31
79     Line: 32 32 32
80     Line: 33 33 33
81     Line: 34 34 34
82     Line: 35 35 35
83     Line: 36 36 36
84     Line: 37 37 37
85     Line: 38 38 38
86     Line: 39 39 39
87     Line: 40 40 40
88     Line: 41 41 41
89     Line: 42 42 42
90     Line: 43 43 43
91     Line: 44 44 44
92     Line: 45 45 45
93     Line: 46 46 46
94     Line: 47 47 47
95     Line: 48 48 48
96     Line: 49 49 49
97     Line: 50 50 50
98     Line: 51 51 51
99     Line: 52 52 52
100     Line: 53 53 53
101     Line: 54 54 54
102     Line: 55 55 55
103     Line: 56 56 56
104     Line: 57 57 57
105     Line: 58 58 58
106     Line: 59 59 59
107     Line: 60 60 60
108     Line: 61 61 61
109     Line: 62 62 62
110     Line: 63 63 63
111     Line: 64 64 64
112     Line: 65 65 65
113     Line: 66 66 66
114     Line: 67 67 67
115     Line: 68 68 68
116     Line: 69 69 69
117     Line: 70 70 70
118     Line: 71 71 71
119     Line: 72 72 72
120     Line: 73 73 73
121     Line: 74 74 74
122     Line: 75 75 75
123     Line: 76 76 76
124     Line: 77 77 77
125     Line: 78 78 78
126     Line: 79 79 79
127     Line: 80 80 80
128     Line: 81 81 81
129     Line: 82 82 82
130     Line: 83 83 83
131     Line: 84 84 84
132     Line: 85 85 85
133     Line: 86 86 86
134     Line: 87 87 87
135     Line: 88 88 88
136     Line: 89 89 89
137     Line: 90 90 90
138     Line: 91 91 91
139     Line: 92 92 92
140     Line: 93 93 93
141     Line: 94 94 94
142     Line: 95 95 95
143     Line: 96 96 96
144     Line: 97 97 97
145     Line: 98 98 98
146     Line: 99 99 99
147     Line: 100 100 100
148     \\.";
149     echo "$table" | psql $pargs $1 || exit
150     if [ "$1" = "$masterdb" ]
151     then
152     rm -rf __tmpf__
153     psql $pargs -c "select * into table testoid from test" $1 || exit
154     psql $pargs -c "copy testoid with oids to '`pwd`/__tmpf__'" $1 || exit
155     psql $pargs -c "select * into table teststr from test" $1 || exit
156     else
157     psql $pargs -c "select * into table testoid from test where k < 0" $1 || exit
158     psql $pargs -c "copy testoid with oids from '`pwd`/__tmpf__'" $1 || exit
159     psql $pargs -c "select * into table teststr from test" $1 || exit
160     rm -rf __tmpf__
161     fi
162     psql $pargs -c "create unique index i_test on test (k)" $1 || exit
163     psql $pargs -c "create unique index i_testoid on testoid (oid)" $1 || exit
164     psql $pargs -c "create unique index i_teststr on teststr (i)" $1 || exit
165     psql $pargs -c vacuum $1 || exit
166     }
167    
168     ############################################################################
169    
170     echo
171     echo
172     echo ' ATTENTION'
173     echo
174     echo This script will destroy databases with names MASTER and SLAVE
175     echo
176     echo -n "Are you going to continue ? [Y/N] "
177    
178     read answ
179    
180     case $answ in
181     Y*|y*)
182     ;;
183     *)
184     exit
185     ;;
186     esac
187    
188     echo
189     echo
190    
191     sql="drop database $masterdb"
192     echo $sql
193     psql $pargs -c "$sql" template1
194     sql="create database $masterdb"
195     echo $sql
196     psql $pargs -c "$sql" template1 || exit
197    
198     echo Setup master system
199     psql $pargs $masterdb < $RSERV_SQL/master.sql || exit
200    
201     echo Wait for template1 to become available...
202     sleep 1
203    
204     sql="drop database $slavedb"
205     echo $sql
206     psql $pargs -c "$sql" template1
207     sql="create database $slavedb"
208     echo $sql
209     psql $pargs -c "$sql" template1 || exit
210    
211     echo Setup slave system
212     psql $pargs $slavedb < $RSERV_SQL/slave.sql || exit
213    
214     echo Create and fill test, testoid and teststr tables in master db
215     fill $masterdb
216     echo
217     echo Register test, testoid and teststr tables for replication on master
218     echo
219     $RSERV_BIN/MasterAddTable $masterdb test k
220     $RSERV_BIN/MasterAddTable $masterdb testoid oid
221     $RSERV_BIN/MasterAddTable $masterdb teststr i
222    
223     echo Create and fill test, testoid and teststr tables in slave db
224     fill $slavedb
225     echo
226     echo Register test, testoid and teststr tables for replication on slave
227     echo
228     $RSERV_BIN/SlaveAddTable $slavedb test k
229     $RSERV_BIN/SlaveAddTable $slavedb testoid oid
230     $RSERV_BIN/SlaveAddTable $slavedb teststr i
231    
232     echo
233     echo
234     echo
235     echo
236     echo
237     echo
238     echo
239     echo
240     echo " Now make changes in $masterdb db and run"
241     echo
242     echo " Replicate $masterdb $slavedb"
243     echo
244     echo " to replicate the master on the slave."
245     echo
246     echo " You may also use the RservTest tcl utility"
247     echo " to demonstrate this functionality."
248     echo
249     echo
250     echo
251     echo
252     echo
253     echo
254     echo
255     echo
256    
257     exit
258    
259     ############################################################################

  ViewVC Help
Powered by ViewVC 1.1.26