StartupMessage
StartupMessage 是前端协议消息。消息内容长度以字节为单位,包含长度字段本身。
当前查看 PostgreSQL 18.6。
说明
StartupMessage 是前端协议消息。消息内容长度以字节为单位,包含长度字段本身。
- 方向
- 前端 → 后端
- 首个线上协议字段
- Int32
- 字段条目
- 8
- 手册中的交互阶段
- 取消正在执行的请求;SSL 会话加密;GSSAPI 会话加密
用法
StartupMessage (F)消息边界与重复字段
下方完整定义保留重复项、计数与条件字段。表格行号表示文档中的字段定义,并非固定字节偏移量。整数编码与交互流程以同版本协议章节为准。
按手册顺序排列的线上协议字段
| 位置 | 格式 | 含义 |
|---|---|---|
| 1 | Int32 | 消息内容的长度(以字节为单位),包括其自身。 |
| 2 | Int32(196610) | 协议版本号。高 16 位为主版本号(此处描述的协议为 3);低 16 位为次版本号(此处描述的协议为 2)。 |
| 3 | 字符串 | 参数名称。目前识别以下名称:user 为连接所用的数据库用户名,必填且没有默认值;database 为要连接的数据库,默认为用户名;options 为传给后端的命令行参数,此用法已弃用,建议单独设置各运行时参数。options 字符串中的空格用于分隔参数,除非用反斜杠(\)转义;两个反斜杠(\\)表示一个字面反斜杠。replication 用于以流复制模式连接,此时可执行少量复制命令而非 SQL 语句,其值可为 true、false 或 database,默认为 false,详情参见第 54.4 节。还可以列出其他参数:以 _pq_. 开头的名称保留给协议扩展,其他名称被视为后端启动时设置的运行时参数。这些设置在后端启动时(若有命令行参数,则在其解析之后)应用,并作为会话默认值。 |
| 4 | user | 要连接的数据库用户名称。必填项;没有默认值。 |
| 5 | database | 要连接的数据库。默认为用户名。 |
| 6 | options | 后端的命令行参数。(已弃用,建议设置单独的运行时参数。)此字符串中的空格被视为分隔参数,除非用反斜杠( \ )转义;写 \\ 表示字面反斜杠。 |
| 7 | replication | 用于以流复制模式连接,可以发出一小组复制命令而不是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 14 → 15: 属性变化。
以下差异保留原始字段名与英文源描述。
--- PostgreSQL 14
+++ PostgreSQL 15
@@ -10,7 +10,7 @@
"format": "Int32(196608)"
},
{
- "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 53.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 55.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"
},
{
@@ -26,7 +26,7 @@
"format": "options"
},
{
- "description": "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 53.4 for details.",
+ "description": "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 55.4 for details.",
"format": "replication"
},
{
比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。
相关条目
导出 JSON · 返回协议消息 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。