> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> PostgreSQLWire 格式文档

# PostgreSQLWire

| 输入 | 输出 | 别名 |
| -- | -- | -- |
| ✗  | ✔  |    |

<div id="description">
  ## 说明
</div>

`PostgreSQLWire` 格式会序列化 PostgreSQL 线协议中的结果集部分。它会写入一条包含列名和类型的
`RowDescription` 消息，随后为结果集中的每一行写入一条 `DataRow` 消息。
值采用文本表示，`NULL` 值采用协议的空字段编码，布尔值则写为
`t` 或 `f`。

这是一种仅用于输出的二进制格式，供通过 ClickHouse 的
[PostgreSQL 接口](/zh/concepts/features/interfaces/postgresql)连接的客户端使用。该接口将 `PostgreSQLWire` 设为会话
默认格式，并在查询未包含显式 `FORMAT` 子句时使用它。显式指定的子句会覆盖默认设置；
其他输出格式无法生成有效的 PostgreSQL 结果集。该接口会写入身份验证、命令完成和查询就绪等外围协议消息。`PostgreSQLWire` 不适合用于将查询结果显示
或存储为独立文件。

<div id="example-usage">
  ## 使用示例
</div>

启用 PostgreSQL 接口后，可使用兼容的客户端执行查询：

```shell theme={null}
psql -p 9005 -h 127.0.0.1 -U default -d default \
    -c "SELECT number, number % 2 = 0 AS even FROM numbers(3)"
```

由于该查询未指定 `FORMAT` 子句，接口会通过 `PostgreSQLWire` 返回结果。

<div id="format-settings">
  ## 格式设置
</div>

`PostgreSQLWire` 对各个值采用标准的文本序列化设置。该格式本身没有特定设置；布尔值始终使用 PostgreSQL 的 `t` 和 `f` 表示形式进行序列化。
