1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

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
This commit is contained in:
Alvaro Herrera
2019-02-01 12:50:32 -03:00
parent f831d4accd
commit 558d77f20e
26 changed files with 555 additions and 523 deletions

View File

@ -66,15 +66,15 @@ exprType(const Node *expr)
case T_WindowFunc:
type = ((const WindowFunc *) expr)->wintype;
break;
case T_ArrayRef:
case T_SubscriptingRef:
{
const ArrayRef *arrayref = (const ArrayRef *) expr;
const SubscriptingRef *sbsref = (const SubscriptingRef *) expr;
/* slice and/or store operations yield the array type */
if (arrayref->reflowerindexpr || arrayref->refassgnexpr)
type = arrayref->refarraytype;
/* slice and/or store operations yield the container type */
if (sbsref->reflowerindexpr || sbsref->refassgnexpr)
type = sbsref->refcontainertype;
else
type = arrayref->refelemtype;
type = sbsref->refelemtype;
}
break;
case T_FuncExpr:
@ -286,9 +286,9 @@ exprTypmod(const Node *expr)
return ((const Const *) expr)->consttypmod;
case T_Param:
return ((const Param *) expr)->paramtypmod;
case T_ArrayRef:
/* typmod is the same for array or element */
return ((const ArrayRef *) expr)->reftypmod;
case T_SubscriptingRef:
/* typmod is the same for container or element */
return ((const SubscriptingRef *) expr)->reftypmod;
case T_FuncExpr:
{
int32 coercedTypmod;
@ -744,8 +744,8 @@ exprCollation(const Node *expr)
case T_WindowFunc:
coll = ((const WindowFunc *) expr)->wincollid;
break;
case T_ArrayRef:
coll = ((const ArrayRef *) expr)->refcollid;
case T_SubscriptingRef:
coll = ((const SubscriptingRef *) expr)->refcollid;
break;
case T_FuncExpr:
coll = ((const FuncExpr *) expr)->funccollid;
@ -992,8 +992,8 @@ exprSetCollation(Node *expr, Oid collation)
case T_WindowFunc:
((WindowFunc *) expr)->wincollid = collation;
break;
case T_ArrayRef:
((ArrayRef *) expr)->refcollid = collation;
case T_SubscriptingRef:
((SubscriptingRef *) expr)->refcollid = collation;
break;
case T_FuncExpr:
((FuncExpr *) expr)->funccollid = collation;
@ -1223,9 +1223,9 @@ exprLocation(const Node *expr)
/* function name should always be the first thing */
loc = ((const WindowFunc *) expr)->location;
break;
case T_ArrayRef:
/* just use array argument's location */
loc = exprLocation((Node *) ((const ArrayRef *) expr)->refexpr);
case T_SubscriptingRef:
/* just use container argument's location */
loc = exprLocation((Node *) ((const SubscriptingRef *) expr)->refexpr);
break;
case T_FuncExpr:
{
@ -1916,21 +1916,22 @@ expression_tree_walker(Node *node,
return true;
}
break;
case T_ArrayRef:
case T_SubscriptingRef:
{
ArrayRef *aref = (ArrayRef *) node;
SubscriptingRef *sbsref = (SubscriptingRef *) node;
/* recurse directly for upper/lower array index lists */
if (expression_tree_walker((Node *) aref->refupperindexpr,
/* recurse directly for upper/lower container index lists */
if (expression_tree_walker((Node *) sbsref->refupperindexpr,
walker, context))
return true;
if (expression_tree_walker((Node *) aref->reflowerindexpr,
if (expression_tree_walker((Node *) sbsref->reflowerindexpr,
walker, context))
return true;
/* walker must see the refexpr and refassgnexpr, however */
if (walker(aref->refexpr, context))
if (walker(sbsref->refexpr, context))
return true;
if (walker(aref->refassgnexpr, context))
if (walker(sbsref->refassgnexpr, context))
return true;
}
break;
@ -2554,20 +2555,21 @@ expression_tree_mutator(Node *node,
return (Node *) newnode;
}
break;
case T_ArrayRef:
case T_SubscriptingRef:
{
ArrayRef *arrayref = (ArrayRef *) node;
ArrayRef *newnode;
SubscriptingRef *sbsref = (SubscriptingRef *) node;
SubscriptingRef *newnode;
FLATCOPY(newnode, arrayref, ArrayRef);
MUTATE(newnode->refupperindexpr, arrayref->refupperindexpr,
FLATCOPY(newnode, sbsref, SubscriptingRef);
MUTATE(newnode->refupperindexpr, sbsref->refupperindexpr,
List *);
MUTATE(newnode->reflowerindexpr, arrayref->reflowerindexpr,
MUTATE(newnode->reflowerindexpr, sbsref->reflowerindexpr,
List *);
MUTATE(newnode->refexpr, arrayref->refexpr,
MUTATE(newnode->refexpr, sbsref->refexpr,
Expr *);
MUTATE(newnode->refassgnexpr, arrayref->refassgnexpr,
MUTATE(newnode->refassgnexpr, sbsref->refassgnexpr,
Expr *);
return (Node *) newnode;
}
break;