mirror of https://github.com/citusdata/citus.git
Fixes review comments
parent
775c78c179
commit
597154985e
|
@ -33,8 +33,7 @@ static void AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt);
|
||||||
static void AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt);
|
static void AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt);
|
||||||
static void AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt);
|
static void AppendDropDatabaseStmt(StringInfo buf, DropdbStmt *stmt);
|
||||||
static void AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt);
|
static void AppendGrantOnDatabaseStmt(StringInfo buf, GrantStmt *stmt);
|
||||||
static void AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool *
|
static void AppendBasicAlterDatabaseOptions(StringInfo buf, AlterDatabaseStmt *stmt);
|
||||||
prefixAppendedForBasicOptions, char *dbname);
|
|
||||||
static void AppendGrantDatabases(StringInfo buf, GrantStmt *stmt);
|
static void AppendGrantDatabases(StringInfo buf, GrantStmt *stmt);
|
||||||
static void AppendAlterDatabaseSetTablespace(StringInfo buf, DefElem *def, char *dbname);
|
static void AppendAlterDatabaseSetTablespace(StringInfo buf, DefElem *def, char *dbname);
|
||||||
|
|
||||||
|
@ -127,21 +126,14 @@ AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||||
{
|
{
|
||||||
if (stmt->options)
|
if (stmt->options)
|
||||||
{
|
{
|
||||||
ListCell *cell = NULL;
|
DefElem *firstOption = linitial(stmt->options);
|
||||||
bool prefixAppendedForBasicOptions = false;
|
if (strcmp(firstOption->defname, "tablespace") == 0)
|
||||||
foreach(cell, stmt->options)
|
|
||||||
{
|
{
|
||||||
DefElem *def = castNode(DefElem, lfirst(cell));
|
AppendAlterDatabaseSetTablespace(buf, firstOption, stmt->dbname);
|
||||||
if (strcmp(def->defname, "tablespace") == 0)
|
|
||||||
{
|
|
||||||
AppendAlterDatabaseSetTablespace(buf, def, stmt->dbname);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AppendBasicAlterDatabaseOptions(buf, def, &prefixAppendedForBasicOptions,
|
AppendBasicAlterDatabaseOptions(buf, stmt);
|
||||||
stmt->dbname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,28 +156,27 @@ AppendAlterDatabaseSetTablespace(StringInfo buf, DefElem *def, char *dbname)
|
||||||
* after the "WITH" keyword.(i.e. ALLOW_CONNECTIONS, CONNECTION LIMIT, IS_TEMPLATE)
|
* after the "WITH" keyword.(i.e. ALLOW_CONNECTIONS, CONNECTION LIMIT, IS_TEMPLATE)
|
||||||
* The tablespace option is not a basic option since it is defined with SET option.
|
* The tablespace option is not a basic option since it is defined with SET option.
|
||||||
*
|
*
|
||||||
* This function takes a string buffer, a DefElem representing a database option,
|
* This function takes a string buffer and an AlterDatabaseStmt as input.
|
||||||
* a boolean indicating whether the prefix "ALTER DATABASE <dbname> WITH" has
|
* It appends the basic options to the string buffer.
|
||||||
* already been appended, and a database name. It appends the SQL representation
|
|
||||||
* of the database option to the string buffer.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
|
||||||
* A boolean indicating whether the prefix "ALTER DATABASE <dbname> WITH" has
|
|
||||||
* been appended to the buffer. This is the same as the input
|
|
||||||
* prefixAppendedForBasicOptions if the prefix was already appended, or true
|
|
||||||
* if this function appended the prefix.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AppendBasicAlterDatabaseOptions(StringInfo buf, DefElem *def, bool *
|
AppendBasicAlterDatabaseOptions(StringInfo buf, AlterDatabaseStmt *stmt)
|
||||||
prefixAppendedForBasicOptions, char *dbname)
|
|
||||||
{
|
{
|
||||||
if (!(*prefixAppendedForBasicOptions))
|
ListCell *cell = NULL;
|
||||||
|
bool prefixAppendedForBasicOptions = false;
|
||||||
|
foreach(cell, stmt->options)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, "ALTER DATABASE %s WITH", quote_identifier(dbname));
|
DefElem *def = castNode(DefElem, lfirst(cell));
|
||||||
*prefixAppendedForBasicOptions = true;
|
if (!prefixAppendedForBasicOptions)
|
||||||
|
{
|
||||||
|
appendStringInfo(buf, "ALTER DATABASE %s WITH", quote_identifier(
|
||||||
|
stmt->dbname));
|
||||||
|
prefixAppendedForBasicOptions = true;
|
||||||
}
|
}
|
||||||
DefElemOptionToStatement(buf, def, alterDatabaseOptionFormats, lengthof(
|
DefElemOptionToStatement(buf, def, alterDatabaseOptionFormats, lengthof(
|
||||||
alterDatabaseOptionFormats));
|
alterDatabaseOptionFormats));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue