mirror of https://github.com/citusdata/citus.git
Fixed review items
parent
3067d1ef08
commit
f8b3f322aa
|
@ -298,7 +298,7 @@ PreprocessCreateDatabaseStmt(Node *node, const char *queryString,
|
||||||
/*
|
/*
|
||||||
* PostprocessCreatedbStmt is executed after the statement is applied to the local
|
* PostprocessCreatedbStmt is executed after the statement is applied to the local
|
||||||
* postgres instance. In this stage we can prepare the commands that need to be run on
|
* postgres instance. In this stage we can prepare the commands that need to be run on
|
||||||
* all workers to create the database. Since the CREATE DATABASE statement gives error
|
* all workers to create the database. Since the CREATE DATABASE statement gives error
|
||||||
* in a transaction block, we need to use NontransactionalNodeDDLTaskList to send the
|
* in a transaction block, we need to use NontransactionalNodeDDLTaskList to send the
|
||||||
* CREATE DATABASE statement to the workers.
|
* CREATE DATABASE statement to the workers.
|
||||||
*
|
*
|
||||||
|
@ -388,11 +388,11 @@ GetDatabaseAddressFromDatabaseName(char *databaseName, bool missingOk)
|
||||||
* object of the DropdbStmt.
|
* object of the DropdbStmt.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
DropDatabaseStmtObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
DropDatabaseStmtObjectAddress(Node *node, bool missingOk, bool isPostprocess)
|
||||||
{
|
{
|
||||||
DropdbStmt *stmt = castNode(DropdbStmt, node);
|
DropdbStmt *stmt = castNode(DropdbStmt, node);
|
||||||
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->dbname,
|
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->dbname,
|
||||||
missing_ok);
|
missingOk);
|
||||||
return list_make1(dbAddress);
|
return list_make1(dbAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,11 +402,11 @@ DropDatabaseStmtObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
||||||
* object of the CreatedbStmt.
|
* object of the CreatedbStmt.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
CreateDatabaseStmtObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
CreateDatabaseStmtObjectAddress(Node *node, bool missingOk, bool isPostprocess)
|
||||||
{
|
{
|
||||||
CreatedbStmt *stmt = castNode(CreatedbStmt, node);
|
CreatedbStmt *stmt = castNode(CreatedbStmt, node);
|
||||||
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->dbname,
|
ObjectAddress *dbAddress = GetDatabaseAddressFromDatabaseName(stmt->dbname,
|
||||||
missing_ok);
|
missingOk);
|
||||||
return list_make1(dbAddress);
|
return list_make1(dbAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ GetTablespaceName(Oid tablespaceOid)
|
||||||
}
|
}
|
||||||
|
|
||||||
Form_pg_tablespace tablespaceForm = (Form_pg_tablespace) GETSTRUCT(tuple);
|
Form_pg_tablespace tablespaceForm = (Form_pg_tablespace) GETSTRUCT(tuple);
|
||||||
char *tablespaceName = NameStr(tablespaceForm->spcname);
|
char *tablespaceName = pstrdup(NameStr(tablespaceForm->spcname));
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
|
@ -437,17 +437,17 @@ GetTablespaceName(Oid tablespaceOid)
|
||||||
* We need this method since collation related info in Form_pg_database is not accessible
|
* We need this method since collation related info in Form_pg_database is not accessible
|
||||||
*/
|
*/
|
||||||
static DatabaseCollationInfo
|
static DatabaseCollationInfo
|
||||||
GetDatabaseCollation(Oid db_oid)
|
GetDatabaseCollation(Oid dbOid)
|
||||||
{
|
{
|
||||||
DatabaseCollationInfo info;
|
DatabaseCollationInfo info;
|
||||||
bool isNull;
|
bool isNull;
|
||||||
|
|
||||||
Snapshot snapshot = RegisterSnapshot(GetLatestSnapshot());
|
Snapshot snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||||
Relation rel = table_open(DatabaseRelationId, AccessShareLock);
|
Relation rel = table_open(DatabaseRelationId, AccessShareLock);
|
||||||
HeapTuple tup = get_catalog_object_by_oid(rel, Anum_pg_database_oid, db_oid);
|
HeapTuple tup = get_catalog_object_by_oid(rel, Anum_pg_database_oid, dbOid);
|
||||||
if (!HeapTupleIsValid(tup))
|
if (!HeapTupleIsValid(tup))
|
||||||
{
|
{
|
||||||
elog(ERROR, "cache lookup failed for database %u", db_oid);
|
elog(ERROR, "cache lookup failed for database %u", dbOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
TupleDesc tupdesc = RelationGetDescr(rel);
|
TupleDesc tupdesc = RelationGetDescr(rel);
|
||||||
|
@ -505,29 +505,6 @@ GetDatabaseCollation(Oid db_oid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FreeDatabaseCollationInfo frees the memory allocated for DatabaseCollationInfo
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
FreeDatabaseCollationInfo(DatabaseCollationInfo collInfo)
|
|
||||||
{
|
|
||||||
if (collInfo.collation != NULL)
|
|
||||||
{
|
|
||||||
pfree(collInfo.collation);
|
|
||||||
}
|
|
||||||
if (collInfo.ctype != NULL)
|
|
||||||
{
|
|
||||||
pfree(collInfo.ctype);
|
|
||||||
}
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_15
|
|
||||||
if (collInfo.icu_locale != NULL)
|
|
||||||
{
|
|
||||||
pfree(collInfo.icu_locale);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_15
|
#if PG_VERSION_NUM >= PG_VERSION_15
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -640,8 +617,6 @@ GenerateCreateDatabaseStatementFromPgDatabase(Form_pg_database databaseForm)
|
||||||
appendStringInfo(&str, " IS_TEMPLATE = %s",
|
appendStringInfo(&str, " IS_TEMPLATE = %s",
|
||||||
quote_literal_cstr(databaseForm->datistemplate ? "true" : "false"));
|
quote_literal_cstr(databaseForm->datistemplate ? "true" : "false"));
|
||||||
|
|
||||||
FreeDatabaseCollationInfo(collInfo);
|
|
||||||
|
|
||||||
|
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
@ -669,7 +644,6 @@ GenerateCreateDatabaseCommandList(void)
|
||||||
|
|
||||||
char *createStmt = GenerateCreateDatabaseStatementFromPgDatabase(databaseForm);
|
char *createStmt = GenerateCreateDatabaseStatementFromPgDatabase(databaseForm);
|
||||||
|
|
||||||
|
|
||||||
StringInfo outerDbStmt = makeStringInfo();
|
StringInfo outerDbStmt = makeStringInfo();
|
||||||
|
|
||||||
/* Generate the CREATE DATABASE statement */
|
/* Generate the CREATE DATABASE statement */
|
||||||
|
@ -678,8 +652,6 @@ GenerateCreateDatabaseCommandList(void)
|
||||||
quote_literal_cstr(
|
quote_literal_cstr(
|
||||||
createStmt));
|
createStmt));
|
||||||
|
|
||||||
elog(LOG, "outerDbStmt: %s", outerDbStmt->data);
|
|
||||||
|
|
||||||
/* Add the statement to the list of commands */
|
/* Add the statement to the list of commands */
|
||||||
commands = lappend(commands, outerDbStmt->data);
|
commands = lappend(commands, outerDbStmt->data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "pg_version_constants.h"
|
#include "pg_version_constants.h"
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
|
||||||
#include "commands/defrem.h"
|
#include "commands/defrem.h"
|
||||||
#include "distributed/deparser.h"
|
#include "distributed/deparser.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
|
@ -275,9 +275,6 @@ ValidateCreateDatabaseOptions(DefElem *option)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prepares a CREATE DATABASE statement with given empty StringInfo buffer and CreatedbStmt node.
|
|
||||||
*/
|
|
||||||
static void
|
static void
|
||||||
AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt)
|
AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt)
|
||||||
{
|
{
|
||||||
|
@ -314,9 +311,6 @@ DeparseCreateDatabaseStmt(Node *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prepares a DROP DATABASE statement with given empty StringInfo buffer and DropdbStmt node.
|
|
||||||
*/
|
|
||||||
static void
|
static void
|
||||||
AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
|
AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,11 +22,13 @@
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/objectaddress.h"
|
#include "catalog/objectaddress.h"
|
||||||
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_extension_d.h"
|
#include "catalog/pg_extension_d.h"
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "citus_version.h"
|
#include "citus_version.h"
|
||||||
|
#include "commands/dbcommands.h"
|
||||||
#include "commands/extension.h"
|
#include "commands/extension.h"
|
||||||
#include "distributed/listutils.h"
|
#include "distributed/listutils.h"
|
||||||
#include "distributed/colocation_utils.h"
|
#include "distributed/colocation_utils.h"
|
||||||
|
@ -48,9 +50,6 @@
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
#include "utils/regproc.h"
|
#include "utils/regproc.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "catalog/pg_database.h"
|
|
||||||
#include "commands/dbcommands.h"
|
|
||||||
|
|
||||||
|
|
||||||
static char * CreatePgDistObjectEntryCommand(const ObjectAddress *objectAddress);
|
static char * CreatePgDistObjectEntryCommand(const ObjectAddress *objectAddress);
|
||||||
static int ExecuteCommandAsSuperuser(char *query, int paramCount, Oid *paramTypes,
|
static int ExecuteCommandAsSuperuser(char *query, int paramCount, Oid *paramTypes,
|
||||||
|
|
|
@ -3951,7 +3951,6 @@ citus_internal_database_command(PG_FUNCTION_ARGS)
|
||||||
bool missingOk = false;
|
bool missingOk = false;
|
||||||
Oid databaseOid = get_database_oid(stmt->dbname, missingOk);
|
Oid databaseOid = get_database_oid(stmt->dbname, missingOk);
|
||||||
|
|
||||||
|
|
||||||
if (OidIsValid(databaseOid))
|
if (OidIsValid(databaseOid))
|
||||||
{
|
{
|
||||||
DropDatabase(pstate, (DropdbStmt *) parseTree);
|
DropDatabase(pstate, (DropdbStmt *) parseTree);
|
||||||
|
|
Loading…
Reference in New Issue