Skip to content

Commit c85ec64

Browse files
committed
Reverse-convert row types in ExecWithCheckOptions.
Just as we already do in ExecConstraints, and for the same reason: to improve the quality of error messages. Etsuro Fujita, reviewed by Amit Langote Discussion: http://postgr.es/m/56e0baa8-e458-2bbb-7936-367f7d832e43@lab.ntt.co.jp
1 parent f81a91d commit c85ec64

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/backend/executor/execMain.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,25 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
20972097
* USING policy.
20982098
*/
20992099
case WCO_VIEW_CHECK:
2100+
/* See the comment in ExecConstraints(). */
2101+
if (resultRelInfo->ri_PartitionRoot)
2102+
{
2103+
HeapTuple tuple = ExecFetchSlotTuple(slot);
2104+
TupleDesc old_tupdesc = RelationGetDescr(rel);
2105+
TupleConversionMap *map;
2106+
2107+
rel = resultRelInfo->ri_PartitionRoot;
2108+
tupdesc = RelationGetDescr(rel);
2109+
/* a reverse map */
2110+
map = convert_tuples_by_name(old_tupdesc, tupdesc,
2111+
gettext_noop("could not convert row type"));
2112+
if (map != NULL)
2113+
{
2114+
tuple = do_convert_tuple(tuple, map);
2115+
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
2116+
}
2117+
}
2118+
21002119
insertedCols = GetInsertedColumns(resultRelInfo, estate);
21012120
updatedCols = GetUpdatedColumns(resultRelInfo, estate);
21022121
modifiedCols = bms_union(insertedCols, updatedCols);

src/test/regress/expected/updatable_views.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,6 @@ select tableoid::regclass, * from pt;
24242424
create view ptv_wco as select * from pt where a = 0 with check option;
24252425
insert into ptv_wco values (1, 2);
24262426
ERROR: new row violates check option for view "ptv_wco"
2427-
DETAIL: Failing row contains (2, 1).
2427+
DETAIL: Failing row contains (1, 2).
24282428
drop view ptv, ptv_wco;
24292429
drop table pt, pt1, pt11;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy