mirror of https://github.com/citusdata/citus.git
Self-review
parent
a519b84b08
commit
f21a80bbef
|
@ -42,9 +42,6 @@ static void AppendAliasesToCreateViewCommandForExistingView(StringInfo createVie
|
|||
/*
|
||||
* PreprocessViewStmt is called during the planning phase for CREATE OR REPLACE VIEW
|
||||
* before it is created on the local node internally.
|
||||
*
|
||||
* We do our basic housekeeping where we make sure we are on the coordinator and
|
||||
* qualify the given statement.
|
||||
*/
|
||||
List *
|
||||
PreprocessViewStmt(Node *node, const char *queryString,
|
||||
|
@ -256,12 +253,8 @@ CreateViewDDLCommandsIdempotent(const ObjectAddress *viewAddress)
|
|||
char *schemaName = get_namespace_name(schemaOid);
|
||||
|
||||
appendStringInfoString(createViewCommand, "CREATE OR REPLACE VIEW ");
|
||||
char *qualifiedViewName = NameListToQuotedString(list_make2(makeString(schemaName),
|
||||
makeString(viewName)));
|
||||
|
||||
appendStringInfo(createViewCommand, "%s ", qualifiedViewName);
|
||||
|
||||
/* Add column aliases to create view command */
|
||||
AddQualifiedViewNameToCreateViewCommand(createViewCommand, viewOid);
|
||||
AppendAliasesToCreateViewCommandForExistingView(createViewCommand, viewOid);
|
||||
|
||||
/* Add rel options to create view command */
|
||||
|
@ -277,7 +270,10 @@ CreateViewDDLCommandsIdempotent(const ObjectAddress *viewAddress)
|
|||
|
||||
/* Add alter owner commmand */
|
||||
StringInfo alterOwnerCommand = makeStringInfo();
|
||||
|
||||
char *viewOwnerName = TableOwner(viewOid);
|
||||
char *qualifiedViewName = NameListToQuotedString(list_make2(makeString(schemaName),
|
||||
makeString(viewName)));
|
||||
appendStringInfo(alterOwnerCommand,
|
||||
"ALTER VIEW %s OWNER TO %s", qualifiedViewName,
|
||||
quote_identifier(viewOwnerName));
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
static void AddQualifiedViewNameToCreateViewCommand(StringInfo buf, Oid viewOid);
|
||||
static void AddAliasesToCreateViewCommand(StringInfo buf, ViewStmt *stmt);
|
||||
static void AddOptionsToCreateViewCommand(StringInfo buf, ViewStmt *stmt);
|
||||
static void AppendDropViewStmt(StringInfo buf, DropStmt *stmt);
|
||||
|
@ -42,20 +41,13 @@ DeparseViewStmt(Node *node)
|
|||
|
||||
if (stmt->replace)
|
||||
{
|
||||
appendStringInfoString(viewString, "CREATE OR REPLACE ");
|
||||
appendStringInfoString(viewString, "CREATE OR REPLACE VIEW ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfoString(viewString, "CREATE ");
|
||||
appendStringInfoString(viewString, "CREATE VIEW ");
|
||||
}
|
||||
|
||||
if (stmt->view->relpersistence == RELPERSISTENCE_TEMP)
|
||||
{
|
||||
appendStringInfoString(viewString, "TEMPORARY ");
|
||||
}
|
||||
|
||||
appendStringInfo(viewString, "VIEW ");
|
||||
|
||||
AddQualifiedViewNameToCreateViewCommand(viewString, viewOid);
|
||||
AddAliasesToCreateViewCommand(viewString, stmt);
|
||||
AddOptionsToCreateViewCommand(viewString, stmt);
|
||||
|
@ -74,9 +66,9 @@ DeparseViewStmt(Node *node)
|
|||
|
||||
/*
|
||||
* AddQualifiedViewNameToCreateViewCommand adds the qualified view of the given view
|
||||
* statement to the given create view command.
|
||||
* oid to the given create view command.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
AddQualifiedViewNameToCreateViewCommand(StringInfo buf, Oid viewOid)
|
||||
{
|
||||
char *viewName = get_rel_name(viewOid);
|
||||
|
@ -125,7 +117,7 @@ AddAliasesToCreateViewCommand(StringInfo buf, ViewStmt *stmt)
|
|||
/*
|
||||
* AddOptionsToCreateViewCommand appends options (if exists) of the given view statement
|
||||
* to the given create view command. Note that this function also handles
|
||||
* WITH [CASCADED | LOCAL] CHECK OPTION part of the CREATE VIEW command as well.
|
||||
* WITH [CASCADED | LOCAL] CHECK OPTION part of the CREATE VIEW command.
|
||||
*/
|
||||
static void
|
||||
AddOptionsToCreateViewCommand(StringInfo buf, ViewStmt *stmt)
|
||||
|
@ -152,7 +144,7 @@ AddOptionsToCreateViewCommand(StringInfo buf, ViewStmt *stmt)
|
|||
}
|
||||
|
||||
appendStringInfoString(buf, option->defname);
|
||||
appendStringInfoString(buf, " = ");
|
||||
appendStringInfoString(buf, "=");
|
||||
appendStringInfoString(buf, defGetString(option));
|
||||
}
|
||||
|
||||
|
@ -169,8 +161,7 @@ AddViewDefinitionToCreateViewCommand(StringInfo buf, Oid viewOid)
|
|||
{
|
||||
/*
|
||||
* Set search_path to NIL so that all objects outside of pg_catalog will be
|
||||
* schema-prefixed. pg_catalog will be added automatically when we call
|
||||
* PushOverrideSearchPath(), since we set addCatalog to true;
|
||||
* schema-prefixed.
|
||||
*/
|
||||
OverrideSearchPath *overridePath = GetOverrideSearchPath(CurrentMemoryContext);
|
||||
overridePath->schemas = NIL;
|
|
@ -147,6 +147,7 @@ extern ObjectAddress RenameAttributeStmtObjectAddress(Node *stmt, bool missing_o
|
|||
/* forward declarations for deparse_view_stmts.c */
|
||||
extern void QualifyDropViewStmt(Node *node);
|
||||
extern void AddViewDefinitionToCreateViewCommand(StringInfo buf, Oid viewOid);
|
||||
extern void AddQualifiedViewNameToCreateViewCommand(StringInfo buf, Oid viewOid);
|
||||
|
||||
/* forward declarations for deparse_function_stmts.c */
|
||||
extern char * DeparseDropFunctionStmt(Node *stmt);
|
||||
|
|
Loading…
Reference in New Issue