PostgreSQL 中奇怪的幽灵记录——它们是什么?

Weird ghost records in PostgreSQL - what are they?

我在我们的 postgresql 数据库上遇到了一个非常奇怪的问题。我有一个名为 "statement" 的 table,里面有一些奇怪的记录。

使用命令行控制台 psql,我查询 select * from customer.statement where type in ('QUOTE'); 并返回 12 行。 7 行看起来很正常,5 行丢失了所有数据,除了一个可以为 null 的列,但似乎包含用户输入的实际值。 psql 告诉我即使有 12 行也返回了 7 行。大多数其他列都不可为空。奇怪的记录是这样的:

select * from customer.statement where type = 'QUOTE';
        id        |    issuer_id     |   recipient_id   | recipient_name | recipient_reference | source_statement_id | catalogue_id | reference | issue_date |  due_date  |                           description                            |   total   | currency | type  | tax_level | rounding_mode |  status   | recall_requested |        time_created        |        time_updated        | time_paid 
------------------+------------------+------------------+----------------+---------------------+---------------------+--------------+-----------+------------+------------+------------------------------------------------------------------+-----------+----------+-------+-----------+---------------+-----------+------------------+----------------------------+----------------------------+-----------
 ... 7 valid records removed ...
                  |                  |                  |                |                     |                     |              |           |            |            | Build bulkheads and sheet with plasterboard.                    +|           |          |       |           |               |           |                  |                            |                            | 
                  |                  |                  |                |                     |                     |              |           |            |            | Patch all patches.                                              +|           |          |       |           |               |           |                  |                            |                            | 
                  |                  |                  |                |                     |                     |              |           |            |            | Set and sand all joints ready for painting.                     +|           |          |       |           |               |           |                  |                            |                            | 
                  |                  |                  |                |                     |                     |              |           |            |            | Use wall angle on bulkhead in main bedroom.                     +|           |          |       |           |               |           |                  |                            |                            | 
                  |                  |                  |                |                     |                     |              |           |            |            | Build nib and sheet and set in entrance                          |           |          |       |           |               |           |                  |                            |                            | 
(7 rows)

如果我 运行 使用 pgAdmin 进行相同的查询,我不会看到那些奇怪的记录。

有人知道这些是什么吗?

分隔符 (+|) 前的加号表示 psql 中显示的字符串值中的换行符。所以没有额外的行,只是同一行继续换行。您报价中的最后一行输出证实了这一点:(7 rows).

在 pgAdmin 中,只要不增加字段的高度(或将内容复制/粘贴到某处),就不会看到额外的行,但也有多行。

在 psql 和 pgAdmin 中尝试:

test=# SELECT E'This\nis\na\ntest.' AS multi_line, 'foo' AS single_line;
  multi_line  | single_line
--------------+-------------
 This        +| foo
 is          +|
 a           +|
 test.        |
(1 row)

The manual about psql:

linestyle

Sets the border line drawing style to one of ascii, old-ascii, or unicode. [...] The default setting is ascii. [...]

ascii style uses plain ASCII characters. Newlines in data are shown using a + symbol in the right-hand margin. [...]