Postgresql 中文操作指南

55.6. Message Data Types #

本部分描述了消息中使用的基本数据类型。

This section describes the base data types used in messages.

  • Int_n_(i)

    • An n-bit integer in network byte order (most significant byte first). If i is specified it is the exact value that will appear, otherwise the value is variable. Eg. Int16, Int32(42).

  • Int_n_[k]

    • An array of k n-bit integers, each in network byte order. The array length k is always determined by an earlier field in the message. Eg. Int16[M].

  • String(s)

    • A null-terminated string (C-style string). There is no specific length limitation on strings. If s is specified it is the exact value that will appear, otherwise the value is variable. Eg. String, String("user").

  • Byte_n_(c)

    • Exactly n bytes. If the field width n is not a constant, it is always determinable from an earlier field in the message. If c is specified it is the exact value. Eg. Byte2, Byte1('\n').

Note

There is no predefined limit 关于后端可以返回的字符串的长度。前端的良好编码策略是使用可扩展缓冲区,以便可以接受任何适合内存的内容。如果这是不可行的,请读取整个字符串并丢弃不适合固定大小缓冲区的尾随字符。

There is no predefined limit on the length of a string that can be returned by the backend. Good coding strategy for a frontend is to use an expandable buffer so that anything that fits in memory can be accepted. If that’s not feasible, read the full string and discard trailing characters that don’t fit into your fixed-size buffer.