Hi, me again.

I noticed that on the table properties dialogue window, the checkbox
for "Has OIDs" is disabled if there aren't any OIDs already for the
table rows.  I believe the check used for enabling this isn taking
into account that PostgreSQL versions 8.4 and above can re-enable
OIDs.

Patch attached to implement this.

While I was poking around in the section in question, I noticed that
some of the ALTER TABLE statements don't place a newline before the
SET keyword, and some do.

For example:

Those without newlines:
ALTER TABLE tablename DROP CONSTRAINT
ALTER TABLE tablename SET WITHOUT OIDS;
ALTER TABLE tablename SET TABLESPACE...

Those with newlines:
ALTER TABLE tablename
  SET (FILLFACTOR=...)
ALTER TABLE tablename
  RESET(...)

I personally prefer the ones with newlines, especially since I've been
experimenting with tables having very long names, and some of the
above statements require lots of horizontal scrolling on the SQL tab
to see what the action will be.  Could we harmonise these?  Note that
I didn't change the format for OIDs when I added the WITH OIDS
variant.

Thanks
-- 
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/pgadmin/dlg/dlgTable.cpp b/pgadmin/dlg/dlgTable.cpp
index d3ae082..6ec4c9f 100644
--- a/pgadmin/dlg/dlgTable.cpp
+++ b/pgadmin/dlg/dlgTable.cpp
@@ -249,7 +249,8 @@ int dlgTable::Go(bool modal)
 
 		btnAddTable->Enable(connection->BackendMinimumVersion(8, 2) && cbTables->GetGuessedSelection() >= 0);
 		lbTables->Enable(connection->BackendMinimumVersion(8, 2));
-		chkHasOids->Enable(table->GetHasOids() && connection->BackendMinimumVersion(8, 0));
+		chkHasOids->Enable((connection->BackendMinimumVersion(8, 0) && table->GetHasOids())
+		                   || connection->BackendMinimumVersion(8, 4));
 		cbTablespace->Enable(connection->BackendMinimumVersion(7, 5));
 
 		wxCookieType cookie;
@@ -921,11 +922,16 @@ wxString dlgTable::GetSql()
 		// Add the ADD CONSTRAINTs...
 		sql += tmpsql;
 
-		if (chkHasOids->GetValue() != table->GetHasOids())
+		if (!chkHasOids->GetValue() && table->GetHasOids())
 		{
 			sql += wxT("ALTER TABLE ") + tabname
 			       +  wxT(" SET WITHOUT OIDS;\n");
 		}
+		if (chkHasOids->GetValue() && !table->GetHasOids())
+		{
+			sql += wxT("ALTER TABLE ") + tabname
+			       +  wxT(" SET WITH OIDS;\n");
+		}
 		if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != table->GetTablespaceOid())
 			sql += wxT("ALTER TABLE ") + tabname
 			       +  wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to