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

Commitc19615f

Browse files
committed
Disallow setting MAX_PARTITION_BUFFERS to less than 2
Add some comments to mention that this value must be at least 2 and alsoadd a StaticAssertDecl to cause compilation failure if anyone tries tobuild with an invalid value.The multiInsertBuffers list must have at least two elements due to how thecode in CopyMultiInsertInfoFlush() pushes the current ResultRelInfo'sCopyMultiInsertBuffer to the end of the list. If the first element isalso the last element, bad things will happen.Author: Zhang Mingli <avamingli@gmail.com>Discussion:https://postgr.es/m/CAApHDvpQ6t9ROcqbD-OgqR04Kfq4vQKw79Vo6r5j%2BciHwsSfkA%40mail.gmail.com
1 parent72fe6d2 commitc19615f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/backend/commands/copyfrom.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@
6868
*/
6969
#defineMAX_BUFFERED_BYTES65535
7070

71-
/* Trim the list of buffers back down to this number after flushing */
71+
/*
72+
* Trim the list of buffers back down to this number after flushing. This
73+
* must be >= 2.
74+
*/
7275
#defineMAX_PARTITION_BUFFERS32
7376

7477
/* Stores multi-insert data related to a single relation in CopyFrom. */
@@ -550,6 +553,13 @@ CopyMultiInsertInfoFlush(CopyMultiInsertInfo *miinfo, ResultRelInfo *curr_rri,
550553
*/
551554
if (buffer->resultRelInfo==curr_rri)
552555
{
556+
/*
557+
* The code below would misbehave if we were trying to reduce the
558+
* list to less than two items.
559+
*/
560+
StaticAssertDecl(MAX_PARTITION_BUFFERS >=2,
561+
"MAX_PARTITION_BUFFERS must be >= 2");
562+
553563
miinfo->multiInsertBuffers=list_delete_first(miinfo->multiInsertBuffers);
554564
miinfo->multiInsertBuffers=lappend(miinfo->multiInsertBuffers,buffer);
555565
buffer= (CopyMultiInsertBuffer*)linitial(miinfo->multiInsertBuffers);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp