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();
|
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()
|
void TablesTableModel::refresh()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
@ -48,8 +62,7 @@ void TablesTableModel::refresh()
|
||||||
m_tables.clear();
|
m_tables.clear();
|
||||||
for (const auto &e : *classes) {
|
for (const auto &e : *classes) {
|
||||||
bool add = false;
|
bool add = false;
|
||||||
if (e.kind == RelKind::Table || e.kind == RelKind::View
|
if (TableLike(e.kind)) {
|
||||||
|| e.kind == RelKind::MaterializedView || e.kind == RelKind::ForeignTable) {
|
|
||||||
switch (m_namespaceFilter) {
|
switch (m_namespaceFilter) {
|
||||||
case NamespaceFilter::User:
|
case NamespaceFilter::User:
|
||||||
add = !e.ns().isSystemCatalog();
|
add = !e.ns().isSystemCatalog();
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,14 @@ void operator<<(RelKind &s, const Pgsql::Value &v)
|
||||||
case 'f':
|
case 'f':
|
||||||
s = RelKind::ForeignTable;
|
s = RelKind::ForeignTable;
|
||||||
break;
|
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)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case RelKind::Table: return "TABLE";
|
case RelKind::Table: return "TABLE";
|
||||||
case RelKind::Index: return "INDEX";
|
case RelKind::Index: return "INDEX";
|
||||||
case RelKind::Sequence: return "SEQUENCE";
|
case RelKind::Sequence: return "SEQUENCE";
|
||||||
case RelKind::View: return "VIEW";
|
case RelKind::View: return "VIEW";
|
||||||
case RelKind::MaterializedView: return "MATERIALIZED VIEW";
|
case RelKind::MaterializedView: return "MATERIALIZED VIEW";
|
||||||
case RelKind::Composite: return "COMPOSITE";
|
case RelKind::Composite: return "COMPOSITE";
|
||||||
case RelKind::Toast: return "TOAST";
|
case RelKind::Toast: return "TOAST";
|
||||||
case RelKind::ForeignTable: return "FOREIGN TABLE";
|
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()");
|
throw std::runtime_error("Unexpected value in PgClass::typeName()");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ enum class RelKind {
|
||||||
MaterializedView, // m
|
MaterializedView, // m
|
||||||
Composite, // c
|
Composite, // c
|
||||||
Toast, // t
|
Toast, // t
|
||||||
ForeignTable // f
|
ForeignTable, // f
|
||||||
|
PartitionedTable, // p
|
||||||
|
PartitionedIndex // I
|
||||||
};
|
};
|
||||||
|
|
||||||
void operator<<(RelKind &s, const Pgsql::Value &v);
|
void operator<<(RelKind &s, const Pgsql::Value &v);
|
||||||
|
|
@ -47,6 +49,7 @@ public:
|
||||||
int minmxid;
|
int minmxid;
|
||||||
std::vector<QString> options;
|
std::vector<QString> options;
|
||||||
QString viewdef;
|
QString viewdef;
|
||||||
|
QString partitionBoundaries;
|
||||||
|
|
||||||
using PgNamespaceObject::PgNamespaceObject;
|
using PgNamespaceObject::PgNamespaceObject;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ std::string PgClassContainer::getLoadQuery() const
|
||||||
|
|
||||||
if (lessThenVersion(120000))
|
if (lessThenVersion(120000))
|
||||||
q += ", relhasoids ";
|
q += ", relhasoids ";
|
||||||
|
if (minimumVersion(100000))
|
||||||
|
q += ", pg_get_expr(relpartbound, oid)"; // partition specification
|
||||||
|
|
||||||
q +=
|
q +=
|
||||||
"\nFROM pg_catalog.pg_class \n"
|
"\nFROM pg_catalog.pg_class \n"
|
||||||
|
|
@ -53,5 +55,8 @@ PgClass PgClassContainer::loadElem(const Pgsql::Row &row)
|
||||||
if (lessThenVersion(120000))
|
if (lessThenVersion(120000))
|
||||||
col >> v.hasoids;
|
col >> v.hasoids;
|
||||||
|
|
||||||
return v;
|
if (minimumVersion(100000))
|
||||||
|
col >> v.partitionBoundaries;
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue