diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2019-02-01 12:50:32 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2019-02-01 12:50:32 -0300 |
commit | 558d77f20e4e9ed18101d5d057b770ae22ece855 (patch) | |
tree | c65b6dff674f7f6a46a391683e281a51839162c1 /src/backend/parser/parse_target.c | |
parent | f831d4accda00b9144bc647ede2e2f848b59f39d (diff) | |
download | postgresql-558d77f20e4e9ed18101d5d057b770ae22ece855.tar.gz postgresql-558d77f20e4e9ed18101d5d057b770ae22ece855.zip |
Renaming for new subscripting mechanism
Over at patch https://commitfest.postgresql.org/21/1062/ Dmitry wants to
introduce a more generic subscription mechanism, which allows
subscripting not only arrays but also other object types such as JSONB.
That functionality is introduced in a largish invasive patch, out of
which this internal renaming patch was extracted.
Author: Dmitry Dolgov
Reviewed-by: Tom Lane, Arthur Zakirov
Discussion: https://postgr.es/m/CA+q6zcUK4EqPAu7XRRO5CCjMwhz5zvg+rfWuLzVoxp_5sKS6=w@mail.gmail.com
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r-- | src/backend/parser/parse_target.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 561d8774f47..0e9598ebfe4 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -655,7 +655,7 @@ updateTargetListEntry(ParseState *pstate, * needed. * * targetName is the name of the field or subfield we're assigning to, and - * targetIsArray is true if we're subscripting it. These are just for + * targetIsSubscripting is true if we're subscripting it. These are just for * error reporting. * * targetTypeId, targetTypMod, targetCollation indicate the datatype and @@ -677,7 +677,7 @@ static Node * transformAssignmentIndirection(ParseState *pstate, Node *basenode, const char *targetName, - bool targetIsArray, + bool targetIsSubscripting, Oid targetTypeId, int32 targetTypMod, Oid targetCollation, @@ -855,7 +855,7 @@ transformAssignmentIndirection(ParseState *pstate, -1); if (result == NULL) { - if (targetIsArray) + if (targetIsSubscripting) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("array assignment to \"%s\" requires type %s" @@ -881,7 +881,7 @@ transformAssignmentIndirection(ParseState *pstate, } /* - * helper for transformAssignmentIndirection: process array assignment + * helper for transformAssignmentIndirection: process container assignment */ static Node * transformAssignmentSubscripts(ParseState *pstate, @@ -897,8 +897,8 @@ transformAssignmentSubscripts(ParseState *pstate, int location) { Node *result; - Oid arrayType; - int32 arrayTypMod; + Oid containerType; + int32 containerTypMod; Oid elementTypeId; Oid typeNeeded; Oid collationNeeded; @@ -906,46 +906,46 @@ transformAssignmentSubscripts(ParseState *pstate, Assert(subscripts != NIL); /* Identify the actual array type and element type involved */ - arrayType = targetTypeId; - arrayTypMod = targetTypMod; - elementTypeId = transformArrayType(&arrayType, &arrayTypMod); + containerType = targetTypeId; + containerTypMod = targetTypMod; + elementTypeId = transformContainerType(&containerType, &containerTypMod); /* Identify type that RHS must provide */ - typeNeeded = isSlice ? arrayType : elementTypeId; + typeNeeded = isSlice ? containerType : elementTypeId; /* - * Array normally has same collation as elements, but there's an - * exception: we might be subscripting a domain over an array type. In + * container normally has same collation as elements, but there's an + * exception: we might be subscripting a domain over a container type. In * that case use collation of the base type. */ - if (arrayType == targetTypeId) + if (containerType == targetTypeId) collationNeeded = targetCollation; else - collationNeeded = get_typcollation(arrayType); + collationNeeded = get_typcollation(containerType); - /* recurse to create appropriate RHS for array assign */ + /* recurse to create appropriate RHS for container assign */ rhs = transformAssignmentIndirection(pstate, NULL, targetName, true, typeNeeded, - arrayTypMod, + containerTypMod, collationNeeded, next_indirection, rhs, location); /* process subscripts */ - result = (Node *) transformArraySubscripts(pstate, - basenode, - arrayType, - elementTypeId, - arrayTypMod, - subscripts, - rhs); - - /* If target was a domain over array, need to coerce up to the domain */ - if (arrayType != targetTypeId) + result = (Node *) transformContainerSubscripts(pstate, + basenode, + containerType, + elementTypeId, + containerTypMod, + subscripts, + rhs); + + /* If target was a domain over container, need to coerce up to the domain */ + if (containerType != targetTypeId) { Oid resulttype = exprType(result); |