DASSL / ClassDB

An open-source system to let students experiment with relational data
https://dassl.github.io/ClassDB/
Other
8 stars 2 forks source link

New functions and views in Public are not removed by the uninstaller (WM) #146

Closed wildtayne closed 6 years ago

wildtayne commented 6 years ago

addFrequentViews.sql adds several new objects to Public that are not removed by removeFromDB.sql. I suggest that we simply add DROP * IF EXISTS statements to removeFromDB.sql for each object needing to be dropped. An initial list of such objects is:

smurthys commented 6 years ago

I gathered some information about generating a script to list/drop functions. The internal function oidvectortypes is the magic sauce as seen in this query:

SELECT 'DROP FUNCTION ' || ns.nspname || '.' || p.proname 
       || '(' || oidvectortypes(p.proargtypes) || ');'
FROM pg_proc p JOIN pg_namespace ns ON p.pronamespace = ns.oid
WHERE ns.nspname = 'classdb'
ORDER BY p.proname;

Useful sources;

wildtayne commented 6 years ago

This is an awesome function @smurthys. I was also thinking that somehow listing all functions owned by ClassDB would be the best way to solve this issue.

wildtayne commented 6 years ago

After investigating #147, it seems these two issues are linked fairly tightly. I will post an update here later.

wildtayne commented 6 years ago

I did some experimenting after our discussion, it seems one fairly simple solution we didn't discuss is to use DROP OWNED BY ClassDB. If this encounters any dependency issues, it throws a very helpful exception, for example:

DETAIL: view m2ins01.insview depends on table classdb.rolebase

The one exception to this is that objects that are owned by superusers, for example, the event triggers and log import function, must be explicitly dropped first. I've pushed an implementation of this to the remove-uninstaller-uname-dep branch. It seems to work as intended the testing I've performed locally.

wildtayne commented 6 years ago

Fixed in #161