summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorPeter Eisentraut2021-09-09 05:58:12 +0000
committerPeter Eisentraut2021-09-09 06:36:53 +0000
commit639a86e36aaecb84faaf941dcd0b183ba0aba9e9 (patch)
tree2b523f247bf373ae61fcff5fb0bf938c6c5bdc07 /src/backend/commands
parentcbdf75bf8053f88bbae6b307f34ab057424a370f (diff)
Remove Value node struct
The Value node struct is a weird construct. It is its own node type, but most of the time, it actually has a node type of Integer, Float, String, or BitString. As a consequence, the struct name and the node type don't match most of the time, and so it has to be treated specially a lot. There doesn't seem to be any value in the special construct. There is very little code that wants to accept all Value variants but nothing else (and even if it did, this doesn't provide any convenient way to check it), and most code wants either just one particular node type (usually String), or it accepts a broader set of node types besides just Value. This change removes the Value struct and node type and replaces them by separate Integer, Float, String, and BitString node types that are proper node types and structs of their own and behave mostly like normal node types. Also, this removes the T_Null node tag, which was previously also a possible variant of Value but wasn't actually used outside of the Value contained in A_Const. Replace that by an isnull field in A_Const. Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/5ba6bc5b-3f95-04f2-2419-f8ddb4c046fb@enterprisedb.com
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/copy.c5
-rw-r--r--src/backend/commands/define.c9
-rw-r--r--src/backend/commands/tsearchcmds.c4
3 files changed, 6 insertions, 12 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 6b33951e0c9..53f48531419 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -222,9 +222,8 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
{
/*
* Build the ColumnRef for each column. The ColumnRef
- * 'fields' property is a String 'Value' node (see
- * nodes/value.h) that corresponds to the column name
- * respectively.
+ * 'fields' property is a String node that corresponds to
+ * the column name respectively.
*/
cr = makeNode(ColumnRef);
cr->fields = list_make1(lfirst(lc));
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index aafd7554e4e..19c317a472e 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -58,12 +58,7 @@ defGetString(DefElem *def)
case T_Integer:
return psprintf("%ld", (long) intVal(def->arg));
case T_Float:
-
- /*
- * T_Float values are kept in string form, so this type cheat
- * works (and doesn't risk losing precision)
- */
- return strVal(def->arg);
+ return castNode(Float, def->arg)->val;
case T_String:
return strVal(def->arg);
case T_TypeName:
@@ -206,7 +201,7 @@ defGetInt64(DefElem *def)
* strings.
*/
return DatumGetInt64(DirectFunctionCall1(int8in,
- CStringGetDatum(strVal(def->arg))));
+ CStringGetDatum(castNode(Float, def->arg)->val)));
default:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index e06fb32b3d1..c47a05d10da 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -1179,7 +1179,7 @@ getTokenTypes(Oid prsId, List *tokennames)
i = 0;
foreach(tn, tokennames)
{
- Value *val = (Value *) lfirst(tn);
+ String *val = lfirst_node(String, tn);
bool found = false;
int j;
@@ -1395,7 +1395,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
i = 0;
foreach(c, stmt->tokentype)
{
- Value *val = (Value *) lfirst(c);
+ String *val = lfirst_node(String, c);
bool found = false;
ScanKeyInit(&skey[0],