Fix insert planner crash

-- TODO crash Citus
--- INSERT INTO domain_indirection_test (f1,f3.if1, f3.if2) SELECT 0, 1, 2;
+INSERT INTO domain_indirection_test (f1,f3.if1, f3.if2) SELECT 0, 1, 2;
+ERROR:  cannot plan distributed INSERT INTO ... SELECT query
+HINT:  Do not use array references and field stores on the INSERT target list.
 INSERT INTO domain_indirection_test (f1,f3.if1) VALUES (0, 1);
 ERROR:  inserting or modifying composite type fields is not supported
 HINT:  Use the column name to insert or update the composite type as a single value
 -- TODO here: not the expected ERROR
 -- INSERT INTO domain_indirection_test (f1,f3.if1) SELECT 0, 1;
 -- ERROR:  could not find a conversion path from type 23 to 17619
  UPDATE domain_indirection_test SET domain_array[0].if2 = 5;
 ERROR:  inserting or modifying composite type fields is not supported
 HINT:  Use the column name to insert or update the composite type as a single value
 -- TODO here: not the expected ERROR
pull/7675/head
Cédric Villemain 2025-02-27 05:05:12 +01:00
parent 7d2a5be312
commit dfc26f9a2a
2 changed files with 5 additions and 4 deletions

View File

@ -1082,6 +1082,11 @@ ReorderInsertSelectTargetLists(Query *originalQuery, RangeTblEntry *insertRte,
TargetEntry *newSubqueryTargetEntry = NULL;
AttrNumber originalAttrNo = get_attnum(insertRelationId,
oldInsertTargetEntry->resname);
Node *expr;
/* we need to explore the underlying expression */
expr = (Node *) oldInsertTargetEntry->expr;
expr = strip_implicit_coercions(expr);
/* we need to explore the underlying expression */
Node *expr = strip_implicit_coercions((Node *) oldInsertTargetEntry->expr);

View File

@ -270,14 +270,10 @@ SELECT create_distributed_table('domain_indirection_test', 'f1');
-- not supported (field indirection to underlying composite type)
INSERT INTO domain_indirection_test (f1,f3.if1, f3.if2) VALUES (0, 1, 2);
INSERT INTO domain_indirection_test (f1,f3.if1, f3.if2) SELECT 0, 1, 2;
-- INSERT INTO domain_indirection_test (f1,f3.if1, f3.if2) SELECT 0, 1, 2;
INSERT INTO domain_indirection_test (f1,f3.if1) VALUES (0, 1);
INSERT INTO domain_indirection_test (f1,f3.if1) SELECT 0, 1;
-- INSERT INTO domain_indirection_test (f1,f3.if1) SELECT 0, 1;
-- ERROR: could not find a conversion path from type 23 to 17619
UPDATE domain_indirection_test SET domain_array[0].if2 = 5;
UPDATE domain_indirection_test SET domain_array[0].if2 = (SELECT 5);
UPDATE domain_indirection_test SET domain_array[0].if2 = (SELECT 5);
-- below are supported as we don't do any field indirection
INSERT INTO field_indirection_test_2 (ct2_col, int_col, ct1_col)