diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-29 21:08:25 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-29 21:08:25 +0000 |
commit | af5ced9cfdb1aefd5e64af405d7e582c99a55106 (patch) | |
tree | 0134c96dae92bd3000cc399a4a76c65cdca4ad01 /src/backend/commands/sequence.c | |
parent | 0eab92c0e674815d3b33868c14886845b68d7cfd (diff) | |
download | postgresql-af5ced9cfdb1aefd5e64af405d7e582c99a55106.tar.gz postgresql-af5ced9cfdb1aefd5e64af405d7e582c99a55106.zip |
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.
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r-- | src/backend/commands/sequence.c | 11 |
1 files changed, 8 insertions, 3 deletions
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); |