From af5ced9cfdb1aefd5e64af405d7e582c99a55106 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 29 Jun 2001 21:08:25 +0000 Subject: Further work on connecting the free space map (which is still just a stub) into the rest of the system. Adopt a cleaner approach to preventing deadlock in concurrent heap_updates: allow RelationGetBufferForTuple to select any page of the rel, and put the onus on it to lock both buffers in a consistent order. Remove no-longer-needed isExtend hack from API of ReleaseAndReadBuffer. --- src/backend/commands/sequence.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/sequence.c') diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 400c60b9b46..1da20e1c098 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.60 2001/06/23 00:07:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.61 2001/06/29 21:08:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -168,21 +168,26 @@ DefineSequence(CreateSeqStmt *seq) DefineRelation(stmt, RELKIND_SEQUENCE); rel = heap_openr(seq->seqname, AccessExclusiveLock); - tupDesc = RelationGetDescr(rel); - Assert(RelationGetNumberOfBlocks(rel) == 0); + /* Initialize first page of relation with special magic number */ + buf = ReadBuffer(rel, P_NEW); if (!BufferIsValid(buf)) elog(ERROR, "DefineSequence: ReadBuffer failed"); + Assert(BufferGetBlockNumber(buf) == 0); + page = (PageHeader) BufferGetPage(buf); PageInit((Page) page, BufferGetPageSize(buf), sizeof(sequence_magic)); sm = (sequence_magic *) PageGetSpecialPointer(page); sm->magic = SEQ_MAGIC; + /* hack: ensure heap_insert will insert on the just-created page */ + rel->rd_targblock = 0; + /* Now - form & insert sequence tuple */ tuple = heap_formtuple(tupDesc, value, null); heap_insert(rel, tuple); -- cgit v1.2.3