Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3908473

Browse files
committed
Make DROP TABLE rollback-able: postpone physical file delete until commit.
(WAL logging for this is not done yet, however.) Clean up a number of reallycrufty things that are no longer needed now that DROP behaves nicely. Maketemp table mapper do the right things when drop or rename affecting a temptable is rolled back. Also, remove "relation modified while in use" errorcheck, in favor of locking tables at first reference and holding that lockthroughout the statement.
1 parentebe0b23 commit3908473

File tree

46 files changed

+1308
-1190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1308
-1190
lines changed

‎src/backend/access/common/tupdesc.c

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.67 2000/10/05 19:48:20 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.68 2000/11/08 22:09:53 tgl Exp $
1212
*
1313
* NOTES
1414
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -228,7 +228,9 @@ FreeTupleDesc(TupleDesc tupdesc)
228228
bool
229229
equalTupleDescs(TupleDesctupdesc1,TupleDesctupdesc2)
230230
{
231-
inti;
231+
inti,
232+
j,
233+
n;
232234

233235
if (tupdesc1->natts!=tupdesc2->natts)
234236
return false;
@@ -240,7 +242,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
240242
/*
241243
* We do not need to check every single field here, and in fact
242244
* some fields such as attdispersion probably shouldn't be
243-
* compared.
245+
* compared. We can also disregard attnum (it was used to
246+
* place the row in the attrs array) and everything derived
247+
* from the column datatype.
244248
*/
245249
if (strcmp(NameStr(attr1->attname),NameStr(attr2->attname))!=0)
246250
return false;
@@ -260,32 +264,53 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
260264

261265
if (constr2==NULL)
262266
return false;
263-
if (constr1->num_defval!=constr2->num_defval)
267+
if (constr1->has_not_null!=constr2->has_not_null)
268+
return false;
269+
n=constr1->num_defval;
270+
if (n!= (int)constr2->num_defval)
264271
return false;
265-
for (i=0;i<(int)constr1->num_defval;i++)
272+
for (i=0;i<n;i++)
266273
{
267274
AttrDefault*defval1=constr1->defval+i;
268-
AttrDefault*defval2=constr2->defval+i;
275+
AttrDefault*defval2=constr2->defval;
269276

270-
if (defval1->adnum!=defval2->adnum)
277+
/*
278+
* We can't assume that the items are always read from the
279+
* system catalogs in the same order; so use the adnum field to
280+
* identify the matching item to compare.
281+
*/
282+
for (j=0;j<n;defval2++,j++)
283+
{
284+
if (defval1->adnum==defval2->adnum)
285+
break;
286+
}
287+
if (j >=n)
271288
return false;
272289
if (strcmp(defval1->adbin,defval2->adbin)!=0)
273290
return false;
274291
}
275-
if (constr1->num_check!=constr2->num_check)
292+
n=constr1->num_check;
293+
if (n!= (int)constr2->num_check)
276294
return false;
277-
for (i=0;i<(int)constr1->num_check;i++)
295+
for (i=0;i<n;i++)
278296
{
279297
ConstrCheck*check1=constr1->check+i;
280-
ConstrCheck*check2=constr2->check+i;
298+
ConstrCheck*check2=constr2->check;
281299

282-
if (strcmp(check1->ccname,check2->ccname)!=0)
283-
return false;
284-
if (strcmp(check1->ccbin,check2->ccbin)!=0)
300+
/*
301+
* Similarly, don't assume that the checks are always read
302+
* in the same order; match them up by name and contents.
303+
* (The name *should* be unique, but...)
304+
*/
305+
for (j=0;j<n;check2++,j++)
306+
{
307+
if (strcmp(check1->ccname,check2->ccname)==0&&
308+
strcmp(check1->ccbin,check2->ccbin)==0)
309+
break;
310+
}
311+
if (j >=n)
285312
return false;
286313
}
287-
if (constr1->has_not_null!=constr2->has_not_null)
288-
return false;
289314
}
290315
elseif (tupdesc2->constr!=NULL)
291316
return false;

