Don't read relhasoids on version 12. Also don't try to select data we are not allowed to read.
This commit is contained in:
parent
1c48b1945c
commit
5494e5076b
3 changed files with 51 additions and 25 deletions
|
|
@ -7,13 +7,20 @@
|
||||||
|
|
||||||
std::string PgClassContainer::getLoadQuery() const
|
std::string PgClassContainer::getLoadQuery() const
|
||||||
{
|
{
|
||||||
return "SELECT oid, relname, relnamespace, reltype, reloftype, "
|
std::string q = "SELECT oid, relname, relnamespace, reltype, reloftype, "
|
||||||
" relowner, relam, relfilenode, reltablespace, relpages, "
|
" relowner, relam, relfilenode, reltablespace, relpages, "
|
||||||
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
||||||
" relkind, relhasoids, relispopulated, relfrozenxid, relminmxid, "
|
" relkind, relispopulated, relfrozenxid, relminmxid, "
|
||||||
" reloptions, relacl \n"
|
" reloptions, relacl";
|
||||||
"FROM pg_catalog.pg_class \n"
|
|
||||||
|
if (lessThenVersion(120000))
|
||||||
|
q += ", relhasoids ";
|
||||||
|
|
||||||
|
q +=
|
||||||
|
"\nFROM pg_catalog.pg_class \n"
|
||||||
"WHERE relkind IN ('r', 'i', 'p', 'I', 'v', 'm', 'f')";
|
"WHERE relkind IN ('r', 'i', 'p', 'I', 'v', 'm', 'f')";
|
||||||
|
|
||||||
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgClass PgClassContainer::loadElem(const Pgsql::Row &row)
|
PgClass PgClassContainer::loadElem(const Pgsql::Row &row)
|
||||||
|
|
@ -28,13 +35,18 @@ PgClass PgClassContainer::loadElem(const Pgsql::Row &row)
|
||||||
col >> v.type >> v.oftype
|
col >> v.type >> v.oftype
|
||||||
>> owner >> v.am >> v.filenode >> v.tablespace >> v.pages_est
|
>> owner >> v.am >> v.filenode >> v.tablespace >> v.pages_est
|
||||||
>> v.tuples_est >> v.toastrelid >> v.isshared >> v.persistence
|
>> v.tuples_est >> v.toastrelid >> v.isshared >> v.persistence
|
||||||
>> v.kind >> v.hasoids >> v.ispopulated >> v.frozenxid >> v.minmxid
|
>> v.kind >> v.ispopulated >> v.frozenxid >> v.minmxid
|
||||||
>> v.options;
|
>> v.options;
|
||||||
|
|
||||||
|
|
||||||
v.setOwnerOid(owner);
|
v.setOwnerOid(owner);
|
||||||
|
|
||||||
AclList acl_list;
|
AclList acl_list;
|
||||||
col >> acl_list;
|
col >> acl_list;
|
||||||
v.setAcls(std::move(acl_list));
|
v.setAcls(std::move(acl_list));
|
||||||
|
|
||||||
|
if (lessThenVersion(120000))
|
||||||
|
col >> v.hasoids;
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ public:
|
||||||
bool cycled = false;
|
bool cycled = false;
|
||||||
bool called = false;
|
bool called = false;
|
||||||
|
|
||||||
|
bool priv_usage = false;
|
||||||
|
bool priv_select = false;
|
||||||
|
bool priv_update = false;
|
||||||
|
|
||||||
using PgClass::PgClass;
|
using PgClass::PgClass;
|
||||||
QString createSql() const;
|
QString createSql() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,17 @@ std::string PgSequenceContainer::getLoadQuery() const
|
||||||
std::string select = "SELECT pg_class.oid, relname, relnamespace, reltype, reloftype, "
|
std::string select = "SELECT pg_class.oid, relname, relnamespace, reltype, reloftype, "
|
||||||
" relowner, relam, relfilenode, reltablespace, relpages, "
|
" relowner, relam, relfilenode, reltablespace, relpages, "
|
||||||
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
||||||
" relkind, relhasoids, relispopulated, relfrozenxid, relminmxid, "
|
" relkind, relispopulated, relfrozenxid, relminmxid, "
|
||||||
" reloptions, relacl \n";
|
" reloptions, relacl, \n"
|
||||||
|
" has_sequence_privilege(pg_class.oid, 'USAGE') AS priv_usage, \n"
|
||||||
|
" has_sequence_privilege(pg_class.oid, 'SELECT') AS priv_select, \n"
|
||||||
|
" has_sequence_privilege(pg_class.oid, 'UPDATE') AS priv_update \n";
|
||||||
std::string from =
|
std::string from =
|
||||||
"FROM pg_catalog.pg_class \n";
|
"FROM pg_catalog.pg_class \n";
|
||||||
|
|
||||||
|
// Starting with 12 oid are not a special column anymore
|
||||||
|
if (lessThenVersion(120000))
|
||||||
|
select += ", relhasoids ";
|
||||||
// Starting with pg10 constanst data of sequences is retrieved from pg_sequence
|
// Starting with pg10 constanst data of sequences is retrieved from pg_sequence
|
||||||
// instead of SELECTing the sequence
|
// instead of SELECTing the sequence
|
||||||
if (minimumVersion(100000)) {
|
if (minimumVersion(100000)) {
|
||||||
|
|
@ -43,8 +49,10 @@ PgSequence PgSequenceContainer::loadElem(const Pgsql::Row &row)
|
||||||
col >> v.type >> v.oftype
|
col >> v.type >> v.oftype
|
||||||
>> owner >> v.am >> v.filenode >> v.tablespace >> v.pages_est
|
>> owner >> v.am >> v.filenode >> v.tablespace >> v.pages_est
|
||||||
>> v.tuples_est >> v.toastrelid >> v.isshared >> v.persistence
|
>> v.tuples_est >> v.toastrelid >> v.isshared >> v.persistence
|
||||||
>> v.kind >> v.hasoids >> v.ispopulated >> v.frozenxid >> v.minmxid
|
>> v.kind >> v.ispopulated >> v.frozenxid >> v.minmxid
|
||||||
>> v.options >> acl_list;
|
>> v.options >> acl_list >> v.priv_usage >> v.priv_select >> v.priv_update;
|
||||||
|
if (lessThenVersion(120000))
|
||||||
|
col >> v.hasoids;
|
||||||
// Read pg_sequence fields
|
// Read pg_sequence fields
|
||||||
if (minimumVersion(100000))
|
if (minimumVersion(100000))
|
||||||
col >> v.typid >> v.start >> v.increment >> v.max >> v.min >> v.cache >> v.cycled;
|
col >> v.typid >> v.start >> v.increment >> v.max >> v.min >> v.cache >> v.cycled;
|
||||||
|
|
@ -60,23 +68,25 @@ void PgSequenceContainer::loadAll(Pgsql::Connection &conn)
|
||||||
IPgContainer::loadAll(conn);
|
IPgContainer::loadAll(conn);
|
||||||
|
|
||||||
for (auto && seq : m_container) {
|
for (auto && seq : m_container) {
|
||||||
auto fqn = seq.fullyQualifiedQuotedObjectName().toUtf8();
|
if (seq.priv_select) {
|
||||||
// SELECTs on a sequence return less fields starting with pg10
|
auto fqn = seq.fullyQualifiedQuotedObjectName().toUtf8();
|
||||||
// the missing fields are now in pg_sequence
|
// SELECTs on a sequence return less fields starting with pg10
|
||||||
std::string q("SELECT last_value, log_cnt, is_called");
|
// the missing fields are now in pg_sequence
|
||||||
if (lessThenVersion(100000)) {
|
std::string q("SELECT last_value, log_cnt, is_called");
|
||||||
q += ", start_value, increment_by, max_value, \n"
|
|
||||||
" min_value, cache_value, is_cycled";
|
|
||||||
}
|
|
||||||
q += "\nFROM " + std::string(fqn.data(), static_cast<size_t>(fqn.count()));
|
|
||||||
auto && res = conn.query(q.c_str());
|
|
||||||
if (res.rows() == 1) {
|
|
||||||
Pgsql::Row row(res, 0);
|
|
||||||
Pgsql::Col col(row);
|
|
||||||
col >> seq.last >> seq.log >> seq.called;
|
|
||||||
if (lessThenVersion(100000)) {
|
if (lessThenVersion(100000)) {
|
||||||
col >> seq.start >> seq.increment >> seq.max >> seq.min >> seq.cache >> seq.cycled;
|
q += ", start_value, increment_by, max_value, \n"
|
||||||
seq.typid = Pgsql::int8_oid; // bigint used to be the only choice
|
" min_value, cache_value, is_cycled";
|
||||||
|
}
|
||||||
|
q += "\nFROM " + std::string(fqn.data(), static_cast<size_t>(fqn.count()));
|
||||||
|
auto && res = conn.query(q.c_str());
|
||||||
|
if (res.rows() == 1) {
|
||||||
|
Pgsql::Row row(res, 0);
|
||||||
|
Pgsql::Col col(row);
|
||||||
|
col >> seq.last >> seq.log >> seq.called;
|
||||||
|
if (lessThenVersion(100000)) {
|
||||||
|
col >> seq.start >> seq.increment >> seq.max >> seq.min >> seq.cache >> seq.cycled;
|
||||||
|
seq.typid = Pgsql::int8_oid; // bigint used to be the only choice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue