设为首页 加入收藏

TOP

PostgreSQL启动过程中的那些事三:加载GUC参数(一)
2014-11-23 20:12:34 来源: 作者: 【 】 浏览:44
Tags:PostgreSQL 启动 过程 那些 加载 GUC 参数

1先上个图,看一下函数调用过程梗概,中间细节有略


\

GUC参数初始化分两步,第一步先读取buildin/compiled-in的GUC参数默认值,这里包括全部的GUC参数,建立GUC参数相关结构变量,第二步读取postgresql.conf配置文件中的参数设置之。从上图中能看出来,这个读取并设置postgresql.conf中参数的过程还是挺复杂的。

2初始化GUC相关数据结构并取hardcode/buildin的参数值。

pg里的GUC参数按设置的值分五种类型,分别是bool、int、real、string、enum,根据这五种类型,定义了五种结构类型,再根据这五种结构,每个类型建一个对应的静态数组,用于存储这些相应类型的GUC参数。这五种类型是config_bool、config_int、config_real、config_string、config_enum,对应的静态数组是ConfigureNamesBool、ConfigureNamesInt、ConfigureNamesReal、ConfigureNamesString、ConfigureNamesEnum。具体结构和数组定义见下面。

五个结构定义:

struct config_bool

{

struct config_generic gen;

/* these fields must be set correctly in initial value: */

/* (all but reset_val are constants) */

bool *variable;

bool boot_val;

GucIntCheckHookcheck_hook;

GucBoolAssignHookassign_hook;

GucShowHookshow_hook;

/* variable fields, initialized at runtime: */

bool reset_val;

void * reset_extra

};

struct config_int

{

struct config_generic gen;

/*constant fields, must be set correctly in initial value: */

int *variable;

int boot_val;

int min;

int max;

GucIntCheckHookcheck_hook;

GucIntAssignHookassign_hook;

GucShowHookshow_hook;

/* variable fields, initialized at runtime: */

int reset_val;

void * reset_extra

};

struct config_real

{

struct config_generic gen;

/* constantfields, must be set correctly in initial value: */

double *variable;

double boot_val;

double min;

double max;

GucIntCheckHookcheck_hook;

GucRealAssignHookassign_hook;

GucShowHookshow_hook;

/* variable fields, initialized at runtime: */

double reset_val;

void * reset_extra

};

struct config_string

{

struct config_generic gen;

/* constant fields, must beset correctly in initial value: */

char **variable;

const char *boot_val;

GucIntCheckHookcheck_hook;

GucStringAssignHookassign_hook;

GucShowHookshow_hook;

/* variable fields, initialized at runtime: */

char *reset_val;

void * reset_extra

};

struct config_enum

{

struct config_generic gen;

/* constant fields, must beset correctly in initial value: */

int *variable;

int boot_val;

GucIntCheckHookcheck_hook;

GucStringAssignHookassign_hook;

GucShowHookshow_hook;

/* variable fields, initialized at runtime: */

int reset_val;

void * reset_extra

};

和结构类型对应的五个静态数组:

static struct config_boolConfigureNamesBool[] =

{

{

{"enable_seqscan",PGC_USERSET, QUERY_TUNING_METHOD,

gettext_noop("Enablesthe planner's use of sequential-scan plans."),

NULL

},

&enable_seqscan,

true,

NULL,NULL, NULL

},

……

/*End-of-list marker */

{

{NULL,0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL

}

};

static struct config_int ConfigureNamesInt[]=

{

{

{"archive_timeout",PGC_SIGHUP, WAL_ARCHIVING,

gettext_noop("Forcesa switch to the next xlog file if a "

"new file has not

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MySQL复制(一) --- 二进制日志.. 下一篇用mysql存储二进制数据流

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: