Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf82595a

Browse files
committed
Fix COPY FROM when database encoding is SQL_ASCII.
In the codepath when no encoding conversion is required, the check forincomplete character at the end of input incorrectly used serverencoding's max character length, instead of the client's. Usually theserver and client encodings are the same when we're not performingencoding conversion, but SQL_ASCII is an exception.In the passing, also fix some outdated comments that still talked aboutthe old COPY protocol. It was removed in v14.Per bug #17501 from Vitaly Voronov. Backpatch to v14 where this wasintroduced.Discussion:https://www.postgresql.org/message-id/17501-128b1dd039362ae6@postgresql.org
1 parent9f2d194 commitf82595a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

‎src/backend/commands/copyfromparse.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ CopyConvertBuf(CopyFromState cstate)
443443
* least one character, and a failure to do so means that we've
444444
* hit an invalid byte sequence.
445445
*/
446-
if (cstate->raw_reached_eof||unverifiedlen >=pg_database_encoding_max_length())
446+
if (cstate->raw_reached_eof||unverifiedlen >=pg_encoding_max_length(cstate->file_encoding))
447447
cstate->input_reached_error= true;
448448
return;
449449
}
@@ -1124,14 +1124,12 @@ CopyReadLineText(CopyFromState cstate)
11241124
charc;
11251125

11261126
/*
1127-
* Load more data if needed. Ideally we would just force four bytes
1128-
* of read-ahead and avoid the many calls to
1129-
* IF_NEED_REFILL_AND_NOT_EOF_CONTINUE(), but the COPY_OLD_FE protocol
1130-
* does not allow us to read too far ahead or we might read into the
1131-
* next data, so we read-ahead only as far we know we can. One
1132-
* optimization would be to read-ahead four byte here if
1133-
* cstate->copy_src != COPY_OLD_FE, but it hardly seems worth it,
1134-
* considering the size of the buffer.
1127+
* Load more data if needed.
1128+
*
1129+
* TODO: We could just force four bytes of read-ahead and avoid the
1130+
* many calls to IF_NEED_REFILL_AND_NOT_EOF_CONTINUE(). That was
1131+
* unsafe with the old v2 COPY protocol, but we don't support that
1132+
* anymore.
11351133
*/
11361134
if (input_buf_ptr >=copy_buf_len||need_data)
11371135
{
@@ -1166,9 +1164,6 @@ CopyReadLineText(CopyFromState cstate)
11661164
* Force fetch of the next character if we don't already have it.
11671165
* We need to do this before changing CSV state, in case one of
11681166
* these characters is also the quote or escape character.
1169-
*
1170-
* Note: old-protocol does not like forced prefetch, but it's OK
1171-
* here since we cannot validly be at EOF.
11721167
*/
11731168
if (c=='\\'||c=='\r')
11741169
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp