diff --git a/db/pgConn.cpp b/db/pgConn.cpp index b0b9142..55ab179 100644 --- a/db/pgConn.cpp +++ b/db/pgConn.cpp @@ -556,7 +556,8 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck) wxT( " 'pg_postmaster_starttime', 'pg_terminate_backend', 'pg_reload_conf',") wxT( " 'pgstattuple', 'pgstatindex','bt_index_parent_check')\n") wxT(" AND nspname IN ('pg_catalog', 'public','profile')") - wxT(" union all select current_setting('log_destination'),555,null,null,null"); + wxT(" union all select current_setting('log_destination'),555,null,null,null") + wxT(" union all select setting,666,null,null,null from pg_settings s where s.name='track_commit_timestamp'"); pgSet *set = ExecuteSet(sql); @@ -591,6 +592,9 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck) features[FEATURE_PGCHECKINDEX] = true; else if (proname == wxT("csvlog") && pronargs == 555) features[FEATURE_CSVLOG] = true; + else if (proname == "on" && pronargs == 666) + features[FEATURE_TRACK_COMMIT_TS] = true; + set->MoveNext(); } delete set; diff --git a/include/schema/pgTable.h b/include/schema/pgTable.h index f1f53a6..f5cba9d 100644 --- a/include/schema/pgTable.h +++ b/include/schema/pgTable.h @@ -142,6 +142,15 @@ public: { tablespace = newVal; } + wxString GetCreateTableTS() const + { + return create_table_TS; + }; + void iSetCreateTableTS(const wxString& newVal) + { + create_table_TS = newVal; + } + wxString GetRatio() const { return ratio; @@ -613,7 +622,7 @@ private: long inheritedTableCount, triggerCount; wxString quotedInheritedTables, inheritedTables, primaryKey, quotedPrimaryKey, - primaryKeyName, primaryKeyColNumbers, tablespace, ratio, + primaryKeyName, primaryKeyColNumbers, tablespace, ratio, create_table_TS, distributionColNumbers, ofType; wxArrayString quotedInheritedTablesList, inheritedTablesOidList; diff --git a/include/utils/pgfeatures.h b/include/utils/pgfeatures.h index f5341e9..c3dd7e5 100644 --- a/include/utils/pgfeatures.h +++ b/include/utils/pgfeatures.h @@ -28,6 +28,7 @@ enum FEATURE_FUNCTION_DEFAULTS, FEATURE_CSVLOG, FEATURE_PGPRO_PWR, + FEATURE_TRACK_COMMIT_TS, FEATURE_LAST }; diff --git a/schema/pgPartition.cpp b/schema/pgPartition.cpp index cdf3ac6..89e3ae0 100644 --- a/schema/pgPartition.cpp +++ b/schema/pgPartition.cpp @@ -231,6 +231,8 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser query += wxT(", rel.relpersistence \n"); if (collection->GetDatabase()->connection()->GetIsPgProEnt()) query += wxT(",left((cfs_fragmentation(rel.oid)*100)::text,5)::text AS cfs_ratio\n"); else query += wxT(",null::text AS cfs_ratio\n"); + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) + query += wxT(", pg_xact_commit_timestamp(typ2.xmin) create_ts\n"); query += wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor \n"); query += wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS autovacuum_enabled \n") @@ -282,6 +284,8 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser wxT(" LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'\n"); query += wxT(" LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid\n"); query += wxT("LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n"); + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) + query += wxT("LEFT JOIN pg_type typ2 ON rel.oid=typ2.typrelid\n"); query += wxT(" WHERE rel.relkind IN ('r','s','t','p')\n"); // show partitions in other schema @@ -330,7 +334,10 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser table->iSetOwner(tables->GetVal(wxT("relowner"))); table->iSetAcl(tables->GetVal(wxT("relacl"))); table->iSetRatio(tables->GetVal(wxT("cfs_ratio"))); - if (tables->GetOid(wxT("spcoid")) == 0) + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) { + table->iSetCreateTableTS(tables->GetVal(wxT("create_ts"))); + } + if (tables->GetOid(wxT("spcoid")) == 0) table->iSetTablespaceOid(collection->GetDatabase()->GetTablespaceOid()); else table->iSetTablespaceOid(tables->GetOid(wxT("spcoid"))); diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 55c0da9..6574ae7 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -1086,9 +1086,11 @@ void pgTable::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *prope properties->AppendYesNoItem(_("Has OIDs?"), GetHasOids()); if (!GetConnection()->BackendMinimumVersion(12, 0)) properties->AppendYesNoItem(_("System table?"), GetSystemObject()); - if (GetConnection()->GetIsPgProEnt()) + if (GetConnection()->GetIsPgProEnt() && GetRatio().Len()>0) properties->AppendItem(_("CFS fragmentation"), GetRatio()); - + if (GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS) && GetCreateTableTS().Len()>0) + properties->AppendItem(_("Create table timestamp"), GetCreateTableTS()); + /* Custom AutoVacuum Settings */ if (GetConnection()->BackendMinimumVersion(8, 4) && GetCustomAutoVacuumEnabled()) { @@ -1563,6 +1565,8 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows } if (collection->GetConnection()->BackendMinimumVersion(9, 0)) query += wxT(", rel.reloftype, typ.typname\n"); + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) + query += wxT(", pg_xact_commit_timestamp(typ2.xmin) create_ts\n"); if (collection->GetDatabase()->BackendMinimumVersion(9, 1)) { query += wxT(",\n(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS labels"); @@ -1610,6 +1614,8 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows if (collection->GetConnection()->BackendMinimumVersion(9, 0)) query += wxT("LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n"); + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) + query += wxT("LEFT JOIN pg_type typ2 ON rel.oid=typ2.typrelid\n"); query += wxT(" WHERE ")+pg10+wxT(" rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n"); @@ -1654,6 +1660,9 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows table->iSetOwner(tables->GetVal(wxT("relowner"))); table->iSetAcl(tables->GetVal(wxT("relacl"))); table->iSetRatio(tables->GetVal(wxT("cfs_ratio"))); + if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) { + table->iSetCreateTableTS(tables->GetVal(wxT("create_ts"))); + } if (collection->GetConnection()->BackendMinimumVersion(8, 0)) { if (tables->GetOid(wxT("spcoid")) == 0)