PG15: Value -> String, Integer, Float.

Handle PG commit 639a86e36a.
pull/5920/head
Jeff Davis 2022-04-09 11:01:49 -07:00 committed by jeff-davis
parent 26f5e20580
commit 3799f95742
27 changed files with 105 additions and 59 deletions

View File

@ -10,6 +10,8 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "pg_version_compat.h"
#include "access/htup_details.h" #include "access/htup_details.h"
#include "access/xact.h" #include "access/xact.h"
#include "catalog/pg_collation.h" #include "catalog/pg_collation.h"
@ -521,7 +523,7 @@ GenerateBackupNameForCollationCollision(const ObjectAddress *address)
return NULL; return NULL;
} }
Form_pg_collation collationForm = (Form_pg_collation) GETSTRUCT(collationTuple); Form_pg_collation collationForm = (Form_pg_collation) GETSTRUCT(collationTuple);
Value *namespace = makeString(get_namespace_name(collationForm->collnamespace)); String *namespace = makeString(get_namespace_name(collationForm->collnamespace));
ReleaseSysCache(collationTuple); ReleaseSysCache(collationTuple);
while (true) while (true)

View File

@ -115,7 +115,7 @@ AlterDatabaseOwnerObjectAddress(Node *node, bool missing_ok)
AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node); AlterOwnerStmt *stmt = castNode(AlterOwnerStmt, node);
Assert(stmt->objectType == OBJECT_DATABASE); Assert(stmt->objectType == OBJECT_DATABASE);
Oid databaseOid = get_database_oid(strVal((Value *) stmt->object), missing_ok); Oid databaseOid = get_database_oid(strVal((String *) stmt->object), missing_ok);
ObjectAddress address = { 0 }; ObjectAddress address = { 0 };
ObjectAddressSet(address, DatabaseRelationId, databaseOid); ObjectAddressSet(address, DatabaseRelationId, databaseOid);

View File

