mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Rename value node fields
For the formerly-Value node types, rename the "val" field to a name specific to the node type, namely "ival", "fval", "sval", and "bsval". This makes some code clearer and catches mixups better. Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/8c1a2e37-c68d-703c-5a83-7a6077f4f997@enterprisedb.com
This commit is contained in:
@@ -1719,7 +1719,7 @@ zone_value:
|
||||
if ($3 != NIL)
|
||||
{
|
||||
A_Const *n = (A_Const *) linitial($3);
|
||||
if ((n->val.ival.val & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
|
||||
if ((n->val.ival.ival & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("time zone interval must be HOUR or HOUR TO MINUTE"),
|
||||
@@ -16667,7 +16667,7 @@ makeStringConst(char *str, int location)
|
||||
A_Const *n = makeNode(A_Const);
|
||||
|
||||
n->val.sval.type = T_String;
|
||||
n->val.sval.val = str;
|
||||
n->val.sval.sval = str;
|
||||
n->location = location;
|
||||
|
||||
return (Node *)n;
|
||||
@@ -16687,7 +16687,7 @@ makeIntConst(int val, int location)
|
||||
A_Const *n = makeNode(A_Const);
|
||||
|
||||
n->val.ival.type = T_Integer;
|
||||
n->val.ival.val = val;
|
||||
n->val.ival.ival = val;
|
||||
n->location = location;
|
||||
|
||||
return (Node *)n;
|
||||
@@ -16699,7 +16699,7 @@ makeFloatConst(char *str, int location)
|
||||
A_Const *n = makeNode(A_Const);
|
||||
|
||||
n->val.fval.type = T_Float;
|
||||
n->val.fval.val = str;
|
||||
n->val.fval.fval = str;
|
||||
n->location = location;
|
||||
|
||||
return (Node *)n;
|
||||
@@ -16711,7 +16711,7 @@ makeBitStringConst(char *str, int location)
|
||||
A_Const *n = makeNode(A_Const);
|
||||
|
||||
n->val.bsval.type = T_BitString;
|
||||
n->val.bsval.val = str;
|
||||
n->val.bsval.bsval = str;
|
||||
n->location = location;
|
||||
|
||||
return (Node *)n;
|
||||
@@ -16736,16 +16736,16 @@ makeAConst(Node *v, int location)
|
||||
switch (v->type)
|
||||
{
|
||||
case T_Float:
|
||||
n = makeFloatConst(castNode(Float, v)->val, location);
|
||||
n = makeFloatConst(castNode(Float, v)->fval, location);
|
||||
break;
|
||||
|
||||
case T_Integer:
|
||||
n = makeIntConst(castNode(Integer, v)->val, location);
|
||||
n = makeIntConst(castNode(Integer, v)->ival, location);
|
||||
break;
|
||||
|
||||
case T_String:
|
||||
default:
|
||||
n = makeStringConst(castNode(String, v)->val, location);
|
||||
n = makeStringConst(castNode(String, v)->sval, location);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17049,7 +17049,7 @@ doNegate(Node *n, int location)
|
||||
|
||||
if (IsA(&con->val, Integer))
|
||||
{
|
||||
con->val.ival.val = -con->val.ival.val;
|
||||
con->val.ival.ival = -con->val.ival.ival;
|
||||
return n;
|
||||
}
|
||||
if (IsA(&con->val, Float))
|
||||
@@ -17065,14 +17065,14 @@ doNegate(Node *n, int location)
|
||||
static void
|
||||
doNegateFloat(Float *v)
|
||||
{
|
||||
char *oldval = v->val;
|
||||
char *oldval = v->fval;
|
||||
|
||||
if (*oldval == '+')
|
||||
oldval++;
|
||||
if (*oldval == '-')
|
||||
v->val = oldval+1; /* just strip the '-' */
|
||||
v->fval = oldval+1; /* just strip the '-' */
|
||||
else
|
||||
v->val = psprintf("-%s", oldval);
|
||||
v->fval = psprintf("-%s", oldval);
|
||||
}
|
||||
|
||||
static Node *
|
||||
|
@@ -376,7 +376,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
switch (nodeTag(&aconst->val))
|
||||
{
|
||||
case T_Integer:
|
||||
val = Int32GetDatum(aconst->val.ival.val);
|
||||
val = Int32GetDatum(intVal(&aconst->val));
|
||||
|
||||
typeid = INT4OID;
|
||||
typelen = sizeof(int32);
|
||||
@@ -385,7 +385,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
|
||||
case T_Float:
|
||||
/* could be an oversize integer as well as a float ... */
|
||||
if (scanint8(aconst->val.fval.val, true, &val64))
|
||||
if (scanint8(aconst->val.fval.fval, true, &val64))
|
||||
{
|
||||
/*
|
||||
* It might actually fit in int32. Probably only INT_MIN can
|
||||
@@ -415,7 +415,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
/* arrange to report location if numeric_in() fails */
|
||||
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
|
||||
val = DirectFunctionCall3(numeric_in,
|
||||
CStringGetDatum(aconst->val.fval.val),
|
||||
CStringGetDatum(aconst->val.fval.fval),
|
||||
ObjectIdGetDatum(InvalidOid),
|
||||
Int32GetDatum(-1));
|
||||
cancel_parser_errposition_callback(&pcbstate);
|
||||
@@ -432,7 +432,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
* We assume here that UNKNOWN's internal representation is the
|
||||
* same as CSTRING
|
||||
*/
|
||||
val = CStringGetDatum(aconst->val.sval.val);
|
||||
val = CStringGetDatum(strVal(&aconst->val));
|
||||
|
||||
typeid = UNKNOWNOID; /* will be coerced later */
|
||||
typelen = -2; /* cstring-style varwidth type */
|
||||
@@ -443,7 +443,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
/* arrange to report location if bit_in() fails */
|
||||
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
|
||||
val = DirectFunctionCall3(bit_in,
|
||||
CStringGetDatum(aconst->val.bsval.val),
|
||||
CStringGetDatum(aconst->val.bsval.bsval),
|
||||
ObjectIdGetDatum(InvalidOid),
|
||||
Int32GetDatum(-1));
|
||||
cancel_parser_errposition_callback(&pcbstate);
|
||||
|
@@ -382,17 +382,17 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
|
||||
|
||||
if (IsA(&ac->val, Integer))
|
||||
{
|
||||
cstr = psprintf("%ld", (long) ac->val.ival.val);
|
||||
cstr = psprintf("%ld", (long) intVal(&ac->val));
|
||||
}
|
||||
else if (IsA(&ac->val, Float))
|
||||
{
|
||||
/* we can just use the string representation directly. */
|
||||
cstr = ac->val.fval.val;
|
||||
cstr = ac->val.fval.fval;
|
||||
}
|
||||
else if (IsA(&ac->val, String))
|
||||
{
|
||||
/* we can just use the string representation directly. */
|
||||
cstr = ac->val.sval.val;
|
||||
cstr = strVal(&ac->val);
|
||||
}
|
||||
}
|
||||
else if (IsA(tm, ColumnRef))
|
||||
|
@@ -603,7 +603,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
||||
qstring = quote_qualified_identifier(snamespace, sname);
|
||||
snamenode = makeNode(A_Const);
|
||||
snamenode->val.node.type = T_String;
|
||||
snamenode->val.sval.val = qstring;
|
||||
snamenode->val.sval.sval = qstring;
|
||||
snamenode->location = -1;
|
||||
castnode = makeNode(TypeCast);
|
||||
castnode->typeName = SystemTypeName("regclass");
|
||||
|
Reference in New Issue
Block a user