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

Commitc53ed26

Browse files
committed
Fix assignment to array of domain over composite, redux.
Commit3e310d8 taught isAssignmentIndirectionExpr() to look throughCoerceToDomain nodes. That's not sufficient, because since commit04fe805 it's been possible for the planner to simplifyCoerceToDomain to RelabelType when the domain has no constraintsto enforce. So we need to look through RelabelType too.Per bug #17897 from Alexander Lakhin. Although3e310d8 wasback-patched to v11, it seems sufficient to apply this changeto v12 and later, since04fe805 came in in v12.Dmitry DolgovDiscussion:https://postgr.es/m/17897-4216c546c3874044@postgresql.org
1 parentde575c7 commitc53ed26

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

‎src/backend/executor/execExpr.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,8 +3131,8 @@ ExecInitSubscriptingRef(ExprEvalStep *scratch, SubscriptingRef *sbsref,
31313131
* trees in which each level of assignment has its own CaseTestExpr, and the
31323132
* recursive structure appears within the newvals or refassgnexpr field.
31333133
* There is an exception, though: if the array is an array-of-domain, we will
3134-
* have a CoerceToDomain as the refassgnexpr, and we need to be able to look
3135-
* through that.
3134+
* have a CoerceToDomainor RelabelTypeas the refassgnexpr, and we need to
3135+
*be able to lookthrough that.
31363136
*/
31373137
staticbool
31383138
isAssignmentIndirectionExpr(Expr*expr)
@@ -3159,6 +3159,12 @@ isAssignmentIndirectionExpr(Expr *expr)
31593159

31603160
returnisAssignmentIndirectionExpr(cd->arg);
31613161
}
3162+
elseif (IsA(expr,RelabelType))
3163+
{
3164+
RelabelType*r= (RelabelType*)expr;
3165+
3166+
returnisAssignmentIndirectionExpr(r->arg);
3167+
}
31623168
return false;
31633169
}
31643170

‎src/test/regress/expected/domain.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,15 @@ table dcomptable;
556556
{"(1,5)"}
557557
(1 row)
558558

559+
-- if there's no constraints, a different code path is taken:
560+
alter domain dcomptype drop constraint dcomptype_check;
561+
update dcomptable set f1[1].cf1 = -1; -- now ok
562+
table dcomptable;
563+
f1
564+
------------
565+
{"(-1,5)"}
566+
(1 row)
567+
559568
drop table dcomptable;
560569
drop type comptype cascade;
561570
NOTICE: drop cascades to type dcomptype

‎src/test/regress/sql/domain.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ table dcomptable;
288288
update dcomptableset f1[1].cf1=-1;-- fail
289289
update dcomptableset f1[1].cf1=1;
290290
table dcomptable;
291+
-- if there's no constraints, a different code path is taken:
292+
alterdomain dcomptype dropconstraint dcomptype_check;
293+
update dcomptableset f1[1].cf1=-1;-- now ok
294+
table dcomptable;
291295

292296
droptable dcomptable;
293297
droptype comptype cascade;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp