mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
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
This commit is contained in:
@ -597,10 +597,12 @@ CopyMultiInsertInfoNextFreeSlot(CopyMultiInsertInfo *miinfo,
|
|||||||
ResultRelInfo *rri)
|
ResultRelInfo *rri)
|
||||||
{
|
{
|
||||||
CopyMultiInsertBuffer *buffer = rri->ri_CopyMultiInsertBuffer;
|
CopyMultiInsertBuffer *buffer = rri->ri_CopyMultiInsertBuffer;
|
||||||
int nused = buffer->nused;
|
int nused;
|
||||||
|
|
||||||
Assert(buffer != NULL);
|
Assert(buffer != NULL);
|
||||||
Assert(nused < MAX_BUFFERED_TUPLES);
|
Assert(buffer->nused < MAX_BUFFERED_TUPLES);
|
||||||
|
|
||||||
|
nused = buffer->nused;
|
||||||
|
|
||||||
if (buffer->slots[nused] == NULL)
|
if (buffer->slots[nused] == NULL)
|
||||||
buffer->slots[nused] = table_slot_create(rri->ri_RelationDesc, NULL);
|
buffer->slots[nused] = table_slot_create(rri->ri_RelationDesc, NULL);
|
||||||
|
Reference in New Issue
Block a user