3.00001 postgres如何初始化系统参数?

文章目录

    • 加载参数整体流程
    • 参数结构
      • 举例:ConfigureNamesBool
    • 初始化参数 InitializeGUCOptions
      • build_guc_variables
      • InitializeOneGUCOption
      • InitializeGUCOptionsFromEnvironment
    • 命令行添加
    • SelectConfigFiles配置

加载参数整体流程

我们先看下guc参数是如何管理的。
在这里插入图片描述
首先初始化GUC选项,将其设置为默认值;然后读取命令行配置,最后读取配置文件postgresql.conf中的配置项。

参数结构

有5类参数:ConfigureNamesBool、ConfigureNamesInt、ConfigureNamesReal、ConfigureNamesReal、ConfigureNamesEnum。

在guc_tables中定义了不同类型的参数清单:

struct config_bool ConfigureNamesBool[] (guc_tables.c:771)
struct config_int ConfigureNamesInt[]   (guc_tables.c:2056)
struct config_real ConfigureNamesReal[] (guc_tables.c:3678)
struct config_string ConfigureNamesString[] (guc_tables.c:3959)
struct config_enum ConfigureNamesEnum[]  (guc_tables.c:4736)

不同的参数类型结构体定义在guc_tables.h

struct config_generic (guc_tables.h:153) //被用于下面几种类型参数的成员。
struct config_bool (guc_tables.h:198)
struct config_int (guc_tables.h:212)
struct config_real (guc_tables.h:228)
struct config_string  (guc_tables.h:254)
struct config_enum (guc_tables.h:268)

在guc_tables.h中定义了参数类型如下:guc_tables.h:21

enum config_type
{PGC_BOOL,PGC_INT,PGC_REAL,PGC_STRING,PGC_ENUM,
};

在guc_tables.c中定义了参数类型对应的值如下:guc_tables.c:731

const char *const config_type_names[] =
{[PGC_BOOL] = "bool",[PGC_INT] = "integer",[PGC_REAL] = "real",[PGC_STRING] = "string",[PGC_ENUM] = "enum",
};

举例:ConfigureNamesBool

ConfigureNamesBool参数组,每一个成员都是一个结构体config_bool

struct config_bool ConfigureNamesBool[] =
{{{"backtrace_on_internal_error", PGC_SUSET, DEVELOPER_OPTIONS,gettext_noop("Log backtrace for any error with error code XX000 (internal error)."),NULL,GUC_NOT_IN_SAMPLE},&backtrace_on_internal_error,false,NULL, NULL, NULL},

结构体config_bool的定义如下:

struct config_bool
{struct config_generic gen;  //包含的config_generic结构体/* constant fields, must be set correctly in initial value: */bool	   *variable;bool		boot_val;GucBoolCheckHook check_hook;GucBoolAssignHook assign_hook;GucShowHook show_hook;/* variable fields, initialized at runtime: */bool		reset_val;void	   *reset_extra;
};

结构体config_generic的定义如下:

struct config_generic
{/* constant fields, must be set correctly in initial value: */const char *name;			/* name of variable - MUST BE FIRST */GucContext	context;		/* context required to set the variable */enum config_group group;	/* to help organize variables by function */const char *short_desc;		/* short desc. of this variable's purpose */const char *long_desc;		/* long desc. of this variable's purpose */int			flags;			/* flag bits, see guc.h *//* variable fields, initialized at runtime: */enum config_type vartype;	/* type of variable (set only at startup) */int			status;			/* status bits, see below */GucSource	source;			/* source of the current actual value */GucSource	reset_source;	/* source of the reset_value */GucContext	scontext;		/* context that set the current value */GucContext	reset_scontext; /* context that set the reset value */Oid			srole;			/* role that set the current value */Oid			reset_srole;	/* role that set the reset value */GucStack   *stack;			/* stacked prior values */void	   *extra;			/* "extra" pointer for current actual value */dlist_node	nondef_link;	/* list link for variables that have source* different from PGC_S_DEFAULT */slist_node	stack_link;		/* list link for variables that have non-NULL* stack */slist_node	report_link;	/* list link for variables that have the* GUC_NEEDS_REPORT bit set in status */char	   *last_reported;	/* if variable is GUC_REPORT, value last sent* to client (NULL if not yet sent) */char	   *sourcefile;		/* file current setting is from (NULL if not* set in config file) */int			sourceline;		/* line in source file */
};

初始化参数 InitializeGUCOptions

InitializeGUCOptionsbuild_guc_variables();InitializeOneGUCOption(guc_variables[i]);InitializeGUCOptionsFromEnvironment

build_guc_variables

完成空间申请与初始化,

