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

# サーバーパケット

> ネイティブプロトコル サーバー

| 値  | 名前                               | 説明                                                                              |
| -- | -------------------------------- | ------------------------------------------------------------------------------- |
| 0  | [Hello](#hello)                  | サーバーのハンドシェイク応答                                                                  |
| 1  | Data                             | [client data](/ja/resources/develop-contribute/native-protocol/client#data) と同じ |
| 2  | [Exception](#exception)          | クエリ処理中の例外                                                                       |
| 3  | [Progress](#progress)            | クエリの進捗                                                                          |
| 4  | [Pong](#pong)                    | Ping への応答                                                                       |
| 5  | [EndOfStream](#end-of-stream)    | すべてのパケットの転送完了                                                                   |
| 6  | [ProfileInfo](#profile-info)     | プロファイリングデータ                                                                     |
| 7  | Totals                           | 合計値                                                                             |
| 8  | Extremes                         | 極値 (最小、最大)                                                                      |
| 9  | TablesStatusResponse             | TableStatus リクエストへの応答                                                           |
| 10 | [Log](#log)                      | クエリのシステムログ                                                                      |
| 11 | TableColumns                     | カラムの説明                                                                          |
| 12 | UUIDs                            | 一意なパーツ ID の一覧                                                                   |
| 13 | ReadTaskRequest                  | 次のタスクが必要なリクエストを表す String (UUID)                                                 |
| 14 | [ProfileEvents](#profile-events) | サーバーからのプロファイルイベントを含むパケット                                                        |

`Data`、`Totals`、`Extremes` は圧縮できます。

<div id="hello">
  ## Hello
</div>

[client hello](/ja/resources/develop-contribute/native-protocol/client#hello) への応答。

| フィールド          | 型       | 値               | 説明             |
| -------------- | ------- | --------------- | -------------- |
| name           | String  | `Clickhouse`    | サーバー名          |
| version\_major | UVarInt | `21`            | サーバーのメジャーバージョン |
| version\_minor | UVarInt | `12`            | サーバーのマイナーバージョン |
| revision       | UVarInt | `54452`         | サーバーのリビジョン     |
| tz             | String  | `Europe/Moscow` | サーバーのタイムゾーン    |
| display\_name  | String  | `Clickhouse`    | UI 用のサーバー名     |
| version\_patch | UVarInt | `3`             | サーバーのパッチバージョン  |

<div id="exception">
  ## 例外
</div>

クエリ処理中のサーバー例外。

| フィールド        | 型      | 値                                      | 説明                                 |
| ------------ | ------ | -------------------------------------- | ---------------------------------- |
| code         | Int32  | `60`                                   | [ErrorCodes.cpp][codes] を参照してください。 |
| name         | String | `DB::Exception`                        | サーバーのメジャーバージョン                     |
| message      | String | `DB::Exception: Table X doesn't exist` | サーバーのマイナーバージョン                     |
| stack\_trace | String | \~                                     | C++ のスタックトレース                      |
| nested       | Bool   | `true`                                 | さらにエラーあり                           |

`nested` が `false` になるまで、例外が連続して並ぶ場合があります。

[codes]: https://clickhouse.com/codebrowser/ClickHouse/src/Common/ErrorCodes.cpp.html "エラーコードの一覧"

<div id="progress">
  ## Progress
</div>

サーバーによって定期的に報告されるクエリ実行の Progress。

<Tip>
  Progress は**差分**で報告されます。合計値はクライアント側で累積してください。
</Tip>

| フィールド        | 型       | 値        | 説明            |
| ------------ | ------- | -------- | ------------- |
| rows         | UVarInt | `65535`  | 行数            |
| bytes        | UVarInt | `871799` | バイト数          |
| total\_rows  | UVarInt | `0`      | 合計行数          |
| wrote\_rows  | UVarInt | `0`      | クライアントからの行数   |
| wrote\_bytes | UVarInt | `0`      | クライアントからのバイト数 |

<div id="pong">
  ## Pong
</div>

[client ping](/ja/resources/develop-contribute/native-protocol/client#ping) に対する応答で、パケット本文はありません。

<div id="end-of-stream">
  ## ストリームの終端
</div>

これ以上 **Data** パケットは送信されず、サーバーからクライアントへのクエリ結果のストリーミングは完了しています。

パケット本文はありません。

<div id="profile-info">
  ## プロファイル情報
</div>

| フィールド                           | 型       |
| ------------------------------- | ------- |
| rows                            | UVarInt |
| blocks                          | UVarInt |
| bytes                           | UVarInt |
| applied\_limit                  | Bool    |
| rows\_before\_limit             | UVarInt |
| calculated\_rows\_before\_limit | Bool    |

<div id="log">
  ## Log
</div>

サーバーログを含む**データブロック**。

<Tip>
  カラムで構成された**データブロック**としてエンコードされますが、圧縮はされません。
</Tip>

| カラム         | 型        |
| ----------- | -------- |
| time        | DateTime |
| time\_micro | UInt32   |
| host\_name  | String   |
| query\_id   | String   |
| thread\_id  | UInt64   |
| priority    | Int8     |
| source      | String   |
| text        | String   |

<div id="profile-events">
  ## プロファイルイベント
</div>

プロファイルイベントを含む**データブロック**。

<Tip>
  **カラム**で構成された**データブロック**としてエンコードされますが、圧縮はされません。

  `value` の型は、サーバー のリビジョンに応じて `UInt64` または `Int64` です。
</Tip>

| カラム           | 型               |
| ------------- | --------------- |
| host\_name    | String          |
| current\_time | DateTime        |
| thread\_id    | UInt64          |
| type          | Int8            |
| name          | String          |
| value         | UInt64 or Int64 |
