mirror of
https://github.com/postgres/postgres.git
synced 2025-05-13 01:13:08 -04:00
Transaction log manager core code.
It doesn't work currently but also don't break anything -:)
This commit is contained in:
parent
2902c4c640
commit
30659d43eb
@ -4,7 +4,7 @@
|
|||||||
# Makefile for access/transam
|
# Makefile for access/transam
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.6 1998/04/06 00:21:52 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.7 1999/09/27 15:47:37 vadim Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ include ../../../Makefile.global
|
|||||||
|
|
||||||
CFLAGS += -I../..
|
CFLAGS += -I../..
|
||||||
|
|
||||||
OBJS = transam.o transsup.o varsup.o xact.o xid.o
|
OBJS = transam.o transsup.o varsup.o xact.o xid.o xlog.o rmgr.o
|
||||||
|
|
||||||
all: SUBSYS.o
|
all: SUBSYS.o
|
||||||
|
|
||||||
|
4
src/backend/access/transam/rmgr.c
Normal file
4
src/backend/access/transam/rmgr.c
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include "postgres.h"
|
||||||
|
#include "access/rmgr.h"
|
||||||
|
|
||||||
|
RmgrData *RmgrTable = NULL;
|
1434
src/backend/access/transam/xlog.c
Normal file
1434
src/backend/access/transam/xlog.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.117 1999/09/27 03:13:05 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.118 1999/09/27 15:47:43 vadim Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -204,9 +204,10 @@ static int SendStop = false;
|
|||||||
|
|
||||||
static bool NetServer = false; /* if not zero, postmaster listen for
|
static bool NetServer = false; /* if not zero, postmaster listen for
|
||||||
* non-local connections */
|
* non-local connections */
|
||||||
|
#ifdef USE_SSL
|
||||||
static bool SecureNetServer = false; /* if not zero, postmaster listens for only SSL
|
static bool SecureNetServer = false; /* if not zero, postmaster listens for only SSL
|
||||||
* non-local connections */
|
* non-local connections */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GH: For !HAVE_SIGPROCMASK (NEXTSTEP), TRH implemented an
|
* GH: For !HAVE_SIGPROCMASK (NEXTSTEP), TRH implemented an
|
||||||
@ -990,12 +991,17 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
|
|||||||
|
|
||||||
/* Could add additional special packet types here */
|
/* Could add additional special packet types here */
|
||||||
|
|
||||||
/* Any SSL negotiation must have taken place here, so drop the connection
|
#ifdef USE_SSL
|
||||||
* ASAP if we require SSL */
|
/*
|
||||||
if (SecureNetServer && !port->ssl) {
|
* Any SSL negotiation must have taken place here, so drop the connection
|
||||||
|
* ASAP if we require SSL
|
||||||
|
*/
|
||||||
|
if (SecureNetServer && !port->ssl)
|
||||||
|
{
|
||||||
PacketSendError(&port->pktInfo, "Backend requires secure connection.");
|
PacketSendError(&port->pktInfo, "Backend requires secure connection.");
|
||||||
return STATUS_OK;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check we can handle the protocol the frontend is using. */
|
/* Check we can handle the protocol the frontend is using. */
|
||||||
|
|
||||||
@ -1832,6 +1838,7 @@ CountChildren(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_SSL
|
||||||
/*
|
/*
|
||||||
* Initialize SSL library and structures
|
* Initialize SSL library and structures
|
||||||
*/
|
*/
|
||||||
@ -1860,3 +1867,4 @@ static void InitSSL(void) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Id: fd.c,v 1.47 1999/07/17 20:17:42 momjian Exp $
|
* $Id: fd.c,v 1.48 1999/09/27 15:47:49 vadim Exp $
|
||||||
*
|
*
|
||||||
* NOTES:
|
* NOTES:
|
||||||
*
|
*
|
||||||
@ -49,6 +49,7 @@
|
|||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
|
|
||||||
|
bool ReleaseDataFile(void);
|
||||||
/*
|
/*
|
||||||
* Problem: Postgres does a system(ld...) to do dynamic loading.
|
* Problem: Postgres does a system(ld...) to do dynamic loading.
|
||||||
* This will open several extra files in addition to those used by
|
* This will open several extra files in addition to those used by
|
||||||
@ -410,6 +411,19 @@ ReleaseLruFile()
|
|||||||
LruDelete(VfdCache[0].lruMoreRecently);
|
LruDelete(VfdCache[0].lruMoreRecently);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ReleaseDataFile()
|
||||||
|
{
|
||||||
|
DO_DB(elog(DEBUG, "ReleaseDataFile. Opened %d", nfile));
|
||||||
|
|
||||||
|
if (nfile <= 0)
|
||||||
|
return(false);
|
||||||
|
Assert(VfdCache[0].lruMoreRecently != 0);
|
||||||
|
LruDelete(VfdCache[0].lruMoreRecently);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
static File
|
static File
|
||||||
AllocateVfd()
|
AllocateVfd()
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.66 1999/09/23 17:02:52 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.67 1999/09/27 15:47:54 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -220,13 +220,13 @@ ProcessUtility(Node *parsetree,
|
|||||||
relname);
|
relname);
|
||||||
}
|
}
|
||||||
|
|
||||||
rel = heap_openr(relname);
|
rel = heap_openr(relname, AccessExclusiveLock);
|
||||||
if (RelationIsValid(rel)) {
|
if (RelationIsValid(rel)) {
|
||||||
if (rel->rd_rel->relkind == RELKIND_SEQUENCE) {
|
if (rel->rd_rel->relkind == RELKIND_SEQUENCE) {
|
||||||
elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence",
|
elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence",
|
||||||
relname);
|
relname);
|
||||||
}
|
}
|
||||||
heap_close(rel);
|
heap_close(rel, NoLock);
|
||||||
}
|
}
|
||||||
#ifndef NO_SECURITY
|
#ifndef NO_SECURITY
|
||||||
if (!pg_ownercheck(userName, relname, RELNAME)) {
|
if (!pg_ownercheck(userName, relname, RELNAME)) {
|
||||||
|
34
src/include/access/rmgr.h
Normal file
34
src/include/access/rmgr.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* rmgr.h
|
||||||
|
*
|
||||||
|
* Resource managers description table
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef RMGR_H
|
||||||
|
#define RMGR_H
|
||||||
|
|
||||||
|
typedef uint8 RmgrId;
|
||||||
|
|
||||||
|
typedef struct RmgrData
|
||||||
|
{
|
||||||
|
char *rm_name;
|
||||||
|
char *(*rm_redo) (); /* REDO(XLogRecPtr rptr) */
|
||||||
|
char *(*rm_undo) (); /* UNDO(XLogRecPtr rptr) */
|
||||||
|
} RmgrData;
|
||||||
|
|
||||||
|
extern RmgrData *RmgrTable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Built-in resource managers
|
||||||
|
*/
|
||||||
|
#define RM_XLOG_ID 0
|
||||||
|
#define RM_XACT_ID 1
|
||||||
|
#define RM_HEAP_ID 2
|
||||||
|
#define RM_BTREE_ID 3
|
||||||
|
#define RM_HASH_ID 4
|
||||||
|
#define RM_RTREE_ID 5
|
||||||
|
#define RM_GIST_ID 6
|
||||||
|
#define RM_MAX_ID RM_GIST_ID
|
||||||
|
|
||||||
|
#endif /* RMGR_H */
|
70
src/include/access/xlog.h
Normal file
70
src/include/access/xlog.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* xlog.h
|
||||||
|
*
|
||||||
|
* Postgres transaction log manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef XLOG_H
|
||||||
|
#define XLOG_H
|
||||||
|
|
||||||
|
#include "access/rmgr.h"
|
||||||
|
#include "access/transam.h"
|
||||||
|
|
||||||
|
typedef struct XLogRecPtr
|
||||||
|
{
|
||||||
|
uint32 xlogid; /* log file #, 0 based */
|
||||||
|
uint32 xrecoff; /* offset of record in log file */
|
||||||
|
} XLogRecPtr;
|
||||||
|
|
||||||
|
typedef struct XLogRecord
|
||||||
|
{
|
||||||
|
XLogRecPtr xl_prev; /* ptr to previous record in log */
|
||||||
|
XLogRecPtr xl_xact_prev; /* ptr to previous record of this xact */
|
||||||
|
TransactionId xl_xid; /* xact id */
|
||||||
|
uint16 xl_len; /* len of record on this page */
|
||||||
|
uint8 xl_info;
|
||||||
|
RmgrId xl_rmid; /* resource manager inserted this record */
|
||||||
|
|
||||||
|
/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
|
||||||
|
|
||||||
|
} XLogRecord;
|
||||||
|
|
||||||
|
#define SizeOfXLogRecord DOUBLEALIGN(sizeof(XLogRecord))
|
||||||
|
#define MAXLOGRECSZ (2 * BLCKSZ)
|
||||||
|
/*
|
||||||
|
* When there is no space on current page we continue on the next
|
||||||
|
* page with subrecord.
|
||||||
|
*/
|
||||||
|
typedef struct XLogSubRecord
|
||||||
|
{
|
||||||
|
uint16 xl_len;
|
||||||
|
uint8 xl_info;
|
||||||
|
|
||||||
|
/* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
|
||||||
|
|
||||||
|
} XLogSubRecord;
|
||||||
|
|
||||||
|
#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord))
|
||||||
|
|
||||||
|
#define XLR_TO_BE_CONTINUED 0x01
|
||||||
|
|
||||||
|
#define XLOG_PAGE_MAGIC 0x17345168
|
||||||
|
|
||||||
|
typedef struct XLogPageHeaderData
|
||||||
|
{
|
||||||
|
uint32 xlp_magic;
|
||||||
|
uint16 xlp_info;
|
||||||
|
} XLogPageHeaderData;
|
||||||
|
|
||||||
|
#define SizeOfXLogPHD DOUBLEALIGN(sizeof(XLogPageHeaderData))
|
||||||
|
|
||||||
|
typedef XLogPageHeaderData *XLogPageHeader;
|
||||||
|
|
||||||
|
#define XLP_FIRST_IS_SUBRECORD 0x0001
|
||||||
|
|
||||||
|
extern XLogRecPtr XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen,
|
||||||
|
char *buf, uint32 buflen);
|
||||||
|
extern void XLogFlush(XLogRecPtr RecPtr);
|
||||||
|
|
||||||
|
#endif /* XLOG_H */
|
@ -6,13 +6,14 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: proc.h,v 1.26 1999/09/24 00:25:27 tgl Exp $
|
* $Id: proc.h,v 1.27 1999/09/27 15:48:06 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#ifndef _PROC_H_
|
#ifndef _PROC_H_
|
||||||
#define _PROC_H_
|
#define _PROC_H_
|
||||||
|
|
||||||
|
#include "access/xlog.h"
|
||||||
#include "storage/lock.h"
|
#include "storage/lock.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -47,7 +48,7 @@ typedef struct proc
|
|||||||
TransactionId xmin; /* minimal running XID as it was when we
|
TransactionId xmin; /* minimal running XID as it was when we
|
||||||
* were starting our xact: vacuum must not
|
* were starting our xact: vacuum must not
|
||||||
* remove tuples deleted by xid >= xmin ! */
|
* remove tuples deleted by xid >= xmin ! */
|
||||||
|
XLogRecPtr logRec;
|
||||||
LOCK *waitLock; /* Lock we're sleeping on ... */
|
LOCK *waitLock; /* Lock we're sleeping on ... */
|
||||||
int token; /* type of lock we sleeping for */
|
int token; /* type of lock we sleeping for */
|
||||||
int holdLock; /* while holding these locks */
|
int holdLock; /* while holding these locks */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: elog.h,v 1.12 1999/09/11 19:06:25 tgl Exp $
|
* $Id: elog.h,v 1.13 1999/09/27 15:48:12 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,9 @@
|
|||||||
#define ERROR (-1) /* user error - return to known state */
|
#define ERROR (-1) /* user error - return to known state */
|
||||||
#define FATAL 1 /* fatal error - abort process */
|
#define FATAL 1 /* fatal error - abort process */
|
||||||
#define REALLYFATAL 2 /* take down the other backends with me */
|
#define REALLYFATAL 2 /* take down the other backends with me */
|
||||||
|
#define STOP REALLYFATAL
|
||||||
#define DEBUG (-2) /* debug message */
|
#define DEBUG (-2) /* debug message */
|
||||||
|
#define LOG DEBUG
|
||||||
#define NOIND (-3) /* debug message, don't indent as far */
|
#define NOIND (-3) /* debug message, don't indent as far */
|
||||||
|
|
||||||
extern void elog(int lev, const char *fmt, ...);
|
extern void elog(int lev, const char *fmt, ...);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user