mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -1486,14 +1486,14 @@ _copyWindowFunc(const WindowFunc *from)
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyArrayRef
|
||||
* _copySubscriptingRef
|
||||
*/
|
||||
static ArrayRef *
|
||||
_copyArrayRef(const ArrayRef *from)
|
||||
static SubscriptingRef *
|
||||
_copySubscriptingRef(const SubscriptingRef *from)
|
||||
{
|
||||
ArrayRef *newnode = makeNode(ArrayRef);
|
||||
SubscriptingRef *newnode = makeNode(SubscriptingRef);
|
||||
|
||||
COPY_SCALAR_FIELD(refarraytype);
|
||||
COPY_SCALAR_FIELD(refcontainertype);
|
||||
COPY_SCALAR_FIELD(refelemtype);
|
||||
COPY_SCALAR_FIELD(reftypmod);
|
||||
COPY_SCALAR_FIELD(refcollid);
|
||||
@@ -4963,8 +4963,8 @@ copyObjectImpl(const void *from)
|
||||
case T_WindowFunc:
|
||||
retval = _copyWindowFunc(from);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
retval = _copyArrayRef(from);
|
||||
case T_SubscriptingRef:
|
||||
retval = _copySubscriptingRef(from);
|
||||
break;
|
||||
case T_FuncExpr:
|
||||
retval = _copyFuncExpr(from);
|
||||
|
@@ -265,9 +265,9 @@ _equalWindowFunc(const WindowFunc *a, const WindowFunc *b)
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalArrayRef(const ArrayRef *a, const ArrayRef *b)
|
||||
_equalSubscriptingRef(const SubscriptingRef *a, const SubscriptingRef *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(refarraytype);
|
||||
COMPARE_SCALAR_FIELD(refcontainertype);
|
||||
COMPARE_SCALAR_FIELD(refelemtype);
|
||||
COMPARE_SCALAR_FIELD(reftypmod);
|
||||
COMPARE_SCALAR_FIELD(refcollid);
|
||||
@@ -3041,8 +3041,8 @@ equal(const void *a, const void *b)
|
||||
case T_WindowFunc:
|
||||
retval = _equalWindowFunc(a, b);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
retval = _equalArrayRef(a, b);
|
||||
case T_SubscriptingRef:
|
||||
retval = _equalSubscriptingRef(a, b);
|
||||
break;
|
||||
case T_FuncExpr:
|
||||
retval = _equalFuncExpr(a, b);
|
||||
|
@@ -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;
|
||||
|
@@ -1153,11 +1153,11 @@ _outWindowFunc(StringInfo str, const WindowFunc *node)
|
||||
}
|
||||
|
||||
static void
|
||||
_outArrayRef(StringInfo str, const ArrayRef *node)
|
||||
_outSubscriptingRef(StringInfo str, const SubscriptingRef *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("ARRAYREF");
|
||||
WRITE_NODE_TYPE("SUBSCRIPTINGREF");
|
||||
|
||||
WRITE_OID_FIELD(refarraytype);
|
||||
WRITE_OID_FIELD(refcontainertype);
|
||||
WRITE_OID_FIELD(refelemtype);
|
||||
WRITE_INT_FIELD(reftypmod);
|
||||
WRITE_OID_FIELD(refcollid);
|
||||
@@ -3789,8 +3789,8 @@ outNode(StringInfo str, const void *obj)
|
||||
case T_WindowFunc:
|
||||
_outWindowFunc(str, obj);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
_outArrayRef(str, obj);
|
||||
case T_SubscriptingRef:
|
||||
_outSubscriptingRef(str, obj);
|
||||
break;
|
||||
case T_FuncExpr:
|
||||
_outFuncExpr(str, obj);
|
||||
|
@@ -657,14 +657,14 @@ _readWindowFunc(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* _readArrayRef
|
||||
* _readSubscriptingRef
|
||||
*/
|
||||
static ArrayRef *
|
||||
_readArrayRef(void)
|
||||
static SubscriptingRef *
|
||||
_readSubscriptingRef(void)
|
||||
{
|
||||
READ_LOCALS(ArrayRef);
|
||||
READ_LOCALS(SubscriptingRef);
|
||||
|
||||
READ_OID_FIELD(refarraytype);
|
||||
READ_OID_FIELD(refcontainertype);
|
||||
READ_OID_FIELD(refelemtype);
|
||||
READ_INT_FIELD(reftypmod);
|
||||
READ_OID_FIELD(refcollid);
|
||||
@@ -2597,8 +2597,8 @@ parseNodeString(void)
|
||||
return_value = _readGroupingFunc();
|
||||
else if (MATCH("WINDOWFUNC", 10))
|
||||
return_value = _readWindowFunc();
|
||||
else if (MATCH("ARRAYREF", 8))
|
||||
return_value = _readArrayRef();
|
||||
else if (MATCH("SUBSCRIPTINGREF", 15))
|
||||
return_value = _readSubscriptingRef();
|
||||
else if (MATCH("FUNCEXPR", 8))
|
||||
return_value = _readFuncExpr();
|
||||
else if (MATCH("NAMEDARGEXPR", 12))
|
||||
|
Reference in New Issue
Block a user