allow wal_log option only if it's set to default

pull/7240/head
Onur Tirtir 2023-11-13 12:16:08 +03:00
parent f5a3f4d351
commit 69217678b3
2 changed files with 12 additions and 5 deletions

View File

@ -259,7 +259,7 @@ DeparseAlterDatabaseSetStmt(Node *node)
static void static void
ValidateCreateDatabaseOptions(DefElem *option) ValidateCreateDatabaseOptions(DefElem *option)
{ {
if (strcmp(option->defname, "strategy") == 0 || strcmp(option->defname, "oid") == 0) if (strcmp(option->defname, "oid") == 0)
{ {
ereport(ERROR, ereport(ERROR,
errmsg("CREATE DATABASE option \"%s\" is not supported", errmsg("CREATE DATABASE option \"%s\" is not supported",
@ -267,11 +267,18 @@ ValidateCreateDatabaseOptions(DefElem *option)
} }
char *optionValue = defGetString(option); char *optionValue = defGetString(option);
if (strcmp(option->defname, "template") == 0 && strcmp(optionValue, "template1") != 0) if (strcmp(option->defname, "template") == 0 && strcmp(optionValue, "template1") != 0)
{ {
ereport(ERROR, errmsg( ereport(ERROR, errmsg("Only template1 is supported as template "
"Only template1 is supported as template parameter for CREATE DATABASE")); "parameter for CREATE DATABASE"));
} }
if (strcmp(option->defname, "strategy") == 0 && strcmp(optionValue, "wal_log") != 0)
{
ereport(ERROR, errmsg("Only wal_log is supported as strategy "
"parameter for CREATE DATABASE"));
}
} }

View File

@ -239,9 +239,9 @@ extern List * PreprocessCreateDatabaseStmt(Node *node, const char *queryString,
extern List * PostprocessCreateDatabaseStmt(Node *node, const char *queryString); extern List * PostprocessCreateDatabaseStmt(Node *node, const char *queryString);
extern List * PreprocessDropDatabaseStmt(Node *node, const char *queryString, extern List * PreprocessDropDatabaseStmt(Node *node, const char *queryString,
ProcessUtilityContext processUtilityContext); ProcessUtilityContext processUtilityContext);
extern List * DropDatabaseStmtObjectAddress(Node *node, bool missing_ok, extern List * DropDatabaseStmtObjectAddress(Node *node, bool missingOk,
bool isPostprocess); bool isPostprocess);
extern List * CreateDatabaseStmtObjectAddress(Node *node, bool missing_ok, extern List * CreateDatabaseStmtObjectAddress(Node *node, bool missingOk,
bool isPostprocess); bool isPostprocess);
extern List * GenerateCreateDatabaseCommandList(void); extern List * GenerateCreateDatabaseCommandList(void);