  1. 会通过设定的参数组ConfigureNamesxxx中的vartype值;
  2. 将所有的参数保存在guc_hashtab全局hash桶内
  • 初始化所有的参数组的vartype为对应的config_type,
		struct config_bool *conf = &ConfigureNamesBool[i];/* Rather than requiring vartype to be filled in by hand, do this: */conf->gen.vartype = PGC_BOOL;num_vars++;
  • 创建hash结构
// (guc.c:976)
guc_hashtab = hash_create("GUC hash table",size_vars,&hash_ctl,HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT);

其中的guc_hashtab为static的hash结构(guc.c:241):

static HTAB *guc_hashtab;		/* entries are GUCHashEntrys */...// HTAB定义如下:
/** Top control structure for a hashtable --- in a shared table, each backend* has its own copy (OK since no fields change at runtime)*/
struct HTAB
{HASHHDR    *hctl;			/* => shared control information */HASHSEGMENT *dir;			/* directory of segment starts */HashValueFunc hash;			/* hash function */HashCompareFunc match;		/* key comparison function */HashCopyFunc keycopy;		/* key copying function */HashAllocFunc alloc;		/* memory allocator */MemoryContext hcxt;			/* memory context if default allocator used */char	   *tabname;		/* table name (for error messages) */bool		isshared;		/* true if table is in shared memory */bool		isfixed;		/* if true, don't enlarge *//* freezing a shared table isn't allowed, so we can keep state here */bool		frozen;			/* true = no more inserts allowed *//* We keep local copies of these fixed values to reduce contention */Size		keysize;		/* hash key length in bytes */long		ssize;			/* segment size --- must be power of 2 */int			sshift;			/* segment shift = log2(ssize) */
};
  • 将参数加入guc_hashtable
		struct config_generic *gucvar = &ConfigureNamesBool[i].gen;//这一步会从guc_hashtab(静态结构的hash表),中查找参数名(gucvar->name),没有的话就会新建一个返回给hentryhentry = (GUCHashEntry *) hash_search(guc_hashtab,&gucvar->name,HASH_ENTER,&found);Assert(!found);//初始化添加时一定找不到参数名的,那么就会新建一个桶,同时把桶赋值gucvar即 &ConfigureNamesBool[i].gen;hentry->gucvar = gucvar;

其中,
结构体GUCHashEntry的定义链如下:

typedef struct
{const char *gucname;		/* hash key */struct config_generic *gucvar;	/* -> GUC's defining structure */
} GUCHashEntry;

hash_search(dynahash.c:955)函数定义如下,其直接套用下层hash_search_with_hash_value函数

void *
hash_search(HTAB *hashp,const void *keyPtr,HASHACTION action,bool *foundPtr)
{return hash_search_with_hash_value(hashp,keyPtr,hashp->hash(keyPtr, hashp->keysize),action,foundPtr);
}

hash_search_with_hash_value(dynahash.c:968)函数大致作用是:
在Bucket中一个个找,用currBucket判断是否为null来确认是非存在对应的桶

// 在Bucket中一个个找,用currBucket判断是否为null来确认是非存在对应的桶while (currBucket != NULL){if (currBucket->hashvalue == hashvalue &&match(ELEMENTKEY(currBucket), keyPtr, keysize) == 0)break;prevBucketPtr = &(currBucket->link);currBucket = *prevBucketPtr;
#ifdef HASH_STATISTICShash_collisions++;hctl->collisions++;
#endif}

针对不同的hashaction有不同的动作

// hashaction的定义如下(hsearch.h:110)
/* hash_search operations */
typedef enum
{HASH_FIND,HASH_ENTER,HASH_REMOVE,HASH_ENTER_NULL,
} HASHACTION;* action is one of:*		HASH_FIND: look up key in table*		HASH_ENTER: look up key in table, creating entry if not present*		HASH_ENTER_NULL: same, but return NULL if out of memory*		HASH_REMOVE: look up key in table, remove entry if present... ...
// (dynahash.c:1037)switch (action){case HASH_FIND:... case HASH_ENTER:case HASH_ENTER_NULL:/* Return existing element if found, else create one */if (currBucket != NULL)return (void *) ELEMENTKEY(currBucket);/* disallow inserts if frozen */if (hashp->frozen)elog(ERROR, "cannot insert into frozen hashtable \"%s\"",hashp->tabname);//重新申请一个hash bucketcurrBucket = get_hash_entry(hashp, freelist_idx);if (currBucket == NULL){/* out of memory */if (action == HASH_ENTER_NULL)return NULL;/* report a generic message */if (hashp->isshared)ereport(ERROR,(errcode(ERRCODE_OUT_OF_MEMORY),errmsg("out of shared memory")));elseereport(ERROR,(errcode(ERRCODE_OUT_OF_MEMORY),errmsg("out of memory")));}/* link into hashbucket chain */*prevBucketPtr = currBucket;currBucket->link = NULL;/* copy key into record */currBucket->hashvalue = hashvalue;hashp->keycopy(ELEMENTKEY(currBucket), keyPtr, keysize);/** Caller is expected to fill the data field on return.  DO NOT* insert any code that could possibly throw error here, as doing* so would leave the table entry incomplete and hence corrupt the* caller's data structure.*/return (void *) ELEMENTKEY(currBucket);}

在初始化参数是的堆栈如下:其中action是“HASH_ENTER”。

#0  hash_search_with_hash_value (hashp=0x1023f80, keyPtr=0xfb4c60 <ConfigureNamesBool>, hashvalue=1010527281, action=HASH_ENTER, foundPtr=0x7fffffffe05f) at dynahash.c:975
#1  0x0000000000bc1901 in hash_search (hashp=0x1023f80, keyPtr=0xfb4c60 <ConfigureNamesBool>, action=HASH_ENTER, foundPtr=0x7fffffffe05f) at dynahash.c:960
#2  0x0000000000bcd413 in build_guc_variables () at guc.c:985
#3  0x0000000000bce451 in InitializeGUCOptions () at guc.c:1546
#4  0x0000000000911a54 in PostmasterMain (argc=1, argv=0x1000ef0) at postmaster.c:585
#5  0x00000000007d3f97 in main (argc=1, argv=0x1000ef0) at main.c:197

如上所示,会使用get_hash_entry(dynahash.c:1256)重新创建一个bucket存储某一个参数。存储类型为GUCHashEntry。

InitializeOneGUCOption

代码栈如下:

Breakpoint 1, InitializeOneGUCOption (gconf=0xfc39c8 <ConfigureNamesString+3400>) at guc.c:1648
1648            gconf->status = 0;
(gdb) bt
#0  InitializeOneGUCOption (gconf=0xfc39c8 <ConfigureNamesString+3400>) at guc.c:1648
#1  0x0000000000bce4a4 in InitializeGUCOptions () at guc.c:1558
#2  0x0000000000911a54 in PostmasterMain (argc=3, argv=0x1000ef0) at postmaster.c:585
#3  0x00000000007d3f97 in main (argc=3, argv=0x1000ef0) at main.c:197

其中
InitializeOneGUCOption函数的入参gconf来源如下,为GUCHashEntry->config_generic:

	hash_seq_init(&status, guc_hashtab);while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL){/* Check mapping between initial and default value */Assert(check_GUC_init(hentry->gucvar));InitializeOneGUCOption(hentry->gucvar);}

即此时通过全局静态变量guc_hashtab来一个个配置参数。配置过程调用InitializeOneGUCOption函数,具体步骤如下:

  • 第一步:填充统一的默认值:
	gconf->status = 0;gconf->source = PGC_S_DEFAULT;gconf->reset_source = PGC_S_DEFAULT;gconf->scontext = PGC_INTERNAL;gconf->reset_scontext = PGC_INTERNAL;gconf->srole = BOOTSTRAP_SUPERUSERID;gconf->reset_srole = BOOTSTRAP_SUPERUSERID;gconf->stack = NULL;gconf->extra = NULL;gconf->last_reported = NULL;gconf->sourcefile = NULL;gconf->sourceline = 0;
  • 第二部,初始化参数值
switch (gconf->vartype){case PGC_BOOL:{struct config_bool *conf = (struct config_bool *) gconf;bool		newval = conf->boot_val;void	   *extra = NULL;if (!call_bool_check_hook(conf, &newval, &extra,PGC_S_DEFAULT, LOG))elog(FATAL, "failed to initialize %s to %d",conf->gen.name, (int) newval);if (conf->assign_hook)conf->assign_hook(newval, extra);*conf->variable = conf->reset_val = newval;conf->gen.extra = conf->reset_extra = extra;break;}case PGC_INT:{......

此时newval值的来源在哪里?
查看此时的conf变量,发现它的初始值中就conf->boot_val就是1!!

(gdb) p *conf
$15 = {gen = {name = 0xe2dc71 "extra_float_digits", context = PGC_USERSET, group = CLIENT_CONN_LOCALE, short_desc = 0xe2dc88 "Sets the number of digits displayed for floating-point values.", long_desc = 0xe2dcc8 "This affects real, double precision, and geometric data types. A zero or negative parameter value is added to the standard number of digits (FLT_DIG or DBL_DIG as appropriate). Any value greater than "..., flags = 0, vartype = PGC_INT, status = 0, source = PGC_S_DEFAULT, reset_source = PGC_S_DEFAULT, scontext = PGC_INTERNAL, reset_scontext = PGC_INTERNAL, srole = 10, reset_srole = 10, stack = 0x0, extra = 0x0, nondef_link = {prev = 0x0, next = 0x0}, stack_link = {next = 0x0}, report_link = {next = 0x0}, last_reported = 0x0, sourcefile = 0x0, sourceline = 0}, variable = 0xfb49d8 <extra_float_digits>, boot_val = 1, min = -15, max = 3, check_hook = 0x0, assign_hook = 0x0, show_hook = 0x0, reset_val = 0, reset_extra = 0x0}

然而此时的conf 来源与gconf,而gconf来源于静态变量guc_hashtab。其中保存的是struct config_int ConfigureNamesInt[]的地址。
查看config_int ConfigureNamesInt[];发现:

	{{"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,gettext_noop("Sets the number of digits displayed for floating-point values."),gettext_noop("This affects real, double precision, and geometric data types. ""A zero or negative parameter value is added to the standard ""number of digits (FLT_DIG or DBL_DIG as appropriate). ""Any value greater than zero selects precise output mode.")},&extra_float_digits,1, -15, 3,NULL, NULL, NULL},

已经默认配置了初始值。见上面的“1,-15,3”分别对应指针conf的“boot_val,min,max”;
同时观察整个ConfigureNamesInt数组,发现初始值也有一些宏,如下

	{/* Can't be set in postgresql.conf */{"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,gettext_noop("Shows the server version as an integer."),NULL,GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE},&server_version_num,PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM,NULL, NULL, NULL},

即通过静态参数组中的boot_val属性为每个参数赋值。

InitializeGUCOptionsFromEnvironment

堆栈如下:

Breakpoint 1, InitializeGUCOptionsFromEnvironment () at guc.c:1596
warning: Source file is more recent than executable.
1596            env = getenv("PGPORT");
(gdb) bt
#0  InitializeGUCOptionsFromEnvironment () at guc.c:1596
#1  0x0000000000bce512 in InitializeGUCOptions () at guc.c:1578
#2  0x0000000000911a54 in PostmasterMain (argc=3, argv=0x1000ef0) at postmaster.c:585
#3  0x00000000007d3f97 in main (argc=3, argv=0x1000ef0) at main.c:197

其中主要调用SetConfigOption(guc.c:4275)来配置PGPORT、PGDATESTYLE、PGCLIENTENCODING这些linuc的宏(环境变量),确认postgresql中的port、datestyle、client_encoding等参数配置,如下图:

	env = getenv("PGPORT");if (env != NULL)SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);env = getenv("PGDATESTYLE");if (env != NULL)SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);env = getenv("PGCLIENTENCODING");if (env != NULL)SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);

其中SetConfigOption(guc.c:4275)

void
SetConfigOption(const char *name, const char *value,GucContext context, GucSource source)
{(void) set_config_option(name, value, context, source,GUC_ACTION_SET, true, 0, false);
}

SetConfigOption嵌套set_config_option(guc.c:3333)函数如下:

int
set_config_option(const char *name, const char *value,GucContext context, GucSource source,GucAction action, bool changeVal, int elevel,bool is_reload)
{// bt如下
#0  set_config_with_handle (name=0xe2460e "transaction_isolation", handle=0x0, value=0xe245ff "read committed", context=PGC_POSTMASTER, source=PGC_S_OVERRIDE, srole=10, action=GUC_ACTION_SET, changeVal=true, elevel=0, is_reload=false) at guc.c:3401
#1  0x0000000000bd16fe in set_config_option (name=0xe2460e "transaction_isolation", value=0xe245ff "read committed", context=PGC_POSTMASTER, source=PGC_S_OVERRIDE, action=GUC_ACTION_SET, changeVal=true, elevel=0, is_reload=false) at guc.c:3351
#2  0x0000000000bd33a0 in SetConfigOption (name=0xe2460e "transaction_isolation", value=0xe245ff "read committed", context=PGC_POSTMASTER, source=PGC_S_OVERRIDE) at guc.c:4278
#3  0x0000000000bce4db in InitializeGUCOptions () at guc.c:1567
#4  0x0000000000911a54 in PostmasterMain (argc=3, argv=0x1000ef0) at postmaster.c:585
#5  0x00000000007d3f97 in main (argc=3, argv=0x1000ef0) at main.c:197

其也是通过将guc_hashtab全局hash表内的值拿出来,经过一系列对比之后进行赋值。

命令行添加

// postmaster.c:594while ((opt = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1){switch (opt)case 'B':SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);break;... ...

这里面会对不同的参数做设置:
同时也是调用的SetConfigOption(guc.c:4275)完成重写

SelectConfigFiles配置

调用堆栈如下:

(gdb) b SelectConfigFiles
Breakpoint 2 at 0xbcedd2: file guc.c, line 1795.
(gdb) r
Starting program: /home/db_postg/build/bin/postgres -D /home/db_postg/data
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".Breakpoint 2, SelectConfigFiles (userDoption=0x102bff0 "/home/db_postg/data", progname=0x10002a0 "postgres") at guc.c:1795
1795            if (userDoption)
(gdb) b read
Breakpoint 3 at 0x7ffff7d5bc10 (2 locations)
(gdb) b open
Breakpoint 4 at 0x7ffff7d5b920 (2 locations)
(gdb) c
Continuing.
Breakpoint 4, 0x00007ffff7d5b920 in open64 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7d5b920 in open64 () from /lib64/libc.so.6
#1  0x00007ffff7ceb956 in _IO_file_open () from /lib64/libc.so.6
#2  0x00007ffff7cebb2a in __GI__IO_file_fopen () from /lib64/libc.so.6
#3  0x00007ffff7cdf41d in __fopen_internal () from /lib64/libc.so.6
#4  0x00000000009a72b3 in AllocateFile (name=0x102c130 "/home/db_postg/data/postgresql.conf", mode=0xe264d2 "r") at fd.c:2601
#5  0x0000000000bd947e in ParseConfigFile (config_file=0x10228b8 "/home/db_postg/data/postgresql.conf", strict=true, calling_file=0x0, calling_lineno=0, depth=0, elevel=15, head_p=0x7fffffffdfb8, tail_p=0x7fffffffdfb0)at guc-file.l:238
#6  0x0000000000bcc202 in ProcessConfigFileInternal (context=PGC_POSTMASTER, applySettings=true, elevel=15) at guc.c:299
#7  0x0000000000bd926d in ProcessConfigFile (context=PGC_POSTMASTER) at guc-file.l:152
#8  0x0000000000bcef97 in SelectConfigFiles (userDoption=0x102bff0 "/home/db_postg/data", progname=0x10002a0 "postgres") at guc.c:1864
#9  0x0000000000911f78 in PostmasterMain (argc=3, argv=0x1000ef0) at postmaster.c:768
#10 0x00000000007d3f97 in main (argc=3, argv=0x1000ef0) at main.c:197
(gdb) c
Continuing.Breakpoint 3, 0x00007ffff7d5bc10 in read () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7d5bc10 in read () from /lib64/libc.so.6
#1  0x00007ffff7ceb118 in __GI__IO_file_xsgetn () from /lib64/libc.so.6
#2  0x00007ffff7cdf983 in fread () from /lib64/libc.so.6
#3  0x0000000000bd8258 in yy_get_next_buffer () at guc-file.c:1369
#4  0x0000000000bd7d38 in GUC_yylex () at guc-file.c:1209
#5  0x0000000000bd9d22 in ParseConfigFp (fp=0x102e040, config_file=0x102c130 "/home/db_postg/data/postgresql.conf", depth=0, elevel=15, head_p=0x7fffffffdfb8, tail_p=0x7fffffffdfb0) at guc-file.l:388
#6  0x0000000000bd956e in ParseConfigFile (config_file=0x10228b8 "/home/db_postg/data/postgresql.conf", strict=true, calling_file=0x0, calling_lineno=0, depth=0, elevel=15, head_p=0x7fffffffdfb8, tail_p=0x7fffffffdfb0)at guc-file.l:262
#7  0x0000000000bcc202 in ProcessConfigFileInternal (context=PGC_POSTMASTER, applySettings=true, elevel=15) at guc.c:299
#8  0x0000000000bd926d in ProcessConfigFile (context=PGC_POSTMASTER) at guc-file.l:152
#9  0x0000000000bcef97 in SelectConfigFiles (userDoption=0x102bff0 "/home/db_postg/data", progname=0x10002a0 "postgres") at guc.c:1864
#10 0x0000000000911f78 in PostmasterMain (argc=3, argv=0x1000ef0) at postmaster.c:768
#11 0x00000000007d3f97 in main (argc=3, argv=0x1000ef0) at main.c:197

其中的主要动作有:
1、生成配置文件路径并打开:

// SelectConfigFiles at guc.c:1826...if (userDoption)configdir = make_absolute_path(userDoption);elseconfigdir = make_absolute_path(getenv("PGDATA"));/*(gdb) p configdir$5 = 0x102c010 "/home/db_postg/data"*/... else if (configdir){fname = guc_malloc(FATAL,strlen(configdir) + strlen(CONFIG_FILENAME) + 2);sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);fname_is_malloced = false;}/*(gdb) p fname$4 = 0x1022868 "/home/db_postg/data/postgresql.conf"*/

2、配置数据目录参数和配置文件参数

	SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);... ...//第一次读取配置文件,只是为了设置data目录。ProcessConfigFile(PGC_POSTMASTER);...data_directory_rec = (struct config_string *)find_option("data_directory", false, false, PANIC);if (*data_directory_rec->variable)SetDataDir(*data_directory_rec->variable);else if (configdir)SetDataDir(configdir);... ...SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);

3、配置其余参数

ProcessConfigFile(PGC_POSTMASTER);
...
SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
...
SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/17789.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

VUE3 学习笔记(6):data数据的监听、表单绑定、操作DOM

data数据的监听&#xff08;侦听&#xff09; 对于data的值的监听&#xff0c;可以用watch中与data中的参数命名一致的值做为函数进行获取监听变动前后的值再做逻辑判断&#xff0c;如下图所示。 示例代码 <template><div><p :class"classDemo">{…

七大获取免费https的方式

想要实现https访问最简单有效的的方法就是安装SSL证书。只要证书正常安装上以后&#xff0c;浏览器就不会出现网站不安全提示或者访问被拦截的情况。下面我来教大家怎么去获取免费的SSL证书&#xff0c;又如何安装证书实现https访问。 一、选择免费SSL证书提供商 有多家机构提…

C#数据类型变量、常量

一个变量只不过是一个供程序操作的存储区的名字。 在 C# 中&#xff0c;变量是用于存储和表示数据的标识符&#xff0c;在声明变量时&#xff0c;您需要指定变量的类型&#xff0c;并且可以选择性地为其分配一个初始值。 在 C# 中&#xff0c;每个变量都有一个特定的类型&…

windows驱动开发-PCI讨论(二)

认识PCI设备&#xff0c;还是要从配置空间说起&#xff0c;当PCI在ACPI和PCI复合体上电和枚举完成后&#xff0c;PCI根复合体会从PCI设备读出PCI设备的配置空间&#xff0c;许多信息(例如寄存器、内存空间、中断信息等等)都是是从配置空间获取的&#xff0c;所以接下来会详细讲…

动手学操作系统(三、通过IO接口直接控制显卡)

动手学操作系统&#xff08;三、通过IO接口直接控制显卡&#xff09; 在之前的学习内容中&#xff0c;我们成功编写了MBR主引导记录&#xff0c;在终端上进行了打印显示&#xff0c;在这一节我们使用MBR通过IO接口来直接控制显卡输出字符。 文章目录 动手学操作系统&#xff0…

逻辑回归(头歌)

第1关&#xff1a;逻辑回归算法大体思想 #encodingutf8import numpy as np#sigmoid函数 def sigmoid(t):#输入&#xff1a;负无穷到正无穷的实数#输出&#xff1a;转换后的概率值#********** Begin **********#result 1.0 / (1 np.exp(-t))#********** End **********#retur…

43、Flink 的 Window Join 详解

1.Window Join a&#xff09;概述 Window join 作用在两个流中有相同 key 且处于相同窗口的元素上&#xff0c;窗口可以通过 window assigner 定义&#xff0c;并且两个流中的元素都会被用于计算窗口的结果。 两个流中的元素在组合之后&#xff0c;会被传递给用户定义的 Joi…

外汇天眼:野村证券和Laser Digital与GMO互联网集团合作发行日元和美元稳定币

野村控股和Laser Digital将与GMO互联网集团合作&#xff0c;在日本探索发行日元和美元稳定币。GMO互联网集团的美国子公司GMO-Z.com Trust Company, Inc. 在纽约州金融服务部的监管框架下&#xff0c;在以太坊、恒星币和Solana等主要区块链上发行稳定币。GMO-Z.com Trust Compa…

MySQL增删查改进阶

数据库约束表的关系增删查改 目录 一.数据库约束类型 NOT NULL约束类型 UNIQUE 唯一约束 DEFAULT 默认值约束 PRIMARY KEY&#xff1a;主键约束 FOREIGN KEY :W外键约束 二&#xff0c;查询 count&#xff08;&#xff09;两种用法 sum&#xff0c;avg&#xff0c;max…

Vue3_创建项目

目录 一、创建vue项目 1.下载vue 2.进入刚才创建的项目 3.安装依赖 4.运行项目 ​5.打包项目放入生产环境 二、vue项目组成 1.项目文件结构 2.项目重要文件 Vue (发音为 /vjuː/&#xff0c;类似 view) 是一款用于构建用户界面的 JavaScript 框架。它基于标准 HTML、C…

【安全产品】基于HFish的MySQL蜜罐溯源实验记录

MySQL蜜罐对攻击者机器任意文件读取 用HFish在3306端口部署MySQL蜜罐 配置读取文件路径 攻击者的mysql客户端版本为5.7(要求低于8.0) 之后用命令行直连 mysql -h 124.222.136.33 -P 3306 -u root -p 可以看到成功连上蜜罐的3306服务&#xff0c;但进行查询后会直接lost con…

for循环绑定id,更新html页面的文字内容

需求&#xff1a;将方法中内容对齐 实现方式 给for循环中每个方法添加一个动态的id在DOM结果渲染完后&#xff0c;更新页面数据&#xff0c;否则会报错&#xff0c;找不到对应节点或对应节点为空 <view v-for"(item, index) in itemList" :key"index"…

OWASP十大API漏洞解析:如何抵御Bot攻击?

新型数字经济中&#xff0c;API是物联网设备、Web和移动应用以及业务合作伙伴流程的入口点。然而&#xff0c;API也是犯罪分子的前门&#xff0c;许多人依靠Bot来发动攻击。对于安全团队来说&#xff0c;保护API并缓解Bot攻击至关重要。那么Bot在API攻击中处于怎样的地位&#…

【ARM+Codesys案例】T3/RK3568/树莓派+Codesys枕式包装机运动控制器

枕式包装机是一种包装能力非常强&#xff0c;且能适合多种规格用于食品和非食品包装的连续式包装机。它不但能用于无商标包装材料的包装&#xff0c;而且能够使用预先印有商标图案的卷筒材料进行高速包装。同时&#xff0c;具有稳定性高、生产效率高&#xff0c;适合连续包装、…

C语言 数组—— 一维数组下标越界问题分析

目录 数组元素的访问 一维数组元素的越界访问 二维数组元素的越界访问 小结 数组元素的访问 访问数组元素时&#xff0c; 下标越界 是大忌&#xff01;  编译器通常不检查下标越界&#xff0c;导致程序运行时错误  下标越界&#xff0c;将访问数组以外的空间  …

pyqt窗体水印

pyqt窗体水印 介绍效果代码 介绍 给窗体加上水印 效果 代码 import sys from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtGui import QPainter, QColor, QFont,QPen from PyQt5.QtCore import Qtclass WatermarkedWindow(QMainWindow):def __init__(se…

鸿蒙4.2小版本推出,鸿蒙5.0已经不远了

上个月&#xff0c;市场上迎来了华为鸿蒙系统4字开头的小升级&#xff0c;版本来到了4.2版本。 我们先来看看4.2版本都给用户带来哪些特色&#xff1a; 界面切换更流畅&#xff1a;无论是响应速度还是操作手感&#xff0c;用户都将感受到更加迅速和顺滑的体验 搜星速度的显著…

工具:Visual Studio Code

一、VSCode生成exe 二、在vs中断点调试 如果没效果需要安装如下与unity相连接的插件 三、注释 1、代码注释 注释和取消都是都是同一个命令&#xff1a;选中代码&#xff0c;然后按住CtrlShift/ 2、方法或类注释 /// 四、导航 五、将变量注释展示到解释面板 1、直接显示 [Too…

pip安装软件包提示“没有那个文件或目录”问题的处理

文章目录 一、Python.h&#xff1a;没有那个文件或目录二、lber.h&#xff1a;没有那个文件或目录 一、Python.h&#xff1a;没有那个文件或目录 pip install -I python-ldap3.0.0b1 #异常提示In file included from Modules/LDAPObject.c:3:0:Modules/common.h:9:20: 致命错…

【NVM】持久内存的架构

1 内存数据持久化 1.1 数据持久化 持久内存系统包含如下关键组件&#xff1a;微处理器、连接微处理器内存总线上的持久内存模组&#xff08;Persistent MemoryModule&#xff0c;PMM&#xff09;及持久内存上的非易失性存储介质。 使用持久内存来实现数据的持久化&#xff0c…