‎src/backend/access/gist/gist.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.63 2000/10/21 15:43:09 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.64 2000/11/08 22:09:53 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -266,13 +266,12 @@ gistbuild(PG_FUNCTION_ARGS)
266266
{
267267
Oidhrelid=RelationGetRelid(heap);
268268
Oidirelid=RelationGetRelid(index);
269-
boolinplace=IsReindexProcessing();
270269

271270
heap_close(heap,NoLock);
272271
index_close(index);
273-
UpdateStats(hrelid,nhtups,inplace);
274-
UpdateStats(irelid,nitups,inplace);
275-
if (oldPred!=NULL&& !inplace)
272+
UpdateStats(hrelid,nhtups);
273+
UpdateStats(irelid,nitups);
274+
if (oldPred!=NULL)
276275
{
277276
if (nitups==nhtups)
278277
pred=NULL;

‎src/backend/access/hash/hash.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.43 2000/10/21 15:43:11 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.44 2000/11/08 22:09:54 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -217,13 +217,12 @@ hashbuild(PG_FUNCTION_ARGS)
217217
{
218218
Oidhrelid=RelationGetRelid(heap);
219219
Oidirelid=RelationGetRelid(index);
220-
boolinplace=IsReindexProcessing();
221220

222221
heap_close(heap,NoLock);
223222
index_close(index);
224-
UpdateStats(hrelid,nhtups,inplace);
225-
UpdateStats(irelid,nitups,inplace);
226-
if (oldPred!=NULL&& !inplace)
223+
UpdateStats(hrelid,nhtups);
224+
UpdateStats(irelid,nitups);
225+
if (oldPred!=NULL)
227226
{
228227
if (nitups==nhtups)
229228
pred=NULL;

‎src/backend/access/heap/heapam.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.92 2000/10/29 18:33:39 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.93 2000/11/08 22:09:54 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -780,19 +780,13 @@ heap_beginscan(Relation relation,
780780

781781
/* ----------------
782782
*increment relation ref count while scanning relation
783-
* ----------------
784-
*/
785-
RelationIncrementReferenceCount(relation);
786-
787-
/* ----------------
788-
*Acquire AccessShareLock for the duration of the scan
789783
*
790-
*Note: we could get an SI inval message here and consequently have
791-
*to rebuildtherelcache entry.The refcount increment above
792-
*ensures that we will rebuild it and not just flush it...
784+
*This is just to make really sure the relcache entry won't go away
785+
*whilethescan has a pointer to it. Caller should be holding the
786+
*rel open anyway, so this is redundant in all normal scenarios...
793787
* ----------------
794788
*/
795-
LockRelation(relation,AccessShareLock);
789+
RelationIncrementReferenceCount(relation);
796790

797791
/* XXX someday assert SelfTimeQual if relkind == RELKIND_UNCATALOGED */
798792
if (relation->rd_rel->relkind==RELKIND_UNCATALOGED)
@@ -809,13 +803,11 @@ heap_beginscan(Relation relation,
809803
scan->rs_snapshot=snapshot;
810804
scan->rs_nkeys= (short)nkeys;
811805

806+
/*
807+
* we do this here instead of in initscan() because heap_rescan
808+
* also calls initscan() and we don't want to allocate memory again
809+
*/
812810
if (nkeys)
813-
814-
/*
815-
* we do this here instead of in initscan() because heap_rescan
816-
* also calls initscan() and we don't want to allocate memory
817-
* again
818-
*/
819811
scan->rs_key= (ScanKey)palloc(sizeof(ScanKeyData)*nkeys);
820812
else
821813
scan->rs_key=NULL;
@@ -841,8 +833,6 @@ heap_rescan(HeapScanDesc scan,
841833
IncrHeapAccessStat(local_rescan);
842834
IncrHeapAccessStat(global_rescan);
843835

844-
/* Note: set relation level read lock is still set */
845-
846836
/* ----------------
847837
*unpin scan buffers
848838
* ----------------
@@ -853,7 +843,7 @@ heap_rescan(HeapScanDesc scan,
853843
*reinitialize scan descriptor
854844
* ----------------
855845
*/
856-
scan->rs_atend=(bool)scanFromEnd;
846+
scan->rs_atend=scanFromEnd;
857847
initscan(scan,scan->rs_rd,scanFromEnd,scan->rs_nkeys,key);
858848
}
859849

@@ -882,12 +872,6 @@ heap_endscan(HeapScanDesc scan)
882872
*/
883873
unpinscan(scan);
884874

885-
/* ----------------
886-
*Release AccessShareLock acquired by heap_beginscan()
887-
* ----------------
888-
*/
889-
UnlockRelation(scan->rs_rd,AccessShareLock);
890-
891875
/* ----------------
892876
*decrement relation reference count and free scan descriptor storage
893877
* ----------------

‎src/backend/access/nbtree/nbtree.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.69 2000/11/01 20:39:58 vadim Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.70 2000/11/08 22:09:55 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -340,19 +340,16 @@ btbuild(PG_FUNCTION_ARGS)
340340
{
341341
Oidhrelid=RelationGetRelid(heap);
342342
Oidirelid=RelationGetRelid(index);
343-
boolinplace=IsReindexProcessing();
344343

345344
heap_close(heap,NoLock);
346345
index_close(index);
347-
348-
UpdateStats(hrelid,nhtups,inplace);
349-
UpdateStats(irelid,nitups,inplace);
346+
UpdateStats(hrelid,nhtups);
347+
UpdateStats(irelid,nitups);
350348
if (oldPred!=NULL)
351349
{
352350
if (nitups==nhtups)
353351
pred=NULL;
354-
if (!inplace)
355-
UpdateIndexPredicate(irelid,oldPred,pred);
352+
UpdateIndexPredicate(irelid,oldPred,pred);
356353
}
357354
}
358355

‎src/backend/access/rtree/rtree.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.54 2000/10/21 15:43:20 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.55 2000/11/08 22:09:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -237,13 +237,12 @@ rtbuild(PG_FUNCTION_ARGS)
237237
{
238238
Oidhrelid=RelationGetRelid(heap);
239239
Oidirelid=RelationGetRelid(index);
240-
boolinplace=IsReindexProcessing();
241240

242241
heap_close(heap,NoLock);
243242
index_close(index);
244-
UpdateStats(hrelid,nhtups,inplace);
245-
UpdateStats(irelid,nitups,inplace);
246-
if (oldPred!=NULL&& !inplace)
243+
UpdateStats(hrelid,nhtups);
244+
UpdateStats(irelid,nitups);
245+
if (oldPred!=NULL)
247246
{
248247
if (nitups==nhtups)
249248
pred=NULL;

‎src/backend/access/transam/varsup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.31 2000/11/03 11:39:35 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.32 2000/11/08 22:09:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -130,7 +130,7 @@ VariableRelationPutNextXid(TransactionId xid)
130130

131131
TransactionIdStore(xid,&(var->nextXidData));
132132

133-
FlushBuffer(buf,TRUE);
133+
FlushBuffer(buf,true, true);
134134
}
135135

136136
/* --------------------------------

‎src/backend/access/transam/xact.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.80 2000/11/05 22:50:19 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.81 2000/11/08 22:09:55 tgl Exp $
1212
*
1313
* NOTES
1414
*Transaction aborts can now occur two ways:
@@ -167,6 +167,7 @@
167167
#include"miscadmin.h"
168168
#include"storage/proc.h"
169169
#include"storage/sinval.h"
170+
#include"storage/smgr.h"
170171
#include"utils/inval.h"
171172
#include"utils/memutils.h"
172173
#include"utils/portal.h"
@@ -1105,6 +1106,9 @@ CommitTransaction(void)
11051106
}
11061107

11071108
RelationPurgeLocalRelation(true);
1109+
AtEOXact_temp_relations(true);
1110+
smgrDoPendingDeletes(true);
1111+
11081112
AtEOXact_SPI();
11091113
AtEOXact_nbtree();
11101114
AtCommit_Cache();
@@ -1181,8 +1185,11 @@ AbortTransaction(void)
11811185
CloseSequences();
11821186
AtEOXact_portals();
11831187
RecordTransactionAbort();
1188+
11841189
RelationPurgeLocalRelation(false);
1185-
remove_temp_rel_in_myxid();
1190+
AtEOXact_temp_relations(false);
1191+
smgrDoPendingDeletes(false);
1192+
11861193
AtEOXact_SPI();
11871194
AtEOXact_nbtree();
11881195
AtAbort_Cache();

‎src/backend/access/transam/xlogutils.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ XLogOpenLogRelation(void)
171171
sprintf(RelationGetPhysicalRelationName(logRelation),"pg_log");
172172
logRelation->rd_node.tblNode=InvalidOid;
173173
logRelation->rd_node.relNode=RelOid_pg_log;
174-
logRelation->rd_unlinked= false;/* must exists */
175174
logRelation->rd_fd=-1;
176-
logRelation->rd_fd=smgropen(DEFAULT_SMGR,logRelation);
175+
logRelation->rd_fd=smgropen(DEFAULT_SMGR,logRelation, false);
177176
if (logRelation->rd_fd<0)
178177
elog(STOP,"XLogOpenLogRelation: failed to open pg_log");
179178
LogRelation=logRelation;
@@ -384,9 +383,9 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
384383

385384
hentry->rdesc=res;
386385

387-
res->reldata.rd_unlinked= true;/* look smgropen */
388386
res->reldata.rd_fd=-1;
389-
res->reldata.rd_fd=smgropen(DEFAULT_SMGR,&(res->reldata));
387+
res->reldata.rd_fd=smgropen(DEFAULT_SMGR,&(res->reldata),
388+
true/* allow failure */);
390389
}
391390

392391
res->moreRecently=&(_xlrelarr[0]);

‎src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.96 2000/11/04 12:43:23 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.97 2000/11/08 22:09:56 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1151,7 +1151,7 @@ build_indices()
11511151
* -mer
11521152
*/
11531153
if (!BootstrapAlreadySeen(RelationGetRelid(heap)))
1154-
UpdateStats(RelationGetRelid(heap),0, true);
1154+
UpdateStats(RelationGetRelid(heap),0);
11551155

11561156
/* XXX Probably we ought to close the heap and index here? */
11571157
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp