↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 协议消息 / 前端消息

StartupMessage

StartupMessage 是前端协议消息。消息内容长度以字节为单位,包含长度字段本身。

当前查看 PostgreSQL 18.6。

说明

StartupMessage 是前端协议消息。消息内容长度以字节为单位,包含长度字段本身。

方向
前端 → 后端
首个线上协议字段
Int32
字段条目
8
手册中的交互阶段
取消正在执行的请求;SSL 会话加密;GSSAPI 会话加密

用法

StartupMessage (F)

消息边界与重复字段

下方完整定义保留重复项、计数与条件字段。表格行号表示文档中的字段定义,并非固定字节偏移量。整数编码与交互流程以同版本协议章节为准。

按手册顺序排列的线上协议字段

位置格式含义
1Int32消息内容的长度(以字节为单位),包括其自身。
2Int32(196610)协议版本号。高 16 位为主版本号(此处描述的协议为 3);低 16 位为次版本号(此处描述的协议为 2)。
3字符串参数名称。目前识别以下名称:user 为连接所用的数据库用户名,必填且没有默认值;database 为要连接的数据库,默认为用户名;options 为传给后端的命令行参数,此用法已弃用,建议单独设置各运行时参数。options 字符串中的空格用于分隔参数,除非用反斜杠(\)转义;两个反斜杠(\\)表示一个字面反斜杠。replication 用于以流复制模式连接,此时可执行少量复制命令而非 SQL 语句,其值可为 true、false 或 database,默认为 false,详情参见第 54.4 节。还可以列出其他参数:以 _pq_. 开头的名称保留给协议扩展,其他名称被视为后端启动时设置的运行时参数。这些设置在后端启动时(若有命令行参数,则在其解析之后)应用,并作为会话默认值。
4user要连接的数据库用户名称。必填项;没有默认值。
5database要连接的数据库。默认为用户名。
6options后端的命令行参数。(已弃用,建议设置单独的运行时参数。)此字符串中的空格被视为分隔参数,除非用反斜杠( \ )转义;写 \\ 表示字面反斜杠。
7replication用于以流复制模式连接,可以发出一小组复制命令而不是SQL语句。值可以是 true 、 false 或 database ,默认为 false 。详细信息请参见 第 54.4 节 。
8字符串参数值。

手册定义

Int32

消息内容的长度(以字节为单位),包括其自身。

Int32(196610)

协议版本号。高 16 位为主版本号(此处描述的协议为 3);低 16 位为次版本号(此处描述的协议为 2)。

协议版本号之后是一个或多个参数名与参数值字符串对。最后一个名称/值对之后必须有一个零字节作为终止符。参数可以按任意顺序出现。其中,user是必需的,其余均为可选。每个参数按以下方式指定:

字符串

参数名称。目前能够识别的名称如下:

user

要连接的数据库用户名称。必填项;没有默认值。

database

要连接的数据库。默认为用户名。

options

后端的命令行参数。(已弃用,建议设置单独的运行时参数。)此字符串中的空格被视为分隔参数,除非用反斜杠(\)转义;写\\表示字面反斜杠。

replication

用于以流复制模式连接,可以发出一小组复制命令而不是SQL语句。值可以是true、false或database,默认为false。详细信息请参见第 54.4 节。

除上述参数外,还可以列出其他参数。以_pq_.开头的参数名称保留用于协议扩展,其余参数则作为运行时参数,在后端启动时设置。这些设置会在后端启动期间应用(在解析命令行参数之后,如果有的话),并作为会话默认值。

字符串

参数值。

相关条目

文档与源码

来源构建
版本
18.6
构建
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
来源指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

版本比较

PostgreSQL 18 → 19: 属性变化。

以下差异保留原始字段名与英文源描述。

--- PostgreSQL 18
+++ PostgreSQL 19
@@ -6,11 +6,11 @@
       "format": "Int32"
     },
     {
-      "description": "The protocol version number. The most significant 16 bits are the major version number (3 for the protocol described here). The least significant 16 bits are the minor version number (2 for the protocol described here).",
-      "format": "Int32(196610)"
+      "description": "The protocol version number. The most significant 16 bits are the major version number. The least significant 16 bits are the minor version number. As an example protocol version 3.2 is represented as 196610 in decimal or more clearly as 0x00030002 in hexadecimal.",
+      "format": "Int32"
     },
     {
-      "description": "The parameter name. Currently recognized names are: user The database user name to connect as. Required; there is no default. database The database to connect to. Defaults to the user name. options Command-line arguments for the backend. (This is deprecated in favor of setting individual run-time parameters.) Spaces within this string are considered to separate arguments, unless escaped with a backslash ( \\ ); write \\\\ to represent a literal backslash. replication Used to connect in streaming replication mode, where a small set of replication commands can be issued instead of SQL statements. Value can be true , false , or database , and the default is false . See Section 54.4 for details. In addition to the above, other parameters may be listed. Parameter names beginning with _pq_. are reserved for use as protocol extensions, while others are treated as run-time parameters to be set at backend start time. Such settings will be applied during backend start (after parsing the command-line arguments if any) and will act as session defaults.",
+      "description": "The parameter name. Currently recognized names are: user The database user name to connect as. Required; there is no default. database The database to connect to. Defaults to the user name. options Command-line arguments for the backend. (This is deprecated in favor of setting individual run-time parameters.) Spaces within this string are considered to separate arguments, unless escaped with a backslash ( \\ ); write \\\\ to represent a literal backslash. replication Used to connect in streaming replication mode, where a small set of replication commands can be issued instead of SQL statements. Value can be true , false , or database , and the default is false . See Section 54.4 for details. In addition to the above, other parameters may be listed. Parameter names beginning with _pq_. are reserved for use as protocol extensions , while others are treated as run-time parameters to be set at backend start time. Such settings will be applied during backend start (after parsing the command-line arguments if any) and will act as session defaults.",
       "format": "String"
     },
     {

比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。

相关条目

导出 JSON · 返回协议消息 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。