@ -40,6 +40,7 @@ static Node *transformAssignmentIndirection(ParseState *pstate,
bool targetIsArray ,
bool targetIsArray ,
Oid targetTypeId ,
Oid targetTypeId ,
int32 targetTypMod ,
int32 targetTypMod ,
Oid targetCollation ,
ListCell * indirection ,
ListCell * indirection ,
Node * rhs ,
Node * rhs ,
int location ) ;
int location ) ;
@ -48,6 +49,7 @@ static Node *transformAssignmentSubscripts(ParseState *pstate,
const char * targetName ,
const char * targetName ,
Oid targetTypeId ,
Oid targetTypeId ,
int32 targetTypMod ,
int32 targetTypMod ,
Oid targetCollation ,
List * subscripts ,
List * subscripts ,
bool isSlice ,
bool isSlice ,
ListCell * next_indirection ,
ListCell * next_indirection ,
@ -455,6 +457,7 @@ transformAssignedExpr(ParseState *pstate,
false ,
false ,
attrtype ,
attrtype ,
attrtypmod ,
attrtypmod ,
attrcollation ,
list_head ( indirection ) ,
list_head ( indirection ) ,
( Node * ) expr ,
( Node * ) expr ,
location ) ;
location ) ;
@ -548,8 +551,9 @@ updateTargetListEntry(ParseState *pstate,
* targetIsArray is true if we ' re subscripting it . These are just for
* targetIsArray is true if we ' re subscripting it . These are just for
* error reporting .
* error reporting .
*
*
* targetTypeId and targetTypMod indicate the datatype of the object to
* targetTypeId , targetTypMod , targetCollation indicate the datatype and
* be assigned to ( initially the target column , later some subobject ) .
* collation of the object to be assigned to ( initially the target column ,
* later some subobject ) .
*
*
* indirection is the sublist remaining to process . When it ' s NULL , we ' re
* indirection is the sublist remaining to process . When it ' s NULL , we ' re
* done recursing and can just coerce and return the RHS .
* done recursing and can just coerce and return the RHS .
@ -569,6 +573,7 @@ transformAssignmentIndirection(ParseState *pstate,
bool targetIsArray ,
bool targetIsArray ,
Oid targetTypeId ,
Oid targetTypeId ,
int32 targetTypMod ,
int32 targetTypMod ,
Oid targetCollation ,
ListCell * indirection ,
ListCell * indirection ,
Node * rhs ,
Node * rhs ,
int location )
int location )
@ -585,6 +590,7 @@ transformAssignmentIndirection(ParseState *pstate,
ctest - > typeId = targetTypeId ;
ctest - > typeId = targetTypeId ;
ctest - > typeMod = targetTypMod ;
ctest - > typeMod = targetTypMod ;
ctest - > collation = targetCollation ;
basenode = ( Node * ) ctest ;
basenode = ( Node * ) ctest ;
}
}
@ -617,6 +623,7 @@ transformAssignmentIndirection(ParseState *pstate,
AttrNumber attnum ;
AttrNumber attnum ;
Oid fieldTypeId ;
Oid fieldTypeId ;
int32 fieldTypMod ;
int32 fieldTypMod ;
Oid fieldCollation ;
Assert ( IsA ( n , String ) ) ;
Assert ( IsA ( n , String ) ) ;
@ -629,6 +636,7 @@ transformAssignmentIndirection(ParseState *pstate,
targetName ,
targetName ,
targetTypeId ,
targetTypeId ,
targetTypMod ,
targetTypMod ,
targetCollation ,
subscripts ,
subscripts ,
isSlice ,
isSlice ,
i ,
i ,
@ -662,8 +670,8 @@ transformAssignmentIndirection(ParseState *pstate,
strVal ( n ) ) ,
strVal ( n ) ) ,
parser_errposition ( pstate , location ) ) ) ;
parser_errposition ( pstate , location ) ) ) ;
get_atttypetypmod ( typrelid , attnum ,
get_atttypetypmodcoll ( typrelid , attnum ,
& fieldTypeId , & fieldTypMod ) ;
& fieldTypeId , & fieldTypMod , & fieldCollation ) ;
/* recurse to create appropriate RHS for field assign */
/* recurse to create appropriate RHS for field assign */
rhs = transformAssignmentIndirection ( pstate ,
rhs = transformAssignmentIndirection ( pstate ,
@ -672,6 +680,7 @@ transformAssignmentIndirection(ParseState *pstate,
false ,
false ,
fieldTypeId ,
fieldTypeId ,
fieldTypMod ,
fieldTypMod ,
fieldCollation ,
lnext ( i ) ,
lnext ( i ) ,
rhs ,
rhs ,
location ) ;
location ) ;
@ -696,6 +705,7 @@ transformAssignmentIndirection(ParseState *pstate,
targetName ,
targetName ,
targetTypeId ,
targetTypeId ,
targetTypMod ,
targetTypMod ,
targetCollation ,
subscripts ,
subscripts ,
isSlice ,
isSlice ,
NULL ,
NULL ,
@ -747,6 +757,7 @@ transformAssignmentSubscripts(ParseState *pstate,
const char * targetName ,
const char * targetName ,
Oid targetTypeId ,
Oid targetTypeId ,
int32 targetTypMod ,
int32 targetTypMod ,
Oid targetCollation ,
List * subscripts ,
List * subscripts ,
bool isSlice ,
bool isSlice ,
ListCell * next_indirection ,
ListCell * next_indirection ,
@ -758,6 +769,7 @@ transformAssignmentSubscripts(ParseState *pstate,
int32 arrayTypMod ;
int32 arrayTypMod ;
Oid elementTypeId ;
Oid elementTypeId ;
Oid typeNeeded ;
Oid typeNeeded ;
Oid collationNeeded ;
Assert ( subscripts ! = NIL ) ;
Assert ( subscripts ! = NIL ) ;
@ -769,6 +781,16 @@ transformAssignmentSubscripts(ParseState *pstate,
/* Identify type that RHS must provide */
/* Identify type that RHS must provide */
typeNeeded = isSlice ? arrayType : elementTypeId ;
typeNeeded = isSlice ? arrayType : elementTypeId ;
/*
* Array normally has same collation as elements , but there ' s an
* exception : we might be subscripting a domain over an array type .
* In that case use collation of the base type .
*/
if ( arrayType = = targetTypeId )
collationNeeded = targetCollation ;
else
collationNeeded = get_typcollation ( arrayType ) ;
/* recurse to create appropriate RHS for array assign */
/* recurse to create appropriate RHS for array assign */
rhs = transformAssignmentIndirection ( pstate ,
rhs = transformAssignmentIndirection ( pstate ,
NULL ,
NULL ,
@ -776,6 +798,7 @@ transformAssignmentSubscripts(ParseState *pstate,
true ,
true ,
typeNeeded ,
typeNeeded ,
arrayTypMod ,
arrayTypMod ,
collationNeeded ,
next_indirection ,
next_indirection ,
rhs ,
rhs ,
location ) ;
location ) ;