Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c4cc285

Browse files
committed
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
1 parent 93415a3 commit c4cc285

File tree

12 files changed

+53
-53
lines changed

12 files changed

+53
-53
lines changed

src/backend/commands/define.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defGetString(DefElem *def)
5858
case T_Integer:
5959
return psprintf("%ld", (long) intVal(def->arg));
6060
case T_Float:
61-
return castNode(Float, def->arg)->val;
61+
return castNode(Float, def->arg)->fval;
6262
case T_String:
6363
return strVal(def->arg);
6464
case T_TypeName:
@@ -201,7 +201,7 @@ defGetInt64(DefElem *def)
201201
* strings.
202202
*/
203203
return DatumGetInt64(DirectFunctionCall1(int8in,
204-
CStringGetDatum(castNode(Float, def->arg)->val)));
204+
CStringGetDatum(castNode(Float, def->arg)->fval)));
205205
default:
206206
ereport(ERROR,
207207
(errcode(ERRCODE_SYNTAX_ERROR),

src/backend/nodes/copyfuncs.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -2745,16 +2745,16 @@ _copyA_Const(const A_Const *from)
27452745
switch (nodeTag(&from->val))
27462746
{
27472747
case T_Integer:
2748-
COPY_SCALAR_FIELD(val.ival.val);
2748+
COPY_SCALAR_FIELD(val.ival.ival);
27492749
break;
27502750
case T_Float:
2751-
COPY_STRING_FIELD(val.fval.val);
2751+
COPY_STRING_FIELD(val.fval.fval);
27522752
break;
27532753
case T_String:
2754-
COPY_STRING_FIELD(val.sval.val);
2754+
COPY_STRING_FIELD(val.sval.sval);
27552755
break;
27562756
case T_BitString:
2757-
COPY_STRING_FIELD(val.bsval.val);
2757+
COPY_STRING_FIELD(val.bsval.bsval);
27582758
break;
27592759
default:
27602760
elog(ERROR, "unrecognized node type: %d",
@@ -4934,7 +4934,7 @@ _copyInteger(const Integer *from)
49344934
{
49354935
Integer *newnode = makeNode(Integer);
49364936

4937-
COPY_SCALAR_FIELD(val);
4937+
COPY_SCALAR_FIELD(ival);
49384938

49394939
return newnode;
49404940
}
@@ -4944,7 +4944,7 @@ _copyFloat(const Float *from)
49444944
{
49454945
Float *newnode = makeNode(Float);
49464946

4947-
COPY_STRING_FIELD(val);
4947+
COPY_STRING_FIELD(fval);
49484948

49494949
return newnode;
49504950
}
@@ -4954,7 +4954,7 @@ _copyString(const String *from)
49544954
{
49554955
String *newnode = makeNode(String);
49564956

4957-
COPY_STRING_FIELD(val);
4957+
COPY_STRING_FIELD(sval);
49584958

49594959
return newnode;
49604960
}
@@ -4964,7 +4964,7 @@ _copyBitString(const BitString *from)
49644964
{
49654965
BitString *newnode = makeNode(BitString);
49664966

4967-
COPY_STRING_FIELD(val);
4967+
COPY_STRING_FIELD(bsval);
49684968

49694969
return newnode;
49704970
}

src/backend/nodes/equalfuncs.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3125,31 +3125,31 @@ _equalList(const List *a, const List *b)
31253125
static bool
31263126
_equalInteger(const Integer *a, const Integer *b)
31273127
{
3128-
COMPARE_SCALAR_FIELD(val);
3128+
COMPARE_SCALAR_FIELD(ival);
31293129

31303130
return true;
31313131
}
31323132

31333133
static bool
31343134
_equalFloat(const Float *a, const Float *b)
31353135
{
3136-
COMPARE_STRING_FIELD(val);
3136+
COMPARE_STRING_FIELD(fval);
31373137

31383138
return true;
31393139
}
31403140

31413141
static bool
31423142
_equalString(const String *a, const String *b)
31433143
{
3144-
COMPARE_STRING_FIELD(val);
3144+
COMPARE_STRING_FIELD(sval);
31453145

31463146
return true;
31473147
}
31483148

31493149
static bool
31503150
_equalBitString(const BitString *a, const BitString *b)
31513151
{
3152-
COMPARE_STRING_FIELD(val);
3152+
COMPARE_STRING_FIELD(bsval);
31533153

31543154
return true;
31553155
}

src/backend/nodes/outfuncs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -3421,7 +3421,7 @@ _outA_Expr(StringInfo str, const A_Expr *node)
34213421
static void
34223422
_outInteger(StringInfo str, const Integer *node)
34233423
{
3424-
appendStringInfo(str, "%d", node->val);
3424+
appendStringInfo(str, "%d", node->ival);
34253425
}
34263426

34273427
static void
@@ -3431,7 +3431,7 @@ _outFloat(StringInfo str, const Float *node)
34313431
* We assume the value is a valid numeric literal and so does not
34323432
* need quoting.
34333433
*/
3434-
appendStringInfoString(str, node->val);
3434+
appendStringInfoString(str, node->fval);
34353435
}
34363436

34373437
static void
@@ -3442,16 +3442,16 @@ _outString(StringInfo str, const String *node)
34423442
* but we don't want it to do anything with an empty string.
34433443
*/
34443444
appendStringInfoChar(str, '"');
3445-
if (node->val[0] != '\0')
3446-
outToken(str, node->val);
3445+
if (node->sval[0] != '\0')
3446+
outToken(str, node->sval);
34473447
appendStringInfoChar(str, '"');
34483448
}
34493449

34503450
static void
34513451
_outBitString(StringInfo str, const BitString *node)
34523452
{
34533453
/* internal representation already has leading 'b' */
3454-
appendStringInfoString(str, node->val);
3454+
appendStringInfoString(str, node->bsval);
34553455
}
34563456

34573457
static void

src/backend/nodes/value.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ makeInteger(int i)
2424
{
2525
Integer *v = makeNode(Integer);
2626

27-
v->val = i;
27+
v->ival = i;
2828
return v;
2929
}
3030

@@ -38,7 +38,7 @@ makeFloat(char *numericStr)
3838
{
3939
Float *v = makeNode(Float);
4040

41-
v->val = numericStr;
41+
v->fval = numericStr;
4242
return v;
4343
}
4444

@@ -52,7 +52,7 @@ makeString(char *str)
5252
{
5353
String *v = makeNode(String);
5454

55-
v->val = str;
55+
v->sval = str;
5656
return v;
5757
}
5858

@@ -66,6 +66,6 @@ makeBitString(char *str)
6666
{
6767
BitString *v = makeNode(BitString);
6868

69-
v->val = str;
69+
v->bsval = str;
7070
return v;
7171
}

src/backend/parser/gram.y

+12-12
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ zone_value:
17191719
if ($3 != NIL)
17201720
{
17211721
A_Const *n = (A_Const *) linitial($3);
1722-
if ((n->val.ival.val & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
1722+
if ((n->val.ival.ival & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
17231723
ereport(ERROR,
17241724
(errcode(ERRCODE_SYNTAX_ERROR),
17251725
errmsg("time zone interval must be HOUR or HOUR TO MINUTE"),
@@ -16667,7 +16667,7 @@ makeStringConst(char *str, int location)
1666716667
A_Const *n = makeNode(A_Const);
1666816668

1666916669
n->val.sval.type = T_String;
16670-
n->val.sval.val = str;
16670+
n->val.sval.sval = str;
1667116671
n->location = location;
1667216672

1667316673
return (Node *)n;
@@ -16687,7 +16687,7 @@ makeIntConst(int val, int location)
1668716687
A_Const *n = makeNode(A_Const);
1668816688

1668916689
n->val.ival.type = T_Integer;
16690-
n->val.ival.val = val;
16690+
n->val.ival.ival = val;
1669116691
n->location = location;
1669216692

1669316693
return (Node *)n;
@@ -16699,7 +16699,7 @@ makeFloatConst(char *str, int location)
1669916699
A_Const *n = makeNode(A_Const);
1670016700

1670116701
n->val.fval.type = T_Float;
16702-
n->val.fval.val = str;
16702+
n->val.fval.fval = str;
1670316703
n->location = location;
1670416704

1670516705
return (Node *)n;
@@ -16711,7 +16711,7 @@ makeBitStringConst(char *str, int location)
1671116711
A_Const *n = makeNode(A_Const);
1671216712

1671316713
n->val.bsval.type = T_BitString;
16714-
n->val.bsval.val = str;
16714+
n->val.bsval.bsval = str;
1671516715
n->location = location;
1671616716

1671716717
return (Node *)n;
@@ -16736,16 +16736,16 @@ makeAConst(Node *v, int location)
1673616736
switch (v->type)
1673716737
{
1673816738
case T_Float:
16739-
n = makeFloatConst(castNode(Float, v)->val, location);
16739+
n = makeFloatConst(castNode(Float, v)->fval, location);
1674016740
break;
1674116741

1674216742
case T_Integer:
16743-
n = makeIntConst(castNode(Integer, v)->val, location);
16743+
n = makeIntConst(castNode(Integer, v)->ival, location);
1674416744
break;
1674516745

1674616746
case T_String:
1674716747
default:
16748-
n = makeStringConst(castNode(String, v)->val, location);
16748+
n = makeStringConst(castNode(String, v)->sval, location);
1674916749
break;
1675016750
}
1675116751

@@ -17049,7 +17049,7 @@ doNegate(Node *n, int location)
1704917049

1705017050
if (IsA(&con->val, Integer))
1705117051
{
17052-
con->val.ival.val = -con->val.ival.val;
17052+
con->val.ival.ival = -con->val.ival.ival;
1705317053
return n;
1705417054
}
1705517055
if (IsA(&con->val, Float))
@@ -17065,14 +17065,14 @@ doNegate(Node *n, int location)
1706517065
static void
1706617066
doNegateFloat(Float *v)
1706717067
{
17068-
char *oldval = v->val;
17068+
char *oldval = v->fval;
1706917069

1707017070
if (*oldval == '+')
1707117071
oldval++;
1707217072
if (*oldval == '-')
17073-
v->val = oldval+1; /* just strip the '-' */
17073+
v->fval = oldval+1; /* just strip the '-' */
1707417074
else
17075-
v->val = psprintf("-%s", oldval);
17075+
v->fval = psprintf("-%s", oldval);
1707617076
}
1707717077

1707817078
static Node *

src/backend/parser/parse_node.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ make_const(ParseState *pstate, A_Const *aconst)
376376
switch (nodeTag(&aconst->val))
377377
{
378378
case T_Integer:
379-
val = Int32GetDatum(aconst->val.ival.val);
379+
val = Int32GetDatum(intVal(&aconst->val));
380380

381381
typeid = INT4OID;
382382
typelen = sizeof(int32);
@@ -385,7 +385,7 @@ make_const(ParseState *pstate, A_Const *aconst)
385385

386386
case T_Float:
387387
/* could be an oversize integer as well as a float ... */
388-
if (scanint8(aconst->val.fval.val, true, &val64))
388+
if (scanint8(aconst->val.fval.fval, true, &val64))
389389
{
390390
/*
391391
* It might actually fit in int32. Probably only INT_MIN can
@@ -415,7 +415,7 @@ make_const(ParseState *pstate, A_Const *aconst)
415415
/* arrange to report location if numeric_in() fails */
416416
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
417417
val = DirectFunctionCall3(numeric_in,
418-
CStringGetDatum(aconst->val.fval.val),
418+
CStringGetDatum(aconst->val.fval.fval),
419419
ObjectIdGetDatum(InvalidOid),
420420
Int32GetDatum(-1));
421421
cancel_parser_errposition_callback(&pcbstate);
@@ -432,7 +432,7 @@ make_const(ParseState *pstate, A_Const *aconst)
432432
* We assume here that UNKNOWN's internal representation is the
433433
* same as CSTRING
434434
*/
435-
val = CStringGetDatum(aconst->val.sval.val);
435+
val = CStringGetDatum(strVal(&aconst->val));
436436

437437
typeid = UNKNOWNOID; /* will be coerced later */
438438
typelen = -2; /* cstring-style varwidth type */
@@ -443,7 +443,7 @@ make_const(ParseState *pstate, A_Const *aconst)
443443
/* arrange to report location if bit_in() fails */
444444
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
445445
val = DirectFunctionCall3(bit_in,
446-
CStringGetDatum(aconst->val.bsval.val),
446+
CStringGetDatum(aconst->val.bsval.bsval),
447447
ObjectIdGetDatum(InvalidOid),
448448
Int32GetDatum(-1));
449449
cancel_parser_errposition_callback(&pcbstate);

src/backend/parser/parse_type.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,17 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
382382

383383
if (IsA(&ac->val, Integer))
384384
{
385-
cstr = psprintf("%ld", (long) ac->val.ival.val);
385+
cstr = psprintf("%ld", (long) intVal(&ac->val));
386386
}
387387
else if (IsA(&ac->val, Float))
388388
{
389389
/* we can just use the string representation directly. */
390-
cstr = ac->val.fval.val;
390+
cstr = ac->val.fval.fval;
391391
}
392392
else if (IsA(&ac->val, String))
393393
{
394394
/* we can just use the string representation directly. */
395-
cstr = ac->val.sval.val;
395+
cstr = strVal(&ac->val);
396396
}
397397
}
398398
else if (IsA(tm, ColumnRef))

src/backend/parser/parse_utilcmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
603603
qstring = quote_qualified_identifier(snamespace, sname);
604604
snamenode = makeNode(A_Const);
605605
snamenode->val.node.type = T_String;
606-
snamenode->val.sval.val = qstring;
606+
snamenode->val.sval.sval = qstring;
607607
snamenode->location = -1;
608608
castnode = makeNode(TypeCast);
609609
castnode->typeName = SystemTypeName("regclass");

src/backend/utils/adt/oid.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ oidparse(Node *node)
324324
* constants by the lexer. Accept these if they are valid OID
325325
* strings.
326326
*/
327-
return oidin_subr(castNode(Float, node)->val, NULL);
327+
return oidin_subr(castNode(Float, node)->fval, NULL);
328328
default:
329329
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
330330
}

src/backend/utils/misc/guc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8332,7 +8332,7 @@ flatten_set_variable_args(const char *name, List *args)
83328332
break;
83338333
case T_Float:
83348334
/* represented as a string, so just copy it */
8335-
appendStringInfoString(&buf, castNode(Float, &con->val)->val);
8335+
appendStringInfoString(&buf, castNode(Float, &con->val)->fval);
83368336
break;
83378337
case T_String:
83388338
val = strVal(&con->val);

0 commit comments

Comments
 (0)