@ -295,7 +295,7 @@ FilterDistributedExtensions(List *extensionObjectList)
{ {
List *extensionNameList = NIL; List *extensionNameList = NIL;
Value *objectName = NULL; String *objectName = NULL;
foreach_ptr(objectName, extensionObjectList) foreach_ptr(objectName, extensionObjectList)
{ {
const char *extensionName = strVal(objectName); const char *extensionName = strVal(objectName);
@ -334,7 +334,7 @@ ExtensionNameListToObjectAddressList(List *extensionObjectList)
{ {
List *extensionObjectAddressList = NIL; List *extensionObjectAddressList = NIL;
Value *objectName; String *objectName;
foreach_ptr(objectName, extensionObjectList) foreach_ptr(objectName, extensionObjectList)
{ {
/* /*
@ -671,7 +671,7 @@ IsDropCitusExtensionStmt(Node *parseTree)
} }
/* now that we have a DropStmt, check if citus extension is among the objects to dropped */ /* now that we have a DropStmt, check if citus extension is among the objects to dropped */
Value *objectName; String *objectName;
foreach_ptr(objectName, dropStmt->objects) foreach_ptr(objectName, dropStmt->objects)
{ {
const char *extensionName = strVal(objectName); const char *extensionName = strVal(objectName);

View File

@ -190,7 +190,7 @@ PreprocessDropForeignServerStmt(Node *node, const char *queryString,
Assert(list_length(stmt->objects) == 1); Assert(list_length(stmt->objects) == 1);
Value *serverValue = linitial(stmt->objects); String *serverValue = linitial(stmt->objects);
ObjectAddress address = GetObjectAddressByServerName(strVal(serverValue), false); ObjectAddress address = GetObjectAddressByServerName(strVal(serverValue), false);
/* unmark distributed server */ /* unmark distributed server */
@ -362,7 +362,7 @@ RecreateForeignServerStmt(Oid serverId)
static bool static bool
NameListHasDistributedServer(List *serverNames) NameListHasDistributedServer(List *serverNames)
{ {
Value *serverValue = NULL; String *serverValue = NULL;
foreach_ptr(serverValue, serverNames) foreach_ptr(serverValue, serverNames)
{ {
ObjectAddress address = GetObjectAddressByServerName(strVal(serverValue), false); ObjectAddress address = GetObjectAddressByServerName(strVal(serverValue), false);

View File

@ -1893,7 +1893,7 @@ AlterFunctionSchemaStmtObjectAddress(Node *node, bool missing_ok)
*/ */
/* the name of the function is the last in the list of names */ /* the name of the function is the last in the list of names */
Value *funcNameStr = lfirst(list_tail(names)); String *funcNameStr = lfirst(list_tail(names));
List *newNames = list_make2(makeString(stmt->newschema), funcNameStr); List *newNames = list_make2(makeString(stmt->newschema), funcNameStr);
/* /*
@ -1938,8 +1938,8 @@ GenerateBackupNameForProcCollision(const ObjectAddress *address)
char *newName = palloc0(NAMEDATALEN); char *newName = palloc0(NAMEDATALEN);
char suffix[NAMEDATALEN] = { 0 }; char suffix[NAMEDATALEN] = { 0 };
int count = 0; int count = 0;
Value *namespace = makeString(get_namespace_name(get_func_namespace( String *namespace = makeString(get_namespace_name(get_func_namespace(
address->objectId))); address->objectId)));
char *baseName = get_func_name(address->objectId); char *baseName = get_func_name(address->objectId);
int baseLength = strlen(baseName); int baseLength = strlen(baseName);
Oid *argtypes = NULL; Oid *argtypes = NULL;

View File

@ -2009,7 +2009,7 @@ CitusCopyDestReceiverStartup(DestReceiver *dest, int operation,
foreach(columnNameCell, columnNameList) foreach(columnNameCell, columnNameList)
{ {
char *columnName = (char *) lfirst(columnNameCell); char *columnName = (char *) lfirst(columnNameCell);
Value *columnNameValue = makeString(columnName); String *columnNameValue = makeString(columnName);
attributeList = lappend(attributeList, columnNameValue); attributeList = lappend(attributeList, columnNameValue);
} }

View File

@ -150,7 +150,7 @@ PostprocessAlterRoleStmt(Node *node, const char *queryString)
if (encryptedPassword != NULL) if (encryptedPassword != NULL)
{ {
Value *encryptedPasswordValue = makeString((char *) encryptedPassword); String *encryptedPasswordValue = makeString((char *) encryptedPassword);
option->arg = (Node *) encryptedPasswordValue; option->arg = (Node *) encryptedPasswordValue;
} }
else else
@ -741,8 +741,13 @@ makeStringConst(char *str, int location)
{ {
A_Const *n = makeNode(A_Const); A_Const *n = makeNode(A_Const);
#if PG_VERSION_NUM >= PG_VERSION_15
n->val.sval.type = T_String;
n->val.sval.sval = str;
#else
n->val.type = T_String; n->val.type = T_String;
n->val.val.str = str; n->val.val.str = str;
#endif
n->location = location; n->location = location;
return (Node *) n; return (Node *) n;
@ -759,8 +764,13 @@ makeIntConst(int val, int location)
{ {
A_Const *n = makeNode(A_Const); A_Const *n = makeNode(A_Const);
#if PG_VERSION_NUM >= PG_VERSION_15
n->val.ival.type = T_Integer;
n->val.ival.ival = val;
#else
n->val.type = T_Integer; n->val.type = T_Integer;
n->val.val.ival = val; n->val.val.ival = val;
#endif
n->location = location; n->location = location;
return (Node *) n; return (Node *) n;
@ -777,8 +787,13 @@ makeFloatConst(char *str, int location)
{ {
A_Const *n = makeNode(A_Const); A_Const *n = makeNode(A_Const);
#if PG_VERSION_NUM >= PG_VERSION_15
n->val.fval.type = T_Float;
n->val.fval.fval = str;
#else
n->val.type = T_Float; n->val.type = T_Float;
n->val.val.str = str; n->val.val.str = str;
#endif
n->location = location; n->location = location;
return (Node *) n; return (Node *) n;

View File

@ -107,7 +107,7 @@ PreprocessDropSchemaStmt(Node *node, const char *queryString,
EnsureSequentialMode(OBJECT_SCHEMA); EnsureSequentialMode(OBJECT_SCHEMA);
Value *schemaVal = NULL; String *schemaVal = NULL;
foreach_ptr(schemaVal, distributedSchemas) foreach_ptr(schemaVal, distributedSchemas)
{ {
if (SchemaHasDistributedTableWithFKey(strVal(schemaVal))) if (SchemaHasDistributedTableWithFKey(strVal(schemaVal)))
@ -288,7 +288,7 @@ FilterDistributedSchemas(List *schemas)
{ {
List *distributedSchemas = NIL; List *distributedSchemas = NIL;
Value *schemaValue = NULL; String *schemaValue = NULL;
foreach_ptr(schemaValue, schemas) foreach_ptr(schemaValue, schemas)
{ {
const char *schemaName = strVal(schemaValue); const char *schemaName = strVal(schemaValue);

View File

@ -295,7 +295,7 @@ PostprocessAlterStatisticsSchemaStmt(Node *node, const char *queryString)
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node); AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
Assert(stmt->objectType == OBJECT_STATISTIC_EXT); Assert(stmt->objectType == OBJECT_STATISTIC_EXT);
Value *statName = llast((List *) stmt->object); String *statName = llast((List *) stmt->object);
Oid statsOid = get_statistics_object_oid(list_make2(makeString(stmt->newschema), Oid statsOid = get_statistics_object_oid(list_make2(makeString(stmt->newschema),
statName), false); statName), false);
Oid relationId = GetRelIdByStatsOid(statsOid); Oid relationId = GetRelIdByStatsOid(statsOid);
@ -328,7 +328,7 @@ AlterStatisticsSchemaStmtObjectAddress(Node *node, bool missingOk)
AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node); AlterObjectSchemaStmt *stmt = castNode(AlterObjectSchemaStmt, node);
ObjectAddress address = { 0 }; ObjectAddress address = { 0 };
Value *statName = llast((List *) stmt->object); String *statName = llast((List *) stmt->object);
Oid statsOid = get_statistics_object_oid(list_make2(makeString(stmt->newschema), Oid statsOid = get_statistics_object_oid(list_make2(makeString(stmt->newschema),
statName), missingOk); statName), missingOk);
ObjectAddressSet(address, StatisticExtRelationId, statsOid); ObjectAddressSet(address, StatisticExtRelationId, statsOid);

View File

@ -44,8 +44,8 @@
/* local function forward declarations */ /* local function forward declarations */
static bool IsCreateCitusTruncateTriggerStmt(CreateTrigStmt *createTriggerStmt); static bool IsCreateCitusTruncateTriggerStmt(CreateTrigStmt *createTriggerStmt);
static Value * GetAlterTriggerDependsTriggerNameValue(AlterObjectDependsStmt * static String * GetAlterTriggerDependsTriggerNameValue(AlterObjectDependsStmt *
alterTriggerDependsStmt); alterTriggerDependsStmt);
static void ErrorIfUnsupportedDropTriggerCommand(DropStmt *dropTriggerStmt); static void ErrorIfUnsupportedDropTriggerCommand(DropStmt *dropTriggerStmt);
static RangeVar * GetDropTriggerStmtRelation(DropStmt *dropTriggerStmt); static RangeVar * GetDropTriggerStmtRelation(DropStmt *dropTriggerStmt);
static void ExtractDropStmtTriggerAndRelationName(DropStmt *dropTriggerStmt, static void ExtractDropStmtTriggerAndRelationName(DropStmt *dropTriggerStmt,
@ -416,7 +416,7 @@ PreprocessAlterTriggerDependsStmt(Node *node, const char *queryString,
* workers * workers
*/ */
Value *triggerNameValue = String *triggerNameValue =
GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt); GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt);
ereport(ERROR, (errmsg( ereport(ERROR, (errmsg(
"Triggers \"%s\" on distributed tables and local tables added to metadata " "Triggers \"%s\" on distributed tables and local tables added to metadata "
@ -454,7 +454,7 @@ PostprocessAlterTriggerDependsStmt(Node *node, const char *queryString)
EnsureCoordinator(); EnsureCoordinator();
ErrorOutForTriggerIfNotSupported(relationId); ErrorOutForTriggerIfNotSupported(relationId);
Value *triggerNameValue = String *triggerNameValue =
GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt); GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt);
return CitusCreateTriggerCommandDDLJob(relationId, strVal(triggerNameValue), return CitusCreateTriggerCommandDDLJob(relationId, strVal(triggerNameValue),
queryString); queryString);
@ -476,7 +476,7 @@ AlterTriggerDependsEventExtendNames(AlterObjectDependsStmt *alterTriggerDependsS
char **relationName = &(relation->relname); char **relationName = &(relation->relname);
AppendShardIdToName(relationName, shardId); AppendShardIdToName(relationName, shardId);
Value *triggerNameValue = String *triggerNameValue =
GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt); GetAlterTriggerDependsTriggerNameValue(alterTriggerDependsStmt);
AppendShardIdToName(&strVal(triggerNameValue), shardId); AppendShardIdToName(&strVal(triggerNameValue), shardId);
@ -489,7 +489,7 @@ AlterTriggerDependsEventExtendNames(AlterObjectDependsStmt *alterTriggerDependsS
* GetAlterTriggerDependsTriggerName returns Value object for the trigger * GetAlterTriggerDependsTriggerName returns Value object for the trigger
* name that given AlterObjectDependsStmt is executed for. * name that given AlterObjectDependsStmt is executed for.
*/ */
static Value * static String *
GetAlterTriggerDependsTriggerNameValue(AlterObjectDependsStmt *alterTriggerDependsStmt) GetAlterTriggerDependsTriggerNameValue(AlterObjectDependsStmt *alterTriggerDependsStmt)
{ {
List *triggerObjectNameList = (List *) alterTriggerDependsStmt->object; List *triggerObjectNameList = (List *) alterTriggerDependsStmt->object;
@ -503,7 +503,7 @@ GetAlterTriggerDependsTriggerNameValue(AlterObjectDependsStmt *alterTriggerDepen
* be the name of the trigger in either before or after standard process * be the name of the trigger in either before or after standard process
* utility. * utility.
*/ */
Value *triggerNameValue = llast(triggerObjectNameList); String *triggerNameValue = llast(triggerObjectNameList);
return triggerNameValue; return triggerNameValue;
} }
@ -642,12 +642,12 @@ DropTriggerEventExtendNames(DropStmt *dropTriggerStmt, char *schemaName, uint64
ExtractDropStmtTriggerAndRelationName(dropTriggerStmt, &triggerName, &relationName); ExtractDropStmtTriggerAndRelationName(dropTriggerStmt, &triggerName, &relationName);
AppendShardIdToName(&triggerName, shardId); AppendShardIdToName(&triggerName, shardId);
Value *triggerNameValue = makeString(triggerName); String *triggerNameValue = makeString(triggerName);
AppendShardIdToName(&relationName, shardId); AppendShardIdToName(&relationName, shardId);
Value *relationNameValue = makeString(relationName); String *relationNameValue = makeString(relationName);
Value *schemaNameValue = makeString(pstrdup(schemaName)); String *schemaNameValue = makeString(pstrdup(schemaName));
List *shardTriggerNameList = List *shardTriggerNameList =
list_make3(schemaNameValue, relationNameValue, triggerNameValue); list_make3(schemaNameValue, relationNameValue, triggerNameValue);

View File

@ -878,7 +878,7 @@ AlterTypeSchemaStmtObjectAddress(Node *node, bool missing_ok)
*/ */
/* typename is the last in the list of names */ /* typename is the last in the list of names */
Value *typeNameStr = lfirst(list_tail(names)); String *typeNameStr = lfirst(list_tail(names));
/* /*
* we don't error here either, as the error would be not a good user facing * we don't error here either, as the error would be not a good user facing

View File

@ -432,7 +432,7 @@ DeparseVacuumColumnNames(List *columnNameList)
appendStringInfoString(columnNames, " ("); appendStringInfoString(columnNames, " (");
Value *columnName = NULL; String *columnName = NULL;
foreach_ptr(columnName, columnNameList) foreach_ptr(columnName, columnNameList)
{ {
appendStringInfo(columnNames, "%s,", strVal(columnName)); appendStringInfo(columnNames, "%s,", strVal(columnName));

View File

@ -11,6 +11,8 @@
#include "postgres.h" #include "postgres.h"
#include "pg_version_compat.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
@ -44,6 +46,6 @@ AppendAlterDatabaseOwnerStmt(StringInfo buf, AlterOwnerStmt *stmt)
appendStringInfo(buf, appendStringInfo(buf,
"ALTER DATABASE %s OWNER TO %s;", "ALTER DATABASE %s OWNER TO %s;",
quote_identifier(strVal((Value *) stmt->object)), quote_identifier(strVal((String *) stmt->object)),
RoleSpecString(stmt->newowner, true)); RoleSpecString(stmt->newowner, true));
} }

View File

@ -223,7 +223,7 @@ AppendDropForeignServerStmt(StringInfo buf, DropStmt *stmt)
static void static void
AppendServerNames(StringInfo buf, DropStmt *stmt) AppendServerNames(StringInfo buf, DropStmt *stmt)
{ {
Value *serverValue = NULL; String *serverValue = NULL;
foreach_ptr(serverValue, stmt->objects) foreach_ptr(serverValue, stmt->objects)
{ {
const char *serverString = quote_identifier(strVal(serverValue)); const char *serverString = quote_identifier(strVal(serverValue));

View File

@ -396,18 +396,18 @@ AppendVarSetValue(StringInfo buf, VariableSetStmt *setStmt)
appendStringInfo(buf, " SET %s =", quote_identifier(setStmt->name)); appendStringInfo(buf, " SET %s =", quote_identifier(setStmt->name));
} }
Value value = varArgConst->val; Node *value = (Node *) &varArgConst->val;
switch (value.type) switch (value->type)
{ {
case T_Integer: case T_Integer:
{ {
appendStringInfo(buf, " %d", intVal(&value)); appendStringInfo(buf, " %d", intVal(value));
break; break;
} }
case T_Float: case T_Float:
{ {
appendStringInfo(buf, " %s", strVal(&value)); appendStringInfo(buf, " %s", strVal(value));
break; break;
} }
@ -428,7 +428,7 @@ AppendVarSetValue(StringInfo buf, VariableSetStmt *setStmt)
Datum interval = Datum interval =
DirectFunctionCall3(interval_in, DirectFunctionCall3(interval_in,
CStringGetDatum(strVal(&value)), CStringGetDatum(strVal(value)),
ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(InvalidOid),
Int32GetDatum(typmod)); Int32GetDatum(typmod));
@ -440,7 +440,7 @@ AppendVarSetValue(StringInfo buf, VariableSetStmt *setStmt)
else else
{ {
appendStringInfo(buf, " %s", quote_literal_cstr(strVal( appendStringInfo(buf, " %s", quote_literal_cstr(strVal(
&value))); value)));
} }
break; break;
} }

View File

@ -126,7 +126,7 @@ AppendDropSchemaStmt(StringInfo buf, DropStmt *stmt)
appendStringInfoString(buf, "IF EXISTS "); appendStringInfoString(buf, "IF EXISTS ");
} }
Value *schemaValue = NULL; String *schemaValue = NULL;
foreach_ptr(schemaValue, stmt->objects) foreach_ptr(schemaValue, stmt->objects)
{ {
const char *schemaString = quote_identifier(strVal(schemaValue)); const char *schemaString = quote_identifier(strVal(schemaValue));

View File

@ -200,10 +200,10 @@ AppendAlterStatisticsOwnerStmt(StringInfo buf, AlterOwnerStmt *stmt)
static void static void
AppendStatisticsName(StringInfo buf, CreateStatsStmt *stmt) AppendStatisticsName(StringInfo buf, CreateStatsStmt *stmt)
{ {
Value *schemaNameVal = (Value *) linitial(stmt->defnames); String *schemaNameVal = (String *) linitial(stmt->defnames);
const char *schemaName = quote_identifier(strVal(schemaNameVal)); const char *schemaName = quote_identifier(strVal(schemaNameVal));
Value *statNameVal = (Value *) lsecond(stmt->defnames); String *statNameVal = (String *) lsecond(stmt->defnames);
const char *statName = quote_identifier(strVal(statNameVal)); const char *statName = quote_identifier(strVal(statNameVal));
appendStringInfo(buf, "%s.%s", schemaName, statName); appendStringInfo(buf, "%s.%s", schemaName, statName);
@ -220,7 +220,7 @@ AppendStatTypes(StringInfo buf, CreateStatsStmt *stmt)
appendStringInfoString(buf, " ("); appendStringInfoString(buf, " (");
Value *statType = NULL; String *statType = NULL;
foreach_ptr(statType, stmt->stat_types) foreach_ptr(statType, stmt->stat_types)
{ {
appendStringInfoString(buf, strVal(statType)); appendStringInfoString(buf, strVal(statType));

View File

@ -464,7 +464,7 @@ DeparseTextSearchDictionaryCommentStmt(Node *node)
static void static void
AppendStringInfoTokentypeList(StringInfo buf, List *tokentypes) AppendStringInfoTokentypeList(StringInfo buf, List *tokentypes)
{ {
Value *tokentype = NULL; String *tokentype = NULL;
bool first = true; bool first = true;
foreach_ptr(tokentype, tokentypes) foreach_ptr(tokentype, tokentypes)
{ {

View File

@ -7,7 +7,9 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h"
#include "distributed/pg_version_constants.h" #include "distributed/pg_version_constants.h"
#include "pg_version_compat.h"
#include "stdint.h" #include "stdint.h"
#include "postgres.h" #include "postgres.h"
@ -2864,8 +2866,8 @@ CurrentUserName(void)
Oid Oid
LookupTypeOid(char *schemaNameSting, char *typeNameString) LookupTypeOid(char *schemaNameSting, char *typeNameString)
{ {
Value *schemaName = makeString(schemaNameSting); String *schemaName = makeString(schemaNameSting);
Value *typeName = makeString(typeNameString); String *typeName = makeString(typeNameString);
List *qualifiedName = list_make2(schemaName, typeName); List *qualifiedName = list_make2(schemaName, typeName);
TypeName *enumTypeName = makeTypeNameFromNameList(qualifiedName); TypeName *enumTypeName = makeTypeNameFromNameList(qualifiedName);

View File

@ -12,6 +12,7 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include "pg_version_compat.h"
#include "distributed/pg_version_constants.h" #include "distributed/pg_version_constants.h"
#include "distributed/cte_inline.h" #include "distributed/cte_inline.h"
@ -309,7 +310,7 @@ inline_cte_walker(Node *node, inline_cte_walker_context *context)
*/ */
if (columnAliasCount >= columnIndex) if (columnAliasCount >= columnIndex)
{ {
Value *columnAlias = (Value *) list_nth(columnAliasList, columnIndex - 1); String *columnAlias = (String *) list_nth(columnAliasList, columnIndex - 1);
Assert(IsA(columnAlias, String)); Assert(IsA(columnAlias, String));
TargetEntry *targetEntry = TargetEntry *targetEntry =
list_nth(rte->subquery->targetList, columnIndex - 1); list_nth(rte->subquery->targetList, columnIndex - 1);

View File

@ -1353,7 +1353,7 @@ FinalizeRouterPlan(PlannedStmt *localPlan, CustomScan *customScan)
TargetEntry *targetEntry = NULL; TargetEntry *targetEntry = NULL;
foreach_ptr(targetEntry, customScan->scan.plan.targetlist) foreach_ptr(targetEntry, customScan->scan.plan.targetlist)
{ {
Value *columnName = makeString(targetEntry->resname); String *columnName = makeString(targetEntry->resname);
columnNameList = lappend(columnNameList, columnName); columnNameList = lappend(columnNameList, columnName);
} }

View File

@ -798,7 +798,7 @@ DerivedColumnNameList(uint32 columnCount, uint64 generatingJobId)
appendStringInfo(columnName, UINT64_FORMAT "_", generatingJobId); appendStringInfo(columnName, UINT64_FORMAT "_", generatingJobId);
appendStringInfo(columnName, "%u", columnIndex); appendStringInfo(columnName, "%u", columnIndex);
Value *columnValue = makeString(columnName->data); String *columnValue = makeString(columnName->data);
columnNameList = lappend(columnNameList, columnValue); columnNameList = lappend(columnNameList, columnValue);
} }

View File

@ -151,7 +151,7 @@ static Job * RouterJob(Query *originalQuery,
static bool RelationPrunesToMultipleShards(List *relationShardList); static bool RelationPrunesToMultipleShards(List *relationShardList);
static void NormalizeMultiRowInsertTargetList(Query *query); static void NormalizeMultiRowInsertTargetList(Query *query);
static void AppendNextDummyColReference(Alias *expendedReferenceNames); static void AppendNextDummyColReference(Alias *expendedReferenceNames);
static Value * MakeDummyColumnString(int dummyColumnId); static String * MakeDummyColumnString(int dummyColumnId);
static List * BuildRoutesForInsert(Query *query, DeferredErrorMessage **planningError); static List * BuildRoutesForInsert(Query *query, DeferredErrorMessage **planningError);
static List * GroupInsertValuesByShardId(List *insertValuesList); static List * GroupInsertValuesByShardId(List *insertValuesList);
static List * ExtractInsertValuesList(Query *query, Var *partitionColumn); static List * ExtractInsertValuesList(Query *query, Var *partitionColumn);
@ -3249,7 +3249,7 @@ AppendNextDummyColReference(Alias *expendedReferenceNames)
{ {
int existingColReferences = list_length(expendedReferenceNames->colnames); int existingColReferences = list_length(expendedReferenceNames->colnames);
int nextColReferenceId = existingColReferences + 1; int nextColReferenceId = existingColReferences + 1;
Value *missingColumnString = MakeDummyColumnString(nextColReferenceId); String *missingColumnString = MakeDummyColumnString(nextColReferenceId);
expendedReferenceNames->colnames = lappend(expendedReferenceNames->colnames, expendedReferenceNames->colnames = lappend(expendedReferenceNames->colnames,
missingColumnString); missingColumnString);
} }
@ -3259,12 +3259,12 @@ AppendNextDummyColReference(Alias *expendedReferenceNames)
* MakeDummyColumnString returns a String (Value) object by appending given * MakeDummyColumnString returns a String (Value) object by appending given
* integer to end of the "column" string. * integer to end of the "column" string.
*/ */
static Value * static String *
MakeDummyColumnString(int dummyColumnId) MakeDummyColumnString(int dummyColumnId)
{ {
StringInfo dummyColumnStringInfo = makeStringInfo(); StringInfo dummyColumnStringInfo = makeStringInfo();
appendStringInfo(dummyColumnStringInfo, "column%d", dummyColumnId); appendStringInfo(dummyColumnStringInfo, "column%d", dummyColumnId);
Value *dummyColumnString = makeString(dummyColumnStringInfo->data); String *dummyColumnString = makeString(dummyColumnStringInfo->data);
return dummyColumnString; return dummyColumnString;
} }

View File

@ -1952,7 +1952,7 @@ BuildReadIntermediateResultsQuery(List *targetEntryList, List *columnAliasList,
*/ */
if (columnAliasCount >= columnNumber) if (columnAliasCount >= columnNumber)
{ {
Value *columnAlias = (Value *) list_nth(columnAliasList, columnNumber - 1); String *columnAlias = (String *) list_nth(columnAliasList, columnNumber - 1);
Assert(IsA(columnAlias, String)); Assert(IsA(columnAlias, String));
newTargetEntry->resname = strVal(columnAlias); newTargetEntry->resname = strVal(columnAlias);
} }

View File

@ -326,8 +326,8 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
if (objectType == OBJECT_TABLE || objectType == OBJECT_INDEX || if (objectType == OBJECT_TABLE || objectType == OBJECT_INDEX ||
objectType == OBJECT_FOREIGN_TABLE || objectType == OBJECT_FOREIGN_SERVER) objectType == OBJECT_FOREIGN_TABLE || objectType == OBJECT_FOREIGN_SERVER)
{ {
Value *relationSchemaNameValue = NULL; String *relationSchemaNameValue = NULL;
Value *relationNameValue = NULL; String *relationNameValue = NULL;
uint32 dropCount = list_length(dropStmt->objects); uint32 dropCount = list_length(dropStmt->objects);
if (dropCount > 1) if (dropCount > 1)
@ -381,11 +381,11 @@ RelayEventExtendNames(Node *parseTree, char *schemaName, uint64 shardId)
/* prefix with schema name if it is not added already */ /* prefix with schema name if it is not added already */
if (relationSchemaNameValue == NULL) if (relationSchemaNameValue == NULL)
{ {
Value *schemaNameValue = makeString(pstrdup(schemaName)); String *schemaNameValue = makeString(pstrdup(schemaName));
relationNameList = lcons(schemaNameValue, relationNameList); relationNameList = lcons(schemaNameValue, relationNameList);
} }
char **relationName = &(relationNameValue->val.str); char **relationName = &(strVal(relationNameValue));
AppendShardIdToName(relationName, shardId); AppendShardIdToName(relationName, shardId);
} }
else if (objectType == OBJECT_POLICY) else if (objectType == OBJECT_POLICY)
@ -750,10 +750,10 @@ UpdateWholeRowColumnReferencesWalker(Node *node, uint64 *shardId)
* extend the penultimate element with the shardId. * extend the penultimate element with the shardId.
*/ */
int colrefFieldCount = list_length(columnRef->fields); int colrefFieldCount = list_length(columnRef->fields);
Value *relnameValue = list_nth(columnRef->fields, colrefFieldCount - 2); String *relnameValue = list_nth(columnRef->fields, colrefFieldCount - 2);
Assert(IsA(relnameValue, String)); Assert(IsA(relnameValue, String));
AppendShardIdToName(&relnameValue->val.str, *shardId); AppendShardIdToName(&strVal(relnameValue), *shardId);
} }
/* might be more than one ColumnRef to visit */ /* might be more than one ColumnRef to visit */

View File

@ -37,6 +37,29 @@ wake_up_connection_pool_waiters(PG_FUNCTION_ARGS)
} }
/*
* makeIntConst creates a Const Node that stores a given integer
*
* copied from backend/parser/gram.c
*/
static Node *
makeIntConst(int val, int location)
{
A_Const *n = makeNode(A_Const);
#if PG_VERSION_NUM >= PG_VERSION_15
n->val.ival.type = T_Integer;
n->val.ival.ival = val;
#else
n->val.type = T_Integer;
n->val.val.ival = val;
#endif
n->location = location;
return (Node *) n;
}
/* /*
* set_max_shared_pool_size is a SQL * set_max_shared_pool_size is a SQL
* interface for setting MaxSharedPoolSize. We use this function in isolation * interface for setting MaxSharedPoolSize. We use this function in isolation
@ -49,9 +72,8 @@ set_max_shared_pool_size(PG_FUNCTION_ARGS)
AlterSystemStmt *alterSystemStmt = palloc0(sizeof(AlterSystemStmt)); AlterSystemStmt *alterSystemStmt = palloc0(sizeof(AlterSystemStmt));
A_Const *aConstValue = makeNode(A_Const); A_Const *aConstValue = castNode(A_Const, makeIntConst(value, 0));
aConstValue->val = *makeInteger(value);
alterSystemStmt->setstmt = makeNode(VariableSetStmt); alterSystemStmt->setstmt = makeNode(VariableSetStmt);
alterSystemStmt->setstmt->name = "citus.max_shared_pool_size"; alterSystemStmt->setstmt->name = "citus.max_shared_pool_size";
alterSystemStmt->setstmt->is_local = false; alterSystemStmt->setstmt->is_local = false;

View File

@ -18,10 +18,12 @@
#define RelationCreateStorage_compat(a, b, c) RelationCreateStorage(a, b, c) #define RelationCreateStorage_compat(a, b, c) RelationCreateStorage(a, b, c)
#else #else
#include "nodes/value.h"
#include "storage/smgr.h" #include "storage/smgr.h"
#include "utils/int8.h" #include "utils/int8.h"
#include "utils/rel.h" #include "utils/rel.h"
typedef Value String;
#ifdef HAVE_LONG_INT_64 #ifdef HAVE_LONG_INT_64
#define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base)) #define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base))