考虑以下来自 PostgreSQL documentation 的文本关于二进制复制:
11-byte sequence PGCOPY\n\377\r\n\0 — note that the zero byte is a required part of the signature. (The signature is designed to allow easy identification of files that have been munged by a non-8-bit-clean transfer. This signature will be changed by end-of-line-translation filters, dropped zero bytes, dropped high bits, or parity changes.)
我可以创建标题的其余部分,但是\377 是什么意思?我认为您可以在单个字节中拥有的最大值是 256?
此外,在示例中:
0000000 P G C O P Y \n 377 \r \n \0 \0 \0 \0 \0 \0
0000020 \0 \0 \0 \0 003 \0 \0 \0 002 A F \0 \0 \0 013 A
0000040 F G H A N I S T A N 377 377 377 377 \0 003
0000060 \0 \0 \0 002 A L \0 \0 \0 007 A L B A N I
0000100 A 377 377 377 377 \0 003 \0 \0 \0 002 D Z \0 \0 \0
0000120 007 A L G E R I A 377 377 377 377 \0 003 \0 \0
0000140 \0 002 Z M \0 \0 \0 006 Z A M B I A 377 377
0000160 377 377 \0 003 \0 \0 \0 002 Z W \0 \0 \0 \b Z I
0000200 M B A B W E 377 377 377 377 377 377
那些相同的 377 个值代表什么,在我解释格式时,它们不应该是\0 吗?
如果有人可以帮助解决格式的其余部分,我们将不胜感激。我可以作弊并使用 CVS 数据库副本,但考虑到我需要复制的行数(数百万),我知道二进制格式在速度方面比 CVS 格式有很多优势。 p>
最佳答案
\377
是八进制的 - 它的十进制值为 255。关于这种格式还有什么特别让您感到困惑的吗?
关于c# - 试图在 C# 中理解 Postgres 的二进制复制格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/759101/