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

Commitd35631e

Browse files
committed
Fix potential crash after constraint violation errors in partitioned tables.
During the reporting of constraint violations for partitioned tables,ExecPartitionCheckEmitError(), ExecConstraints(),ExecWithCheckOptions() set the slot descriptor of the input slot tothe root partition's tuple desc. That's generally problematic whenthe slot could be used by other routines, but can cause crashes afterthe introduction of slots with "fixed" tuple descriptors inad7dbee.The problem likely escaped detection so far for two reasons: First,currently the only known way that these routines are used with apartitioned table that is not "owned" by partitioning code is when"fast defaults" are used for the child partition. Second, as an erroris raised afterwards, an "external" slot that had its descriptorchanged, is very unlikely to continue being used.Even though the issue currently is only known to cause a crash for11 (as that has both fast defaults and "fixed" slot descriptors), itseems worth applying the fix to 10 too. Potentially changing randomslots is hazardous.Regression tests will be added in a separate commit, as it seems bestto add them for master and 12 too.Reported-By: Daniel WMAuthor: Andres FreundBug: #16293Discussion:https://postgr.es/m/16293-26f5777d10143a66@postgresql.orgBackpatch: 11, 10 only
1 parent25bf317 commitd35631e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/backend/executor/execMain.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,8 @@ ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
19321932
if (map!=NULL)
19331933
{
19341934
tuple=do_convert_tuple(tuple,map);
1935-
ExecSetSlotDescriptor(slot,tupdesc);
1935+
/* one off slot for building error message */
1936+
slot=MakeTupleTableSlot(tupdesc);
19361937
ExecStoreTuple(tuple,slot,InvalidBuffer, false);
19371938
}
19381939
}
@@ -2011,7 +2012,8 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
20112012
if (map!=NULL)
20122013
{
20132014
tuple=do_convert_tuple(tuple,map);
2014-
ExecSetSlotDescriptor(slot,tupdesc);
2015+
/* one off slot for building error message */
2016+
slot=MakeTupleTableSlot(tupdesc);
20152017
ExecStoreTuple(tuple,slot,InvalidBuffer, false);
20162018
}
20172019
}
@@ -2059,7 +2061,8 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
20592061
if (map!=NULL)
20602062
{
20612063
tuple=do_convert_tuple(tuple,map);
2062-
ExecSetSlotDescriptor(slot,tupdesc);
2064+
/* one off slot for building error message */
2065+
slot=MakeTupleTableSlot(tupdesc);
20632066
ExecStoreTuple(tuple,slot,InvalidBuffer, false);
20642067
}
20652068
}
@@ -2165,7 +2168,8 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
21652168
if (map!=NULL)
21662169
{
21672170
tuple=do_convert_tuple(tuple,map);
2168-
ExecSetSlotDescriptor(slot,tupdesc);
2171+
/* one off slot for building error message */
2172+
slot=MakeTupleTableSlot(tupdesc);
21692173
ExecStoreTuple(tuple,slot,InvalidBuffer, false);
21702174
}
21712175
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp