diff --git a/pglab/catalog/models/TablesTableModel.cpp b/pglab/catalog/models/TablesTableModel.cpp index 4a07b9f..fd285ed 100644 --- a/pglab/catalog/models/TablesTableModel.cpp +++ b/pglab/catalog/models/TablesTableModel.cpp @@ -33,6 +33,20 @@ void TablesTableModel::setCatalog(std::shared_ptr cat) refresh(); } +bool TableLike(RelKind relkind) +{ + switch (relkind) { + case RelKind::Table: + case RelKind::View: + case RelKind::MaterializedView: + case RelKind::ForeignTable: + case RelKind::PartitionedTable: + return true; + default: + return false; + } +} + void TablesTableModel::refresh() { beginResetModel(); @@ -48,8 +62,7 @@ void TablesTableModel::refresh() m_tables.clear(); for (const auto &e : *classes) { bool add = false; - if (e.kind == RelKind::Table || e.kind == RelKind::View - || e.kind == RelKind::MaterializedView || e.kind == RelKind::ForeignTable) { + if (TableLike(e.kind)) { switch (m_namespaceFilter) { case NamespaceFilter::User: add = !e.ns().isSystemCatalog(); diff --git a/pglablib/catalog/PgClass.cpp b/pglablib/catalog/PgClass.cpp index 5dec586..90b1b71 100644 --- a/pglablib/catalog/PgClass.cpp +++ b/pglablib/catalog/PgClass.cpp @@ -57,6 +57,14 @@ void operator<<(RelKind &s, const Pgsql::Value &v) case 'f': s = RelKind::ForeignTable; break; + case 'p': + s = RelKind::PartitionedTable; + break; + case 'I': + s = RelKind::PartitionedIndex; + break; + default: + throw std::runtime_error("Unknown RelKind"); } } @@ -81,14 +89,16 @@ QString PgClass::typeName() const { switch (kind) { - case RelKind::Table: return "TABLE"; - case RelKind::Index: return "INDEX"; - case RelKind::Sequence: return "SEQUENCE"; - case RelKind::View: return "VIEW"; - case RelKind::MaterializedView: return "MATERIALIZED VIEW"; - case RelKind::Composite: return "COMPOSITE"; - case RelKind::Toast: return "TOAST"; - case RelKind::ForeignTable: return "FOREIGN TABLE"; + case RelKind::Table: return "TABLE"; + case RelKind::Index: return "INDEX"; + case RelKind::Sequence: return "SEQUENCE"; + case RelKind::View: return "VIEW"; + case RelKind::MaterializedView: return "MATERIALIZED VIEW"; + case RelKind::Composite: return "COMPOSITE"; + case RelKind::Toast: return "TOAST"; + case RelKind::ForeignTable: return "FOREIGN TABLE"; + case RelKind::PartitionedTable: return "PARTITIONED TABLE"; + case RelKind::PartitionedIndex: return "PARTITIONED INDEX"; } throw std::runtime_error("Unexpected value in PgClass::typeName()"); } diff --git a/pglablib/catalog/PgClass.h b/pglablib/catalog/PgClass.h index 4e53a93..524b87d 100644 --- a/pglablib/catalog/PgClass.h +++ b/pglablib/catalog/PgClass.h @@ -22,7 +22,9 @@ enum class RelKind { MaterializedView, // m Composite, // c Toast, // t - ForeignTable // f + ForeignTable, // f + PartitionedTable, // p + PartitionedIndex // I }; void operator<<(RelKind &s, const Pgsql::Value &v); @@ -47,6 +49,7 @@ public: int minmxid; std::vector options; QString viewdef; + QString partitionBoundaries; using PgNamespaceObject::PgNamespaceObject; diff --git a/pglablib/catalog/PgClassContainer.cpp b/pglablib/catalog/PgClassContainer.cpp index eb563f6..426b390 100644 --- a/pglablib/catalog/PgClassContainer.cpp +++ b/pglablib/catalog/PgClassContainer.cpp @@ -16,6 +16,8 @@ std::string PgClassContainer::getLoadQuery() const if (lessThenVersion(120000)) q += ", relhasoids "; + if (minimumVersion(100000)) + q += ", pg_get_expr(relpartbound, oid)"; // partition specification q += "\nFROM pg_catalog.pg_class \n" @@ -53,5 +55,8 @@ PgClass PgClassContainer::loadElem(const Pgsql::Row &row) if (lessThenVersion(120000)) col >> v.hasoids; - return v; + if (minimumVersion(100000)) + col >> v.partitionBoundaries; + + return v; }