Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cfa191f3
Commit
cfa191f3
authored
Jul 24, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error message editing in backend/storage.
parent
658fca8d
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
426 additions
and
321 deletions
+426
-321
src/backend/storage/buffer/buf_table.c
src/backend/storage/buffer/buf_table.c
+10
-19
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/bufmgr.c
+55
-35
src/backend/storage/buffer/freelist.c
src/backend/storage/buffer/freelist.c
+4
-2
src/backend/storage/buffer/localbuf.c
src/backend/storage/buffer/localbuf.c
+8
-4
src/backend/storage/file/buffile.c
src/backend/storage/file/buffile.c
+3
-3
src/backend/storage/file/fd.c
src/backend/storage/file/fd.c
+45
-34
src/backend/storage/freespace/freespace.c
src/backend/storage/freespace/freespace.c
+44
-31
src/backend/storage/ipc/README
src/backend/storage/ipc/README
+2
-16
src/backend/storage/ipc/ipc.c
src/backend/storage/ipc/ipc.c
+12
-8
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/ipci.c
+2
-2
src/backend/storage/ipc/shmem.c
src/backend/storage/ipc/shmem.c
+15
-7
src/backend/storage/ipc/sinval.c
src/backend/storage/ipc/sinval.c
+10
-6
src/backend/storage/ipc/sinvaladt.c
src/backend/storage/ipc/sinvaladt.c
+3
-3
src/backend/storage/large_object/inv_api.c
src/backend/storage/large_object/inv_api.c
+15
-11
src/backend/storage/lmgr/deadlock.c
src/backend/storage/lmgr/deadlock.c
+27
-15
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/lmgr.c
+11
-11
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+28
-28
src/backend/storage/lmgr/lwlock.c
src/backend/storage/lmgr/lwlock.c
+6
-6
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+18
-13
src/backend/storage/page/bufpage.c
src/backend/storage/page/bufpage.c
+29
-17
src/backend/storage/smgr/md.c
src/backend/storage/smgr/md.c
+17
-17
src/backend/storage/smgr/mm.c
src/backend/storage/smgr/mm.c
+9
-7
src/backend/storage/smgr/smgr.c
src/backend/storage/smgr/smgr.c
+46
-21
src/backend/storage/smgr/smgrtype.c
src/backend/storage/smgr/smgrtype.c
+3
-3
src/include/utils/elog.h
src/include/utils/elog.h
+4
-2
No files found.
src/backend/storage/buffer/buf_table.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.2
7 2002/06/20 20:29:34 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.2
8 2003/07/24 22:04:08 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -55,7 +55,7 @@ InitBufTable(void)
...
@@ -55,7 +55,7 @@ InitBufTable(void)
HASH_ELEM
|
HASH_FUNCTION
);
HASH_ELEM
|
HASH_FUNCTION
);
if
(
!
SharedBufHash
)
if
(
!
SharedBufHash
)
elog
(
FATAL
,
"could
n't initialize shared buffer pool Hash Tbl
"
);
elog
(
FATAL
,
"could
not initialize shared buffer hash table
"
);
}
}
BufferDesc
*
BufferDesc
*
...
@@ -94,12 +94,8 @@ BufTableDelete(BufferDesc *buf)
...
@@ -94,12 +94,8 @@ BufTableDelete(BufferDesc *buf)
result
=
(
BufferLookupEnt
*
)
result
=
(
BufferLookupEnt
*
)
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_REMOVE
,
NULL
);
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_REMOVE
,
NULL
);
if
(
!
result
)
if
(
!
result
)
/* shouldn't happen */
{
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
/* shouldn't happen */
elog
(
ERROR
,
"BufTableDelete: BufferLookup table corrupted"
);
return
FALSE
;
}
/*
/*
* Clear the buffer's tag. This doesn't matter for the hash table,
* Clear the buffer's tag. This doesn't matter for the hash table,
...
@@ -127,17 +123,12 @@ BufTableInsert(BufferDesc *buf)
...
@@ -127,17 +123,12 @@ BufTableInsert(BufferDesc *buf)
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_ENTER
,
&
found
);
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_ENTER
,
&
found
);
if
(
!
result
)
if
(
!
result
)
{
ereport
(
ERROR
,
elog
(
ERROR
,
"BufTableInsert: BufferLookup table out of memory"
);
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
return
FALSE
;
errmsg
(
"out of shared memory"
)));
}
if
(
found
)
/* found something else in the table? */
/* found something else in the table ! */
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
if
(
found
)
{
elog
(
ERROR
,
"BufTableInsert: BufferLookup table corrupted"
);
return
FALSE
;
}
result
->
id
=
buf
->
buf_id
;
result
->
id
=
buf
->
buf_id
;
return
TRUE
;
return
TRUE
;
...
...
src/backend/storage/buffer/bufmgr.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.13
6 2003/05/10 19:04:30
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.13
7 2003/07/24 22:04:08
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -229,13 +229,17 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
...
@@ -229,13 +229,17 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
{
{
if
(
zero_damaged_pages
)
if
(
zero_damaged_pages
)
{
{
elog
(
WARNING
,
"Invalid page header in block %u of %s; zeroing out page"
,
ereport
(
WARNING
,
blockNum
,
RelationGetRelationName
(
reln
));
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"invalid page header in block %u of
\"
%s
\"
; zeroing out page"
,
blockNum
,
RelationGetRelationName
(
reln
))));
MemSet
((
char
*
)
MAKE_PTR
(
bufHdr
->
data
),
0
,
BLCKSZ
);
MemSet
((
char
*
)
MAKE_PTR
(
bufHdr
->
data
),
0
,
BLCKSZ
);
}
}
else
else
elog
(
ERROR
,
"Invalid page header in block %u of %s"
,
ereport
(
ERROR
,
blockNum
,
RelationGetRelationName
(
reln
));
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"invalid page header in block %u of
\"
%s
\"
"
,
blockNum
,
RelationGetRelationName
(
reln
))));
}
}
}
}
...
@@ -260,7 +264,7 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
...
@@ -260,7 +264,7 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
if
(
!
BufTableDelete
(
bufHdr
))
if
(
!
BufTableDelete
(
bufHdr
))
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"
BufRead: buffer table broken after I
O error"
);
elog
(
FATAL
,
"
buffer table broken after I/
O error"
);
}
}
/* remember that BufferAlloc() pinned the buffer */
/* remember that BufferAlloc() pinned the buffer */
UnpinBuffer
(
bufHdr
);
UnpinBuffer
(
bufHdr
);
...
@@ -430,9 +434,12 @@ BufferAlloc(Relation reln,
...
@@ -430,9 +434,12 @@ BufferAlloc(Relation reln,
if
(
smok
==
FALSE
)
if
(
smok
==
FALSE
)
{
{
elog
(
WARNING
,
"BufferAlloc: cannot write block %u for %u/%u"
,
ereport
(
WARNING
,
buf
->
tag
.
blockNum
,
(
errcode
(
ERRCODE_IO_ERROR
),
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
);
errmsg
(
"could not write block %u of %u/%u"
,
buf
->
tag
.
blockNum
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
)));
inProgress
=
FALSE
;
inProgress
=
FALSE
;
buf
->
flags
|=
BM_IO_ERROR
;
buf
->
flags
|=
BM_IO_ERROR
;
buf
->
flags
&=
~
BM_IO_IN_PROGRESS
;
buf
->
flags
&=
~
BM_IO_IN_PROGRESS
;
...
@@ -448,7 +455,7 @@ BufferAlloc(Relation reln,
...
@@ -448,7 +455,7 @@ BufferAlloc(Relation reln,
*/
*/
if
(
buf
->
flags
&
BM_JUST_DIRTIED
)
if
(
buf
->
flags
&
BM_JUST_DIRTIED
)
{
{
elog
(
PANIC
,
"
BufferAlloc: content of block %u (%u/%u)
changed while flushing"
,
elog
(
PANIC
,
"
content of block %u of %u/%u
changed while flushing"
,
buf
->
tag
.
blockNum
,
buf
->
tag
.
blockNum
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
);
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
);
}
}
...
@@ -540,7 +547,7 @@ BufferAlloc(Relation reln,
...
@@ -540,7 +547,7 @@ BufferAlloc(Relation reln,
if
(
!
BufTableDelete
(
buf
))
if
(
!
BufTableDelete
(
buf
))
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"buffer wasn't in the buffer table"
);
elog
(
FATAL
,
"buffer wasn't in the buffer
hash
table"
);
}
}
INIT_BUFFERTAG
(
&
(
buf
->
tag
),
reln
,
blockNum
);
INIT_BUFFERTAG
(
&
(
buf
->
tag
),
reln
,
blockNum
);
...
@@ -548,7 +555,7 @@ BufferAlloc(Relation reln,
...
@@ -548,7 +555,7 @@ BufferAlloc(Relation reln,
if
(
!
BufTableInsert
(
buf
))
if
(
!
BufTableInsert
(
buf
))
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"
Buffer in lookup
table twice"
);
elog
(
FATAL
,
"
buffer in buffer hash
table twice"
);
}
}
/*
/*
...
@@ -587,7 +594,7 @@ write_buffer(Buffer buffer, bool release)
...
@@ -587,7 +594,7 @@ write_buffer(Buffer buffer, bool release)
}
}
if
(
BAD_BUFFER_ID
(
buffer
))
if
(
BAD_BUFFER_ID
(
buffer
))
elog
(
ERROR
,
"
write_buffer: bad buffer
%d"
,
buffer
);
elog
(
ERROR
,
"
bad buffer id:
%d"
,
buffer
);
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
...
@@ -809,9 +816,12 @@ BufferSync(void)
...
@@ -809,9 +816,12 @@ BufferSync(void)
}
}
if
(
status
==
SM_FAIL
)
/* disk failure ?! */
if
(
status
==
SM_FAIL
)
/* disk failure ?! */
elog
(
PANIC
,
"BufferSync: cannot write %u for %u/%u"
,
ereport
(
PANIC
,
bufHdr
->
tag
.
blockNum
,
(
errcode
(
ERRCODE_IO_ERROR
),
bufHdr
->
tag
.
rnode
.
tblNode
,
bufHdr
->
tag
.
rnode
.
relNode
);
errmsg
(
"could not write block %u of %u/%u"
,
bufHdr
->
tag
.
blockNum
,
bufHdr
->
tag
.
rnode
.
tblNode
,
bufHdr
->
tag
.
rnode
.
relNode
)));
/*
/*
* Note that it's safe to change cntxDirty here because of we
* Note that it's safe to change cntxDirty here because of we
...
@@ -932,7 +942,7 @@ ResetBufferUsage(void)
...
@@ -932,7 +942,7 @@ ResetBufferUsage(void)
* AtEOXact_Buffers - clean up at end of transaction.
* AtEOXact_Buffers - clean up at end of transaction.
*
*
* During abort, we need to release any buffer pins we're holding
* During abort, we need to release any buffer pins we're holding
* (this cleans up in case e
log
interrupted a routine that pins a
* (this cleans up in case e
report
interrupted a routine that pins a
* buffer). During commit, we shouldn't need to do that, but check
* buffer). During commit, we shouldn't need to do that, but check
* anyway to see if anyone leaked a buffer reference count.
* anyway to see if anyone leaked a buffer reference count.
*/
*/
...
@@ -949,8 +959,8 @@ AtEOXact_Buffers(bool isCommit)
...
@@ -949,8 +959,8 @@ AtEOXact_Buffers(bool isCommit)
if
(
isCommit
)
if
(
isCommit
)
elog
(
WARNING
,
elog
(
WARNING
,
"
Buffer L
eak: [%03d] (freeNext=%d, freePrev=%d, "
"
buffer refcount l
eak: [%03d] (freeNext=%d, freePrev=%d, "
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
i
,
buf
->
freeNext
,
buf
->
freePrev
,
i
,
buf
->
freeNext
,
buf
->
freePrev
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
...
@@ -1206,8 +1216,10 @@ recheck:
...
@@ -1206,8 +1216,10 @@ recheck:
{
{
/* the sole pin should be ours */
/* the sole pin should be ours */
if
(
bufHdr
->
refcount
!=
1
||
PrivateRefCount
[
i
-
1
]
==
0
)
if
(
bufHdr
->
refcount
!=
1
||
PrivateRefCount
[
i
-
1
]
==
0
)
elog
(
FATAL
,
"
DropRelFileNodeBuffers: block %u is
referenced (private %ld, global %d)"
,
elog
(
FATAL
,
"
block %u of %u/%u is still
referenced (private %ld, global %d)"
,
bufHdr
->
tag
.
blockNum
,
bufHdr
->
tag
.
blockNum
,
bufHdr
->
tag
.
rnode
.
tblNode
,
bufHdr
->
tag
.
rnode
.
relNode
,
PrivateRefCount
[
i
-
1
],
bufHdr
->
refcount
);
PrivateRefCount
[
i
-
1
],
bufHdr
->
refcount
);
/* Make sure it will be released */
/* Make sure it will be released */
PrivateRefCount
[
i
-
1
]
=
1
;
PrivateRefCount
[
i
-
1
]
=
1
;
...
@@ -1427,7 +1439,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
...
@@ -1427,7 +1439,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
{
{
error_context_stack
=
errcontext
.
previous
;
error_context_stack
=
errcontext
.
previous
;
elog
(
WARNING
,
"FlushRelationBuffers(
%s
(local), %u): block %u is dirty, could not flush it"
,
elog
(
WARNING
,
"FlushRelationBuffers(
\"
%s
\"
(local), %u): block %u is dirty, could not flush it"
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
bufHdr
->
tag
.
blockNum
);
bufHdr
->
tag
.
blockNum
);
return
(
-
1
);
return
(
-
1
);
...
@@ -1438,7 +1450,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
...
@@ -1438,7 +1450,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
if
(
LocalRefCount
[
i
]
>
0
)
if
(
LocalRefCount
[
i
]
>
0
)
{
{
error_context_stack
=
errcontext
.
previous
;
error_context_stack
=
errcontext
.
previous
;
elog
(
WARNING
,
"FlushRelationBuffers(
%s
(local), %u): block %u is referenced (%ld)"
,
elog
(
WARNING
,
"FlushRelationBuffers(
\"
%s
\"
(local), %u): block %u is referenced (%ld)"
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
bufHdr
->
tag
.
blockNum
,
LocalRefCount
[
i
]);
bufHdr
->
tag
.
blockNum
,
LocalRefCount
[
i
]);
return
(
-
2
);
return
(
-
2
);
...
@@ -1495,10 +1507,12 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
...
@@ -1495,10 +1507,12 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
(
char
*
)
MAKE_PTR
(
bufHdr
->
data
));
(
char
*
)
MAKE_PTR
(
bufHdr
->
data
));
if
(
status
==
SM_FAIL
)
/* disk failure ?! */
if
(
status
==
SM_FAIL
)
/* disk failure ?! */
elog
(
PANIC
,
"FlushRelationBuffers: cannot write %u for %u/%u"
,
ereport
(
PANIC
,
bufHdr
->
tag
.
blockNum
,
(
errcode
(
ERRCODE_IO_ERROR
),
bufHdr
->
tag
.
rnode
.
tblNode
,
errmsg
(
"could not write block %u of %u/%u"
,
bufHdr
->
tag
.
rnode
.
relNode
);
bufHdr
->
tag
.
blockNum
,
bufHdr
->
tag
.
rnode
.
tblNode
,
bufHdr
->
tag
.
rnode
.
relNode
)));
BufferFlushCount
++
;
BufferFlushCount
++
;
...
@@ -1522,7 +1536,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
...
@@ -1522,7 +1536,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
error_context_stack
=
errcontext
.
previous
;
error_context_stack
=
errcontext
.
previous
;
elog
(
WARNING
,
"FlushRelationBuffers(
%s
, %u): block %u is referenced (private %ld, global %d)"
,
elog
(
WARNING
,
"FlushRelationBuffers(
\"
%s
\"
, %u): block %u is referenced (private %ld, global %d)"
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
RelationGetRelationName
(
rel
),
firstDelBlock
,
bufHdr
->
tag
.
blockNum
,
bufHdr
->
tag
.
blockNum
,
PrivateRefCount
[
i
],
bufHdr
->
refcount
);
PrivateRefCount
[
i
],
bufHdr
->
refcount
);
...
@@ -1825,7 +1839,7 @@ SetBufferCommitInfoNeedsSave(Buffer buffer)
...
@@ -1825,7 +1839,7 @@ SetBufferCommitInfoNeedsSave(Buffer buffer)
}
}
if
(
BAD_BUFFER_ID
(
buffer
))
if
(
BAD_BUFFER_ID
(
buffer
))
elog
(
ERROR
,
"
SetBufferCommitInfoNeedsSave: bad buffer
%d"
,
buffer
);
elog
(
ERROR
,
"
bad buffer id:
%d"
,
buffer
);
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
...
@@ -1919,7 +1933,7 @@ LockBuffer(Buffer buffer, int mode)
...
@@ -1919,7 +1933,7 @@ LockBuffer(Buffer buffer, int mode)
buf
->
cntxDirty
=
true
;
buf
->
cntxDirty
=
true
;
}
}
else
else
elog
(
ERROR
,
"
LockBuffer: unknown lock mode
%d"
,
mode
);
elog
(
ERROR
,
"
unrecognized buffer lock mode:
%d"
,
mode
);
}
}
/*
/*
...
@@ -1950,14 +1964,16 @@ LockBufferForCleanup(Buffer buffer)
...
@@ -1950,14 +1964,16 @@ LockBufferForCleanup(Buffer buffer)
{
{
/* There should be exactly one pin */
/* There should be exactly one pin */
if
(
LocalRefCount
[
-
buffer
-
1
]
!=
1
)
if
(
LocalRefCount
[
-
buffer
-
1
]
!=
1
)
elog
(
ERROR
,
"LockBufferForCleanup: wrong local pin count"
);
elog
(
ERROR
,
"incorrect local pin count: %ld"
,
LocalRefCount
[
-
buffer
-
1
]);
/* Nobody else to wait for */
/* Nobody else to wait for */
return
;
return
;
}
}
/* There should be exactly one local pin */
/* There should be exactly one local pin */
if
(
PrivateRefCount
[
buffer
-
1
]
!=
1
)
if
(
PrivateRefCount
[
buffer
-
1
]
!=
1
)
elog
(
ERROR
,
"LockBufferForCleanup: wrong local pin count"
);
elog
(
ERROR
,
"incorrect local pin count: %ld"
,
PrivateRefCount
[
buffer
-
1
]);
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
buflock
=
&
(
BufferLocks
[
buffer
-
1
]);
buflock
=
&
(
BufferLocks
[
buffer
-
1
]);
...
@@ -1979,7 +1995,7 @@ LockBufferForCleanup(Buffer buffer)
...
@@ -1979,7 +1995,7 @@ LockBufferForCleanup(Buffer buffer)
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
elog
(
ERROR
,
"
M
ultiple backends attempting to wait for pincount 1"
);
elog
(
ERROR
,
"
m
ultiple backends attempting to wait for pincount 1"
);
}
}
bufHdr
->
wait_backend_id
=
MyBackendId
;
bufHdr
->
wait_backend_id
=
MyBackendId
;
bufHdr
->
flags
|=
BM_PIN_COUNT_WAITER
;
bufHdr
->
flags
|=
BM_PIN_COUNT_WAITER
;
...
@@ -2102,9 +2118,13 @@ AbortBufferIO(void)
...
@@ -2102,9 +2118,13 @@ AbortBufferIO(void)
/* Issue notice if this is not the first failure... */
/* Issue notice if this is not the first failure... */
if
(
buf
->
flags
&
BM_IO_ERROR
)
if
(
buf
->
flags
&
BM_IO_ERROR
)
{
{
elog
(
WARNING
,
"write error may be permanent: cannot write block %u for %u/%u"
,
ereport
(
WARNING
,
buf
->
tag
.
blockNum
,
(
errcode
(
ERRCODE_IO_ERROR
),
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
);
errmsg
(
"could not write block %u of %u/%u"
,
buf
->
tag
.
blockNum
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
),
errdetail
(
"Multiple failures --- write error may be permanent."
)));
}
}
buf
->
flags
|=
BM_DIRTY
;
buf
->
flags
|=
BM_DIRTY
;
}
}
...
...
src/backend/storage/buffer/freelist.c
View file @
cfa191f3
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.
29 2002/06/20 20:29:34 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.
30 2003/07/24 22:04:08 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -198,7 +198,9 @@ GetFreeBuffer(void)
...
@@ -198,7 +198,9 @@ GetFreeBuffer(void)
if
(
Free_List_Descriptor
==
SharedFreeList
->
freeNext
)
if
(
Free_List_Descriptor
==
SharedFreeList
->
freeNext
)
{
{
/* queue is empty. All buffers in the buffer pool are pinned. */
/* queue is empty. All buffers in the buffer pool are pinned. */
elog
(
ERROR
,
"out of free buffers: time to abort!"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
errmsg
(
"out of free buffers"
)));
return
NULL
;
return
NULL
;
}
}
buf
=
&
(
BufferDescriptors
[
SharedFreeList
->
freeNext
]);
buf
=
&
(
BufferDescriptors
[
SharedFreeList
->
freeNext
]);
...
...
src/backend/storage/buffer/localbuf.c
View file @
cfa191f3
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.4
7 2002/12/05 22:48:03
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.4
8 2003/07/24 22:04:08
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -80,7 +80,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
...
@@ -80,7 +80,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
}
}
}
}
if
(
bufHdr
==
NULL
)
if
(
bufHdr
==
NULL
)
elog
(
ERROR
,
"no empty local buffer."
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
errmsg
(
"no empty local buffer available"
)));
/*
/*
* this buffer is not referenced but it might still be dirty. if
* this buffer is not referenced but it might still be dirty. if
...
@@ -122,7 +124,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
...
@@ -122,7 +124,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
char
*
data
=
(
char
*
)
malloc
(
BLCKSZ
);
char
*
data
=
(
char
*
)
malloc
(
BLCKSZ
);
if
(
data
==
NULL
)
if
(
data
==
NULL
)
elog
(
ERROR
,
"Out of memory in LocalBufferAlloc"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
/*
/*
* This is a bit of a hack: bufHdr->data needs to be a shmem
* This is a bit of a hack: bufHdr->data needs to be a shmem
...
@@ -229,7 +233,7 @@ AtEOXact_LocalBuffers(bool isCommit)
...
@@ -229,7 +233,7 @@ AtEOXact_LocalBuffers(bool isCommit)
if
(
isCommit
)
if
(
isCommit
)
elog
(
WARNING
,
elog
(
WARNING
,
"
Local Buffer L
eak: [%03d] (rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
"
local buffer l
eak: [%03d] (rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
i
,
i
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
...
...
src/backend/storage/file/buffile.c
View file @
cfa191f3
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.1
6 2003/04/29 03:21:2
9 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.1
7 2003/07/24 22:04:0
9 tgl Exp $
*
*
* NOTES:
* NOTES:
*
*
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
* will go away automatically at transaction end. If the underlying
* will go away automatically at transaction end. If the underlying
* virtual File is made with OpenTemporaryFile, then all resources for
* virtual File is made with OpenTemporaryFile, then all resources for
* the file are certain to be cleaned up even if processing is aborted
* the file are certain to be cleaned up even if processing is aborted
* by e
log
(ERROR). To avoid confusion, the caller should take care that
* by e
report
(ERROR). To avoid confusion, the caller should take care that
* all calls for a single BufFile are made in the same palloc context.
* all calls for a single BufFile are made in the same palloc context.
*
*
* BufFile also supports temporary files that exceed the OS file size limit
* BufFile also supports temporary files that exceed the OS file size limit
...
@@ -479,7 +479,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
...
@@ -479,7 +479,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
break
;
break
;
#endif
#endif
default:
default:
elog
(
ERROR
,
"
BufFileSeek:
invalid whence: %d"
,
whence
);
elog
(
ERROR
,
"invalid whence: %d"
,
whence
);
return
EOF
;
return
EOF
;
}
}
while
(
newOffset
<
0
)
while
(
newOffset
<
0
)
...
...
src/backend/storage/file/fd.c
View file @
cfa191f3
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.9
8 2003/04/29 03:21:2
9 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.9
9 2003/07/24 22:04:0
9 tgl Exp $
*
*
* NOTES:
* NOTES:
*
*
...
@@ -247,7 +247,7 @@ pg_fdatasync(int fd)
...
@@ -247,7 +247,7 @@ pg_fdatasync(int fd)
* This is exported for use by places that really want a plain kernel FD,
* This is exported for use by places that really want a plain kernel FD,
* but need to be proof against running out of FDs. Once an FD has been
* but need to be proof against running out of FDs. Once an FD has been
* successfully returned, it is the caller's responsibility to ensure that
* successfully returned, it is the caller's responsibility to ensure that
* it will not be leaked on e
log
()! Most users should *not* call this
* it will not be leaked on e
report
()! Most users should *not* call this
* routine directly, but instead use the VFD abstraction level, which
* routine directly, but instead use the VFD abstraction level, which
* provides protection against descriptor leaks as well as management of
* provides protection against descriptor leaks as well as management of
* files that need to be open for more than a short period of time.
* files that need to be open for more than a short period of time.
...
@@ -272,8 +272,9 @@ tryAgain:
...
@@ -272,8 +272,9 @@ tryAgain:
{
{
int
save_errno
=
errno
;
int
save_errno
=
errno
;
DO_DB
(
elog
(
LOG
,
"BasicOpenFile: not enough descs, retry, er= %d"
,
ereport
(
LOG
,
errno
));
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
errmsg
(
"out of file descriptors: %m; release and retry"
)));
errno
=
0
;
errno
=
0
;
if
(
ReleaseLruFile
())
if
(
ReleaseLruFile
())
goto
tryAgain
;
goto
tryAgain
;
...
@@ -306,7 +307,7 @@ pg_nofile(void)
...
@@ -306,7 +307,7 @@ pg_nofile(void)
#else
#else
no_files
=
(
long
)
max_files_per_process
;
no_files
=
(
long
)
max_files_per_process
;
#endif
#endif
elog
(
LOG
,
"
pg_nofile:
sysconf(_SC_OPEN_MAX) failed; using %ld"
,
elog
(
LOG
,
"sysconf(_SC_OPEN_MAX) failed; using %ld"
,
no_files
);
no_files
);
}
}
#else
/* !HAVE_SYSCONF */
#else
/* !HAVE_SYSCONF */
...
@@ -328,9 +329,11 @@ pg_nofile(void)
...
@@ -328,9 +329,11 @@ pg_nofile(void)
* Make sure we have enough to get by after reserving some for LD.
* Make sure we have enough to get by after reserving some for LD.
*/
*/
if
((
no_files
-
RESERVE_FOR_LD
)
<
FD_MINFREE
)
if
((
no_files
-
RESERVE_FOR_LD
)
<
FD_MINFREE
)
elog
(
FATAL
,
"pg_nofile: insufficient file descriptors available to start backend.
\n
"
ereport
(
FATAL
,
"
\t
System allows %ld, we need at least %d."
,
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
no_files
,
RESERVE_FOR_LD
+
FD_MINFREE
);
errmsg
(
"insufficient file descriptors available to start backend"
),
errdetail
(
"System allows %ld, we need at least %d."
,
no_files
,
RESERVE_FOR_LD
+
FD_MINFREE
)));
no_files
-=
RESERVE_FOR_LD
;
no_files
-=
RESERVE_FOR_LD
;
}
}
...
@@ -399,7 +402,7 @@ LruDelete(File file)
...
@@ -399,7 +402,7 @@ LruDelete(File file)
/* close the file */
/* close the file */
if
(
close
(
vfdP
->
fd
))
if
(
close
(
vfdP
->
fd
))
elog
(
LOG
,
"
LruDelete: failed to close %s
: %m"
,
elog
(
LOG
,
"
failed to close
\"
%s
\"
: %m"
,
vfdP
->
fileName
);
vfdP
->
fileName
);
--
nfile
;
--
nfile
;
...
@@ -515,7 +518,9 @@ AllocateVfd(void)
...
@@ -515,7 +518,9 @@ AllocateVfd(void)
/* initialize header entry first time through */
/* initialize header entry first time through */
VfdCache
=
(
Vfd
*
)
malloc
(
sizeof
(
Vfd
));
VfdCache
=
(
Vfd
*
)
malloc
(
sizeof
(
Vfd
));
if
(
VfdCache
==
NULL
)
if
(
VfdCache
==
NULL
)
elog
(
FATAL
,
"AllocateVfd: no room for VFD array"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
MemSet
((
char
*
)
&
(
VfdCache
[
0
]),
0
,
sizeof
(
Vfd
));
MemSet
((
char
*
)
&
(
VfdCache
[
0
]),
0
,
sizeof
(
Vfd
));
VfdCache
->
fd
=
VFD_CLOSED
;
VfdCache
->
fd
=
VFD_CLOSED
;
...
@@ -542,12 +547,13 @@ AllocateVfd(void)
...
@@ -542,12 +547,13 @@ AllocateVfd(void)
newCacheSize
=
32
;
newCacheSize
=
32
;
/*
/*
* Be careful not to clobber VfdCache ptr if realloc fails; we
* Be careful not to clobber VfdCache ptr if realloc fails.
* will need it during proc_exit cleanup!
*/
*/
newVfdCache
=
(
Vfd
*
)
realloc
(
VfdCache
,
sizeof
(
Vfd
)
*
newCacheSize
);
newVfdCache
=
(
Vfd
*
)
realloc
(
VfdCache
,
sizeof
(
Vfd
)
*
newCacheSize
);
if
(
newVfdCache
==
NULL
)
if
(
newVfdCache
==
NULL
)
elog
(
FATAL
,
"AllocateVfd: no room to enlarge VFD array"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
VfdCache
=
newVfdCache
;
VfdCache
=
newVfdCache
;
/*
/*
...
@@ -678,15 +684,22 @@ fileNameOpenFile(FileName fileName,
...
@@ -678,15 +684,22 @@ fileNameOpenFile(FileName fileName,
int
fileFlags
,
int
fileFlags
,
int
fileMode
)
int
fileMode
)
{
{
char
*
fnamecopy
;
File
file
;
File
file
;
Vfd
*
vfdP
;
Vfd
*
vfdP
;
if
(
fileName
==
NULL
)
elog
(
ERROR
,
"fileNameOpenFile: NULL fname"
);
DO_DB
(
elog
(
LOG
,
"fileNameOpenFile: %s %x %o"
,
DO_DB
(
elog
(
LOG
,
"fileNameOpenFile: %s %x %o"
,
fileName
,
fileFlags
,
fileMode
));
fileName
,
fileFlags
,
fileMode
));
/*
* We need a malloc'd copy of the file name; fail cleanly if no room.
*/
fnamecopy
=
strdup
(
fileName
);
if
(
fnamecopy
==
NULL
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
file
=
AllocateVfd
();
file
=
AllocateVfd
();
vfdP
=
&
VfdCache
[
file
];
vfdP
=
&
VfdCache
[
file
];
...
@@ -701,6 +714,7 @@ fileNameOpenFile(FileName fileName,
...
@@ -701,6 +714,7 @@ fileNameOpenFile(FileName fileName,
if
(
vfdP
->
fd
<
0
)
if
(
vfdP
->
fd
<
0
)
{
{
FreeVfd
(
file
);
FreeVfd
(
file
);
free
(
fnamecopy
);
return
-
1
;
return
-
1
;
}
}
++
nfile
;
++
nfile
;
...
@@ -709,11 +723,7 @@ fileNameOpenFile(FileName fileName,
...
@@ -709,11 +723,7 @@ fileNameOpenFile(FileName fileName,
Insert
(
file
);
Insert
(
file
);
vfdP
->
fileName
=
(
char
*
)
malloc
(
strlen
(
fileName
)
+
1
);
vfdP
->
fileName
=
fnamecopy
;
if
(
vfdP
->
fileName
==
NULL
)
elog
(
FATAL
,
"fileNameOpenFile: no room to save VFD filename"
);
strcpy
(
vfdP
->
fileName
,
fileName
);
/* Saved flags are adjusted to be OK for re-opening file */
/* Saved flags are adjusted to be OK for re-opening file */
vfdP
->
fileFlags
=
fileFlags
&
~
(
O_CREAT
|
O_TRUNC
|
O_EXCL
);
vfdP
->
fileFlags
=
fileFlags
&
~
(
O_CREAT
|
O_TRUNC
|
O_EXCL
);
vfdP
->
fileMode
=
fileMode
;
vfdP
->
fileMode
=
fileMode
;
...
@@ -801,7 +811,7 @@ OpenTemporaryFile(bool interXact)
...
@@ -801,7 +811,7 @@ OpenTemporaryFile(bool interXact)
O_RDWR
|
O_CREAT
|
O_TRUNC
|
PG_BINARY
,
O_RDWR
|
O_CREAT
|
O_TRUNC
|
PG_BINARY
,
0600
);
0600
);
if
(
file
<=
0
)
if
(
file
<=
0
)
elog
(
ERROR
,
"
Failed to create temporary file %s
: %m"
,
elog
(
ERROR
,
"
could not create temporary file
\"
%s
\"
: %m"
,
tempfilepath
);
tempfilepath
);
}
}
...
@@ -837,7 +847,7 @@ FileClose(File file)
...
@@ -837,7 +847,7 @@ FileClose(File file)
/* close the file */
/* close the file */
if
(
close
(
vfdP
->
fd
))
if
(
close
(
vfdP
->
fd
))
elog
(
LOG
,
"
FileClose: failed to close %s
: %m"
,
elog
(
LOG
,
"
failed to close
\"
%s
\"
: %m"
,
vfdP
->
fileName
);
vfdP
->
fileName
);
--
nfile
;
--
nfile
;
...
@@ -852,7 +862,7 @@ FileClose(File file)
...
@@ -852,7 +862,7 @@ FileClose(File file)
/* reset flag so that die() interrupt won't cause problems */
/* reset flag so that die() interrupt won't cause problems */
vfdP
->
fdstate
&=
~
FD_TEMPORARY
;
vfdP
->
fdstate
&=
~
FD_TEMPORARY
;
if
(
unlink
(
vfdP
->
fileName
))
if
(
unlink
(
vfdP
->
fileName
))
elog
(
LOG
,
"
FileClose: failed to unlink %s
: %m"
,
elog
(
LOG
,
"
failed to unlink
\"
%s
\"
: %m"
,
vfdP
->
fileName
);
vfdP
->
fileName
);
}
}
...
@@ -943,7 +953,7 @@ FileSeek(File file, long offset, int whence)
...
@@ -943,7 +953,7 @@ FileSeek(File file, long offset, int whence)
{
{
case
SEEK_SET
:
case
SEEK_SET
:
if
(
offset
<
0
)
if
(
offset
<
0
)
elog
(
ERROR
,
"
FileSeek: invalid
offset: %ld"
,
offset
);
elog
(
ERROR
,
"
invalid seek
offset: %ld"
,
offset
);
VfdCache
[
file
].
seekPos
=
offset
;
VfdCache
[
file
].
seekPos
=
offset
;
break
;
break
;
case
SEEK_CUR
:
case
SEEK_CUR
:
...
@@ -954,7 +964,7 @@ FileSeek(File file, long offset, int whence)
...
@@ -954,7 +964,7 @@ FileSeek(File file, long offset, int whence)
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
FileSeek:
invalid whence: %d"
,
whence
);
elog
(
ERROR
,
"invalid whence: %d"
,
whence
);
break
;
break
;
}
}
}
}
...
@@ -964,7 +974,7 @@ FileSeek(File file, long offset, int whence)
...
@@ -964,7 +974,7 @@ FileSeek(File file, long offset, int whence)
{
{
case
SEEK_SET
:
case
SEEK_SET
:
if
(
offset
<
0
)
if
(
offset
<
0
)
elog
(
ERROR
,
"
FileSeek: invalid
offset: %ld"
,
offset
);
elog
(
ERROR
,
"
invalid seek
offset: %ld"
,
offset
);
if
(
VfdCache
[
file
].
seekPos
!=
offset
)
if
(
VfdCache
[
file
].
seekPos
!=
offset
)
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
break
;
break
;
...
@@ -976,7 +986,7 @@ FileSeek(File file, long offset, int whence)
...
@@ -976,7 +986,7 @@ FileSeek(File file, long offset, int whence)
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
VfdCache
[
file
].
seekPos
=
lseek
(
VfdCache
[
file
].
fd
,
offset
,
whence
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
FileSeek:
invalid whence: %d"
,
whence
);
elog
(
ERROR
,
"invalid whence: %d"
,
whence
);
break
;
break
;
}
}
}
}
...
@@ -1026,7 +1036,7 @@ FileTruncate(File file, long offset)
...
@@ -1026,7 +1036,7 @@ FileTruncate(File file, long offset)
*
*
* fd.c will automatically close all files opened with AllocateFile at
* fd.c will automatically close all files opened with AllocateFile at
* transaction commit or abort; this prevents FD leakage if a routine
* transaction commit or abort; this prevents FD leakage if a routine
* that calls AllocateFile is terminated prematurely by e
log
(ERROR).
* that calls AllocateFile is terminated prematurely by e
report
(ERROR).
*
*
* Ideally this should be the *only* direct call of fopen() in the backend.
* Ideally this should be the *only* direct call of fopen() in the backend.
*/
*/
...
@@ -1038,7 +1048,7 @@ AllocateFile(char *name, char *mode)
...
@@ -1038,7 +1048,7 @@ AllocateFile(char *name, char *mode)
DO_DB
(
elog
(
LOG
,
"AllocateFile: Allocated %d"
,
numAllocatedFiles
));
DO_DB
(
elog
(
LOG
,
"AllocateFile: Allocated %d"
,
numAllocatedFiles
));
if
(
numAllocatedFiles
>=
MAX_ALLOCATED_FILES
)
if
(
numAllocatedFiles
>=
MAX_ALLOCATED_FILES
)
elog
(
ERROR
,
"
AllocateFile:
too many private FDs demanded"
);
elog
(
ERROR
,
"too many private FDs demanded"
);
TryAgain:
TryAgain:
if
((
file
=
fopen
(
name
,
mode
))
!=
NULL
)
if
((
file
=
fopen
(
name
,
mode
))
!=
NULL
)
...
@@ -1052,8 +1062,9 @@ TryAgain:
...
@@ -1052,8 +1062,9 @@ TryAgain:
{
{
int
save_errno
=
errno
;
int
save_errno
=
errno
;
DO_DB
(
elog
(
LOG
,
"AllocateFile: not enough descs, retry, er= %d"
,
ereport
(
LOG
,
errno
));
(
errcode
(
ERRCODE_INSUFFICIENT_RESOURCES
),
errmsg
(
"out of file descriptors: %m; release and retry"
)));
errno
=
0
;
errno
=
0
;
if
(
ReleaseLruFile
())
if
(
ReleaseLruFile
())
goto
TryAgain
;
goto
TryAgain
;
...
@@ -1081,7 +1092,7 @@ FreeFile(FILE *file)
...
@@ -1081,7 +1092,7 @@ FreeFile(FILE *file)
}
}
}
}
if
(
i
<
0
)
if
(
i
<
0
)
elog
(
WARNING
,
"
FreeFile: f
ile was not obtained from AllocateFile"
);
elog
(
WARNING
,
"
file passed to FreeF
ile was not obtained from AllocateFile"
);
fclose
(
file
);
fclose
(
file
);
}
}
...
@@ -1234,7 +1245,7 @@ RemovePgTempFiles(void)
...
@@ -1234,7 +1245,7 @@ RemovePgTempFiles(void)
unlink
(
rm_path
);
unlink
(
rm_path
);
else
else
elog
(
LOG
,
elog
(
LOG
,
"
Unexpected file found in temporary-files directory: %s
"
,
"
unexpected file found in temporary-files directory:
\"
%s
\"
"
,
rm_path
);
rm_path
);
}
}
closedir
(
temp_dir
);
closedir
(
temp_dir
);
...
...
src/backend/storage/freespace/freespace.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.1
7 2003/03/06 00:04:27
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.1
8 2003/07/24 22:04:09
tgl Exp $
*
*
*
*
* NOTES:
* NOTES:
...
@@ -269,7 +269,9 @@ InitFreeSpaceMap(void)
...
@@ -269,7 +269,9 @@ InitFreeSpaceMap(void)
/* Create table header */
/* Create table header */
FreeSpaceMap
=
(
FSMHeader
*
)
ShmemAlloc
(
sizeof
(
FSMHeader
));
FreeSpaceMap
=
(
FSMHeader
*
)
ShmemAlloc
(
sizeof
(
FSMHeader
));
if
(
FreeSpaceMap
==
NULL
)
if
(
FreeSpaceMap
==
NULL
)
elog
(
FATAL
,
"Insufficient shared memory for free space map"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"insufficient shared memory for free space map"
)));
MemSet
(
FreeSpaceMap
,
0
,
sizeof
(
FSMHeader
));
MemSet
(
FreeSpaceMap
,
0
,
sizeof
(
FSMHeader
));
/* Create hashtable for FSMRelations */
/* Create hashtable for FSMRelations */
...
@@ -284,18 +286,24 @@ InitFreeSpaceMap(void)
...
@@ -284,18 +286,24 @@ InitFreeSpaceMap(void)
(
HASH_ELEM
|
HASH_FUNCTION
));
(
HASH_ELEM
|
HASH_FUNCTION
));
if
(
!
FreeSpaceMap
->
relHash
)
if
(
!
FreeSpaceMap
->
relHash
)
elog
(
FATAL
,
"Insufficient shared memory for free space map"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"insufficient shared memory for free space map"
)));
/* Allocate page-storage arena */
/* Allocate page-storage arena */
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
/* This check ensures spareChunks will be greater than zero */
/* This check ensures spareChunks will be greater than zero */
if
(
nchunks
<=
MaxFSMRelations
)
if
(
nchunks
<=
MaxFSMRelations
)
elog
(
FATAL
,
"max_fsm_pages must exceed max_fsm_relations * %d"
,
ereport
(
FATAL
,
CHUNKPAGES
);
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"max_fsm_pages must exceed max_fsm_relations * %d"
,
CHUNKPAGES
)));
FreeSpaceMap
->
arena
=
(
char
*
)
ShmemAlloc
(
nchunks
*
CHUNKBYTES
);
FreeSpaceMap
->
arena
=
(
char
*
)
ShmemAlloc
(
nchunks
*
CHUNKBYTES
);
if
(
FreeSpaceMap
->
arena
==
NULL
)
if
(
FreeSpaceMap
->
arena
==
NULL
)
elog
(
FATAL
,
"Insufficient shared memory for free space map"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"insufficient shared memory for free space map"
)));
FreeSpaceMap
->
totalChunks
=
nchunks
;
FreeSpaceMap
->
totalChunks
=
nchunks
;
FreeSpaceMap
->
usedChunks
=
0
;
FreeSpaceMap
->
usedChunks
=
0
;
...
@@ -321,7 +329,9 @@ FreeSpaceShmemSize(void)
...
@@ -321,7 +329,9 @@ FreeSpaceShmemSize(void)
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
if
(
nchunks
>=
(
INT_MAX
/
CHUNKBYTES
))
if
(
nchunks
>=
(
INT_MAX
/
CHUNKBYTES
))
elog
(
FATAL
,
"max_fsm_pages is too large"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"max_fsm_pages is too large"
)));
size
+=
MAXALIGN
(
nchunks
*
CHUNKBYTES
);
size
+=
MAXALIGN
(
nchunks
*
CHUNKBYTES
);
...
@@ -491,7 +501,7 @@ RecordRelationFreeSpace(RelFileNode *rel,
...
@@ -491,7 +501,7 @@ RecordRelationFreeSpace(RelFileNode *rel,
/* Check caller provides sorted data */
/* Check caller provides sorted data */
if
(
i
>
0
&&
page
<=
pageSpaces
[
i
-
1
].
blkno
)
if
(
i
>
0
&&
page
<=
pageSpaces
[
i
-
1
].
blkno
)
elog
(
ERROR
,
"
RecordRelationFreeSpace: data
not in page order"
);
elog
(
ERROR
,
"
free-space data is
not in page order"
);
FSMPageSetPageNum
(
newLocation
,
page
);
FSMPageSetPageNum
(
newLocation
,
page
);
FSMPageSetSpace
(
newLocation
,
avail
);
FSMPageSetSpace
(
newLocation
,
avail
);
newLocation
++
;
newLocation
++
;
...
@@ -578,7 +588,7 @@ RecordIndexFreeSpace(RelFileNode *rel,
...
@@ -578,7 +588,7 @@ RecordIndexFreeSpace(RelFileNode *rel,
/* Check caller provides sorted data */
/* Check caller provides sorted data */
if
(
i
>
0
&&
page
<=
pages
[
i
-
1
])
if
(
i
>
0
&&
page
<=
pages
[
i
-
1
])
elog
(
ERROR
,
"
RecordIndexFreeSpace: data
not in page order"
);
elog
(
ERROR
,
"
free-space data is
not in page order"
);
IndexFSMPageSetPageNum
(
newLocation
,
page
);
IndexFSMPageSetPageNum
(
newLocation
,
page
);
newLocation
++
;
newLocation
++
;
}
}
...
@@ -660,7 +670,7 @@ FreeSpaceMapForgetDatabase(Oid dbid)
...
@@ -660,7 +670,7 @@ FreeSpaceMapForgetDatabase(Oid dbid)
/*
/*
* PrintFreeSpaceMapStatistics - print statistics about FSM contents
* PrintFreeSpaceMapStatistics - print statistics about FSM contents
*
*
* The info is sent to e
log
() with the specified message level. This is
* The info is sent to e
report
() with the specified message level. This is
* intended for use during VACUUM.
* intended for use during VACUUM.
*/
*/
void
void
...
@@ -688,11 +698,12 @@ PrintFreeSpaceMapStatistics(int elevel)
...
@@ -688,11 +698,12 @@ PrintFreeSpaceMapStatistics(int elevel)
/* Convert stats to actual number of page slots needed */
/* Convert stats to actual number of page slots needed */
needed
=
(
sumRequests
+
numRels
)
*
CHUNKPAGES
;
needed
=
(
sumRequests
+
numRels
)
*
CHUNKPAGES
;
elog
(
elevel
,
"Free space map: %d relations, %d pages stored; %.0f total pages needed."
ereport
(
elevel
,
"
\n\t
Allocated FSM size: %d relations + %d pages = %.0f KB shared mem."
,
(
errmsg
(
"free space map: %d relations, %d pages stored; %.0f total pages needed"
,
numRels
,
storedPages
,
needed
,
numRels
,
storedPages
,
needed
),
MaxFSMRelations
,
MaxFSMPages
,
errdetail
(
"Allocated FSM size: %d relations + %d pages = %.0f KB shared mem."
,
(
double
)
FreeSpaceShmemSize
()
/
1024
.
0
);
MaxFSMRelations
,
MaxFSMPages
,
(
double
)
FreeSpaceShmemSize
()
/
1024
.
0
)));
}
}
/*
/*
...
@@ -719,7 +730,7 @@ DumpFreeSpaceMap(void)
...
@@ -719,7 +730,7 @@ DumpFreeSpaceMap(void)
fp
=
AllocateFile
(
cachefilename
,
PG_BINARY_W
);
fp
=
AllocateFile
(
cachefilename
,
PG_BINARY_W
);
if
(
fp
==
NULL
)
if
(
fp
==
NULL
)
{
{
elog
(
LOG
,
"
Failed to write %s
: %m"
,
cachefilename
);
elog
(
LOG
,
"
could not write
\"
%s
\"
: %m"
,
cachefilename
);
return
;
return
;
}
}
...
@@ -778,7 +789,7 @@ DumpFreeSpaceMap(void)
...
@@ -778,7 +789,7 @@ DumpFreeSpaceMap(void)
return
;
return
;
write_failed:
write_failed:
elog
(
LOG
,
"
Failed to write %s
: %m"
,
cachefilename
);
elog
(
LOG
,
"
could not write
\"
%s
\"
: %m"
,
cachefilename
);
/* Clean up */
/* Clean up */
LWLockRelease
(
FreeSpaceLock
);
LWLockRelease
(
FreeSpaceLock
);
...
@@ -819,7 +830,7 @@ LoadFreeSpaceMap(void)
...
@@ -819,7 +830,7 @@ LoadFreeSpaceMap(void)
if
(
fp
==
NULL
)
if
(
fp
==
NULL
)
{
{
if
(
errno
!=
ENOENT
)
if
(
errno
!=
ENOENT
)
elog
(
LOG
,
"
Failed to read %s
: %m"
,
cachefilename
);
elog
(
LOG
,
"
could not read
\"
%s
\"
: %m"
,
cachefilename
);
return
;
return
;
}
}
...
@@ -832,7 +843,7 @@ LoadFreeSpaceMap(void)
...
@@ -832,7 +843,7 @@ LoadFreeSpaceMap(void)
header
.
version
!=
FSM_CACHE_VERSION
||
header
.
version
!=
FSM_CACHE_VERSION
||
header
.
numRels
<
0
)
header
.
numRels
<
0
)
{
{
elog
(
LOG
,
"
Bogus file header in %s
"
,
cachefilename
);
elog
(
LOG
,
"
bogus file header in
\"
%s
\"
"
,
cachefilename
);
goto
read_failed
;
goto
read_failed
;
}
}
...
@@ -854,7 +865,7 @@ LoadFreeSpaceMap(void)
...
@@ -854,7 +865,7 @@ LoadFreeSpaceMap(void)
relheader
.
lastPageCount
<
0
||
relheader
.
lastPageCount
<
0
||
relheader
.
storedPages
<
0
)
relheader
.
storedPages
<
0
)
{
{
elog
(
LOG
,
"
Bogus rel header in %s
"
,
cachefilename
);
elog
(
LOG
,
"
bogus rel header in
\"
%s
\"
"
,
cachefilename
);
goto
read_failed
;
goto
read_failed
;
}
}
...
@@ -871,7 +882,7 @@ LoadFreeSpaceMap(void)
...
@@ -871,7 +882,7 @@ LoadFreeSpaceMap(void)
data
=
(
char
*
)
palloc
(
len
+
1
);
/* +1 to avoid palloc(0) */
data
=
(
char
*
)
palloc
(
len
+
1
);
/* +1 to avoid palloc(0) */
if
(
fread
(
data
,
1
,
len
,
fp
)
!=
len
)
if
(
fread
(
data
,
1
,
len
,
fp
)
!=
len
)
{
{
elog
(
LOG
,
"
Premature EOF in %s
"
,
cachefilename
);
elog
(
LOG
,
"
premature EOF in
\"
%s
\"
"
,
cachefilename
);
pfree
(
data
);
pfree
(
data
);
goto
read_failed
;
goto
read_failed
;
}
}
...
@@ -984,7 +995,9 @@ create_fsm_rel(RelFileNode *rel)
...
@@ -984,7 +995,9 @@ create_fsm_rel(RelFileNode *rel)
HASH_ENTER
,
HASH_ENTER
,
&
found
);
&
found
);
if
(
!
fsmrel
)
if
(
!
fsmrel
)
elog
(
ERROR
,
"FreeSpaceMap hashtable out of memory"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of shared memory"
)));
if
(
!
found
)
if
(
!
found
)
{
{
...
@@ -1182,7 +1195,7 @@ find_free_space(FSMRelation *fsmrel, Size spaceNeeded)
...
@@ -1182,7 +1195,7 @@ find_free_space(FSMRelation *fsmrel, Size spaceNeeded)
pageIndex
;
/* current page index */
pageIndex
;
/* current page index */
if
(
fsmrel
->
isIndex
)
if
(
fsmrel
->
isIndex
)
elog
(
ERROR
,
"find_free_space
:
called for an index relation"
);
elog
(
ERROR
,
"find_free_space called for an index relation"
);
info
=
(
FSMPageData
*
)
info
=
(
FSMPageData
*
)
(
FreeSpaceMap
->
arena
+
fsmrel
->
firstChunk
*
CHUNKBYTES
);
(
FreeSpaceMap
->
arena
+
fsmrel
->
firstChunk
*
CHUNKBYTES
);
pageIndex
=
fsmrel
->
nextPage
;
pageIndex
=
fsmrel
->
nextPage
;
...
@@ -1232,7 +1245,7 @@ find_index_free_space(FSMRelation *fsmrel)
...
@@ -1232,7 +1245,7 @@ find_index_free_space(FSMRelation *fsmrel)
{
{
if
(
fsmrel
->
storedPages
==
0
)
if
(
fsmrel
->
storedPages
==
0
)
return
InvalidBlockNumber
;
return
InvalidBlockNumber
;
elog
(
ERROR
,
"find_index_free_space
:
called for a non-index relation"
);
elog
(
ERROR
,
"find_index_free_space called for a non-index relation"
);
}
}
/*
/*
* For indexes, there's no need for the nextPage state variable; we just
* For indexes, there's no need for the nextPage state variable; we just
...
@@ -1260,7 +1273,7 @@ fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail)
...
@@ -1260,7 +1273,7 @@ fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail)
int
pageIndex
;
int
pageIndex
;
if
(
fsmrel
->
isIndex
)
if
(
fsmrel
->
isIndex
)
elog
(
ERROR
,
"fsm_record_free_space
:
called for an index relation"
);
elog
(
ERROR
,
"fsm_record_free_space called for an index relation"
);
if
(
lookup_fsm_page_entry
(
fsmrel
,
page
,
&
pageIndex
))
if
(
lookup_fsm_page_entry
(
fsmrel
,
page
,
&
pageIndex
))
{
{
/* Found an existing entry for page; update it */
/* Found an existing entry for page; update it */
...
@@ -1420,7 +1433,7 @@ compact_fsm_storage(void)
...
@@ -1420,7 +1433,7 @@ compact_fsm_storage(void)
int
limitChunkIndex
;
int
limitChunkIndex
;
if
(
newAllocPages
<
fsmrel
->
storedPages
)
if
(
newAllocPages
<
fsmrel
->
storedPages
)
elog
(
PANIC
,
"c
ompact_fsm_storage: c
an't juggle and compress too"
);
elog
(
PANIC
,
"can't juggle and compress too"
);
if
(
fsmrel
->
nextPhysical
!=
NULL
)
if
(
fsmrel
->
nextPhysical
!=
NULL
)
limitChunkIndex
=
fsmrel
->
nextPhysical
->
firstChunk
;
limitChunkIndex
=
fsmrel
->
nextPhysical
->
firstChunk
;
else
else
...
@@ -1435,7 +1448,7 @@ compact_fsm_storage(void)
...
@@ -1435,7 +1448,7 @@ compact_fsm_storage(void)
else
else
limitChunkIndex
=
FreeSpaceMap
->
totalChunks
;
limitChunkIndex
=
FreeSpaceMap
->
totalChunks
;
if
(
newChunkIndex
+
curChunks
>
limitChunkIndex
)
if
(
newChunkIndex
+
curChunks
>
limitChunkIndex
)
elog
(
PANIC
,
"
compact_fsm_storage:
insufficient room"
);
elog
(
PANIC
,
"insufficient room"
);
}
}
memmove
(
newLocation
,
oldLocation
,
curChunks
*
CHUNKBYTES
);
memmove
(
newLocation
,
oldLocation
,
curChunks
*
CHUNKBYTES
);
}
}
...
@@ -1511,7 +1524,7 @@ push_fsm_rels_after(FSMRelation *afterRel)
...
@@ -1511,7 +1524,7 @@ push_fsm_rels_after(FSMRelation *afterRel)
if
(
newChunkIndex
<
oldChunkIndex
)
if
(
newChunkIndex
<
oldChunkIndex
)
{
{
/* trouble... */
/* trouble... */
elog
(
PANIC
,
"
push_fsm_rels_after:
out of room"
);
elog
(
PANIC
,
"out of room"
);
}
}
else
if
(
newChunkIndex
>
oldChunkIndex
)
else
if
(
newChunkIndex
>
oldChunkIndex
)
{
{
...
@@ -1554,7 +1567,7 @@ pack_incoming_pages(FSMPageData *newLocation, int newPages,
...
@@ -1554,7 +1567,7 @@ pack_incoming_pages(FSMPageData *newLocation, int newPages,
Size
avail
=
pageSpaces
[
i
].
avail
;
Size
avail
=
pageSpaces
[
i
].
avail
;
if
(
avail
>=
BLCKSZ
)
if
(
avail
>=
BLCKSZ
)
elog
(
ERROR
,
"
pack_incoming_pages:
bogus freespace amount"
);
elog
(
ERROR
,
"bogus freespace amount"
);
avail
/=
(
BLCKSZ
/
HISTOGRAM_BINS
);
avail
/=
(
BLCKSZ
/
HISTOGRAM_BINS
);
histogram
[
avail
]
++
;
histogram
[
avail
]
++
;
}
}
...
@@ -1580,7 +1593,7 @@ pack_incoming_pages(FSMPageData *newLocation, int newPages,
...
@@ -1580,7 +1593,7 @@ pack_incoming_pages(FSMPageData *newLocation, int newPages,
/* Check caller provides sorted data */
/* Check caller provides sorted data */
if
(
i
>
0
&&
page
<=
pageSpaces
[
i
-
1
].
blkno
)
if
(
i
>
0
&&
page
<=
pageSpaces
[
i
-
1
].
blkno
)
elog
(
ERROR
,
"
RecordIndexFreeSpace: data
not in page order"
);
elog
(
ERROR
,
"
free-space data is
not in page order"
);
/* Save this page? */
/* Save this page? */
if
(
avail
>=
thresholdU
||
if
(
avail
>=
thresholdU
||
(
avail
>=
thresholdL
&&
(
--
binct
>=
0
)))
(
avail
>=
thresholdL
&&
(
--
binct
>=
0
)))
...
@@ -1625,7 +1638,7 @@ pack_existing_pages(FSMPageData *newLocation, int newPages,
...
@@ -1625,7 +1638,7 @@ pack_existing_pages(FSMPageData *newLocation, int newPages,
/* Shouldn't happen, but test to protect against stack clobber */
/* Shouldn't happen, but test to protect against stack clobber */
if
(
avail
>=
BLCKSZ
)
if
(
avail
>=
BLCKSZ
)
elog
(
ERROR
,
"
pack_existing_pages:
bogus freespace amount"
);
elog
(
ERROR
,
"bogus freespace amount"
);
avail
/=
(
BLCKSZ
/
HISTOGRAM_BINS
);
avail
/=
(
BLCKSZ
/
HISTOGRAM_BINS
);
histogram
[
avail
]
++
;
histogram
[
avail
]
++
;
}
}
...
...
src/backend/storage/ipc/README
View file @
cfa191f3
$Header: /cvsroot/pgsql/src/backend/storage/ipc/README,v 1.
2 2002/09/20 03:53:55 momjian
Exp $
$Header: /cvsroot/pgsql/src/backend/storage/ipc/README,v 1.
3 2003/07/24 22:04:09 tgl
Exp $
Mon Jul 18 11:09:22 PDT 1988 W.KLAS
Mon Jul 18 11:09:22 PDT 1988 W.KLAS
Cache invalidation synchronization routines:
Cache invalidation synchronization routines:
...
@@ -9,23 +9,9 @@ backend can register a message which then has to be read by
...
@@ -9,23 +9,9 @@ backend can register a message which then has to be read by
all backends. A message read by all backends is removed from the
all backends. A message read by all backends is removed from the
queue automatically. If a message has been lost because the buffer
queue automatically. If a message has been lost because the buffer
was full, all backends that haven't read this message will be
was full, all backends that haven't read this message will be
notice
d that they have to reset their cache state. This is done
tol
d that they have to reset their cache state. This is done
at the time when they try to read the message queue.
at the time when they try to read the message queue.
The message queue is implemented as a shared buffer segment. Actually,
The message queue is implemented as a shared buffer segment. Actually,
the queue is a circle to allow fast inserting, reading (invalidate data) and
the queue is a circle to allow fast inserting, reading (invalidate data) and
maintaining the buffer.
maintaining the buffer.
Access to this shared message buffer is synchronized by the lock manager.
The lock manager treats the buffer as a regular relation and sets
relation level locks (with mode = LockWait) to block backends while
another backend is writing or reading the buffer. The identifiers used
for this special 'relation' are database id = 0 and relation id = 0.
The current implementation prints regular (e)log information
when a message has been removed from the buffer because the buffer
is full, and a backend has to reset its cache state. The elog level
is NOTICE. This can be used to improve the behavior of backends
when invalidating or resetting their cache state.
src/backend/storage/ipc/ipc.c
View file @
cfa191f3
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.8
2 2003/05/27 17:49:46 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.8
3 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
/*
/*
* This flag is set during proc_exit() to change e
log
()'s behavior,
* This flag is set during proc_exit() to change e
report
()'s behavior,
* so that an e
log
() from an on_proc_exit routine cannot get us out
* so that an e
report
() from an on_proc_exit routine cannot get us out
* of the exit procedure. We do NOT want to go back to the idle loop...
* of the exit procedure. We do NOT want to go back to the idle loop...
*/
*/
bool
proc_exit_inprogress
=
false
;
bool
proc_exit_inprogress
=
false
;
...
@@ -74,7 +74,7 @@ void
...
@@ -74,7 +74,7 @@ void
proc_exit
(
int
code
)
proc_exit
(
int
code
)
{
{
/*
/*
* Once we set this flag, we are committed to exit. Any e
log
() will
* Once we set this flag, we are committed to exit. Any e
report
() will
* NOT send control back to the main loop, but right back here.
* NOT send control back to the main loop, but right back here.
*/
*/
proc_exit_inprogress
=
true
;
proc_exit_inprogress
=
true
;
...
@@ -101,8 +101,8 @@ proc_exit(int code)
...
@@ -101,8 +101,8 @@ proc_exit(int code)
* call all the callbacks registered before calling exit().
* call all the callbacks registered before calling exit().
*
*
* Note that since we decrement on_proc_exit_index each time, if a
* Note that since we decrement on_proc_exit_index each time, if a
* callback calls e
log(ERROR) or elog(FATAL) then it won't be invoked
* callback calls e
report(ERROR) or ereport(FATAL) then it won't be
* again when control comes back here (nor will the
*
invoked
again when control comes back here (nor will the
* previously-completed callbacks). So, an infinite loop should not
* previously-completed callbacks). So, an infinite loop should not
* be possible.
* be possible.
*/
*/
...
@@ -149,7 +149,9 @@ void
...
@@ -149,7 +149,9 @@ void
on_proc_exit
(
void
(
*
function
)
(),
Datum
arg
)
on_proc_exit
(
void
(
*
function
)
(),
Datum
arg
)
{
{
if
(
on_proc_exit_index
>=
MAX_ON_EXITS
)
if
(
on_proc_exit_index
>=
MAX_ON_EXITS
)
elog
(
FATAL
,
"Out of on_proc_exit slots"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg_internal
(
"out of on_proc_exit slots"
)));
on_proc_exit_list
[
on_proc_exit_index
].
function
=
function
;
on_proc_exit_list
[
on_proc_exit_index
].
function
=
function
;
on_proc_exit_list
[
on_proc_exit_index
].
arg
=
arg
;
on_proc_exit_list
[
on_proc_exit_index
].
arg
=
arg
;
...
@@ -168,7 +170,9 @@ void
...
@@ -168,7 +170,9 @@ void
on_shmem_exit
(
void
(
*
function
)
(),
Datum
arg
)
on_shmem_exit
(
void
(
*
function
)
(),
Datum
arg
)
{
{
if
(
on_shmem_exit_index
>=
MAX_ON_EXITS
)
if
(
on_shmem_exit_index
>=
MAX_ON_EXITS
)
elog
(
FATAL
,
"Out of on_shmem_exit slots"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg_internal
(
"out of on_shmem_exit slots"
)));
on_shmem_exit_list
[
on_shmem_exit_index
].
function
=
function
;
on_shmem_exit_list
[
on_shmem_exit_index
].
function
=
function
;
on_shmem_exit_list
[
on_shmem_exit_index
].
arg
=
arg
;
on_shmem_exit_list
[
on_shmem_exit_index
].
arg
=
arg
;
...
...
src/backend/storage/ipc/ipci.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.5
3 2003/05/27 17:49:46 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.5
4 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -112,7 +112,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
...
@@ -112,7 +112,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
*/
*/
InitLocks
();
InitLocks
();
if
(
InitLockTable
(
maxBackends
)
==
INVALID_TABLEID
)
if
(
InitLockTable
(
maxBackends
)
==
INVALID_TABLEID
)
elog
(
FATAL
,
"
Couldn'
t create the lock table"
);
elog
(
FATAL
,
"
could no
t create the lock table"
);
/*
/*
* Set up process table
* Set up process table
...
...
src/backend/storage/ipc/shmem.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6
8 2003/05/06 23:34:55 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6
9 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -158,7 +158,9 @@ ShmemAlloc(Size size)
...
@@ -158,7 +158,9 @@ ShmemAlloc(Size size)
SpinLockRelease
(
ShmemLock
);
SpinLockRelease
(
ShmemLock
);
if
(
!
newSpace
)
if
(
!
newSpace
)
elog
(
WARNING
,
"ShmemAlloc: out of memory"
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
return
newSpace
;
return
newSpace
;
}
}
...
@@ -204,7 +206,7 @@ InitShmemIndex(void)
...
@@ -204,7 +206,7 @@ InitShmemIndex(void)
SHMEM_INDEX_SIZE
,
SHMEM_INDEX_SIZE
,
SHMEM_INDEX_SIZE
,
SHMEM_INDEX_SIZE
,
&
info
,
hash_flags
);
&
info
,
hash_flags
);
if
(
!
ShmemIndex
)
if
(
!
ShmemIndex
)
elog
(
FATAL
,
"
InitShmemIndex: couldn'
t initialize Shmem Index"
);
elog
(
FATAL
,
"
could no
t initialize Shmem Index"
);
/*
/*
* Now, create an entry in the hashtable for the index itself.
* Now, create an entry in the hashtable for the index itself.
...
@@ -215,7 +217,9 @@ InitShmemIndex(void)
...
@@ -215,7 +217,9 @@ InitShmemIndex(void)
result
=
(
ShmemIndexEnt
*
)
result
=
(
ShmemIndexEnt
*
)
hash_search
(
ShmemIndex
,
(
void
*
)
&
item
,
HASH_ENTER
,
&
found
);
hash_search
(
ShmemIndex
,
(
void
*
)
&
item
,
HASH_ENTER
,
&
found
);
if
(
!
result
)
if
(
!
result
)
elog
(
FATAL
,
"InitShmemIndex: Shmem Index out of memory"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
Assert
(
ShmemBootstrap
&&
!
found
);
Assert
(
ShmemBootstrap
&&
!
found
);
...
@@ -333,7 +337,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
...
@@ -333,7 +337,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
if
(
!
result
)
if
(
!
result
)
{
{
LWLockRelease
(
ShmemIndexLock
);
LWLockRelease
(
ShmemIndexLock
);
elog
(
ERROR
,
"ShmemInitStruct: Shmem Index out of memory"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
return
NULL
;
return
NULL
;
}
}
...
@@ -348,7 +354,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
...
@@ -348,7 +354,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
{
LWLockRelease
(
ShmemIndexLock
);
LWLockRelease
(
ShmemIndexLock
);
elog
(
WARNING
,
"ShmemIn
itStruct: ShmemIn
dex entry size is wrong"
);
elog
(
WARNING
,
"ShmemIndex entry size is wrong"
);
/* let caller print its message too */
/* let caller print its message too */
return
NULL
;
return
NULL
;
}
}
...
@@ -365,7 +371,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
...
@@ -365,7 +371,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
hash_search
(
ShmemIndex
,
(
void
*
)
&
item
,
HASH_REMOVE
,
NULL
);
hash_search
(
ShmemIndex
,
(
void
*
)
&
item
,
HASH_REMOVE
,
NULL
);
LWLockRelease
(
ShmemIndexLock
);
LWLockRelease
(
ShmemIndexLock
);
elog
(
WARNING
,
"ShmemInitStruct: cannot allocate '%s'"
,
name
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"could not allocate
\"
%s
\"
"
,
name
)));
*
foundPtr
=
FALSE
;
*
foundPtr
=
FALSE
;
return
NULL
;
return
NULL
;
}
}
...
...
src/backend/storage/ipc/sinval.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.5
6 2003/06/12 01:42:19 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.5
7 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -47,9 +47,11 @@ InitBackendSharedInvalidationState(void)
...
@@ -47,9 +47,11 @@ InitBackendSharedInvalidationState(void)
flag
=
SIBackendInit
(
shmInvalBuffer
);
flag
=
SIBackendInit
(
shmInvalBuffer
);
LWLockRelease
(
SInvalLock
);
LWLockRelease
(
SInvalLock
);
if
(
flag
<
0
)
/* unexpected problem */
if
(
flag
<
0
)
/* unexpected problem */
elog
(
FATAL
,
"
Backen
d cache invalidation initialization failed"
);
elog
(
FATAL
,
"
share
d cache invalidation initialization failed"
);
if
(
flag
==
0
)
/* expected problem: MaxBackends exceeded */
if
(
flag
==
0
)
/* expected problem: MaxBackends exceeded */
elog
(
FATAL
,
"Sorry, too many clients already"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_TOO_MANY_CONNECTIONS
),
errmsg
(
"sorry, too many clients already"
)));
}
}
/*
/*
...
@@ -65,7 +67,7 @@ SendSharedInvalidMessage(SharedInvalidationMessage *msg)
...
@@ -65,7 +67,7 @@ SendSharedInvalidMessage(SharedInvalidationMessage *msg)
insertOK
=
SIInsertDataEntry
(
shmInvalBuffer
,
msg
);
insertOK
=
SIInsertDataEntry
(
shmInvalBuffer
,
msg
);
LWLockRelease
(
SInvalLock
);
LWLockRelease
(
SInvalLock
);
if
(
!
insertOK
)
if
(
!
insertOK
)
elog
(
DEBUG4
,
"S
endSharedInvalidMessage: S
I buffer overflow"
);
elog
(
DEBUG4
,
"SI buffer overflow"
);
}
}
/*
/*
...
@@ -108,7 +110,7 @@ ReceiveSharedInvalidMessages(
...
@@ -108,7 +110,7 @@ ReceiveSharedInvalidMessages(
if
(
getResult
<
0
)
if
(
getResult
<
0
)
{
{
/* got a reset message */
/* got a reset message */
elog
(
DEBUG4
,
"
ReceiveSharedInvalidMessages:
cache state reset"
);
elog
(
DEBUG4
,
"cache state reset"
);
resetFunction
();
resetFunction
();
}
}
else
else
...
@@ -336,7 +338,9 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
...
@@ -336,7 +338,9 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
snapshot
->
xip
=
(
TransactionId
*
)
snapshot
->
xip
=
(
TransactionId
*
)
malloc
(
MaxBackends
*
sizeof
(
TransactionId
));
malloc
(
MaxBackends
*
sizeof
(
TransactionId
));
if
(
snapshot
->
xip
==
NULL
)
if
(
snapshot
->
xip
==
NULL
)
elog
(
ERROR
,
"Memory exhausted in GetSnapshotData"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
}
}
globalxmin
=
xmin
=
GetCurrentTransactionId
();
globalxmin
=
xmin
=
GetCurrentTransactionId
();
...
...
src/backend/storage/ipc/sinvaladt.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.5
0 2003/05/27 17:49:46 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.5
1 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -121,7 +121,7 @@ SIBackendInit(SISeg *segP)
...
@@ -121,7 +121,7 @@ SIBackendInit(SISeg *segP)
MyBackendId
=
(
stateP
-
&
segP
->
procState
[
0
])
+
1
;
MyBackendId
=
(
stateP
-
&
segP
->
procState
[
0
])
+
1
;
#ifdef INVALIDDEBUG
#ifdef INVALIDDEBUG
elog
(
DEBUG2
,
"
SIBackendInit: backend id
%d"
,
MyBackendId
);
elog
(
DEBUG2
,
"
my backend id is
%d"
,
MyBackendId
);
#endif
/* INVALIDDEBUG */
#endif
/* INVALIDDEBUG */
/* Reduce free slot count */
/* Reduce free slot count */
...
@@ -226,7 +226,7 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data)
...
@@ -226,7 +226,7 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data)
if
(
numMsgs
==
(
MAXNUMMESSAGES
*
70
/
100
)
&&
if
(
numMsgs
==
(
MAXNUMMESSAGES
*
70
/
100
)
&&
IsUnderPostmaster
)
IsUnderPostmaster
)
{
{
elog
(
DEBUG4
,
"SI
InsertDataEntry:
table is 70%% full, signaling postmaster"
);
elog
(
DEBUG4
,
"SI table is 70%% full, signaling postmaster"
);
SendPostmasterSignal
(
PMSIGNAL_WAKEN_CHILDREN
);
SendPostmasterSignal
(
PMSIGNAL_WAKEN_CHILDREN
);
}
}
...
...
src/backend/storage/large_object/inv_api.c
View file @
cfa191f3
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.9
6 2002/09/02 02:47:03 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.9
7 2003/07/24 22:04:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,7 +45,7 @@ getbytealen(bytea *data)
...
@@ -45,7 +45,7 @@ getbytealen(bytea *data)
{
{
Assert
(
!
VARATT_IS_EXTENDED
(
data
));
Assert
(
!
VARATT_IS_EXTENDED
(
data
));
if
(
VARSIZE
(
data
)
<
VARHDRSZ
)
if
(
VARSIZE
(
data
)
<
VARHDRSZ
)
elog
(
ERROR
,
"
getbytealen: VARSIZE(data) < VARHDRSZ. This is internal error.
"
);
elog
(
ERROR
,
"
invalid VARSIZE(data)
"
);
return
(
VARSIZE
(
data
)
-
VARHDRSZ
);
return
(
VARSIZE
(
data
)
-
VARHDRSZ
);
}
}
...
@@ -71,7 +71,7 @@ inv_create(int flags)
...
@@ -71,7 +71,7 @@ inv_create(int flags)
/* Check for duplicate (shouldn't happen) */
/* Check for duplicate (shouldn't happen) */
if
(
LargeObjectExists
(
file_oid
))
if
(
LargeObjectExists
(
file_oid
))
elog
(
ERROR
,
"
inv_create: large object %u already exists. This is internal error.
"
,
file_oid
);
elog
(
ERROR
,
"
large object %u already exists
"
,
file_oid
);
/*
/*
* Create the LO by writing an empty first page for it in
* Create the LO by writing an empty first page for it in
...
@@ -104,7 +104,7 @@ inv_create(int flags)
...
@@ -104,7 +104,7 @@ inv_create(int flags)
retval
->
heap_r
=
heap_openr
(
LargeObjectRelationName
,
AccessShareLock
);
retval
->
heap_r
=
heap_openr
(
LargeObjectRelationName
,
AccessShareLock
);
}
}
else
else
elog
(
ERROR
,
"inv
_create: inv
alid flags: %d"
,
flags
);
elog
(
ERROR
,
"invalid flags: %d"
,
flags
);
retval
->
index_r
=
index_openr
(
LargeObjectLOidPNIndex
);
retval
->
index_r
=
index_openr
(
LargeObjectLOidPNIndex
);
...
@@ -123,7 +123,9 @@ inv_open(Oid lobjId, int flags)
...
@@ -123,7 +123,9 @@ inv_open(Oid lobjId, int flags)
LargeObjectDesc
*
retval
;
LargeObjectDesc
*
retval
;
if
(
!
LargeObjectExists
(
lobjId
))
if
(
!
LargeObjectExists
(
lobjId
))
elog
(
ERROR
,
"inv_open: large object %u not found"
,
lobjId
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"large object %u does not exist"
,
lobjId
)));
retval
=
(
LargeObjectDesc
*
)
palloc
(
sizeof
(
LargeObjectDesc
));
retval
=
(
LargeObjectDesc
*
)
palloc
(
sizeof
(
LargeObjectDesc
));
...
@@ -141,7 +143,7 @@ inv_open(Oid lobjId, int flags)
...
@@ -141,7 +143,7 @@ inv_open(Oid lobjId, int flags)
retval
->
heap_r
=
heap_openr
(
LargeObjectRelationName
,
AccessShareLock
);
retval
->
heap_r
=
heap_openr
(
LargeObjectRelationName
,
AccessShareLock
);
}
}
else
else
elog
(
ERROR
,
"inv
_open: inv
alid flags: %d"
,
flags
);
elog
(
ERROR
,
"invalid flags: %d"
,
flags
);
retval
->
index_r
=
index_openr
(
LargeObjectLOidPNIndex
);
retval
->
index_r
=
index_openr
(
LargeObjectLOidPNIndex
);
...
@@ -241,7 +243,9 @@ inv_getsize(LargeObjectDesc *obj_desc)
...
@@ -241,7 +243,9 @@ inv_getsize(LargeObjectDesc *obj_desc)
index_endscan
(
sd
);
index_endscan
(
sd
);
if
(
!
found
)
if
(
!
found
)
elog
(
ERROR
,
"inv_getsize: large object %u not found"
,
obj_desc
->
id
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"large object %u does not exist"
,
obj_desc
->
id
)));
return
lastbyte
;
return
lastbyte
;
}
}
...
@@ -254,12 +258,12 @@ inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
...
@@ -254,12 +258,12 @@ inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
{
{
case
SEEK_SET
:
case
SEEK_SET
:
if
(
offset
<
0
)
if
(
offset
<
0
)
elog
(
ERROR
,
"inv
_seek: invalid
offset: %d"
,
offset
);
elog
(
ERROR
,
"inv
alid seek
offset: %d"
,
offset
);
obj_desc
->
offset
=
offset
;
obj_desc
->
offset
=
offset
;
break
;
break
;
case
SEEK_CUR
:
case
SEEK_CUR
:
if
(
offset
<
0
&&
obj_desc
->
offset
<
((
uint32
)
(
-
offset
)))
if
(
offset
<
0
&&
obj_desc
->
offset
<
((
uint32
)
(
-
offset
)))
elog
(
ERROR
,
"inv
_seek: invalid
offset: %d"
,
offset
);
elog
(
ERROR
,
"inv
alid seek
offset: %d"
,
offset
);
obj_desc
->
offset
+=
offset
;
obj_desc
->
offset
+=
offset
;
break
;
break
;
case
SEEK_END
:
case
SEEK_END
:
...
@@ -267,12 +271,12 @@ inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
...
@@ -267,12 +271,12 @@ inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
uint32
size
=
inv_getsize
(
obj_desc
);
uint32
size
=
inv_getsize
(
obj_desc
);
if
(
offset
<
0
&&
size
<
((
uint32
)
(
-
offset
)))
if
(
offset
<
0
&&
size
<
((
uint32
)
(
-
offset
)))
elog
(
ERROR
,
"inv
_seek: invalid
offset: %d"
,
offset
);
elog
(
ERROR
,
"inv
alid seek
offset: %d"
,
offset
);
obj_desc
->
offset
=
size
+
offset
;
obj_desc
->
offset
=
size
+
offset
;
}
}
break
;
break
;
default:
default:
elog
(
ERROR
,
"inv
_seek: inv
alid whence: %d"
,
whence
);
elog
(
ERROR
,
"invalid whence: %d"
,
whence
);
}
}
return
obj_desc
->
offset
;
return
obj_desc
->
offset
;
}
}
...
...
src/backend/storage/lmgr/deadlock.c
View file @
cfa191f3
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.2
0 2003/03/31 20:32:29
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.2
1 2003/07/24 22:04:13
tgl Exp $
*
*
* Interface:
* Interface:
*
*
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "miscadmin.h"
#include "storage/proc.h"
#include "storage/proc.h"
#include "utils/memutils.h"
#include "utils/memutils.h"
...
@@ -224,7 +225,7 @@ DeadLockCheck(PGPROC *proc)
...
@@ -224,7 +225,7 @@ DeadLockCheck(PGPROC *proc)
nWaitOrders
=
0
;
nWaitOrders
=
0
;
if
(
!
FindLockCycle
(
proc
,
possibleConstraints
,
&
nSoftEdges
))
if
(
!
FindLockCycle
(
proc
,
possibleConstraints
,
&
nSoftEdges
))
elog
(
FATAL
,
"
DeadLockCheck:
deadlock seems to have disappeared"
);
elog
(
FATAL
,
"deadlock seems to have disappeared"
);
return
true
;
/* cannot find a non-deadlocked state */
return
true
;
/* cannot find a non-deadlocked state */
}
}
...
@@ -309,7 +310,7 @@ DeadLockCheckRecurse(PGPROC *proc)
...
@@ -309,7 +310,7 @@ DeadLockCheckRecurse(PGPROC *proc)
{
{
/* Regenerate the list of possible added constraints */
/* Regenerate the list of possible added constraints */
if
(
nEdges
!=
TestConfiguration
(
proc
))
if
(
nEdges
!=
TestConfiguration
(
proc
))
elog
(
FATAL
,
"
DeadLockCheckRecurse: inconsistent results
"
);
elog
(
FATAL
,
"
inconsistent results during deadlock check
"
);
}
}
curConstraints
[
nCurConstraints
]
=
curConstraints
[
nCurConstraints
]
=
possibleConstraints
[
oldPossibleConstraints
+
i
];
possibleConstraints
[
oldPossibleConstraints
+
i
];
...
@@ -837,13 +838,15 @@ PrintLockQueue(LOCK *lock, const char *info)
...
@@ -837,13 +838,15 @@ PrintLockQueue(LOCK *lock, const char *info)
#endif
#endif
/*
/*
* Report
details about a detected deadlock
.
* Report
a detected deadlock, with available details
.
*/
*/
void
void
DeadLockReport
(
void
)
DeadLockReport
(
void
)
{
{
StringInfoData
buf
;
int
i
;
int
i
;
initStringInfo
(
&
buf
);
for
(
i
=
0
;
i
<
nDeadlockDetails
;
i
++
)
for
(
i
=
0
;
i
<
nDeadlockDetails
;
i
++
)
{
{
DEADLOCK_INFO
*
info
=
&
deadlockDetails
[
i
];
DEADLOCK_INFO
*
info
=
&
deadlockDetails
[
i
];
...
@@ -855,26 +858,35 @@ DeadLockReport(void)
...
@@ -855,26 +858,35 @@ DeadLockReport(void)
else
else
nextpid
=
deadlockDetails
[
0
].
pid
;
nextpid
=
deadlockDetails
[
0
].
pid
;
if
(
i
>
0
)
appendStringInfoChar
(
&
buf
,
'\n'
);
if
(
info
->
locktag
.
relId
==
XactLockTableId
&&
info
->
locktag
.
dbId
==
0
)
if
(
info
->
locktag
.
relId
==
XactLockTableId
&&
info
->
locktag
.
dbId
==
0
)
{
{
/* Lock is for transaction ID */
/* Lock is for transaction ID */
elog
(
NOTICE
,
"Proc %d waits for %s on transaction %u; blocked by %d"
,
appendStringInfo
(
&
buf
,
info
->
pid
,
gettext
(
"Proc %d waits for %s on transaction %u; blocked by proc %d."
),
GetLockmodeName
(
info
->
lockmode
),
info
->
pid
,
info
->
locktag
.
objId
.
xid
,
GetLockmodeName
(
info
->
lockmode
),
nextpid
);
info
->
locktag
.
objId
.
xid
,
nextpid
);
}
}
else
else
{
{
/* Lock is for a relation */
/* Lock is for a relation */
elog
(
NOTICE
,
"Proc %d waits for %s on relation %u database %u; blocked by %d"
,
appendStringInfo
(
&
buf
,
info
->
pid
,
gettext
(
"Proc %d waits for %s on relation %u of database %u; blocked by proc %d."
),
GetLockmodeName
(
info
->
lockmode
),
info
->
pid
,
info
->
locktag
.
relId
,
GetLockmodeName
(
info
->
lockmode
),
info
->
locktag
.
dbId
,
info
->
locktag
.
relId
,
nextpid
);
info
->
locktag
.
dbId
,
nextpid
);
}
}
}
}
ereport
(
ERROR
,
(
errcode
(
ERRCODE_T_R_DEADLOCK_DETECTED
),
errmsg
(
"deadlock detected"
),
errdetail
(
"%s"
,
buf
.
data
)));
}
}
/*
/*
...
...
src/backend/storage/lmgr/lmgr.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.5
6 2003/02/19 23:41:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.5
7 2003/07/24 22:04:13 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -82,7 +82,7 @@ InitLockTable(int maxBackends)
...
@@ -82,7 +82,7 @@ InitLockTable(int maxBackends)
LockTableId
=
lockmethod
;
LockTableId
=
lockmethod
;
if
(
!
(
LockTableId
))
if
(
!
(
LockTableId
))
elog
(
ERROR
,
"
InitLockTable: couldn'
t initialize lock table"
);
elog
(
ERROR
,
"
could no
t initialize lock table"
);
#ifdef USER_LOCKS
#ifdef USER_LOCKS
...
@@ -91,7 +91,7 @@ InitLockTable(int maxBackends)
...
@@ -91,7 +91,7 @@ InitLockTable(int maxBackends)
*/
*/
LongTermTableId
=
LockMethodTableRename
(
LockTableId
);
LongTermTableId
=
LockMethodTableRename
(
LockTableId
);
if
(
!
(
LongTermTableId
))
if
(
!
(
LongTermTableId
))
elog
(
ERROR
,
"
InitLockTable: couldn'
t rename long-term lock table"
);
elog
(
ERROR
,
"
could no
t rename long-term lock table"
);
#endif
#endif
return
LockTableId
;
return
LockTableId
;
...
@@ -132,11 +132,11 @@ LockRelation(Relation relation, LOCKMODE lockmode)
...
@@ -132,11 +132,11 @@ LockRelation(Relation relation, LOCKMODE lockmode)
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
GetCurrentTransactionId
(),
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
GetCurrentTransactionId
(),
lockmode
,
false
))
lockmode
,
false
))
elog
(
ERROR
,
"Lock
Relation: Lock
Acquire failed"
);
elog
(
ERROR
,
"LockAcquire failed"
);
/*
/*
* Check to see if the relcache entry has been invalidated while we
* Check to see if the relcache entry has been invalidated while we
* were waiting to lock it. If so, rebuild it, or e
log
() trying.
* were waiting to lock it. If so, rebuild it, or e
report
() trying.
* Increment the refcount to ensure that RelationFlushRelation will
* Increment the refcount to ensure that RelationFlushRelation will
* rebuild it and not just delete it.
* rebuild it and not just delete it.
*/
*/
...
@@ -170,7 +170,7 @@ ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
...
@@ -170,7 +170,7 @@ ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
/*
/*
* Check to see if the relcache entry has been invalidated while we
* Check to see if the relcache entry has been invalidated while we
* were waiting to lock it. If so, rebuild it, or e
log
() trying.
* were waiting to lock it. If so, rebuild it, or e
report
() trying.
* Increment the refcount to ensure that RelationFlushRelation will
* Increment the refcount to ensure that RelationFlushRelation will
* rebuild it and not just delete it.
* rebuild it and not just delete it.
*/
*/
...
@@ -202,7 +202,7 @@ UnlockRelation(Relation relation, LOCKMODE lockmode)
...
@@ -202,7 +202,7 @@ UnlockRelation(Relation relation, LOCKMODE lockmode)
*
*
* This routine grabs a session-level lock on the target relation. The
* This routine grabs a session-level lock on the target relation. The
* session lock persists across transaction boundaries. It will be removed
* session lock persists across transaction boundaries. It will be removed
* when UnlockRelationForSession() is called, or if an e
log
(ERROR) occurs,
* when UnlockRelationForSession() is called, or if an e
report
(ERROR) occurs,
* or if the backend exits.
* or if the backend exits.
*
*
* Note that one should also grab a transaction-level lock on the rel
* Note that one should also grab a transaction-level lock on the rel
...
@@ -221,7 +221,7 @@ LockRelationForSession(LockRelId *relid, LOCKMODE lockmode)
...
@@ -221,7 +221,7 @@ LockRelationForSession(LockRelId *relid, LOCKMODE lockmode)
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
InvalidTransactionId
,
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
InvalidTransactionId
,
lockmode
,
false
))
lockmode
,
false
))
elog
(
ERROR
,
"Lock
RelationForSession: Lock
Acquire failed"
);
elog
(
ERROR
,
"LockAcquire failed"
);
}
}
/*
/*
...
@@ -259,7 +259,7 @@ LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
...
@@ -259,7 +259,7 @@ LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
GetCurrentTransactionId
(),
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
GetCurrentTransactionId
(),
lockmode
,
false
))
lockmode
,
false
))
elog
(
ERROR
,
"Lock
Page: Lock
Acquire failed"
);
elog
(
ERROR
,
"LockAcquire failed"
);
}
}
/*
/*
...
@@ -300,7 +300,7 @@ XactLockTableInsert(TransactionId xid)
...
@@ -300,7 +300,7 @@ XactLockTableInsert(TransactionId xid)
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
xid
,
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
xid
,
ExclusiveLock
,
false
))
ExclusiveLock
,
false
))
elog
(
ERROR
,
"
XactLockTableInsert:
LockAcquire failed"
);
elog
(
ERROR
,
"LockAcquire failed"
);
}
}
/*
/*
...
@@ -323,7 +323,7 @@ XactLockTableWait(TransactionId xid)
...
@@ -323,7 +323,7 @@ XactLockTableWait(TransactionId xid)
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
myxid
,
if
(
!
LockAcquire
(
LockTableId
,
&
tag
,
myxid
,
ShareLock
,
false
))
ShareLock
,
false
))
elog
(
ERROR
,
"
XactLockTableWait:
LockAcquire failed"
);
elog
(
ERROR
,
"LockAcquire failed"
);
LockRelease
(
LockTableId
,
&
tag
,
myxid
,
ShareLock
);
LockRelease
(
LockTableId
,
&
tag
,
myxid
,
ShareLock
);
...
...
src/backend/storage/lmgr/lock.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.12
2 2003/02/19 23:41:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.12
3 2003/07/24 22:04:14 tgl
Exp $
*
*
* NOTES
* NOTES
* Outside modules can create a lock table and acquire/release
* Outside modules can create a lock table and acquire/release
...
@@ -242,7 +242,7 @@ LockMethodTableInit(char *tabName,
...
@@ -242,7 +242,7 @@ LockMethodTableInit(char *tabName,
if
(
numModes
>=
MAX_LOCKMODES
)
if
(
numModes
>=
MAX_LOCKMODES
)
{
{
elog
(
WARNING
,
"
LockMethodTableInit: too many lock types %d greater than %d
"
,
elog
(
WARNING
,
"
too many lock types %d (limit is %d)
"
,
numModes
,
MAX_LOCKMODES
);
numModes
,
MAX_LOCKMODES
);
return
INVALID_LOCKMETHOD
;
return
INVALID_LOCKMETHOD
;
}
}
...
@@ -261,7 +261,7 @@ LockMethodTableInit(char *tabName,
...
@@ -261,7 +261,7 @@ LockMethodTableInit(char *tabName,
ShmemInitStruct
(
shmemName
,
sizeof
(
LOCKMETHODTABLE
),
&
found
);
ShmemInitStruct
(
shmemName
,
sizeof
(
LOCKMETHODTABLE
),
&
found
);
if
(
!
lockMethodTable
)
if
(
!
lockMethodTable
)
elog
(
FATAL
,
"
LockMethodTableInit: couldn't initialize %s
"
,
tabName
);
elog
(
FATAL
,
"
could not initialize lock table
\"
%s
\"
"
,
tabName
);
/*
/*
* Lock the LWLock for the table (probably not necessary here)
* Lock the LWLock for the table (probably not necessary here)
...
@@ -307,7 +307,7 @@ LockMethodTableInit(char *tabName,
...
@@ -307,7 +307,7 @@ LockMethodTableInit(char *tabName,
hash_flags
);
hash_flags
);
if
(
!
lockMethodTable
->
lockHash
)
if
(
!
lockMethodTable
->
lockHash
)
elog
(
FATAL
,
"
LockMethodTableInit: couldn't initialize %s
"
,
tabName
);
elog
(
FATAL
,
"
could not initialize lock table
\"
%s
\"
"
,
tabName
);
Assert
(
lockMethodTable
->
lockHash
->
hash
==
tag_hash
);
Assert
(
lockMethodTable
->
lockHash
->
hash
==
tag_hash
);
/*
/*
...
@@ -327,7 +327,7 @@ LockMethodTableInit(char *tabName,
...
@@ -327,7 +327,7 @@ LockMethodTableInit(char *tabName,
hash_flags
);
hash_flags
);
if
(
!
lockMethodTable
->
proclockHash
)
if
(
!
lockMethodTable
->
proclockHash
)
elog
(
FATAL
,
"
LockMethodTableInit: couldn't initialize %s
"
,
tabName
);
elog
(
FATAL
,
"
could not initialize lock table
\"
%s
\"
"
,
tabName
);
/* init data structures */
/* init data structures */
LockMethodInit
(
lockMethodTable
,
conflictsP
,
numModes
);
LockMethodInit
(
lockMethodTable
,
conflictsP
,
numModes
);
...
@@ -377,7 +377,7 @@ LockMethodTableRename(LOCKMETHOD lockmethod)
...
@@ -377,7 +377,7 @@ LockMethodTableRename(LOCKMETHOD lockmethod)
* Returns: TRUE if lock was acquired, FALSE otherwise. Note that
* Returns: TRUE if lock was acquired, FALSE otherwise. Note that
* a FALSE return is to be expected if dontWait is TRUE;
* a FALSE return is to be expected if dontWait is TRUE;
* but if dontWait is FALSE, only a parameter error can cause
* but if dontWait is FALSE, only a parameter error can cause
* a FALSE return. (XXX probably we should just e
log
on parameter
* a FALSE return. (XXX probably we should just e
report
on parameter
* errors, instead of conflating this with failure to acquire lock?)
* errors, instead of conflating this with failure to acquire lock?)
*
*
* Side Effects: The lock is acquired and recorded in lock tables.
* Side Effects: The lock is acquired and recorded in lock tables.
...
@@ -459,7 +459,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -459,7 +459,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
lockMethodTable
=
LockMethodTable
[
lockmethod
];
lockMethodTable
=
LockMethodTable
[
lockmethod
];
if
(
!
lockMethodTable
)
if
(
!
lockMethodTable
)
{
{
elog
(
WARNING
,
"
LockAcquire: bad lock table
%d"
,
lockmethod
);
elog
(
WARNING
,
"
bad lock table id:
%d"
,
lockmethod
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -477,8 +477,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -477,8 +477,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if
(
!
lock
)
if
(
!
lock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
ERROR
,
"LockAcquire: lock table %d is out of memory"
,
ereport
(
ERROR
,
lockmethod
);
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
return
FALSE
;
return
FALSE
;
}
}
...
@@ -524,7 +525,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -524,7 +525,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if
(
!
proclock
)
if
(
!
proclock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
ERROR
,
"LockAcquire: proclock table out of memory"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
return
FALSE
;
return
FALSE
;
}
}
...
@@ -569,7 +572,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -569,7 +572,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
{
{
if
(
i
>=
(
int
)
lockmode
)
if
(
i
>=
(
int
)
lockmode
)
break
;
/* safe: we have a lock >= req level */
break
;
/* safe: we have a lock >= req level */
elog
(
LOG
,
"
D
eadlock risk: raising lock level"
elog
(
LOG
,
"
d
eadlock risk: raising lock level"
" from %s to %s on object %u/%u/%u"
,
" from %s to %s on object %u/%u/%u"
,
lock_mode_names
[
i
],
lock_mode_names
[
lockmode
],
lock_mode_names
[
i
],
lock_mode_names
[
lockmode
],
lock
->
tag
.
relId
,
lock
->
tag
.
dbId
,
lock
->
tag
.
objId
.
blkno
);
lock
->
tag
.
relId
,
lock
->
tag
.
dbId
,
lock
->
tag
.
objId
.
blkno
);
...
@@ -649,7 +652,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -649,7 +652,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
(
void
*
)
proclock
,
(
void
*
)
proclock
,
HASH_REMOVE
,
NULL
);
HASH_REMOVE
,
NULL
);
if
(
!
proclock
)
if
(
!
proclock
)
elog
(
WARNING
,
"
LockAcquire: remove proclock,
table corrupted"
);
elog
(
WARNING
,
"
proclock
table corrupted"
);
}
}
else
else
PROCLOCK_PRINT
(
"LockAcquire: NHOLDING"
,
proclock
);
PROCLOCK_PRINT
(
"LockAcquire: NHOLDING"
,
proclock
);
...
@@ -906,13 +909,10 @@ WaitOnLock(LOCKMETHOD lockmethod, LOCKMODE lockmode,
...
@@ -906,13 +909,10 @@ WaitOnLock(LOCKMETHOD lockmethod, LOCKMODE lockmode,
LOCK_PRINT
(
"WaitOnLock: aborting on lock"
,
lock
,
lockmode
);
LOCK_PRINT
(
"WaitOnLock: aborting on lock"
,
lock
,
lockmode
);
LWLockRelease
(
lockMethodTable
->
masterLock
);
LWLockRelease
(
lockMethodTable
->
masterLock
);
/*
/*
* Now that we aren't holding the LockMgrLock, print details about
* Now that we aren't holding the LockMgrLock, we can give an error
* the detected deadlock. We didn't want to do this before because
* report including details about the detected deadlock.
* sending elog messages to the client while holding the shared lock
* is bad for concurrency.
*/
*/
DeadLockReport
();
DeadLockReport
();
elog
(
ERROR
,
"deadlock detected"
);
/* not reached */
/* not reached */
}
}
...
@@ -1020,12 +1020,12 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -1020,12 +1020,12 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/*
/*
* let the caller print its own error message, too. Do not
* let the caller print its own error message, too. Do not
* e
log
(ERROR).
* e
report
(ERROR).
*/
*/
if
(
!
lock
)
if
(
!
lock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockRelease:
no such lock"
);
elog
(
WARNING
,
"no such lock"
);
return
FALSE
;
return
FALSE
;
}
}
LOCK_PRINT
(
"LockRelease: found"
,
lock
,
lockmode
);
LOCK_PRINT
(
"LockRelease: found"
,
lock
,
lockmode
);
...
@@ -1048,10 +1048,10 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -1048,10 +1048,10 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
#ifdef USER_LOCKS
#ifdef USER_LOCKS
if
(
lockmethod
==
USER_LOCKMETHOD
)
if
(
lockmethod
==
USER_LOCKMETHOD
)
elog
(
WARNING
,
"
LockRelease:
no lock with this tag"
);
elog
(
WARNING
,
"no lock with this tag"
);
else
else
#endif
#endif
elog
(
WARNING
,
"
LockRelease:
proclock table corrupted"
);
elog
(
WARNING
,
"proclock table corrupted"
);
return
FALSE
;
return
FALSE
;
}
}
PROCLOCK_PRINT
(
"LockRelease: found"
,
proclock
);
PROCLOCK_PRINT
(
"LockRelease: found"
,
proclock
);
...
@@ -1065,7 +1065,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -1065,7 +1065,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
PROCLOCK_PRINT
(
"LockRelease: WRONGTYPE"
,
proclock
);
PROCLOCK_PRINT
(
"LockRelease: WRONGTYPE"
,
proclock
);
Assert
(
proclock
->
holding
[
lockmode
]
>=
0
);
Assert
(
proclock
->
holding
[
lockmode
]
>=
0
);
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockRelease:
you don't own a lock of type %s"
,
elog
(
WARNING
,
"you don't own a lock of type %s"
,
lock_mode_names
[
lockmode
]);
lock_mode_names
[
lockmode
]);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -1119,7 +1119,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -1119,7 +1119,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if
(
!
lock
)
if
(
!
lock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockRelease: remove lock,
table corrupted"
);
elog
(
WARNING
,
"
lock
table corrupted"
);
return
FALSE
;
return
FALSE
;
}
}
wakeupNeeded
=
false
;
/* should be false, but make sure */
wakeupNeeded
=
false
;
/* should be false, but make sure */
...
@@ -1148,7 +1148,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
...
@@ -1148,7 +1148,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if
(
!
proclock
)
if
(
!
proclock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockRelease: remove proclock,
table corrupted"
);
elog
(
WARNING
,
"
proclock
table corrupted"
);
return
FALSE
;
return
FALSE
;
}
}
}
}
...
@@ -1197,7 +1197,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
...
@@ -1197,7 +1197,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
lockMethodTable
=
LockMethodTable
[
lockmethod
];
lockMethodTable
=
LockMethodTable
[
lockmethod
];
if
(
!
lockMethodTable
)
if
(
!
lockMethodTable
)
{
{
elog
(
WARNING
,
"
LockReleaseAll:
bad lockmethod %d"
,
lockmethod
);
elog
(
WARNING
,
"bad lockmethod %d"
,
lockmethod
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -1301,7 +1301,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
...
@@ -1301,7 +1301,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
if
(
!
proclock
)
if
(
!
proclock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockReleaseAll:
proclock table corrupted"
);
elog
(
WARNING
,
"proclock table corrupted"
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -1319,7 +1319,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
...
@@ -1319,7 +1319,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
if
(
!
lock
)
if
(
!
lock
)
{
{
LWLockRelease
(
masterLock
);
LWLockRelease
(
masterLock
);
elog
(
WARNING
,
"
LockReleaseAll:
cannot remove lock from HTAB"
);
elog
(
WARNING
,
"cannot remove lock from HTAB"
);
return
FALSE
;
return
FALSE
;
}
}
}
}
...
@@ -1334,7 +1334,7 @@ next_item:
...
@@ -1334,7 +1334,7 @@ next_item:
#ifdef LOCK_DEBUG
#ifdef LOCK_DEBUG
if
(
lockmethod
==
USER_LOCKMETHOD
?
Trace_userlocks
:
Trace_locks
)
if
(
lockmethod
==
USER_LOCKMETHOD
?
Trace_userlocks
:
Trace_locks
)
elog
(
LOG
,
"LockReleaseAll
:
done"
);
elog
(
LOG
,
"LockReleaseAll done"
);
#endif
#endif
return
TRUE
;
return
TRUE
;
...
...
src/backend/storage/lmgr/lwlock.c
View file @
cfa191f3
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.1
5 2003/06/11 22:37:45 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.1
6 2003/07/24 22:04:14 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -181,7 +181,7 @@ LWLockId
...
@@ -181,7 +181,7 @@ LWLockId
LWLockAssign
(
void
)
LWLockAssign
(
void
)
{
{
if
(
LWLockCounter
[
0
]
>=
LWLockCounter
[
1
])
if
(
LWLockCounter
[
0
]
>=
LWLockCounter
[
1
])
elog
(
FATAL
,
"
N
o more LWLockIds available"
);
elog
(
FATAL
,
"
n
o more LWLockIds available"
);
return
(
LWLockId
)
(
LWLockCounter
[
0
]
++
);
return
(
LWLockId
)
(
LWLockCounter
[
0
]
++
);
}
}
...
@@ -278,7 +278,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
...
@@ -278,7 +278,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
* shared memory initialization.
* shared memory initialization.
*/
*/
if
(
proc
==
NULL
)
if
(
proc
==
NULL
)
elog
(
FATAL
,
"
LWLockAcquire: can'
t wait without a PGPROC structure"
);
elog
(
FATAL
,
"
canno
t wait without a PGPROC structure"
);
proc
->
lwWaiting
=
true
;
proc
->
lwWaiting
=
true
;
proc
->
lwExclusive
=
(
mode
==
LW_EXCLUSIVE
);
proc
->
lwExclusive
=
(
mode
==
LW_EXCLUSIVE
);
...
@@ -424,7 +424,7 @@ LWLockRelease(LWLockId lockid)
...
@@ -424,7 +424,7 @@ LWLockRelease(LWLockId lockid)
break
;
break
;
}
}
if
(
i
<
0
)
if
(
i
<
0
)
elog
(
ERROR
,
"
LWLockRelease:
lock %d is not held"
,
(
int
)
lockid
);
elog
(
ERROR
,
"lock %d is not held"
,
(
int
)
lockid
);
num_held_lwlocks
--
;
num_held_lwlocks
--
;
for
(;
i
<
num_held_lwlocks
;
i
++
)
for
(;
i
<
num_held_lwlocks
;
i
++
)
held_lwlocks
[
i
]
=
held_lwlocks
[
i
+
1
];
held_lwlocks
[
i
]
=
held_lwlocks
[
i
+
1
];
...
@@ -503,10 +503,10 @@ LWLockRelease(LWLockId lockid)
...
@@ -503,10 +503,10 @@ LWLockRelease(LWLockId lockid)
/*
/*
* LWLockReleaseAll - release all currently-held locks
* LWLockReleaseAll - release all currently-held locks
*
*
* Used to clean up after e
log(ERROR).
An important difference between this
* Used to clean up after e
report(ERROR).
An important difference between this
* function and retail LWLockRelease calls is that InterruptHoldoffCount is
* function and retail LWLockRelease calls is that InterruptHoldoffCount is
* unchanged by this operation. This is necessary since InterruptHoldoffCount
* unchanged by this operation. This is necessary since InterruptHoldoffCount
* has been set to an appropriate level earlier in error recovery.
We could
* has been set to an appropriate level earlier in error recovery.
We could
* decrement it below zero if we allow it to drop for each released lock!
* decrement it below zero if we allow it to drop for each released lock!
*/
*/
void
void
...
...
src/backend/storage/lmgr/proc.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.13
0 2003/05/15 16:35:29 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.13
1 2003/07/24 22:04:14 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -148,7 +148,9 @@ InitProcGlobal(int maxBackends)
...
@@ -148,7 +148,9 @@ InitProcGlobal(int maxBackends)
proc
=
(
PGPROC
*
)
ShmemAlloc
(
sizeof
(
PGPROC
));
proc
=
(
PGPROC
*
)
ShmemAlloc
(
sizeof
(
PGPROC
));
if
(
!
proc
)
if
(
!
proc
)
elog
(
FATAL
,
"cannot create new proc: out of memory"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
MemSet
(
proc
,
0
,
sizeof
(
PGPROC
));
MemSet
(
proc
,
0
,
sizeof
(
PGPROC
));
PGSemaphoreCreate
(
&
proc
->
sem
);
PGSemaphoreCreate
(
&
proc
->
sem
);
proc
->
links
.
next
=
ProcGlobal
->
freeProcs
;
proc
->
links
.
next
=
ProcGlobal
->
freeProcs
;
...
@@ -162,7 +164,9 @@ InitProcGlobal(int maxBackends)
...
@@ -162,7 +164,9 @@ InitProcGlobal(int maxBackends)
*/
*/
DummyProc
=
(
PGPROC
*
)
ShmemAlloc
(
sizeof
(
PGPROC
));
DummyProc
=
(
PGPROC
*
)
ShmemAlloc
(
sizeof
(
PGPROC
));
if
(
!
DummyProc
)
if
(
!
DummyProc
)
elog
(
FATAL
,
"cannot create new proc: out of memory"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
MemSet
(
DummyProc
,
0
,
sizeof
(
PGPROC
));
MemSet
(
DummyProc
,
0
,
sizeof
(
PGPROC
));
DummyProc
->
pid
=
0
;
/* marks DummyProc as not in use */
DummyProc
->
pid
=
0
;
/* marks DummyProc as not in use */
PGSemaphoreCreate
(
&
DummyProc
->
sem
);
PGSemaphoreCreate
(
&
DummyProc
->
sem
);
...
@@ -189,10 +193,10 @@ InitProcess(void)
...
@@ -189,10 +193,10 @@ InitProcess(void)
* we are a backend, we inherit this by fork() from the postmaster).
* we are a backend, we inherit this by fork() from the postmaster).
*/
*/
if
(
procglobal
==
NULL
)
if
(
procglobal
==
NULL
)
elog
(
PANIC
,
"
InitProcess: Proc H
eader uninitialized"
);
elog
(
PANIC
,
"
proc h
eader uninitialized"
);
if
(
MyProc
!=
NULL
)
if
(
MyProc
!=
NULL
)
elog
(
ERROR
,
"
InitProcess:
you already exist"
);
elog
(
ERROR
,
"you already exist"
);
/*
/*
* Try to get a proc struct from the free list. If this fails, we
* Try to get a proc struct from the free list. If this fails, we
...
@@ -216,7 +220,9 @@ InitProcess(void)
...
@@ -216,7 +220,9 @@ InitProcess(void)
* standard error message.
* standard error message.
*/
*/
SpinLockRelease
(
ProcStructLock
);
SpinLockRelease
(
ProcStructLock
);
elog
(
FATAL
,
"Sorry, too many clients already"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_TOO_MANY_CONNECTIONS
),
errmsg
(
"sorry, too many clients already"
)));
}
}
/*
/*
...
@@ -270,17 +276,16 @@ InitDummyProcess(void)
...
@@ -270,17 +276,16 @@ InitDummyProcess(void)
* inherit this by fork() from the postmaster).
* inherit this by fork() from the postmaster).
*/
*/
if
(
ProcGlobal
==
NULL
||
DummyProc
==
NULL
)
if
(
ProcGlobal
==
NULL
||
DummyProc
==
NULL
)
elog
(
PANIC
,
"
InitDummyProcess: Proc H
eader uninitialized"
);
elog
(
PANIC
,
"
proc h
eader uninitialized"
);
if
(
MyProc
!=
NULL
)
if
(
MyProc
!=
NULL
)
elog
(
ERROR
,
"
InitDummyProcess:
you already exist"
);
elog
(
ERROR
,
"you already exist"
);
/*
/*
* DummyProc should not presently be in use by anyone else
* DummyProc should not presently be in use by anyone else
*/
*/
if
(
DummyProc
->
pid
!=
0
)
if
(
DummyProc
->
pid
!=
0
)
elog
(
FATAL
,
"InitDummyProcess: DummyProc is in use by PID %d"
,
elog
(
FATAL
,
"DummyProc is in use by PID %d"
,
DummyProc
->
pid
);
DummyProc
->
pid
);
MyProc
=
DummyProc
;
MyProc
=
DummyProc
;
/*
/*
...
@@ -319,7 +324,7 @@ InitDummyProcess(void)
...
@@ -319,7 +324,7 @@ InitDummyProcess(void)
* Returns true if we had been waiting for a lock, else false.
* Returns true if we had been waiting for a lock, else false.
*
*
* (Normally, this would only happen if we accept a cancel/die
* (Normally, this would only happen if we accept a cancel/die
* interrupt while waiting; but an e
log
(ERROR) while waiting is
* interrupt while waiting; but an e
report
(ERROR) while waiting is
* within the realm of possibility, too.)
* within the realm of possibility, too.)
*/
*/
bool
bool
...
@@ -655,7 +660,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
...
@@ -655,7 +660,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
* running the rather expensive deadlock-check code in most cases.
* running the rather expensive deadlock-check code in most cases.
*/
*/
if
(
!
enable_sig_alarm
(
DeadlockTimeout
,
false
))
if
(
!
enable_sig_alarm
(
DeadlockTimeout
,
false
))
elog
(
FATAL
,
"
ProcSleep: Unable to
set timer for process wakeup"
);
elog
(
FATAL
,
"
could not
set timer for process wakeup"
);
/*
/*
* If someone wakes us between LWLockRelease and PGSemaphoreLock,
* If someone wakes us between LWLockRelease and PGSemaphoreLock,
...
@@ -677,7 +682,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
...
@@ -677,7 +682,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
* Disable the timer, if it's still running
* Disable the timer, if it's still running
*/
*/
if
(
!
disable_sig_alarm
(
false
))
if
(
!
disable_sig_alarm
(
false
))
elog
(
FATAL
,
"
ProcSleep: Unable to
disable timer for process wakeup"
);
elog
(
FATAL
,
"
could not
disable timer for process wakeup"
);
/*
/*
* Now there is nothing for LockWaitCancel to do.
* Now there is nothing for LockWaitCancel to do.
...
...
src/backend/storage/page/bufpage.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.5
2 2003/03/28 20:17:13
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.5
3 2003/07/24 22:04:15
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -103,7 +103,7 @@ PageHeaderIsValid(PageHeader page)
...
@@ -103,7 +103,7 @@ PageHeaderIsValid(PageHeader page)
* If offsetNumber is not valid, then assign one by finding the first
* If offsetNumber is not valid, then assign one by finding the first
* one that is both unused and deallocated.
* one that is both unused and deallocated.
*
*
* !!! E
LOG
(ERROR) IS DISALLOWED HERE !!!
* !!! E
REPORT
(ERROR) IS DISALLOWED HERE !!!
*
*
* ----------------
* ----------------
*/
*/
...
@@ -132,8 +132,10 @@ PageAddItem(Page page,
...
@@ -132,8 +132,10 @@ PageAddItem(Page page,
phdr
->
pd_lower
>
phdr
->
pd_upper
||
phdr
->
pd_lower
>
phdr
->
pd_upper
||
phdr
->
pd_upper
>
phdr
->
pd_special
||
phdr
->
pd_upper
>
phdr
->
pd_special
||
phdr
->
pd_special
>
BLCKSZ
)
phdr
->
pd_special
>
BLCKSZ
)
elog
(
PANIC
,
"PageAddItem: corrupted page pointers: lower = %u, upper = %u, special = %u"
,
ereport
(
PANIC
,
phdr
->
pd_lower
,
phdr
->
pd_upper
,
phdr
->
pd_special
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted page pointers: lower = %u, upper = %u, special = %u"
,
phdr
->
pd_lower
,
phdr
->
pd_upper
,
phdr
->
pd_special
)));
/*
/*
* Select offsetNumber to place the new item at
* Select offsetNumber to place the new item at
...
@@ -152,7 +154,7 @@ PageAddItem(Page page,
...
@@ -152,7 +154,7 @@ PageAddItem(Page page,
if
(((
*
itemId
).
lp_flags
&
LP_USED
)
||
if
(((
*
itemId
).
lp_flags
&
LP_USED
)
||
((
*
itemId
).
lp_len
!=
0
))
((
*
itemId
).
lp_len
!=
0
))
{
{
elog
(
WARNING
,
"
PageAddItem: tried overwrite of
used ItemId"
);
elog
(
WARNING
,
"
will not overwrite a
used ItemId"
);
return
InvalidOffsetNumber
;
return
InvalidOffsetNumber
;
}
}
}
}
...
@@ -179,7 +181,7 @@ PageAddItem(Page page,
...
@@ -179,7 +181,7 @@ PageAddItem(Page page,
if
(
offsetNumber
>
limit
)
if
(
offsetNumber
>
limit
)
{
{
elog
(
WARNING
,
"
PageAddItem: specified offset after maxoff
"
);
elog
(
WARNING
,
"
specified item offset is too large
"
);
return
InvalidOffsetNumber
;
return
InvalidOffsetNumber
;
}
}
...
@@ -328,8 +330,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
...
@@ -328,8 +330,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
pd_upper
>
pd_special
||
pd_upper
>
pd_special
||
pd_special
>
BLCKSZ
||
pd_special
>
BLCKSZ
||
pd_special
!=
MAXALIGN
(
pd_special
))
pd_special
!=
MAXALIGN
(
pd_special
))
elog
(
ERROR
,
"PageRepairFragmentation: corrupted page pointers: lower = %u, upper = %u, special = %u"
,
ereport
(
ERROR
,
pd_lower
,
pd_upper
,
pd_special
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted page pointers: lower = %u, upper = %u, special = %u"
,
pd_lower
,
pd_upper
,
pd_special
)));
nline
=
PageGetMaxOffsetNumber
(
page
);
nline
=
PageGetMaxOffsetNumber
(
page
);
nused
=
0
;
nused
=
0
;
...
@@ -370,8 +374,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
...
@@ -370,8 +374,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
itemidptr
->
itemoff
=
(
*
lp
).
lp_off
;
itemidptr
->
itemoff
=
(
*
lp
).
lp_off
;
if
(
itemidptr
->
itemoff
<
(
int
)
pd_upper
||
if
(
itemidptr
->
itemoff
<
(
int
)
pd_upper
||
itemidptr
->
itemoff
>=
(
int
)
pd_special
)
itemidptr
->
itemoff
>=
(
int
)
pd_special
)
elog
(
ERROR
,
"PageRepairFragmentation: corrupted item pointer %u"
,
ereport
(
ERROR
,
itemidptr
->
itemoff
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted item pointer: %u"
,
itemidptr
->
itemoff
)));
itemidptr
->
alignedlen
=
MAXALIGN
((
*
lp
).
lp_len
);
itemidptr
->
alignedlen
=
MAXALIGN
((
*
lp
).
lp_len
);
totallen
+=
itemidptr
->
alignedlen
;
totallen
+=
itemidptr
->
alignedlen
;
itemidptr
++
;
itemidptr
++
;
...
@@ -383,8 +389,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
...
@@ -383,8 +389,10 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
}
}
if
(
totallen
>
(
Size
)
(
pd_special
-
pd_lower
))
if
(
totallen
>
(
Size
)
(
pd_special
-
pd_lower
))
elog
(
ERROR
,
"PageRepairFragmentation: corrupted item lengths, total %u, avail %u"
,
ereport
(
ERROR
,
(
unsigned
int
)
totallen
,
pd_special
-
pd_lower
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted item lengths: total %u, available space %u"
,
(
unsigned
int
)
totallen
,
pd_special
-
pd_lower
)));
/* sort itemIdSortData array into decreasing itemoff order */
/* sort itemIdSortData array into decreasing itemoff order */
qsort
((
char
*
)
itemidbase
,
nused
,
sizeof
(
struct
itemIdSortData
),
qsort
((
char
*
)
itemidbase
,
nused
,
sizeof
(
struct
itemIdSortData
),
...
@@ -461,12 +469,14 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
...
@@ -461,12 +469,14 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
phdr
->
pd_lower
>
phdr
->
pd_upper
||
phdr
->
pd_lower
>
phdr
->
pd_upper
||
phdr
->
pd_upper
>
phdr
->
pd_special
||
phdr
->
pd_upper
>
phdr
->
pd_special
||
phdr
->
pd_special
>
BLCKSZ
)
phdr
->
pd_special
>
BLCKSZ
)
elog
(
ERROR
,
"PageIndexTupleDelete: corrupted page pointers: lower = %u, upper = %u, special = %u"
,
ereport
(
ERROR
,
phdr
->
pd_lower
,
phdr
->
pd_upper
,
phdr
->
pd_special
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted page pointers: lower = %u, upper = %u, special = %u"
,
phdr
->
pd_lower
,
phdr
->
pd_upper
,
phdr
->
pd_special
)));
nline
=
PageGetMaxOffsetNumber
(
page
);
nline
=
PageGetMaxOffsetNumber
(
page
);
if
((
int
)
offnum
<=
0
||
(
int
)
offnum
>
nline
)
if
((
int
)
offnum
<=
0
||
(
int
)
offnum
>
nline
)
elog
(
ERROR
,
"
PageIndexTupleDelete: bad offnum
%u"
,
offnum
);
elog
(
ERROR
,
"
invalid index offnum:
%u"
,
offnum
);
/* change offset number to offset index */
/* change offset number to offset index */
offidx
=
offnum
-
1
;
offidx
=
offnum
-
1
;
...
@@ -477,8 +487,10 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
...
@@ -477,8 +487,10 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
if
(
offset
<
phdr
->
pd_upper
||
(
offset
+
size
)
>
phdr
->
pd_special
||
if
(
offset
<
phdr
->
pd_upper
||
(
offset
+
size
)
>
phdr
->
pd_special
||
offset
!=
MAXALIGN
(
offset
)
||
size
!=
MAXALIGN
(
size
))
offset
!=
MAXALIGN
(
offset
)
||
size
!=
MAXALIGN
(
size
))
elog
(
ERROR
,
"PageIndexTupleDelete: corrupted item pointer: offset = %u size = %u"
,
ereport
(
ERROR
,
offset
,
(
unsigned
int
)
size
);
(
errcode
(
ERRCODE_DATA_CORRUPTED
),
errmsg
(
"corrupted item pointer: offset = %u size = %u"
,
offset
,
(
unsigned
int
)
size
)));
/*
/*
* First, we want to get rid of the pd_linp entry for the index tuple.
* First, we want to get rid of the pd_linp entry for the index tuple.
...
...
src/backend/storage/smgr/md.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.9
4 2003/01/07 01:19:12
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.9
5 2003/07/24 22:04:15
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -249,7 +249,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -249,7 +249,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
%
((
BlockNumber
)
RELSEG_SIZE
)));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
%
((
BlockNumber
)
RELSEG_SIZE
)));
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
elog
(
FATAL
,
"seekpos too big
!
"
);
elog
(
FATAL
,
"seekpos too big"
);
#endif
#endif
#else
#else
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
...
@@ -284,7 +284,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -284,7 +284,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
#ifndef LET_OS_MANAGE_FILESIZE
#ifndef LET_OS_MANAGE_FILESIZE
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
if
(
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
elog
(
FATAL
,
"segment too big
!
"
);
elog
(
FATAL
,
"segment too big"
);
#endif
#endif
#endif
#endif
...
@@ -338,7 +338,7 @@ mdopen(Relation reln)
...
@@ -338,7 +338,7 @@ mdopen(Relation reln)
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
_mdnblocks
(
fd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
if
(
_mdnblocks
(
fd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
elog
(
FATAL
,
"segment too big
on relopen!
"
);
elog
(
FATAL
,
"segment too big"
);
#endif
#endif
#endif
#endif
...
@@ -421,7 +421,7 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -421,7 +421,7 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
elog
(
FATAL
,
"seekpos too big
!
"
);
elog
(
FATAL
,
"seekpos too big"
);
#endif
#endif
#else
#else
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
...
@@ -468,7 +468,7 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -468,7 +468,7 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
%
((
BlockNumber
)
RELSEG_SIZE
)));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
%
((
BlockNumber
)
RELSEG_SIZE
)));
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
elog
(
FATAL
,
"seekpos too big
!
"
);
elog
(
FATAL
,
"seekpos too big"
);
#endif
#endif
#else
#else
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blocknum
));
...
@@ -507,7 +507,7 @@ mdblindwrt(RelFileNode rnode,
...
@@ -507,7 +507,7 @@ mdblindwrt(RelFileNode rnode,
seekpos
=
(
long
)
(
BLCKSZ
*
(
blkno
%
((
BlockNumber
)
RELSEG_SIZE
)));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blkno
%
((
BlockNumber
)
RELSEG_SIZE
)));
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
if
(
seekpos
>=
BLCKSZ
*
RELSEG_SIZE
)
elog
(
FATAL
,
"seekpos too big
!
"
);
elog
(
FATAL
,
"seekpos too big"
);
#endif
#endif
#else
#else
seekpos
=
(
long
)
(
BLCKSZ
*
(
blkno
));
seekpos
=
(
long
)
(
BLCKSZ
*
(
blkno
));
...
@@ -516,7 +516,7 @@ mdblindwrt(RelFileNode rnode,
...
@@ -516,7 +516,7 @@ mdblindwrt(RelFileNode rnode,
errno
=
0
;
errno
=
0
;
if
(
lseek
(
fd
,
seekpos
,
SEEK_SET
)
!=
seekpos
)
if
(
lseek
(
fd
,
seekpos
,
SEEK_SET
)
!=
seekpos
)
{
{
elog
(
LOG
,
"
mdblindwrt:
lseek(%ld) failed: %m"
,
seekpos
);
elog
(
LOG
,
"lseek(%ld) failed: %m"
,
seekpos
);
close
(
fd
);
close
(
fd
);
return
SM_FAIL
;
return
SM_FAIL
;
}
}
...
@@ -530,13 +530,13 @@ mdblindwrt(RelFileNode rnode,
...
@@ -530,13 +530,13 @@ mdblindwrt(RelFileNode rnode,
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
if
(
errno
==
0
)
if
(
errno
==
0
)
errno
=
ENOSPC
;
errno
=
ENOSPC
;
elog
(
LOG
,
"
mdblindwrt:
write() failed: %m"
);
elog
(
LOG
,
"write() failed: %m"
);
status
=
SM_FAIL
;
status
=
SM_FAIL
;
}
}
if
(
close
(
fd
)
<
0
)
if
(
close
(
fd
)
<
0
)
{
{
elog
(
LOG
,
"
mdblindwrt:
close() failed: %m"
);
elog
(
LOG
,
"close() failed: %m"
);
status
=
SM_FAIL
;
status
=
SM_FAIL
;
}
}
...
@@ -551,7 +551,7 @@ mdblindwrt(RelFileNode rnode,
...
@@ -551,7 +551,7 @@ mdblindwrt(RelFileNode rnode,
* called, then only segments up to the last one actually touched
* called, then only segments up to the last one actually touched
* are present in the chain...
* are present in the chain...
*
*
* Returns # of blocks, e
log
's on error.
* Returns # of blocks, e
report
's on error.
*/
*/
BlockNumber
BlockNumber
mdnblocks
(
Relation
reln
)
mdnblocks
(
Relation
reln
)
...
@@ -588,7 +588,7 @@ mdnblocks(Relation reln)
...
@@ -588,7 +588,7 @@ mdnblocks(Relation reln)
{
{
nblocks
=
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
);
nblocks
=
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
);
if
(
nblocks
>
((
BlockNumber
)
RELSEG_SIZE
))
if
(
nblocks
>
((
BlockNumber
)
RELSEG_SIZE
))
elog
(
FATAL
,
"segment too big
in mdnblocks!
"
);
elog
(
FATAL
,
"segment too big"
);
if
(
nblocks
<
((
BlockNumber
)
RELSEG_SIZE
))
if
(
nblocks
<
((
BlockNumber
)
RELSEG_SIZE
))
return
(
segno
*
((
BlockNumber
)
RELSEG_SIZE
))
+
nblocks
;
return
(
segno
*
((
BlockNumber
)
RELSEG_SIZE
))
+
nblocks
;
...
@@ -608,7 +608,7 @@ mdnblocks(Relation reln)
...
@@ -608,7 +608,7 @@ mdnblocks(Relation reln)
*/
*/
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
segno
,
O_CREAT
);
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
segno
,
O_CREAT
);
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
elog
(
ERROR
,
"c
annot count blocks for %s -- open failed
: %m"
,
elog
(
ERROR
,
"c
ould not count blocks for
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
));
RelationGetRelationName
(
reln
));
}
}
...
@@ -855,7 +855,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
...
@@ -855,7 +855,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
#ifdef DIAGNOSTIC
#ifdef DIAGNOSTIC
if
(
_mdnblocks
(
fd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
if
(
_mdnblocks
(
fd
,
BLCKSZ
)
>
((
BlockNumber
)
RELSEG_SIZE
))
elog
(
FATAL
,
"segment too big
on openseg!
"
);
elog
(
FATAL
,
"segment too big"
);
#endif
#endif
#endif
#endif
...
@@ -874,7 +874,7 @@ _mdfd_getrelnfd(Relation reln)
...
@@ -874,7 +874,7 @@ _mdfd_getrelnfd(Relation reln)
if
(
fd
<
0
)
if
(
fd
<
0
)
{
{
if
((
fd
=
mdopen
(
reln
))
<
0
)
if
((
fd
=
mdopen
(
reln
))
<
0
)
elog
(
ERROR
,
"
_mdfd_getrelnfd: cannot open relation %s
: %m"
,
elog
(
ERROR
,
"
could not open relation
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
));
RelationGetRelationName
(
reln
));
reln
->
rd_fd
=
fd
;
reln
->
rd_fd
=
fd
;
}
}
...
@@ -917,7 +917,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
...
@@ -917,7 +917,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
i
,
(
segno
==
1
)
?
O_CREAT
:
0
);
v
->
mdfd_chain
=
_mdfd_openseg
(
reln
,
i
,
(
segno
==
1
)
?
O_CREAT
:
0
);
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
elog
(
ERROR
,
"c
annot open segment %u of relation %s
(target block %u): %m"
,
elog
(
ERROR
,
"c
ould not open segment %u of relation
\"
%s
\"
(target block %u): %m"
,
i
,
RelationGetRelationName
(
reln
),
blkno
);
i
,
RelationGetRelationName
(
reln
),
blkno
);
}
}
v
=
v
->
mdfd_chain
;
v
=
v
->
mdfd_chain
;
...
@@ -970,7 +970,7 @@ _mdfd_blind_getseg(RelFileNode rnode, BlockNumber blkno)
...
@@ -970,7 +970,7 @@ _mdfd_blind_getseg(RelFileNode rnode, BlockNumber blkno)
/* call fd.c to allow other FDs to be closed if needed */
/* call fd.c to allow other FDs to be closed if needed */
fd
=
BasicOpenFile
(
path
,
O_RDWR
|
PG_BINARY
,
0600
);
fd
=
BasicOpenFile
(
path
,
O_RDWR
|
PG_BINARY
,
0600
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
LOG
,
"
_mdfd_blind_getseg: couldn't open %s
: %m"
,
path
);
elog
(
LOG
,
"
could not open
\"
%s
\"
: %m"
,
path
);
pfree
(
path
);
pfree
(
path
);
...
...
src/backend/storage/smgr/mm.c
View file @
cfa191f3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.3
2 2002/08/06 02:36:34
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.3
3 2003/07/24 22:04:15
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -186,7 +186,9 @@ mmcreate(Relation reln)
...
@@ -186,7 +186,9 @@ mmcreate(Relation reln)
if
(
entry
==
(
MMRelHashEntry
*
)
NULL
)
if
(
entry
==
(
MMRelHashEntry
*
)
NULL
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"main memory storage mgr hash table out of memory"
);
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of memory"
)));
}
}
if
(
found
)
if
(
found
)
...
@@ -229,7 +231,7 @@ mmunlink(RelFileNode rnode)
...
@@ -229,7 +231,7 @@ mmunlink(RelFileNode rnode)
if
(
entry
==
(
MMHashEntry
*
)
NULL
)
if
(
entry
==
(
MMHashEntry
*
)
NULL
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"
mmunlink:
cache hash table corrupted"
);
elog
(
FATAL
,
"cache hash table corrupted"
);
}
}
MMBlockTags
[
i
].
mmct_dbid
=
(
Oid
)
0
;
MMBlockTags
[
i
].
mmct_dbid
=
(
Oid
)
0
;
MMBlockTags
[
i
].
mmct_relid
=
(
Oid
)
0
;
MMBlockTags
[
i
].
mmct_relid
=
(
Oid
)
0
;
...
@@ -246,7 +248,7 @@ mmunlink(RelFileNode rnode)
...
@@ -246,7 +248,7 @@ mmunlink(RelFileNode rnode)
if
(
rentry
==
(
MMRelHashEntry
*
)
NULL
)
if
(
rentry
==
(
MMRelHashEntry
*
)
NULL
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"
mmunlink:
rel cache hash table corrupted"
);
elog
(
FATAL
,
"rel cache hash table corrupted"
);
}
}
(
*
MMCurRelno
)
--
;
(
*
MMCurRelno
)
--
;
...
@@ -309,7 +311,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -309,7 +311,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
if
(
rentry
==
(
MMRelHashEntry
*
)
NULL
)
if
(
rentry
==
(
MMRelHashEntry
*
)
NULL
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"
mmextend: rel cache hash table corrupt
"
);
elog
(
FATAL
,
"
rel cache hash table corrupted
"
);
}
}
tag
.
mmct_blkno
=
rentry
->
mmrhe_nblocks
;
tag
.
mmct_blkno
=
rentry
->
mmrhe_nblocks
;
...
@@ -320,7 +322,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -320,7 +322,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
if
(
entry
==
(
MMHashEntry
*
)
NULL
||
found
)
if
(
entry
==
(
MMHashEntry
*
)
NULL
||
found
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"
mmextend: cache hash table corrupt
"
);
elog
(
FATAL
,
"
cache hash table corrupted
"
);
}
}
entry
->
mmhe_bufno
=
i
;
entry
->
mmhe_bufno
=
i
;
...
@@ -431,7 +433,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -431,7 +433,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
if
(
entry
==
(
MMHashEntry
*
)
NULL
)
if
(
entry
==
(
MMHashEntry
*
)
NULL
)
{
{
LWLockRelease
(
MMCacheLock
);
LWLockRelease
(
MMCacheLock
);
elog
(
FATAL
,
"
mmwrite:
hash table missing requested page"
);
elog
(
FATAL
,
"
cache
hash table missing requested page"
);
}
}
offset
=
(
entry
->
mmhe_bufno
*
BLCKSZ
);
offset
=
(
entry
->
mmhe_bufno
*
BLCKSZ
);
...
...
src/backend/storage/smgr/smgr.c
View file @
cfa191f3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.6
2 2003/03/04 21:51:21
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.6
3 2003/07/24 22:04:15
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -129,7 +129,7 @@ smgrinit(void)
...
@@ -129,7 +129,7 @@ smgrinit(void)
if
(
smgrsw
[
i
].
smgr_init
)
if
(
smgrsw
[
i
].
smgr_init
)
{
{
if
((
*
(
smgrsw
[
i
].
smgr_init
))
()
==
SM_FAIL
)
if
((
*
(
smgrsw
[
i
].
smgr_init
))
()
==
SM_FAIL
)
elog
(
FATAL
,
"initialization failed on %s: %m"
,
elog
(
FATAL
,
"
smgr
initialization failed on %s: %m"
,
DatumGetCString
(
DirectFunctionCall1
(
smgrout
,
DatumGetCString
(
DirectFunctionCall1
(
smgrout
,
Int16GetDatum
(
i
))));
Int16GetDatum
(
i
))));
}
}
...
@@ -151,7 +151,7 @@ smgrshutdown(void)
...
@@ -151,7 +151,7 @@ smgrshutdown(void)
if
(
smgrsw
[
i
].
smgr_shutdown
)
if
(
smgrsw
[
i
].
smgr_shutdown
)
{
{
if
((
*
(
smgrsw
[
i
].
smgr_shutdown
))
()
==
SM_FAIL
)
if
((
*
(
smgrsw
[
i
].
smgr_shutdown
))
()
==
SM_FAIL
)
elog
(
FATAL
,
"shutdown failed on %s: %m"
,
elog
(
FATAL
,
"s
mgr s
hutdown failed on %s: %m"
,
DatumGetCString
(
DirectFunctionCall1
(
smgrout
,
DatumGetCString
(
DirectFunctionCall1
(
smgrout
,
Int16GetDatum
(
i
))));
Int16GetDatum
(
i
))));
}
}
...
@@ -171,7 +171,10 @@ smgrcreate(int16 which, Relation reln)
...
@@ -171,7 +171,10 @@ smgrcreate(int16 which, Relation reln)
PendingRelDelete
*
pending
;
PendingRelDelete
*
pending
;
if
((
fd
=
(
*
(
smgrsw
[
which
].
smgr_create
))
(
reln
))
<
0
)
if
((
fd
=
(
*
(
smgrsw
[
which
].
smgr_create
))
(
reln
))
<
0
)
elog
(
ERROR
,
"cannot create %s: %m"
,
RelationGetRelationName
(
reln
));
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not create
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
))));
/* Add the relation to the list of stuff to delete at abort */
/* Add the relation to the list of stuff to delete at abort */
pending
=
(
PendingRelDelete
*
)
pending
=
(
PendingRelDelete
*
)
...
@@ -243,8 +246,11 @@ smgrextend(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -243,8 +246,11 @@ smgrextend(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status
=
(
*
(
smgrsw
[
which
].
smgr_extend
))
(
reln
,
blocknum
,
buffer
);
status
=
(
*
(
smgrsw
[
which
].
smgr_extend
))
(
reln
,
blocknum
,
buffer
);
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
elog
(
ERROR
,
"cannot extend %s: %m.
\n\t
Check free disk space."
,
ereport
(
ERROR
,
RelationGetRelationName
(
reln
));
(
errcode_for_file_access
(),
errmsg
(
"could not extend
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
)),
errhint
(
"Check free disk space."
)));
return
status
;
return
status
;
}
}
...
@@ -267,7 +273,10 @@ smgropen(int16 which, Relation reln, bool failOK)
...
@@ -267,7 +273,10 @@ smgropen(int16 which, Relation reln, bool failOK)
return
-
1
;
return
-
1
;
if
((
fd
=
(
*
(
smgrsw
[
which
].
smgr_open
))
(
reln
))
<
0
)
if
((
fd
=
(
*
(
smgrsw
[
which
].
smgr_open
))
(
reln
))
<
0
)
if
(
!
failOK
)
if
(
!
failOK
)
elog
(
ERROR
,
"cannot open %s: %m"
,
RelationGetRelationName
(
reln
));
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not open
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
))));
return
fd
;
return
fd
;
}
}
...
@@ -281,7 +290,10 @@ int
...
@@ -281,7 +290,10 @@ int
smgrclose
(
int16
which
,
Relation
reln
)
smgrclose
(
int16
which
,
Relation
reln
)
{
{
if
((
*
(
smgrsw
[
which
].
smgr_close
))
(
reln
)
==
SM_FAIL
)
if
((
*
(
smgrsw
[
which
].
smgr_close
))
(
reln
)
==
SM_FAIL
)
elog
(
ERROR
,
"cannot close %s: %m"
,
RelationGetRelationName
(
reln
));
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not close
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
))));
return
SM_SUCCESS
;
return
SM_SUCCESS
;
}
}
...
@@ -304,8 +316,10 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -304,8 +316,10 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status
=
(
*
(
smgrsw
[
which
].
smgr_read
))
(
reln
,
blocknum
,
buffer
);
status
=
(
*
(
smgrsw
[
which
].
smgr_read
))
(
reln
,
blocknum
,
buffer
);
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
elog
(
ERROR
,
"cannot read block %d of %s: %m"
,
ereport
(
ERROR
,
blocknum
,
RelationGetRelationName
(
reln
));
(
errcode_for_file_access
(),
errmsg
(
"could not read block %d of
\"
%s
\"
: %m"
,
blocknum
,
RelationGetRelationName
(
reln
))));
return
status
;
return
status
;
}
}
...
@@ -328,8 +342,10 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
...
@@ -328,8 +342,10 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status
=
(
*
(
smgrsw
[
which
].
smgr_write
))
(
reln
,
blocknum
,
buffer
);
status
=
(
*
(
smgrsw
[
which
].
smgr_write
))
(
reln
,
blocknum
,
buffer
);
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
elog
(
ERROR
,
"cannot write block %d of %s: %m"
,
ereport
(
ERROR
,
blocknum
,
RelationGetRelationName
(
reln
));
(
errcode_for_file_access
(),
errmsg
(
"could not write block %d of
\"
%s
\"
: %m"
,
blocknum
,
RelationGetRelationName
(
reln
))));
return
status
;
return
status
;
}
}
...
@@ -357,8 +373,10 @@ smgrblindwrt(int16 which,
...
@@ -357,8 +373,10 @@ smgrblindwrt(int16 which,
status
=
(
*
(
smgrsw
[
which
].
smgr_blindwrt
))
(
rnode
,
blkno
,
buffer
);
status
=
(
*
(
smgrsw
[
which
].
smgr_blindwrt
))
(
rnode
,
blkno
,
buffer
);
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
elog
(
ERROR
,
"cannot write block %d of %u/%u blind: %m"
,
ereport
(
ERROR
,
blkno
,
rnode
.
tblNode
,
rnode
.
relNode
);
(
errcode_for_file_access
(),
errmsg
(
"could not write block %d of %u/%u blind: %m"
,
blkno
,
rnode
.
tblNode
,
rnode
.
relNode
)));
return
status
;
return
status
;
}
}
...
@@ -384,8 +402,10 @@ smgrnblocks(int16 which, Relation reln)
...
@@ -384,8 +402,10 @@ smgrnblocks(int16 which, Relation reln)
* actually is InvalidBlockNumber.
* actually is InvalidBlockNumber.
*/
*/
if
(
nblocks
==
InvalidBlockNumber
)
if
(
nblocks
==
InvalidBlockNumber
)
elog
(
ERROR
,
"cannot count blocks for %s: %m"
,
ereport
(
ERROR
,
RelationGetRelationName
(
reln
));
(
errcode_for_file_access
(),
errmsg
(
"could not count blocks of
\"
%s
\"
: %m"
,
RelationGetRelationName
(
reln
))));
return
nblocks
;
return
nblocks
;
}
}
...
@@ -414,8 +434,10 @@ smgrtruncate(int16 which, Relation reln, BlockNumber nblocks)
...
@@ -414,8 +434,10 @@ smgrtruncate(int16 which, Relation reln, BlockNumber nblocks)
newblks
=
(
*
(
smgrsw
[
which
].
smgr_truncate
))
(
reln
,
nblocks
);
newblks
=
(
*
(
smgrsw
[
which
].
smgr_truncate
))
(
reln
,
nblocks
);
if
(
newblks
==
InvalidBlockNumber
)
if
(
newblks
==
InvalidBlockNumber
)
elog
(
ERROR
,
"cannot truncate %s to %u blocks: %m"
,
ereport
(
ERROR
,
RelationGetRelationName
(
reln
),
nblocks
);
(
errcode_for_file_access
(),
errmsg
(
"could not truncate
\"
%s
\"
to %u blocks: %m"
,
RelationGetRelationName
(
reln
),
nblocks
)));
}
}
return
newblks
;
return
newblks
;
...
@@ -456,8 +478,11 @@ smgrDoPendingDeletes(bool isCommit)
...
@@ -456,8 +478,11 @@ smgrDoPendingDeletes(bool isCommit)
* current xact.
* current xact.
*/
*/
if
((
*
(
smgrsw
[
pending
->
which
].
smgr_unlink
))
(
pending
->
relnode
)
==
SM_FAIL
)
if
((
*
(
smgrsw
[
pending
->
which
].
smgr_unlink
))
(
pending
->
relnode
)
==
SM_FAIL
)
elog
(
WARNING
,
"cannot unlink %u/%u: %m"
,
ereport
(
WARNING
,
pending
->
relnode
.
tblNode
,
pending
->
relnode
.
relNode
);
(
errcode_for_file_access
(),
errmsg
(
"could not unlink %u/%u: %m"
,
pending
->
relnode
.
tblNode
,
pending
->
relnode
.
relNode
)));
}
}
pfree
(
pending
);
pfree
(
pending
);
}
}
...
@@ -539,7 +564,7 @@ bool
...
@@ -539,7 +564,7 @@ bool
smgriswo
(
int16
smgrno
)
smgriswo
(
int16
smgrno
)
{
{
if
(
smgrno
<
0
||
smgrno
>=
NSmgr
)
if
(
smgrno
<
0
||
smgrno
>=
NSmgr
)
elog
(
ERROR
,
"i
llegal storage manager number
%d"
,
smgrno
);
elog
(
ERROR
,
"i
nvalid storage manager id:
%d"
,
smgrno
);
return
smgrwo
[
smgrno
];
return
smgrwo
[
smgrno
];
}
}
...
...
src/backend/storage/smgr/smgrtype.c
View file @
cfa191f3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.
19 2002/06/20 20:29:36 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.
20 2003/07/24 22:04:15 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,7 +48,7 @@ smgrin(PG_FUNCTION_ARGS)
...
@@ -48,7 +48,7 @@ smgrin(PG_FUNCTION_ARGS)
if
(
strcmp
(
s
,
StorageManager
[
i
].
smgr_name
)
==
0
)
if
(
strcmp
(
s
,
StorageManager
[
i
].
smgr_name
)
==
0
)
PG_RETURN_INT16
(
i
);
PG_RETURN_INT16
(
i
);
}
}
elog
(
ERROR
,
"
smgrin: unknown storage manager name '%s'
"
,
s
);
elog
(
ERROR
,
"
unrecognized storage manager name
\"
%s
\"
"
,
s
);
PG_RETURN_INT16
(
0
);
PG_RETURN_INT16
(
0
);
}
}
...
@@ -59,7 +59,7 @@ smgrout(PG_FUNCTION_ARGS)
...
@@ -59,7 +59,7 @@ smgrout(PG_FUNCTION_ARGS)
char
*
s
;
char
*
s
;
if
(
i
>=
NStorageManagers
||
i
<
0
)
if
(
i
>=
NStorageManagers
||
i
<
0
)
elog
(
ERROR
,
"
Illegal storage manager id
%d"
,
i
);
elog
(
ERROR
,
"
invalid storage manager id:
%d"
,
i
);
s
=
pstrdup
(
StorageManager
[
i
].
smgr_name
);
s
=
pstrdup
(
StorageManager
[
i
].
smgr_name
);
PG_RETURN_CSTRING
(
s
);
PG_RETURN_CSTRING
(
s
);
...
...
src/include/utils/elog.h
View file @
cfa191f3
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: elog.h,v 1.5
6 2003/07/24 17:52:49
tgl Exp $
* $Id: elog.h,v 1.5
7 2003/07/24 22:04:15
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -237,6 +237,7 @@
...
@@ -237,6 +237,7 @@
#define ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('4','0', '0','0','2')
#define ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('4','0', '0','0','2')
#define ERRCODE_T_R_SERIALIZATION_FAILURE MAKE_SQLSTATE('4','0', '0','0','1')
#define ERRCODE_T_R_SERIALIZATION_FAILURE MAKE_SQLSTATE('4','0', '0','0','1')
#define ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN MAKE_SQLSTATE('4','0', '0','0','3')
#define ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN MAKE_SQLSTATE('4','0', '0','0','3')
#define ERRCODE_T_R_DEADLOCK_DETECTED MAKE_SQLSTATE('4','0', 'P','0','1')
/* Class 42 - Syntax Error or Access Rule Violation */
/* Class 42 - Syntax Error or Access Rule Violation */
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2', '0','0','0')
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2', '0','0','0')
...
@@ -316,7 +317,6 @@
...
@@ -316,7 +317,6 @@
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('5','5', 'P','0','2')
/* Class 57 - Operator Intervention (class borrowed from DB2) */
/* Class 57 - Operator Intervention (class borrowed from DB2) */
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
...
@@ -335,6 +335,8 @@
...
@@ -335,6 +335,8 @@
/* Class XX - Internal Error (PostgreSQL-specific error class) */
/* Class XX - Internal Error (PostgreSQL-specific error class) */
/* (this is for "can't-happen" conditions and software bugs) */
/* (this is for "can't-happen" conditions and software bugs) */
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
#define ERRCODE_DATA_CORRUPTED MAKE_SQLSTATE('X','X', '0','0','1')
#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('X','X', '0','0','2')
/* Which __func__ symbol do we have, if any? */
/* Which __func__ symbol do we have, if any? */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment