diff --git a/Release_(3.0)/pgAdmin3.exe b/Release_(3.0)/pgAdmin3.exe index e066a6e..39f03f3 100644 Binary files a/Release_(3.0)/pgAdmin3.exe and b/Release_(3.0)/pgAdmin3.exe differ diff --git a/db/pgConn.cpp b/db/pgConn.cpp index 8b5bb67..3a8705a 100644 --- a/db/pgConn.cpp +++ b/db/pgConn.cpp @@ -409,6 +409,12 @@ bool pgConn::GetIsEdb() BackendMinimumVersion(0, 0); return isEdb; } +bool pgConn::GetIsPgProEnt() +{ + // to retrieve edb flag + BackendMinimumVersion(0, 0); + return isPgProEnt; +} bool pgConn::GetIsGreenplum() { @@ -495,6 +501,10 @@ bool pgConn::BackendMinimumVersion(int major, int minor) if (ExecuteScalar(wxT("SELECT count(*) FROM pg_attribute WHERE attname = 'proconfig' AND attrelid = 'pg_proc'::regclass")) == wxT("0")) minorVersion = 2; } + isPgProEnt=false; + wxString ed=ExecuteScalar(wxT("select to_regproc('pgpro_edition')::text")); + if (!ed.IsEmpty()) ed=ExecuteScalar(wxT("select pgpro_edition()")); + if (ed==wxT("enterprise")) isPgProEnt=true; isGreenplum = version.Upper().Matches(wxT("*GREENPLUM DATABASE*")); isHawq = version.Upper().Matches(wxT("*GREENPLUM DATABASE*")) && version.Upper().Matches(wxT("*HAWQ*"));; diff --git a/include/db/pgConn.h b/include/db/pgConn.h index 19d9d5c..2af4733 100644 --- a/include/db/pgConn.h +++ b/include/db/pgConn.h @@ -109,6 +109,7 @@ public: return minorVersion; } bool GetIsEdb(); + bool GetIsPgProEnt(); bool GetIsGreenplum(); bool GetIsHawq(); wxString EncryptPassword(const wxString &user, const wxString &password); @@ -296,6 +297,7 @@ private: int minorVersion, majorVersion, patchVersion; bool isEdb; bool isGreenplum; + bool isPgProEnt; bool isHawq; wxString reservedNamespaces; diff --git a/include/pgAdmin3.h b/include/pgAdmin3.h index 2176532..8b28e7c 100644 --- a/include/pgAdmin3.h +++ b/include/pgAdmin3.h @@ -60,8 +60,8 @@ // Supported server minimum and maximum values. const short SERVER_MIN_VERSION_N = 0x0804; const wxString SERVER_MIN_VERSION_T = wxT("8.4"); -const short SERVER_MAX_VERSION_N = 0x0C00; -const wxString SERVER_MAX_VERSION_T = wxT("12"); +const short SERVER_MAX_VERSION_N = 0x0D00; +const wxString SERVER_MAX_VERSION_T = wxT("13"); // Supported Greenplum Database and Greenplum HAWQ minimum and maximum values. const short GP_MIN_VERSION_N = 0x0802; const wxString GP_MIN_VERSION_T = wxT("8.2"); diff --git a/include/schema/pgTable.h b/include/schema/pgTable.h index 03a9598..f1f53a6 100644 --- a/include/schema/pgTable.h +++ b/include/schema/pgTable.h @@ -142,6 +142,15 @@ public: { tablespace = newVal; } + wxString GetRatio() const + { + return ratio; + }; + void iSetRatio(const wxString &newVal) + { + if (newVal==wxT("NaN")) ratio=wxEmptyString; else ratio = newVal; + + } OID GetTablespaceOid() const { return tablespaceOid; @@ -604,7 +613,7 @@ private: long inheritedTableCount, triggerCount; wxString quotedInheritedTables, inheritedTables, primaryKey, quotedPrimaryKey, - primaryKeyName, primaryKeyColNumbers, tablespace, + primaryKeyName, primaryKeyColNumbers, tablespace, ratio, distributionColNumbers, ofType; wxArrayString quotedInheritedTablesList, inheritedTablesOidList; diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 581ee33..7ed54d4 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -513,107 +513,117 @@ wxString pgTable::GetSql(ctlTree *browser) } if (GetConnection()->BackendMinimumVersion(8, 2)) { - sql += wxT("\nWITH ("); + wxString sqlopt=wxEmptyString; if (GetFillFactor().Length() > 0) - sql += wxT("\n FILLFACTOR=") + GetFillFactor() + wxT(", "); + sqlopt += wxT("\n FILLFACTOR=") + GetFillFactor() + wxT(", "); if (GetAppendOnly().Length() > 0) - sql += wxT("APPENDONLY=") + GetAppendOnly() + wxT(", "); + sqlopt += wxT("APPENDONLY=") + GetAppendOnly() + wxT(", "); if (GetCompressLevel().Length() > 0) - sql += wxT("COMPRESSLEVEL=") + GetCompressLevel() + wxT(", "); + sqlopt += wxT("COMPRESSLEVEL=") + GetCompressLevel() + wxT(", "); if (GetOrientation().Length() > 0) - sql += wxT("ORIENTATION=") + GetOrientation() + wxT(", "); + sqlopt += wxT("ORIENTATION=") + GetOrientation() + wxT(", "); if (GetCompressType().Length() > 0) - sql += wxT("COMPRESSTYPE=") + GetCompressType() + wxT(", "); + sqlopt += wxT("COMPRESSTYPE=") + GetCompressType() + wxT(", "); if (GetBlocksize().Length() > 0) - sql += wxT("BLOCKSIZE=") + GetBlocksize() + wxT(", "); + sqlopt += wxT("BLOCKSIZE=") + GetBlocksize() + wxT(", "); if (GetChecksum().Length() > 0) - sql += wxT("CHECKSUM=") + GetChecksum() + wxT(", "); - if (GetHasOids()) - sql += wxT("\n OIDS=TRUE"); - else - sql += wxT("\n OIDS=FALSE"); + sqlopt += wxT("CHECKSUM=") + GetChecksum() + wxT(", "); + if (GetConnection()->BackendMinimumVersion(12, 0)) { + if (!sqlopt.IsEmpty()) sqlopt=sqlopt.BeforeLast(','); + } else { + if (GetHasOids()) + sqlopt += wxT("\n OIDS=TRUE"); + else + sqlopt += wxT("\n OIDS=FALSE"); + } + if(GetConnection()->BackendMinimumVersion(8, 4)) { if (GetCustomAutoVacuumEnabled()) { if (GetAutoVacuumEnabled() == 1) - sql += wxT(",\n autovacuum_enabled=true"); + sqlopt += wxT(",\n autovacuum_enabled=true"); else if (GetCustomAutoVacuumEnabled() == 0) - sql += wxT(",\n autovacuum_enabled=false"); + sqlopt += wxT(",\n autovacuum_enabled=false"); if (!GetAutoVacuumVacuumThreshold().IsEmpty()) { - sql += wxT(",\n autovacuum_vacuum_threshold=") + GetAutoVacuumVacuumThreshold(); + sqlopt += wxT(",\n autovacuum_vacuum_threshold=") + GetAutoVacuumVacuumThreshold(); } if (!GetAutoVacuumVacuumScaleFactor().IsEmpty()) { - sql += wxT(",\n autovacuum_vacuum_scale_factor=") + GetAutoVacuumVacuumScaleFactor(); + sqlopt += wxT(",\n autovacuum_vacuum_scale_factor=") + GetAutoVacuumVacuumScaleFactor(); } if (!GetAutoVacuumAnalyzeThreshold().IsEmpty()) { - sql += wxT(",\n autovacuum_analyze_threshold=") + GetAutoVacuumAnalyzeThreshold(); + sqlopt += wxT(",\n autovacuum_analyze_threshold=") + GetAutoVacuumAnalyzeThreshold(); } if (!GetAutoVacuumAnalyzeScaleFactor().IsEmpty()) { - sql += wxT(",\n autovacuum_analyze_scale_factor=") + GetAutoVacuumAnalyzeScaleFactor(); + sqlopt += wxT(",\n autovacuum_analyze_scale_factor=") + GetAutoVacuumAnalyzeScaleFactor(); } if (!GetAutoVacuumVacuumCostDelay().IsEmpty()) { - sql += wxT(",\n autovacuum_vacuum_cost_delay=") + GetAutoVacuumVacuumCostDelay(); + sqlopt += wxT(",\n autovacuum_vacuum_cost_delay=") + GetAutoVacuumVacuumCostDelay(); } if (!GetAutoVacuumVacuumCostLimit().IsEmpty()) { - sql += wxT(",\n autovacuum_vacuum_cost_limit=") + GetAutoVacuumVacuumCostLimit(); + sqlopt += wxT(",\n autovacuum_vacuum_cost_limit=") + GetAutoVacuumVacuumCostLimit(); } if (!GetAutoVacuumFreezeMinAge().IsEmpty()) { - sql += wxT(",\n autovacuum_freeze_min_age=") + GetAutoVacuumFreezeMinAge(); + sqlopt += wxT(",\n autovacuum_freeze_min_age=") + GetAutoVacuumFreezeMinAge(); } if (!GetAutoVacuumFreezeMaxAge().IsEmpty()) { - sql += wxT(",\n autovacuum_freeze_max_age=") + GetAutoVacuumFreezeMaxAge(); + sqlopt += wxT(",\n autovacuum_freeze_max_age=") + GetAutoVacuumFreezeMaxAge(); } if (!GetAutoVacuumFreezeTableAge().IsEmpty()) { - sql += wxT(",\n autovacuum_freeze_table_age=") + GetAutoVacuumFreezeTableAge(); + sqlopt += wxT(",\n autovacuum_freeze_table_age=") + GetAutoVacuumFreezeTableAge(); } } if (GetHasToastTable() && GetToastCustomAutoVacuumEnabled()) { if (GetToastAutoVacuumEnabled() == 1) - sql += wxT(",\n toast.autovacuum_enabled=true"); + sqlopt += wxT(",\n toast.autovacuum_enabled=true"); else if (GetToastAutoVacuumEnabled() == 0) - sql += wxT(",\n toast.autovacuum_enabled=false"); + sqlopt += wxT(",\n toast.autovacuum_enabled=false"); if (!GetToastAutoVacuumVacuumThreshold().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_vacuum_threshold=") + GetToastAutoVacuumVacuumThreshold(); + sqlopt += wxT(",\n toast.autovacuum_vacuum_threshold=") + GetToastAutoVacuumVacuumThreshold(); } if (!GetToastAutoVacuumVacuumScaleFactor().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_vacuum_scale_factor=") + GetToastAutoVacuumVacuumScaleFactor(); + sqlopt += wxT(",\n toast.autovacuum_vacuum_scale_factor=") + GetToastAutoVacuumVacuumScaleFactor(); } if (!GetToastAutoVacuumVacuumCostDelay().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_vacuum_cost_delay=") + GetToastAutoVacuumVacuumCostDelay(); + sqlopt += wxT(",\n toast.autovacuum_vacuum_cost_delay=") + GetToastAutoVacuumVacuumCostDelay(); } if (!GetToastAutoVacuumVacuumCostLimit().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_vacuum_cost_limit=") + GetToastAutoVacuumVacuumCostLimit(); + sqlopt += wxT(",\n toast.autovacuum_vacuum_cost_limit=") + GetToastAutoVacuumVacuumCostLimit(); } if (!GetToastAutoVacuumFreezeMinAge().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_freeze_min_age=") + GetToastAutoVacuumFreezeMinAge(); + sqlopt += wxT(",\n toast.autovacuum_freeze_min_age=") + GetToastAutoVacuumFreezeMinAge(); } if (!GetToastAutoVacuumFreezeMaxAge().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_freeze_max_age=") + GetToastAutoVacuumFreezeMaxAge(); + sqlopt += wxT(",\n toast.autovacuum_freeze_max_age=") + GetToastAutoVacuumFreezeMaxAge(); } if (!GetToastAutoVacuumFreezeTableAge().IsEmpty()) { - sql += wxT(",\n toast.autovacuum_freeze_table_age=") + GetToastAutoVacuumFreezeTableAge(); + sqlopt += wxT(",\n toast.autovacuum_freeze_table_age=") + GetToastAutoVacuumFreezeTableAge(); } } } - sql += wxT("\n)"); + if (!sqlopt.IsEmpty()) { + sql += wxT("\nWITH ("); + if (sqlopt.Index(',')==0) sqlopt=sqlopt.Mid(1); + sql += sqlopt; + sql += wxT("\n)"); + } } else { @@ -1052,9 +1062,13 @@ void pgTable::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *prope properties->AppendItem(_("Inherited tables"), GetInheritedTables()); if (GetConnection()->BackendMinimumVersion(9, 1)) properties->AppendYesNoItem(_("Unlogged?"), GetUnlogged()); - properties->AppendYesNoItem(_("Has OIDs?"), GetHasOids()); - properties->AppendYesNoItem(_("System table?"), GetSystemObject()); - + if (!GetConnection()->BackendMinimumVersion(12, 0)) + properties->AppendYesNoItem(_("Has OIDs?"), GetHasOids()); + if (!GetConnection()->BackendMinimumVersion(12, 0)) + properties->AppendYesNoItem(_("System table?"), GetSystemObject()); + if (GetConnection()->GetIsPgProEnt()) + properties->AppendItem(_("CFS fragmentation"), GetRatio()); + /* Custom AutoVacuum Settings */ if (GetConnection()->BackendMinimumVersion(8, 4) && GetCustomAutoVacuumEnabled()) { @@ -1534,6 +1548,9 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows } // 'ALTER STATISTICS '||substring('CREATE STATISTICS public.tab_a (dependencies) ON c1, c3 FROM a' from 'ICS (.+?)\s\(')||' OWNER TO '|| //select relation from pg_locks where locktype='relation' and granted=true and mode='AccessExclusiveLock' + if (collection->GetDatabase()->connection()->GetIsPgProEnt()) query += wxT(",left((cfs_fragmentation(rel.oid)*100)::text,5)::text AS cfs_ratio"); + else query += wxT(",null::text AS cfs_ratio"); + if (collection->GetDatabase()->BackendMinimumVersion(10, 0)) { query += wxT(",\n pg_get_statisticsobjdef(stat_ext.oid) AS stat_stmt"); @@ -1600,6 +1617,7 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows table->iSetOid(tables->GetOid(wxT("oid"))); table->iSetOwner(tables->GetVal(wxT("relowner"))); table->iSetAcl(tables->GetVal(wxT("relacl"))); + table->iSetRatio(tables->GetVal(wxT("cfs_ratio"))); if (collection->GetConnection()->BackendMinimumVersion(8, 0)) { if (tables->GetOid(wxT("spcoid")) == 0) @@ -1612,6 +1630,7 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows else table->iSetTablespace(tables->GetVal(wxT("spcname"))); } + if (collection->GetConnection()->BackendMinimumVersion(9, 0)) { table->iSetOfTypeOid(tables->GetOid(wxT("reloftype")));