Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
626eb021
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
626eb021
编写于
3月 07, 2007
作者:
A
Alvaro Herrera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup the bootstrap code a little, and rename "dummy procs" in the code
comments and variables to "auxiliary proc", per Heikki's request.
上级
cc0cac4a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
151 addition
and
168 deletion
+151
-168
src/backend/bootstrap/bootparse.y
src/backend/bootstrap/bootparse.y
+2
-5
src/backend/bootstrap/bootstrap.c
src/backend/bootstrap/bootstrap.c
+67
-81
src/backend/main/main.c
src/backend/main/main.c
+2
-2
src/backend/postmaster/autovacuum.c
src/backend/postmaster/autovacuum.c
+3
-3
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+22
-22
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+41
-41
src/include/bootstrap/bootstrap.h
src/include/bootstrap/bootstrap.h
+9
-6
src/include/storage/proc.h
src/include/storage/proc.h
+4
-4
src/include/tcop/tcopprot.h
src/include/tcop/tcopprot.h
+1
-4
未找到文件。
src/backend/bootstrap/bootparse.y
浏览文件 @
626eb021
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.8
6 2007/01/09 02:14:11 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.8
7 2007/03/07 13:35:02 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -235,10 +235,7 @@ Boot_InsertStmt:
elog(ERROR, "incorrect number of columns in row (expected %d, got %d)",
numattr, num_columns_read);
if (boot_reldesc == NULL)
{
elog(ERROR, "relation not open");
err_out();
}
elog(FATAL, "relation not open");
InsertOneTuple($2);
do_end();
}
...
...
src/backend/bootstrap/bootstrap.c
浏览文件 @
626eb021
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.23
2 2007/02/16 02:10:07
alvherre Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.23
3 2007/03/07 13:35:02
alvherre Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,8 +20,6 @@
#include <getopt.h>
#endif
#define BOOTSTRAP_INCLUDE
/* mask out stuff in tcop/tcopprot.h */
#include "access/genam.h"
#include "access/heapam.h"
#include "access/xact.h"
...
...
@@ -48,8 +46,10 @@ extern char *optarg;
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
static
void
CheckerModeMain
(
void
);
static
void
BootstrapModeMain
(
void
);
static
void
bootstrap_signals
(
void
);
static
void
Shutdown
Dumm
yProcess
(
int
code
,
Datum
arg
);
static
void
Shutdown
Auxiliar
yProcess
(
int
code
,
Datum
arg
);
static
hashnode
*
AddStr
(
char
*
str
,
int
strlength
,
int
mderef
);
static
Form_pg_attribute
AllocateAttribute
(
void
);
static
int
CompHash
(
char
*
str
,
int
len
);
...
...
@@ -166,7 +166,6 @@ struct typmap
static
struct
typmap
**
Typ
=
NULL
;
static
struct
typmap
*
Ap
=
NULL
;
static
int
Warnings
=
0
;
static
char
Blanks
[
MAXATTR
];
Form_pg_attribute
attrtypes
[
MAXATTR
];
/* points to attribute info */
...
...
@@ -193,23 +192,19 @@ static IndexList *ILHead = NULL;
/*
*
The main entry point for running the backend in bootstrap mode
*
AuxiliaryProcessMain
*
* The bootstrap mode is used to initialize the template database.
* The bootstrap backend doesn't speak SQL, but instead expects
* commands in a special bootstrap language.
* The main entry point for auxiliary processes, such as the bgwriter,
* bootstrapper and the shared memory checker code.
*
* For historical reasons, BootstrapMain is also used as the control
* routine for non-backend subprocesses launched by the postmaster,
* such as startup and shutdown.
* This code is here just because of historical reasons.
*/
int
Bootstrap
Main
(
int
argc
,
char
*
argv
[])
void
AuxiliaryProcess
Main
(
int
argc
,
char
*
argv
[])
{
char
*
progname
=
argv
[
0
];
int
i
;
int
flag
;
int
xlogop
=
BS_XLOG_NOP
;
AuxProcType
auxType
=
CheckerProcess
;
char
*
userDoption
=
NULL
;
/*
...
...
@@ -278,7 +273,7 @@ BootstrapMain(int argc, char *argv[])
strlcpy
(
OutputFileName
,
optarg
,
MAXPGPATH
);
break
;
case
'x'
:
xlogop
=
atoi
(
optarg
);
auxType
=
atoi
(
optarg
);
break
;
case
'c'
:
case
'-'
:
...
...
@@ -328,12 +323,12 @@ BootstrapMain(int argc, char *argv[])
{
const
char
*
statmsg
;
switch
(
xlogop
)
switch
(
auxType
)
{
case
BS_XLOG_STARTUP
:
case
StartupProcess
:
statmsg
=
"startup process"
;
break
;
case
B
S_XLOG_BGWRITER
:
case
B
gWriterProcess
:
statmsg
=
"writer process"
;
break
;
default:
...
...
@@ -372,9 +367,9 @@ BootstrapMain(int argc, char *argv[])
BaseInit
();
/*
* When we are a
dumm
y process, we aren't going to do the full
* When we are a
n auxiliar
y process, we aren't going to do the full
* InitPostgres pushups, but there are a couple of things that need to get
* lit up even in a
dumm
y process.
* lit up even in a
n auxiliar
y process.
*/
if
(
IsUnderPostmaster
)
{
...
...
@@ -383,14 +378,14 @@ BootstrapMain(int argc, char *argv[])
* this was already done by SubPostmasterMain().
*/
#ifndef EXEC_BACKEND
Init
Dumm
yProcess
();
Init
Auxiliar
yProcess
();
#endif
/* finish setting up bufmgr.c */
InitBufferPoolBackend
();
/* register a shutdown callback for LWLock cleanup */
on_shmem_exit
(
Shutdown
Dumm
yProcess
,
0
);
on_shmem_exit
(
Shutdown
Auxiliar
yProcess
,
0
);
}
/*
...
...
@@ -398,36 +393,47 @@ BootstrapMain(int argc, char *argv[])
*/
SetProcessingMode
(
NormalProcessing
);
switch
(
xlogop
)
switch
(
auxType
)
{
case
BS_XLOG_NOP
:
case
CheckerProcess
:
bootstrap_signals
();
break
;
CheckerModeMain
();
proc_exit
(
1
);
/* should never return */
case
B
S_XLOG_BOOTSTRAP
:
case
B
ootstrapProcess
:
bootstrap_signals
();
BootStrapXLOG
();
StartupXLOG
();
break
;
BootstrapModeMain
();
proc_exit
(
1
);
/* should never return */
case
BS_XLOG_STARTUP
:
case
StartupProcess
:
bootstrap_signals
();
StartupXLOG
();
LoadFreeSpaceMap
();
BuildFlatFiles
(
false
);
proc_exit
(
0
);
/* startup done */
case
B
S_XLOG_BGWRITER
:
case
B
gWriterProcess
:
/* don't set signals, bgwriter has its own agenda */
InitXLOGAccess
();
BackgroundWriterMain
();
proc_exit
(
1
);
/* should never return */
default:
elog
(
PANIC
,
"unrecognized
XLOG op: %d"
,
xlogop
);
elog
(
PANIC
,
"unrecognized
process type: %d"
,
auxType
);
proc_exit
(
1
);
}
}
/*
* In shared memory checker mode, all we really want to do is create shared
* memory and semaphores (just to prove we can do it with the current GUC
* settings).
*/
static
void
CheckerModeMain
(
void
)
{
/*
* We must be getting invoked for bootstrap mode
*/
...
...
@@ -439,15 +445,31 @@ BootstrapMain(int argc, char *argv[])
* Do backend-like initialization for bootstrap mode
*/
InitProcess
();
(
void
)
InitPostgres
(
NULL
,
InvalidOid
,
NULL
,
NULL
);
InitPostgres
(
NULL
,
InvalidOid
,
NULL
,
NULL
);
proc_exit
(
0
);
}
/*
* The main entry point for running the backend in bootstrap mode
*
* The bootstrap mode is used to initialize the template database.
* The bootstrap backend doesn't speak SQL, but instead expects
* commands in a special bootstrap language.
*/
static
void
BootstrapModeMain
(
void
)
{
int
i
;
Assert
(
!
IsUnderPostmaster
);
SetProcessingMode
(
BootstrapProcessing
);
/*
* In NOP mode, all we really want to do is create shared memory and
* semaphores (just to prove we can do it with the current GUC settings).
* So, quit now.
* Do backend-like initialization for bootstrap mode
*/
if
(
xlogop
==
BS_XLOG_NOP
)
proc_exit
(
0
);
InitProcess
();
InitPostgres
(
NULL
,
InvalidOid
,
NULL
,
NULL
);
/* Initialize stuff for bootstrap-file processing */
for
(
i
=
0
;
i
<
MAXATTR
;
i
++
)
...
...
@@ -468,14 +490,10 @@ BootstrapMain(int argc, char *argv[])
/* Perform a checkpoint to ensure everything's down to disk */
SetProcessingMode
(
NormalProcessing
);
CreateCheckPoint
(
true
,
true
);
SetProcessingMode
(
BootstrapProcessing
);
/* Clean up and exit */
StartTransactionCommand
();
cleanup
();
/* not reached, here to make compiler happy */
return
0
;
proc_exit
(
0
);
}
...
...
@@ -538,30 +556,18 @@ bootstrap_signals(void)
}
/*
* Begin shutdown of a
dumm
y process. This is approximately the equivalent
* of ShutdownPostgres() in postinit.c. We can't run transactions in a
*
dumm
y process, so most of the work of AbortTransaction() is not needed,
* Begin shutdown of a
n auxiliar
y process. This is approximately the equivalent
* of ShutdownPostgres() in postinit.c. We can't run transactions in a
n
*
auxiliar
y process, so most of the work of AbortTransaction() is not needed,
* but we do need to make sure we've released any LWLocks we are holding.
* (This is only critical during an error exit.)
*/
static
void
Shutdown
Dumm
yProcess
(
int
code
,
Datum
arg
)
Shutdown
Auxiliar
yProcess
(
int
code
,
Datum
arg
)
{
LWLockReleaseAll
();
}
/* ----------------
* error handling / abort routines
* ----------------
*/
void
err_out
(
void
)
{
Warnings
++
;
cleanup
();
}
/* ----------------------------------------------------------------
* MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
* ----------------------------------------------------------------
...
...
@@ -815,15 +821,7 @@ InsertOneValue(char *value, int i)
elog
(
DEBUG4
,
"inserting column %d value
\"
%s
\"
"
,
i
,
value
);
if
(
Typ
!=
NULL
)
{
typoid
=
boot_reldesc
->
rd_att
->
attrs
[
i
]
->
atttypid
;
}
else
{
/* XXX why is typoid determined differently in this case? */
typoid
=
attrtypes
[
i
]
->
atttypid
;
}
typoid
=
boot_reldesc
->
rd_att
->
attrs
[
i
]
->
atttypid
;
boot_get_type_io_data
(
typoid
,
&
typlen
,
&
typbyval
,
&
typalign
,
...
...
@@ -856,19 +854,8 @@ InsertOneNull(int i)
static
void
cleanup
(
void
)
{
static
int
beenhere
=
0
;
if
(
!
beenhere
)
beenhere
=
1
;
else
{
elog
(
FATAL
,
"cleanup called twice"
);
proc_exit
(
1
);
}
if
(
boot_reldesc
!=
NULL
)
closerel
(
NULL
);
CommitTransactionCommand
();
proc_exit
(
Warnings
?
1
:
0
);
}
/* ----------------
...
...
@@ -934,7 +921,6 @@ gettype(char *type)
return
gettype
(
type
);
}
elog
(
ERROR
,
"unrecognized type
\"
%s
\"
"
,
type
);
err_out
();
/* not reached, here to make compiler happy */
return
0
;
}
...
...
src/backend/main/main.c
浏览文件 @
626eb021
...
...
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.10
7 2007/01/05 22:19:29 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.10
8 2007/03/07 13:35:02 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
#endif
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"--boot"
)
==
0
)
exit
(
BootstrapMain
(
argc
,
argv
));
AuxiliaryProcessMain
(
argc
,
argv
);
/* does not return */
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"--describe-config"
)
==
0
)
exit
(
GucInfoMain
());
...
...
src/backend/postmaster/autovacuum.c
浏览文件 @
626eb021
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.3
2 2007/02/15 23:23:23
alvherre Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.3
3 2007/03/07 13:35:02
alvherre Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -246,7 +246,7 @@ AutoVacLauncherMain(int argc, char *argv[])
#endif
/*
* Set up signal handlers. Since this is a
"dummy"
process, it has
* Set up signal handlers. Since this is a
n auxiliary
process, it has
* particular signal requirements -- no deadlock checker or sinval
* catchup, for example.
*
...
...
@@ -277,7 +277,7 @@ AutoVacLauncherMain(int argc, char *argv[])
* had to do some stuff with LWLocks).
*/
#ifndef EXEC_BACKEND
Init
Dumm
yProcess
();
Init
Auxiliar
yProcess
();
#endif
/*
...
...
src/backend/postmaster/postmaster.c
浏览文件 @
626eb021
...
...
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.52
5 2007/02/16 17:06:59 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.52
6 2007/03/07 13:35:02 alvherre
Exp $
*
* NOTES
*
...
...
@@ -275,7 +275,7 @@ static void SignalChildren(int signal);
static
void
SignalSomeChildren
(
int
signal
,
bool
only_autovac
);
static
int
CountChildren
(
void
);
static
bool
CreateOptsFile
(
int
argc
,
char
*
argv
[],
char
*
fullprogname
);
static
pid_t
StartChildProcess
(
int
xlop
);
static
pid_t
StartChildProcess
(
AuxProcType
type
);
static
void
StartAutovacuumWorker
(
void
);
#ifdef EXEC_BACKEND
...
...
@@ -328,7 +328,7 @@ typedef struct
LWLock
*
LWLockArray
;
slock_t
*
ProcStructLock
;
PROC_HDR
*
ProcGlobal
;
PGPROC
*
Dumm
yProcs
;
PGPROC
*
Auxiliar
yProcs
;
InheritableSocket
pgStatSock
;
pid_t
PostmasterPid
;
TimestampTz
PgStartTime
;
...
...
@@ -360,8 +360,8 @@ static void ShmemBackendArrayAdd(Backend *bn);
static
void
ShmemBackendArrayRemove
(
pid_t
pid
);
#endif
/* EXEC_BACKEND */
#define StartupDataBase() StartChildProcess(
BS_XLOG_STARTUP
)
#define StartBackgroundWriter() StartChildProcess(B
S_XLOG_BGWRITER
)
#define StartupDataBase() StartChildProcess(
StartupProcess
)
#define StartBackgroundWriter() StartChildProcess(B
gWriterProcess
)
/* Macros to check exit status of a child process */
#define EXIT_STATUS_0(st) ((st) == 0)
...
...
@@ -3433,12 +3433,12 @@ SubPostmasterMain(int argc, char *argv[])
InitShmemAccess
(
UsedShmemSegAddr
);
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
Init
Dumm
yProcess
();
Init
Auxiliar
yProcess
();
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores
(
false
,
0
);
Bootstrap
Main
(
argc
-
2
,
argv
+
2
);
AuxiliaryProcess
Main
(
argc
-
2
,
argv
+
2
);
proc_exit
(
0
);
}
if
(
strcmp
(
argv
[
1
],
"--forkavlauncher"
)
==
0
)
...
...
@@ -3450,7 +3450,7 @@ SubPostmasterMain(int argc, char *argv[])
InitShmemAccess
(
UsedShmemSegAddr
);
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
Init
Dumm
yProcess
();
Init
Auxiliar
yProcess
();
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores
(
false
,
0
);
...
...
@@ -3700,21 +3700,21 @@ CountChildren(void)
/*
* StartChildProcess -- start a
non-backend child
process for the postmaster
* StartChildProcess -- start a
n auxiliary
process for the postmaster
*
* xlop determines what kind of child will be started. All child types
* initially go to
Bootstrap
Main, which will handle common setup.
* initially go to
AuxiliaryProcess
Main, which will handle common setup.
*
* Return value of StartChildProcess is subprocess' PID, or 0 if failed
* to start subprocess.
*/
static
pid_t
StartChildProcess
(
int
xlop
)
StartChildProcess
(
AuxProcType
type
)
{
pid_t
pid
;
char
*
av
[
10
];
int
ac
=
0
;
char
xl
buf
[
32
];
char
type
buf
[
32
];
/*
* Set up command-line arguments for subprocess
...
...
@@ -3726,8 +3726,8 @@ StartChildProcess(int xlop)
av
[
ac
++
]
=
NULL
;
/* filled in by postmaster_forkexec */
#endif
snprintf
(
xlbuf
,
sizeof
(
xlbuf
),
"-x%d"
,
xlop
);
av
[
ac
++
]
=
xl
buf
;
snprintf
(
typebuf
,
sizeof
(
typebuf
),
"-x%d"
,
type
);
av
[
ac
++
]
=
type
buf
;
av
[
ac
]
=
NULL
;
Assert
(
ac
<
lengthof
(
av
));
...
...
@@ -3752,7 +3752,7 @@ StartChildProcess(int xlop)
MemoryContextDelete
(
PostmasterContext
);
PostmasterContext
=
NULL
;
Bootstrap
Main
(
ac
,
av
);
AuxiliaryProcess
Main
(
ac
,
av
);
ExitPostmaster
(
0
);
}
#endif
/* EXEC_BACKEND */
...
...
@@ -3763,13 +3763,13 @@ StartChildProcess(int xlop)
int
save_errno
=
errno
;
errno
=
save_errno
;
switch
(
xlop
)
switch
(
type
)
{
case
BS_XLOG_STARTUP
:
case
StartupProcess
:
ereport
(
LOG
,
(
errmsg
(
"could not fork startup process: %m"
)));
break
;
case
B
S_XLOG_BGWRITER
:
case
B
gWriterProcess
:
ereport
(
LOG
,
(
errmsg
(
"could not fork background writer process: %m"
)));
break
;
...
...
@@ -3783,7 +3783,7 @@ StartChildProcess(int xlop)
* fork failure is fatal during startup, but there's no need to choke
* immediately if starting other child types fails.
*/
if
(
xlop
==
BS_XLOG_STARTUP
)
if
(
type
==
StartupProcess
)
ExitPostmaster
(
1
);
return
0
;
}
...
...
@@ -3887,7 +3887,7 @@ extern slock_t *ShmemLock;
extern
LWLock
*
LWLockArray
;
extern
slock_t
*
ProcStructLock
;
extern
PROC_HDR
*
ProcGlobal
;
extern
PGPROC
*
Dumm
yProcs
;
extern
PGPROC
*
Auxiliar
yProcs
;
extern
int
pgStatSock
;
#ifndef WIN32
...
...
@@ -3930,7 +3930,7 @@ save_backend_variables(BackendParameters * param, Port *port,
param
->
LWLockArray
=
LWLockArray
;
param
->
ProcStructLock
=
ProcStructLock
;
param
->
ProcGlobal
=
ProcGlobal
;
param
->
DummyProcs
=
Dumm
yProcs
;
param
->
AuxiliaryProcs
=
Auxiliar
yProcs
;
write_inheritable_socket
(
&
param
->
pgStatSock
,
pgStatSock
,
childPid
);
param
->
PostmasterPid
=
PostmasterPid
;
...
...
@@ -4133,7 +4133,7 @@ restore_backend_variables(BackendParameters * param, Port *port)
LWLockArray
=
param
->
LWLockArray
;
ProcStructLock
=
param
->
ProcStructLock
;
ProcGlobal
=
param
->
ProcGlobal
;
DummyProcs
=
param
->
Dumm
yProcs
;
AuxiliaryProcs
=
param
->
Auxiliar
yProcs
;
read_inheritable_socket
(
&
pgStatSock
,
&
param
->
pgStatSock
);
PostmasterPid
=
param
->
PostmasterPid
;
...
...
src/backend/storage/lmgr/proc.c
浏览文件 @
626eb021
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.18
5 2007/03/03 18:46:40 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.18
6 2007/03/07 13:35:03 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -64,7 +64,7 @@ NON_EXEC_STATIC slock_t *ProcStructLock = NULL;
/* Pointers to shared-memory structures */
NON_EXEC_STATIC
PROC_HDR
*
ProcGlobal
=
NULL
;
NON_EXEC_STATIC
PGPROC
*
Dumm
yProcs
=
NULL
;
NON_EXEC_STATIC
PGPROC
*
Auxiliar
yProcs
=
NULL
;
/* If we are waiting for a lock, this points to the associated LOCALLOCK */
static
LOCALLOCK
*
lockAwaited
=
NULL
;
...
...
@@ -80,7 +80,7 @@ static TimestampTz statement_fin_time;
static
void
RemoveProcFromArray
(
int
code
,
Datum
arg
);
static
void
ProcKill
(
int
code
,
Datum
arg
);
static
void
Dumm
yProcKill
(
int
code
,
Datum
arg
);
static
void
Auxiliar
yProcKill
(
int
code
,
Datum
arg
);
static
bool
CheckStatementTimeout
(
void
);
...
...
@@ -94,8 +94,8 @@ ProcGlobalShmemSize(void)
/* ProcGlobal */
size
=
add_size
(
size
,
sizeof
(
PROC_HDR
));
/*
Dumm
yProcs */
size
=
add_size
(
size
,
mul_size
(
NUM_
DUMM
Y_PROCS
,
sizeof
(
PGPROC
)));
/*
Auxiliar
yProcs */
size
=
add_size
(
size
,
mul_size
(
NUM_
AUXILIAR
Y_PROCS
,
sizeof
(
PGPROC
)));
/* MyProcs */
size
=
add_size
(
size
,
mul_size
(
MaxBackends
,
sizeof
(
PGPROC
)));
/* ProcStructLock */
...
...
@@ -110,8 +110,8 @@ ProcGlobalShmemSize(void)
int
ProcGlobalSemas
(
void
)
{
/* We need a sema per backend, plus one for each
dumm
y process. */
return
MaxBackends
+
NUM_
DUMM
Y_PROCS
;
/* We need a sema per backend, plus one for each
auxiliar
y process. */
return
MaxBackends
+
NUM_
AUXILIAR
Y_PROCS
;
}
/*
...
...
@@ -135,7 +135,7 @@ ProcGlobalSemas(void)
* postmaster, not in backends.
*
* Note: this is NOT called by individual backends under a postmaster,
* not even in the EXEC_BACKEND case. The ProcGlobal and
Dumm
yProcs
* not even in the EXEC_BACKEND case. The ProcGlobal and
Auxiliar
yProcs
* pointers must be propagated specially for EXEC_BACKEND operation.
*/
void
...
...
@@ -151,11 +151,11 @@ InitProcGlobal(void)
Assert
(
!
found
);
/*
* Create the PGPROC structures for
dummy (bgwriter) processes, too. These
* do not get linked into the freeProcs list.
* Create the PGPROC structures for
auxiliary (bgwriter) processes, too.
*
These
do not get linked into the freeProcs list.
*/
Dumm
yProcs
=
(
PGPROC
*
)
ShmemInitStruct
(
"
DummyProcs"
,
NUM_DUMM
Y_PROCS
*
sizeof
(
PGPROC
),
Auxiliar
yProcs
=
(
PGPROC
*
)
ShmemInitStruct
(
"
AuxiliaryProcs"
,
NUM_AUXILIAR
Y_PROCS
*
sizeof
(
PGPROC
),
&
found
);
Assert
(
!
found
);
...
...
@@ -182,11 +182,11 @@ InitProcGlobal(void)
ProcGlobal
->
freeProcs
=
MAKE_OFFSET
(
&
procs
[
i
]);
}
MemSet
(
DummyProcs
,
0
,
NUM_DUMM
Y_PROCS
*
sizeof
(
PGPROC
));
for
(
i
=
0
;
i
<
NUM_
DUMM
Y_PROCS
;
i
++
)
MemSet
(
AuxiliaryProcs
,
0
,
NUM_AUXILIAR
Y_PROCS
*
sizeof
(
PGPROC
));
for
(
i
=
0
;
i
<
NUM_
AUXILIAR
Y_PROCS
;
i
++
)
{
DummyProcs
[
i
].
pid
=
0
;
/* marks dumm
y proc as not in use */
PGSemaphoreCreate
(
&
(
Dumm
yProcs
[
i
].
sem
));
AuxiliaryProcs
[
i
].
pid
=
0
;
/* marks auxiliar
y proc as not in use */
PGSemaphoreCreate
(
&
(
Auxiliar
yProcs
[
i
].
sem
));
}
/* Create ProcStructLock spinlock, too */
...
...
@@ -320,21 +320,21 @@ InitProcessPhase2(void)
}
/*
* Init
DummyProcess -- create a dummy per
-process data structure
* Init
AuxiliaryProcess -- create a per-auxiliary
-process data structure
*
* This is called by bgwriter and similar processes so that they will have a
* MyProc value that's real enough to let them wait for LWLocks. The PGPROC
* and sema that are assigned are one of the extra ones created during
* InitProcGlobal.
*
*
Dumm
y processes are presently not expected to wait for real (lockmgr)
*
Auxiliar
y processes are presently not expected to wait for real (lockmgr)
* locks, so we need not set up the deadlock checker. They are never added
* to the ProcArray or the sinval messaging mechanism, either.
*/
void
Init
Dumm
yProcess
(
void
)
Init
Auxiliar
yProcess
(
void
)
{
PGPROC
*
dummy
proc
;
PGPROC
*
aux
proc
;
int
proctype
;
int
i
;
...
...
@@ -342,7 +342,7 @@ InitDummyProcess(void)
* ProcGlobal should be set up already (if we are a backend, we inherit
* this by fork() or EXEC_BACKEND mechanism from the postmaster).
*/
if
(
ProcGlobal
==
NULL
||
Dumm
yProcs
==
NULL
)
if
(
ProcGlobal
==
NULL
||
Auxiliar
yProcs
==
NULL
)
elog
(
PANIC
,
"proc header uninitialized"
);
if
(
MyProc
!=
NULL
)
...
...
@@ -350,7 +350,7 @@ InitDummyProcess(void)
/*
* We use the ProcStructLock to protect assignment and releasing of
*
Dumm
yProcs entries.
*
Auxiliar
yProcs entries.
*
* While we are holding the ProcStructLock, also copy the current shared
* estimate of spins_per_delay to local storage.
...
...
@@ -360,25 +360,25 @@ InitDummyProcess(void)
set_spins_per_delay
(
ProcGlobal
->
spins_per_delay
);
/*
* Find a free
dummy
proc ... *big* trouble if there isn't one ...
* Find a free
aux
proc ... *big* trouble if there isn't one ...
*/
for
(
proctype
=
0
;
proctype
<
NUM_
DUMM
Y_PROCS
;
proctype
++
)
for
(
proctype
=
0
;
proctype
<
NUM_
AUXILIAR
Y_PROCS
;
proctype
++
)
{
dummyproc
=
&
Dumm
yProcs
[
proctype
];
if
(
dummy
proc
->
pid
==
0
)
auxproc
=
&
Auxiliar
yProcs
[
proctype
];
if
(
aux
proc
->
pid
==
0
)
break
;
}
if
(
proctype
>=
NUM_
DUMM
Y_PROCS
)
if
(
proctype
>=
NUM_
AUXILIAR
Y_PROCS
)
{
SpinLockRelease
(
ProcStructLock
);
elog
(
FATAL
,
"all
Dumm
yProcs are in use"
);
elog
(
FATAL
,
"all
Auxiliar
yProcs are in use"
);
}
/* Mark
dumm
y proc as in use by me */
/* Mark
auxiliar
y proc as in use by me */
/* use volatile pointer to prevent code rearrangement */
((
volatile
PGPROC
*
)
dummy
proc
)
->
pid
=
MyProcPid
;
((
volatile
PGPROC
*
)
aux
proc
)
->
pid
=
MyProcPid
;
MyProc
=
dummy
proc
;
MyProc
=
aux
proc
;
SpinLockRelease
(
ProcStructLock
);
...
...
@@ -412,7 +412,7 @@ InitDummyProcess(void)
/*
* Arrange to clean up at process exit.
*/
on_shmem_exit
(
Dumm
yProcKill
,
Int32GetDatum
(
proctype
));
on_shmem_exit
(
Auxiliar
yProcKill
,
Int32GetDatum
(
proctype
));
}
/*
...
...
@@ -582,28 +582,28 @@ ProcKill(int code, Datum arg)
}
/*
*
DummyProcKill() -- Cut-down version of ProcKill for dummy (bgwriter)
* processes
. The PGPROC and sema are not released, only marked
* as not-in-use.
*
AuxiliaryProcKill() -- Cut-down version of ProcKill for auxiliary
* processes
(bgwriter, etc). The PGPROC and sema are not released, only
*
marked
as not-in-use.
*/
static
void
Dumm
yProcKill
(
int
code
,
Datum
arg
)
Auxiliar
yProcKill
(
int
code
,
Datum
arg
)
{
int
proctype
=
DatumGetInt32
(
arg
);
PGPROC
*
dummy
proc
;
PGPROC
*
aux
proc
;
Assert
(
proctype
>=
0
&&
proctype
<
NUM_
DUMM
Y_PROCS
);
Assert
(
proctype
>=
0
&&
proctype
<
NUM_
AUXILIAR
Y_PROCS
);
dummyproc
=
&
Dumm
yProcs
[
proctype
];
auxproc
=
&
Auxiliar
yProcs
[
proctype
];
Assert
(
MyProc
==
dummy
proc
);
Assert
(
MyProc
==
aux
proc
);
/* Release any LW locks I am holding (see notes above) */
LWLockReleaseAll
();
SpinLockAcquire
(
ProcStructLock
);
/* Mark
dumm
y proc no longer in use */
/* Mark
auxiliar
y proc no longer in use */
MyProc
->
pid
=
0
;
/* PGPROC struct isn't mine anymore */
...
...
src/include/bootstrap/bootstrap.h
浏览文件 @
626eb021
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.4
5 2007/01/05 22:19:51 momjian
Exp $
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.4
6 2007/03/07 13:35:03 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -32,7 +32,7 @@ typedef struct hashnode
extern
Relation
boot_reldesc
;
extern
Form_pg_attribute
attrtypes
[
MAXATTR
];
extern
int
numattr
;
extern
int
Bootstrap
Main
(
int
argc
,
char
*
argv
[]);
extern
void
AuxiliaryProcess
Main
(
int
argc
,
char
*
argv
[]);
extern
void
index_register
(
Oid
heap
,
Oid
ind
,
IndexInfo
*
indexInfo
);
...
...
@@ -64,9 +64,12 @@ extern int boot_yyparse(void);
extern
int
boot_yylex
(
void
);
extern
void
boot_yyerror
(
const
char
*
str
);
#define BS_XLOG_NOP 0
#define BS_XLOG_BOOTSTRAP 1
#define BS_XLOG_STARTUP 2
#define BS_XLOG_BGWRITER 3
typedef
enum
{
CheckerProcess
,
BootstrapProcess
,
StartupProcess
,
BgWriterProcess
}
AuxProcType
;
#endif
/* BOOTSTRAP_H */
src/include/storage/proc.h
浏览文件 @
626eb021
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.9
5 2007/03/03 18:46:40 momjian
Exp $
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.9
6 2007/03/07 13:35:03 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -118,10 +118,10 @@ typedef struct PROC_HDR
}
PROC_HDR
;
/*
* We set aside some extra PGPROC structures for
"dummy"
processes,
* We set aside some extra PGPROC structures for
auxiliary
processes,
* ie things that aren't full-fledged backends but need shmem access.
*/
#define NUM_
DUMM
Y_PROCS 3
#define NUM_
AUXILIAR
Y_PROCS 3
/* configurable options */
...
...
@@ -140,7 +140,7 @@ extern Size ProcGlobalShmemSize(void);
extern
void
InitProcGlobal
(
void
);
extern
void
InitProcess
(
void
);
extern
void
InitProcessPhase2
(
void
);
extern
void
Init
Dumm
yProcess
(
void
);
extern
void
Init
Auxiliar
yProcess
(
void
);
extern
bool
HaveNFreeProcs
(
int
n
);
extern
void
ProcReleaseLocks
(
bool
isCommit
);
...
...
src/include/tcop/tcopprot.h
浏览文件 @
626eb021
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.8
7 2007/02/20 17:32:17 tgl
Exp $
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.8
8 2007/03/07 13:35:03 alvherre
Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
...
...
@@ -44,8 +44,6 @@ typedef enum
extern
LogStmtLevel
log_statement
;
#ifndef BOOTSTRAP_INCLUDE
extern
List
*
pg_parse_and_rewrite
(
const
char
*
query_string
,
Oid
*
paramTypes
,
int
numParams
);
extern
List
*
pg_parse_query
(
const
char
*
query_string
);
...
...
@@ -56,7 +54,6 @@ extern List *pg_plan_queries(List *querytrees, ParamListInfo boundParams,
bool
needSnapshot
);
extern
bool
assign_max_stack_depth
(
int
newval
,
bool
doit
,
GucSource
source
);
#endif
/* BOOTSTRAP_INCLUDE */
extern
void
die
(
SIGNAL_ARGS
);
extern
void
quickdie
(
SIGNAL_ARGS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录