|
15 | 15 | * |
16 | 16 | * |
17 | 17 | * IDENTIFICATION |
18 | | - *$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.66 2003/01/27 00:23:38 tgl Exp $ |
| 18 | + *$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.67 2003/02/01 22:06:59 tgl Exp $ |
19 | 19 | * |
20 | 20 | *------------------------------------------------------------------------- |
21 | 21 | */ |
@@ -122,102 +122,6 @@ CloseArchive(Archive *AHX) |
122 | 122 | die_horribly(AH,modulename,"could not close the output file in CloseArchive\n"); |
123 | 123 | } |
124 | 124 |
|
125 | | -/* |
126 | | - *This function repairs a slip when upgrading PG cast |
127 | | - *mechanism from 7.2 or earlier to 7.3 or later. |
128 | | - *The casts between lo and oid are needed when retrieving |
129 | | - *lo type data in FixupBlobRefs and so adjust lo type in |
130 | | - *contrib before processing FixupBlobRefs. |
131 | | - */ |
132 | | -staticvoid |
133 | | -Adjust_lo_type(ArchiveHandle*AH) |
134 | | -{ |
135 | | -PGresult*res; |
136 | | -intnTuples; |
137 | | - |
138 | | -/* |
139 | | - *First check the existence of the cast oid as lo. |
140 | | - */ |
141 | | -res=PQexec(AH->blobConnection,"select 1 from pg_cast where" |
142 | | -" castsource in (select oid from pg_type where typname = 'oid')" |
143 | | -" and casttarget in (select oid from pg_type where typname = 'lo')"); |
144 | | - |
145 | | -if (!res||PQresultStatus(res)!=PGRES_TUPLES_OK) |
146 | | -die_horribly(AH,modulename,"error while checking the cast oid as lo\n"); |
147 | | -nTuples=PQntuples(res); |
148 | | -PQclear(res); |
149 | | -if (nTuples==0) |
150 | | -{ |
151 | | -/* |
152 | | - *Check the existence of the cast function lo(oid) |
153 | | - *and change it to be IMMUTABLE. |
154 | | - */ |
155 | | -res=PQexec(AH->blobConnection,"update pg_proc set provolatile = 'i'" |
156 | | -" where proname = 'lo'" |
157 | | -" and pronargs = 1" |
158 | | -" and prorettype in (select oid from pg_type where typname = 'lo')" |
159 | | -" and proargtypes[0] in (select oid from pg_type where typname = 'oid')"); |
160 | | - |
161 | | -if (!res||PQresultStatus(res)!=PGRES_COMMAND_OK) |
162 | | -die_horribly(AH,modulename,"could not adjust lo(oid) function\n"); |
163 | | -nTuples=atoi(PQcmdTuples(res)); |
164 | | -PQclear(res); |
165 | | -if (nTuples==1) |
166 | | -{ |
167 | | -/* |
168 | | - *The cast function lo(oid) exists and |
169 | | - *then create the correspoding cast. |
170 | | - */ |
171 | | -res=PQexec(AH->blobConnection,"create cast" |
172 | | -" (oid as lo) with function lo(oid) as implicit"); |
173 | | -if (!res||PQresultStatus(res)!=PGRES_COMMAND_OK) |
174 | | -die_horribly(AH,modulename,"couldn't create cast (oid as lo)\n"); |
175 | | -PQclear(res); |
176 | | -} |
177 | | -} |
178 | | - |
179 | | -/* |
180 | | - *Also check the existence of the cast lo as oid. |
181 | | - */ |
182 | | -res=PQexec(AH->blobConnection,"select 1 from pg_cast where" |
183 | | -" castsource in (select oid from pg_type where typname = 'lo')" |
184 | | -" and casttarget in (select oid from pg_type where typname = 'oid')"); |
185 | | - |
186 | | -if (!res||PQresultStatus(res)!=PGRES_TUPLES_OK) |
187 | | -die_horribly(AH,modulename,"error while checking the cast lo as oid\n"); |
188 | | -nTuples=PQntuples(res); |
189 | | -PQclear(res); |
190 | | -if (nTuples==0) |
191 | | -{ |
192 | | -/* |
193 | | - *Check the existence of the cast function oid(lo) |
194 | | - *and change it to be IMMUTABLE. |
195 | | - */ |
196 | | -res=PQexec(AH->blobConnection,"update pg_proc set provolatile = 'i'" |
197 | | -" where proname = 'oid'" |
198 | | -" and pronargs = 1" |
199 | | -" and prorettype in (select oid from pg_type where typname = 'oid')" |
200 | | -" and proargtypes[0] in (select oid from pg_type where typname = 'lo')"); |
201 | | - |
202 | | -if (!res||PQresultStatus(res)!=PGRES_COMMAND_OK) |
203 | | -die_horribly(AH,modulename,"could not adjust oid(lo) function\n"); |
204 | | -nTuples=atoi(PQcmdTuples(res)); |
205 | | -PQclear(res); |
206 | | -if (nTuples==1) |
207 | | -{ |
208 | | -/* |
209 | | - *The cast function oid(lo) exists and |
210 | | - *then create the correspoding cast. |
211 | | - */ |
212 | | -res=PQexec(AH->blobConnection,"create cast" |
213 | | -" (lo as oid) with function oid(lo) as implicit"); |
214 | | -if (!res||PQresultStatus(res)!=PGRES_COMMAND_OK) |
215 | | -die_horribly(AH,modulename,"couldn't create cast (lo as oid)\n"); |
216 | | -PQclear(res); |
217 | | -} |
218 | | -} |
219 | | -} |
220 | | - |
221 | 125 | /* Public */ |
222 | 126 | void |
223 | 127 | RestoreArchive(Archive*AHX,RestoreOptions*ropt) |
@@ -453,7 +357,6 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) |
453 | 357 | /* NULL parameter means disable ALL user triggers */ |
454 | 358 | _disableTriggersIfNecessary(AH,NULL,ropt); |
455 | 359 |
|
456 | | -Adjust_lo_type(AH); |
457 | 360 | te=AH->toc->next; |
458 | 361 | while (te!=AH->toc) |
459 | 362 | { |
|