SVN Commit by andreas: r4522 - in trunk/pgadmin3: . src/dlg src/schema

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by andreas: r4522 - in trunk/pgadmin3: . src/dlg src/schema
Date: 2005-10-08 16:52:18
Message-ID: 200510081652.j98GqIBX004897@developer.pgadmin.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Author: andreas
Date: 2005-10-08 17:52:18 +0100 (Sat, 08 Oct 2005)
New Revision: 4522

Modified:
trunk/pgadmin3/CHANGELOG.txt
trunk/pgadmin3/src/dlg/dlgColumn.cpp
trunk/pgadmin3/src/dlg/dlgRole.cpp
trunk/pgadmin3/src/schema/pgColumn.cpp
Log:
Check for catalog access privilege in pg_authid and pg_depend

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt 2005-10-07 11:10:37 UTC (rev 4521)
+++ trunk/pgadmin3/CHANGELOG.txt 2005-10-08 16:52:18 UTC (rev 4522)
@@ -17,6 +17,7 @@
</ul>
<br>
<ul>
+ <li>2005-10-08 AP Check for catalog access privilege in pg_authid and pg_depend
<li>2005-10-04 AP -t cmd line option to enable language debugging
<li>2005-10-03 AP pg_autovacuum support
<li>2005-10-03 AP upgrade slony node

Modified: trunk/pgadmin3/src/dlg/dlgColumn.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgColumn.cpp 2005-10-07 11:10:37 UTC (rev 4521)
+++ trunk/pgadmin3/src/dlg/dlgColumn.cpp 2005-10-08 16:52:18 UTC (rev 4522)
@@ -282,31 +282,50 @@
wxString sequence;
bool newSequence = (cbSequence->GetSelection() <= 0);

- if (newSequence)
+ if (connection->BackendMinimumVersion(8, 0) && newSequence)
{
- sequence = qtIdent(table->GetSchema()->GetName()) + wxT(".") +
- qtIdent(table->GetName() + wxT("_") + name + wxT("_seq"));
-
- sql = wxT("CREATE SEQUENCE ") + sequence + wxT(";\n");
+ sql +=wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
+ + wxT("\n ADD COLUMN ") + qtIdent(name)
+ + wxT(" ") + cbDatatype->GetValue() + wxT(";\n");
}
else
- sequence=sequences.Item(cbSequence->GetSelection());
+ {
+ if (newSequence)
+ {
+ sequence = qtIdent(table->GetSchema()->GetName()) + wxT(".") +
+ qtIdent(table->GetName() + wxT("_") + name + wxT("_seq"));

- sql +=wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
- + wxT("\n ADD COLUMN ") + qtIdent(name)
- + wxT(" ") + typname + wxT(";\n")
- + wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
- + wxT("\n ALTER COLUMN ") + qtIdent(name)
- + wxT(" SET DEFAULT nextval('") + sequence + wxT("'::text);\n")
+ sql = wxT("CREATE SEQUENCE ") + sequence + wxT(";\n");
+ }
+ else
+ sequence=sequences.Item(cbSequence->GetSelection());

- wxT("INSERT INTO pg_depend(classid, objid, objsubid, refclassid, refobjid, refobjsubid, deptype)\n")
- wxT("SELECT cl.oid, seq.oid, 0, cl.oid, ") + table->GetOidStr() + wxT(", attnum, 'i'\n")
- wxT(" FROM pg_class cl, pg_attribute, pg_class seq\n")
- wxT(" JOIN pg_namespace sn ON sn.OID=seq.relnamespace\n")
- wxT(" WHERE cl.relname='pg_class'\n")
- wxT(" AND seq.relname=") + qtString(table->GetName() + wxT("_") + name + wxT("_seq")) + wxT("\n")
- wxT(" AND sn.nspname=") + qtString(table->GetSchema()->GetName()) + wxT("\n")
- wxT(" AND attrelid=") + table->GetOidStr() + wxT(" AND attname=") + qtString(name) + wxT(";\n");
+ sql +=wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
+ + wxT("\n ADD COLUMN ") + qtIdent(name)
+ + wxT(" ") + typname + wxT(";\n")
+ + wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
+ + wxT("\n ALTER COLUMN ") + qtIdent(name)
+ + wxT(" SET DEFAULT nextval('") + sequence + wxT("'::text);\n");
+
+
+ if (connection->HasPrivilege(wxT("Table"), wxT("pg_depend"), wxT("insert")))
+ {
+ sql +=
+ wxT("INSERT INTO pg_depend(classid, objid, objsubid, refclassid, refobjid, refobjsubid, deptype)\n")
+ wxT("SELECT cl.oid, seq.oid, 0, cl.oid, ") + table->GetOidStr() + wxT(", attnum, 'i'\n")
+ wxT(" FROM pg_class cl, pg_attribute, pg_class seq\n")
+ wxT(" JOIN pg_namespace sn ON sn.OID=seq.relnamespace\n")
+ wxT(" WHERE cl.relname='pg_class'\n")
+ wxT(" AND seq.relname=") + qtString(table->GetName() + wxT("_") + name + wxT("_seq")) + wxT("\n")
+ wxT(" AND sn.nspname=") + qtString(table->GetSchema()->GetName()) + wxT("\n")
+ wxT(" AND attrelid=") + table->GetOidStr() + wxT(" AND attname=") + qtString(name) + wxT(";\n");
+ }
+ else
+ {
+ sql +=
+ wxT("-- Dependency information can't be added; no insert into pg_depend allowed.\n");
+ }
+ }
}
else
{

Modified: trunk/pgadmin3/src/dlg/dlgRole.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgRole.cpp 2005-10-07 11:10:37 UTC (rev 4521)
+++ trunk/pgadmin3/src/dlg/dlgRole.cpp 2005-10-08 16:52:18 UTC (rev 4522)
@@ -546,9 +546,14 @@
}

if (chkUpdateCat->GetValue() != role->GetUpdateCatalog())
+ {
+ if (!connection->HasPrivilege(wxT("Table"), wxT("pg_authid"), wxT("update")))
+ sql += wxT(" -- Can't update 'UpdateCatalog privilege: can't write to pg_authid.\n")
+ wxT("-- ");
+
sql += wxT("UPDATE pg_authid SET rolcatupdate=") + BoolToStr(chkUpdateCat->GetValue())
- + wxT(" WHERE OID=") + role->GetOidStr() + wxT(";\n");
-
+ + wxT(" WHERE OID=") + role->GetOidStr() + wxT(";\n");
+ }
cnt=lbRolesIn->GetCount();
wxArrayString tmpRoles=role->GetRolesIn();

Modified: trunk/pgadmin3/src/schema/pgColumn.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgColumn.cpp 2005-10-07 11:10:37 UTC (rev 4521)
+++ trunk/pgadmin3/src/schema/pgColumn.cpp 2005-10-08 16:52:18 UTC (rev 4522)
@@ -132,7 +132,7 @@
+ schema->GetName() + wxT(".") + GetTableName()
+ wxT("_") + GetName() + wxT("_seq'::text)"))
{
- if (sql == wxT("int8"))
+ if (sql.Right(4) == wxT("int8"))
sql = wxT("bigserial");
else
sql = wxT("serial");

Browse pgadmin-hackers by date

  From Date Subject
Next Message Tomasz Rybak 2005-10-08 19:42:51 Re: Crash during displaying drop-down menu for
Previous Message Aftab Alam 2005-10-07 11:11:37 mailling list