Log Message:
-----------
owner related fixes
Modified Files:
--------------
pgadmin3/src/schema:
pgAggregate.cpp (r1.24 -> r1.25)
pgConversion.cpp (r1.19 -> r1.20)
pgDomain.cpp (r1.22 -> r1.23)
pgFunction.cpp (r1.39 -> r1.40)
pgLanguage.cpp (r1.25 -> r1.26)
pgObject.cpp (r1.74 -> r1.75)
pgSchema.cpp (r1.36 -> r1.37)
pgSequence.cpp (r1.27 -> r1.28)
pgTable.cpp (r1.56 -> r1.57)
pgType.cpp (r1.23 -> r1.24)
pgView.cpp (r1.33 -> r1.34)
Index: pgObject.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgObject.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -Lsrc/schema/pgObject.cpp -Lsrc/schema/pgObject.cpp -u -w -r1.74 -r1.75
--- src/schema/pgObject.cpp
+++ src/schema/pgObject.cpp
@@ -457,6 +457,22 @@
}
+wxString pgObject::GetOwnerSql(int major, int minor, wxString objname)
+{
+ wxString sql;
+ if (GetConnection()->BackendMinimumVersion(major, minor))
+ {
+// if (GetConnection()->GetUser() != owner) // optional?
+ {
+ if (objname.IsEmpty())
+ objname = GetTypeName().Upper() + wxT(" ") +
GetQuotedFullIdentifier();
+ sql = wxT("ALTER ") + objname + wxT(" OWNER TO ") + qtIdent(owner) +
wxT(";\n");
+ }
+ }
+ return sql;
+}
+
+
void pgObject::AppendRight(wxString &rights, const wxString& acl, wxChar c, wxChar
*rightName)
{
if (acl.Find(c) >= 0)
@@ -532,7 +548,7 @@
}
-wxString pgObject::GetGrant(const wxString& allPattern, const wxString& _grantFor,
bool noOwner)
+wxString pgObject::GetGrant(const wxString& allPattern, const wxString& _grantFor)
{
wxString grant, str, user, grantFor;
if (_grantFor.IsNull())
Index: pgFunction.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgFunction.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lsrc/schema/pgFunction.cpp -Lsrc/schema/pgFunction.cpp -u -w -r1.39 -r1.40
--- src/schema/pgFunction.cpp
+++ src/schema/pgFunction.cpp
@@ -79,6 +79,7 @@
if (GetSecureDefiner())
sql += wxT(" SECURITY DEFINER");
sql += wxT(";\n")
+ + GetOwnerSql(8, 0, qtName)
+ GetGrant(wxT("X"), qtName);
if (!GetComment().IsNull())
Index: pgView.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgView.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -Lsrc/schema/pgView.cpp -Lsrc/schema/pgView.cpp -u -w -r1.33 -r1.34
--- src/schema/pgView.cpp
+++ src/schema/pgView.cpp
@@ -53,6 +53,7 @@
+ wxT("\n\nCREATE OR REPLACE VIEW ") + GetQuotedFullIdentifier() + wxT("
AS \n")
+ GetFormattedDefinition()
+ wxT("\n\n")
+ + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier())
+ GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier())
+ GetCommentSql();
}
Index: pgSequence.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgSequence.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lsrc/schema/pgSequence.cpp -Lsrc/schema/pgSequence.cpp -u -w -r1.27 -r1.28
--- src/schema/pgSequence.cpp
+++ src/schema/pgSequence.cpp
@@ -71,6 +71,7 @@
sql += wxT("\n CYCLE");
AppendIfFilled(sql, wxT("\n TABLESPACE "), qtIdent(tablespace));
sql += wxT(";\n")
+ + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier())
+ GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier())
+ GetCommentSql();
}
Index: pgAggregate.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgAggregate.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -Lsrc/schema/pgAggregate.cpp -Lsrc/schema/pgAggregate.cpp -u -w -r1.24 -r1.25
--- src/schema/pgAggregate.cpp
+++ src/schema/pgAggregate.cpp
@@ -47,7 +47,8 @@
AppendIfFilled(sql, wxT(",\n FFUNC="), qtIdent(GetFinalFunction()));
if (GetInitialCondition().length() > 0)
sql += wxT(",\n INITCOND=") + qtString(GetInitialCondition());
- sql += wxT("\n);\n");
+ sql += wxT("\n);\n")
+ + GetOwnerSql(8, 0);
if (!GetComment().IsNull())
{
Index: pgTable.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgTable.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -Lsrc/schema/pgTable.cpp -Lsrc/schema/pgTable.cpp -u -w -r1.56 -r1.57
--- src/schema/pgTable.cpp
+++ src/schema/pgTable.cpp
@@ -204,9 +204,9 @@
AppendIfFilled(sql, wxT(" TABLESPACE "), qtIdent(tablespace));
- sql += wxT(";\n");
-
- sql += GetGrant(wxT("arwdRxt"))
+ sql += wxT(";\n")
+ + GetOwnerSql(7, 3)
+ + GetGrant(wxT("arwdRxt"))
+ GetCommentSql();
// Column comments
Index: pgLanguage.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgLanguage.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lsrc/schema/pgLanguage.cpp -Lsrc/schema/pgLanguage.cpp -u -w -r1.25 -r1.26
--- src/schema/pgLanguage.cpp
+++ src/schema/pgLanguage.cpp
@@ -47,7 +47,7 @@
sql += wxT("TRUSTED ");
sql += wxT("PROCEDURAL LANGUAGE '") + GetName()
+ wxT("'\n HANDLER ") + GetHandlerProc() + wxT(";\n")
- + GetGrant(wxT("X"), wxT("LANGUAGE ") + GetQuotedFullIdentifier(), true);
+ + GetGrant(wxT("X"), wxT("LANGUAGE ") + GetQuotedFullIdentifier());
}
return sql;
Index: pgSchema.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgSchema.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/schema/pgSchema.cpp -Lsrc/schema/pgSchema.cpp -u -w -r1.36 -r1.37
--- src/schema/pgSchema.cpp
+++ src/schema/pgSchema.cpp
@@ -73,7 +73,7 @@
AppendIfFilled(sql, wxT(" TABLESPACE "), qtIdent(tablespace));
sql += wxT(";\n")
- + GetGrant(wxT("UC"), wxT("SCHEMA ") + GetQuotedFullIdentifier(), true)
+ + GetGrant(wxT("UC"), wxT("SCHEMA ") + GetQuotedFullIdentifier())
+ GetCommentSql();
}
return sql;
Index: pgType.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgType.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lsrc/schema/pgType.cpp -Lsrc/schema/pgType.cpp -u -w -r1.23 -r1.24
--- src/schema/pgType.cpp
+++ src/schema/pgType.cpp
@@ -62,6 +62,7 @@
+ wxT(", STORAGE=") + GetStorage());
}
sql += wxT(");\n")
+ + GetOwnerSql(8, 0)
+ GetCommentSql();
}
Index: pgConversion.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgConversion.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lsrc/schema/pgConversion.cpp -Lsrc/schema/pgConversion.cpp -u -w -r1.19 -r1.20
--- src/schema/pgConversion.cpp
+++ src/schema/pgConversion.cpp
@@ -47,7 +47,8 @@
+ wxT("\n FOR '") + GetForEncoding() + wxT("'")
+ wxT("\n TO '") + GetToEncoding() + wxT("'")
+ wxT("\n FROM ") +
GetDatabase()->GetQuotedSchemaPrefix(GetProcNamespace())
- + qtIdent(GetProc()) + wxT(";\n");
+ + qtIdent(GetProc()) + wxT(";\n")
+ + GetOwnerSql(8, 0);
}
return sql;
Index: pgDomain.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgDomain.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lsrc/schema/pgDomain.cpp -Lsrc/schema/pgDomain.cpp -u -w -r1.22 -r1.23
--- src/schema/pgDomain.cpp
+++ src/schema/pgDomain.cpp
@@ -50,6 +50,7 @@
AppendIfFilled(sql, wxT("\n CHECK "), GetCheck());
sql += wxT(";\n")
+ + GetOwnerSql(7, 4)
+ GetCommentSql();
}
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html