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
b98ba2a0
Commit
b98ba2a0
authored
Nov 03, 2000
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pg_variable is not used in WAL version now.
parent
b703c127
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
197 additions
and
13 deletions
+197
-13
src/backend/access/transam/transam.c
src/backend/access/transam/transam.c
+11
-1
src/backend/access/transam/varsup.c
src/backend/access/transam/varsup.c
+8
-5
src/backend/access/transam/xlog.c
src/backend/access/transam/xlog.c
+32
-5
src/backend/access/transam/xlog_varsup.c
src/backend/access/transam/xlog_varsup.c
+142
-0
src/include/access/transam.h
src/include/access/transam.h
+4
-2
No files found.
src/backend/access/transam/transam.c
View file @
b98ba2a0
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.3
5 2000/08/03 19:18:55 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.3
6 2000/11/03 11:39:35 vadim
Exp $
*
* NOTES
* This file contains the high level access-method interface to the
...
...
@@ -83,6 +83,10 @@ int RecoveryCheckingEnableState = 0;
*/
extern
int
OidGenLockId
;
#ifdef XLOG
#include "miscadmin.h"
extern
VariableCache
ShmemVariableCache
;
#endif
/* ----------------
* recovery checking accessors
...
...
@@ -438,7 +442,13 @@ InitializeTransactionLog(void)
TransactionLogUpdate
(
AmiTransactionId
,
XID_COMMIT
);
TransactionIdStore
(
AmiTransactionId
,
&
cachedTestXid
);
cachedTestXidStatus
=
XID_COMMIT
;
#ifdef XLOG
Assert
(
!
IsUnderPostmaster
&&
ShmemVariableCache
->
nextXid
<=
FirstTransactionId
);
ShmemVariableCache
->
nextXid
=
FirstTransactionId
;
#else
VariableRelationPutNextXid
(
FirstTransactionId
);
#endif
}
else
if
(
RecoveryCheckingEnabled
())
...
...
src/backend/access/transam/varsup.c
View file @
b98ba2a0
...
...
@@ -8,10 +8,15 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.3
0 2000/10/28 16:20:53
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.3
1 2000/11/03 11:39:35
vadim Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef XLOG
#include "xlog_varsup.c"
#else
#include "postgres.h"
...
...
@@ -125,11 +130,7 @@ VariableRelationPutNextXid(TransactionId xid)
TransactionIdStore
(
xid
,
&
(
var
->
nextXidData
));
#ifdef XLOG
WriteBuffer
(
buf
);
/* temp */
#else
FlushBuffer
(
buf
,
TRUE
);
#endif
}
/* --------------------------------
...
...
@@ -520,3 +521,5 @@ CheckMaxObjectId(Oid assigned_oid)
prefetched_oid_count
=
0
;
/* force reload */
GetNewObjectId
(
&
temp_oid
);
/* cause target OID to be allocated */
}
#endif
/* !XLOG */
src/backend/access/transam/xlog.c
View file @
b98ba2a0
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.2
2 2000/10/28 16:20:54
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.2
3 2000/11/03 11:39:35
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -157,6 +157,7 @@ typedef struct CheckPoint
}
CheckPoint
;
#define XLOG_CHECKPOINT 0x00
#define XLOG_NEXTOID 0x10
/*
* We break each log file in 16Mb segments
...
...
@@ -1373,10 +1374,9 @@ StartupXLOG()
elog
(
LOG
,
"Invalid NextTransactionId/NextOid"
);
#endif
#ifdef XLOG_2
ShmemVariableCache
->
nextXid
=
checkPoint
.
nextXid
;
ShmemVariableCache
->
nextOid
=
checkPoint
.
nextOid
;
#endif
ShmemVariableCache
->
oidCount
=
0
;
ThisStartUpID
=
checkPoint
.
ThisStartUpID
;
...
...
@@ -1430,10 +1430,8 @@ StartupXLOG()
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
);
do
{
#ifdef XLOG_2
if
(
record
->
xl_xid
>=
ShmemVariableCache
->
nextXid
)
ShmemVariableCache
->
nextXid
=
record
->
xl_xid
+
1
;
#endif
if
(
XLOG_DEBUG
)
{
char
buf
[
8192
];
...
...
@@ -1609,6 +1607,9 @@ CreateCheckPoint(bool shutdown)
SpinRelease
(
XidGenLockId
);
SpinAcquire
(
OidGenLockId
);
checkPoint
.
nextOid
=
ShmemVariableCache
->
nextOid
;
if
(
!
shutdown
)
checkPoint
.
nextOid
+=
ShmemVariableCache
->
oidCount
;
SpinRelease
(
OidGenLockId
);
FlushBufferPool
();
...
...
@@ -1647,6 +1648,15 @@ CreateCheckPoint(bool shutdown)
return
;
}
void
XLogPutNextOid
(
Oid
nextOid
);
void
XLogPutNextOid
(
Oid
nextOid
)
{
(
void
)
XLogInsert
(
RM_XLOG_ID
,
XLOG_NEXTOID
,
(
char
*
)
&
nextOid
,
sizeof
(
Oid
),
NULL
,
0
);
}
void
xlog_redo
(
XLogRecPtr
lsn
,
XLogRecord
*
record
);
void
xlog_undo
(
XLogRecPtr
lsn
,
XLogRecord
*
record
);
void
xlog_desc
(
char
*
buf
,
uint8
xl_info
,
char
*
rec
);
...
...
@@ -1654,6 +1664,16 @@ void xlog_desc(char *buf, uint8 xl_info, char* rec);
void
xlog_redo
(
XLogRecPtr
lsn
,
XLogRecord
*
record
)
{
uint8
info
=
record
->
xl_info
&
~
XLR_INFO_MASK
;
if
(
info
==
XLOG_NEXTOID
)
{
Oid
nextOid
;
memcpy
(
&
nextOid
,
XLogRecGetData
(
record
),
sizeof
(
Oid
));
if
(
ShmemVariableCache
->
nextOid
<
nextOid
)
ShmemVariableCache
->
nextOid
=
nextOid
;
}
}
void
...
...
@@ -1677,6 +1697,13 @@ xlog_desc(char *buf, uint8 xl_info, char* rec)
checkpoint
->
nextOid
,
(
checkpoint
->
Shutdown
)
?
"shutdown"
:
"online"
);
}
else
if
(
info
==
XLOG_NEXTOID
)
{
Oid
nextOid
;
memcpy
(
&
nextOid
,
rec
,
sizeof
(
Oid
));
sprintf
(
buf
+
strlen
(
buf
),
"nextOid: %u"
,
nextOid
);
}
else
strcat
(
buf
,
"UNKNOWN"
);
}
...
...
src/backend/access/transam/xlog_varsup.c
0 → 100644
View file @
b98ba2a0
/*-------------------------------------------------------------------------
*
* varsup.c
* postgres OID & XID variables support routines
*
* Copyright (c) 2000, PostgreSQL, Inc
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xlog_varsup.c,v 1.1 2000/11/03 11:39:35 vadim Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/transam.h"
#include "storage/proc.h"
SPINLOCK
OidGenLockId
;
extern
SPINLOCK
XidGenLockId
;
extern
void
XLogPutNextOid
(
Oid
nextOid
);
/* pointer to "variable cache" in shared memory (set up by shmem.c) */
VariableCache
ShmemVariableCache
=
NULL
;
void
GetNewTransactionId
(
TransactionId
*
xid
)
{
/*
* During bootstrap initialization, we return the special
* bootstrap transaction id.
*/
if
(
AMI_OVERRIDE
)
{
*
xid
=
AmiTransactionId
;
return
;
}
SpinAcquire
(
XidGenLockId
);
*
xid
=
ShmemVariableCache
->
nextXid
;
(
ShmemVariableCache
->
nextXid
)
++
;
if
(
MyProc
!=
(
PROC
*
)
NULL
)
MyProc
->
xid
=
*
xid
;
SpinRelease
(
XidGenLockId
);
}
/*
* Like GetNewTransactionId reads nextXid but don't fetch it.
*/
void
ReadNewTransactionId
(
TransactionId
*
xid
)
{
/*
* During bootstrap initialization, we return the special
* bootstrap transaction id.
*/
if
(
AMI_OVERRIDE
)
{
*
xid
=
AmiTransactionId
;
return
;
}
SpinAcquire
(
XidGenLockId
);
*
xid
=
ShmemVariableCache
->
nextXid
;
SpinRelease
(
XidGenLockId
);
}
/* ----------------------------------------------------------------
* object id generation support
* ----------------------------------------------------------------
*/
#define VAR_OID_PREFETCH 8192
static
Oid
lastSeenOid
=
InvalidOid
;
void
GetNewObjectId
(
Oid
*
oid_return
)
{
SpinAcquire
(
OidGenLockId
);
/* If we run out of logged for use oids then we log more */
if
(
ShmemVariableCache
->
oidCount
==
0
)
{
XLogPutNextOid
(
ShmemVariableCache
->
nextOid
+
VAR_OID_PREFETCH
);
ShmemVariableCache
->
oidCount
=
VAR_OID_PREFETCH
;
}
if
(
PointerIsValid
(
oid_return
))
lastSeenOid
=
(
*
oid_return
)
=
ShmemVariableCache
->
nextOid
;
(
ShmemVariableCache
->
nextOid
)
++
;
(
ShmemVariableCache
->
oidCount
)
--
;
SpinRelease
(
OidGenLockId
);
}
void
CheckMaxObjectId
(
Oid
assigned_oid
)
{
if
(
lastSeenOid
!=
InvalidOid
&&
assigned_oid
<
lastSeenOid
)
return
;
SpinAcquire
(
OidGenLockId
);
if
(
assigned_oid
<
ShmemVariableCache
->
nextOid
)
{
lastSeenOid
=
ShmemVariableCache
->
nextOid
-
1
;
SpinRelease
(
OidGenLockId
);
return
;
}
/* If we are in the logged oid range, just bump nextOid up */
if
(
assigned_oid
<=
ShmemVariableCache
->
nextOid
+
ShmemVariableCache
->
oidCount
-
1
)
{
ShmemVariableCache
->
oidCount
-=
assigned_oid
-
ShmemVariableCache
->
nextOid
+
1
;
ShmemVariableCache
->
nextOid
=
assigned_oid
+
1
;
SpinRelease
(
OidGenLockId
);
return
;
}
/*
* We have exceeded the logged oid range.
* We should lock the database and kill all other backends
* but we are loading oid's that we can not guarantee are unique
* anyway, so we must rely on the user.
*/
XLogPutNextOid
(
assigned_oid
+
VAR_OID_PREFETCH
);
ShmemVariableCache
->
oidCount
=
VAR_OID_PREFETCH
-
1
;
ShmemVariableCache
->
nextOid
=
assigned_oid
+
1
;
SpinRelease
(
OidGenLockId
);
}
src/include/access/transam.h
View file @
b98ba2a0
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: transam.h,v 1.2
5 2000/10/28 16:20:59
vadim Exp $
* $Id: transam.h,v 1.2
6 2000/11/03 11:39:36
vadim Exp $
*
* NOTES
* Transaction System Version 101 now support proper oid
...
...
@@ -136,10 +136,12 @@ typedef VariableRelationContentsData *VariableRelationContents;
*/
typedef
struct
VariableCacheData
{
#ifndef XLOG
uint32
xid_count
;
#endif
TransactionId
nextXid
;
uint32
oid_count
;
/* not implemented, yet */
Oid
nextOid
;
uint32
oidCount
;
}
VariableCacheData
;
typedef
VariableCacheData
*
VariableCache
;
...
...
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