Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bd8fe12

Browse files
committed
Relocate a badly placed Assert in COPY FROM code
There's not much point in asserting a pointer isn't NULL after some code has already dereferenced that pointer. Adjust the code so that the Assert occurs before the pointer dereference. The Assert probably has questionable value in the first place, but it seems worth keeping around to document the contract between CopyMultiInsertInfoNextFreeSlot() and its callers. Author: Amul Sul <sulamul@gmail.com> Discussion: https://postgr.es/m/CAAJ_b94hXQzXaJxTLShkxQUgezf_SUxhzX9TH2f-g6gP7bne7g@mail.gmail.com
1 parent 1d80d6b commit bd8fe12

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/commands/copyfrom.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,12 @@ CopyMultiInsertInfoNextFreeSlot(CopyMultiInsertInfo *miinfo,
597597
ResultRelInfo *rri)
598598
{
599599
CopyMultiInsertBuffer *buffer = rri->ri_CopyMultiInsertBuffer;
600-
int nused = buffer->nused;
600+
int nused;
601601

602602
Assert(buffer != NULL);
603-
Assert(nused < MAX_BUFFERED_TUPLES);
603+
Assert(buffer->nused < MAX_BUFFERED_TUPLES);
604+
605+
nused = buffer->nused;
604606

605607
if (buffer->slots[nused] == NULL)
606608
buffer->slots[nused] = table_slot_create(rri->ri_RelationDesc, NULL);

0 commit comments

Comments
 (0)