Move the view table/creation to after data collection.

It takes longer to create table than a view but the view is slower in use than is a table.
make this move in preparation to having an option to create either a view or a table for this information.
This commit is contained in:
Douglas Clowes
2014-04-03 12:37:52 +11:00
parent a43ca1cf94
commit 8306d8587f

View File

@ -18,14 +18,6 @@ def setup_database():
curs.execute("CREATE INDEX symidx ON symtab ( name )")
curs.execute("CREATE VIEW defs AS SELECT DISTINCT s.name sym, s.obj_id mod FROM symtab s WHERE s.usage != 'U'");
curs.execute("CREATE VIEW refs AS SELECT DISTINCT s.name sym, s.obj_id mod FROM symtab s WHERE s.usage = 'U'");
curs.execute("""CREATE VIEW v AS SELECT distinct a.name from_name, b.name to_name
FROM defs, refs, objtab a, objtab b
WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod
""")
curs.execute("""CREATE VIEW vnum AS SELECT distinct a.name from_name, b.name to_name, defs.sym sym
FROM defs, refs, objtab a, objtab b
WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod
""")
def get_one_object(arg):
line = arg.strip()
@ -190,3 +182,17 @@ if dict_sf.has_key("main"):
if dict_sm.has_key("main"):
print "main is in library", dict_sm["main"]
curs.execute("""CREATE VIEW v AS SELECT distinct a.name from_name, b.name to_name
FROM defs, refs, objtab a, objtab b
WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod
""")
curs.execute("""CREATE VIEW vnum AS SELECT distinct a.name from_name, b.name to_name, defs.sym sym
FROM defs, refs, objtab a, objtab b
WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod
""")
curs.execute("""CREATE VIEW level_1 AS SELECT DISTINCT to_name name
FROM v
WHERE to_name NOT IN (SELECT DISTINCT from_name FROM v)
""")
curs.execute("CREATE TABLE associations AS SELECT * from v")
curs.execute("CREATE TABLE linkages AS SELECT * from vnum")