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

Commit01038d4

Browse files
committed
A better fix for the "ARRAY[...]::domain" problem. The previous patch worked,
but the transformed ArrayExpr claimed to have a return type of "domain",even though the domain constraint was only checked by the enclosingCoerceToDomain node. With this fix, the ArrayExpr is correctly labeled withthe base type of the domain. Per gripe by Tom Lane.
1 parent942702a commit01038d4

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.249 2009/11/1316:09:10 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.250 2009/11/1319:48:20 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -164,32 +164,23 @@ transformExpr(ParseState *pstate, Node *expr)
164164
elementType=get_element_type(targetType);
165165
if (OidIsValid(elementType))
166166
{
167-
result=transformArrayExpr(pstate,
168-
(A_ArrayExpr*)tc->arg,
169-
targetType,
170-
elementType,
171-
targetTypmod);
172-
173167
/*
174-
* If the target array type is a domain, we still need
175-
* to check the domain constraint. (coerce_to_domain
176-
* is a no-op if targetType is not a domain)
168+
* tranformArrayExpr doesn't know how to check domain
169+
* constraints, so ask it to return the base type
170+
* instead. transformTypeCast below will cast it to
171+
* the domain. In the usual case that the target is
172+
* not a domain, transformTypeCast is a no-op.
177173
*/
178-
result=coerce_to_domain(result,
179-
InvalidOid,
180-
-1,
181-
targetType,
182-
COERCE_IMPLICIT_CAST,
183-
tc->location,
184-
false,
185-
true);
186-
break;
174+
targetType=getBaseTypeAndTypmod(targetType,
175+
&targetTypmod);
176+
177+
tc=copyObject(tc);
178+
tc->arg=transformArrayExpr(pstate,
179+
(A_ArrayExpr*)tc->arg,
180+
targetType,
181+
elementType,
182+
targetTypmod);
187183
}
188-
189-
/*
190-
* Corner case: ARRAY[] cast to a non-array type. Fall
191-
* through to do it the standard way.
192-
*/
193184
}
194185

195186
result=transformTypeCast(pstate,tc);
@@ -324,6 +315,7 @@ transformExpr(ParseState *pstate, Node *expr)
324315
caseT_ArrayCoerceExpr:
325316
caseT_ConvertRowtypeExpr:
326317
caseT_CaseTestExpr:
318+
caseT_ArrayExpr:
327319
caseT_CoerceToDomain:
328320
caseT_CoerceToDomainValue:
329321
caseT_SetToDefault:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp