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:
eelke 2023-01-07 07:44:33 +01:00
parent 0cd019db92
commit 33319e3461
4 changed files with 43 additions and 12 deletions

View file

@ -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()");
}

View file

@ -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;

View file

@ -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;
}