Fix reading from catalog so that information about declarative partitioning is read correctly
(View and SQL generation still need fixes)
This commit is contained in:
parent
0cd019db92
commit
33319e3461
4 changed files with 43 additions and 12 deletions
|
|
@ -33,6 +33,20 @@ void TablesTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> 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();
|
||||
|
|
|
|||
|
|
@ -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()");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<QString> options;
|
||||
QString viewdef;
|
||||
QString partitionBoundaries;
|
||||
|
||||
using PgNamespaceObject::PgNamespaceObject;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue