Skip to content
Permalink
Browse files

dbmanager: include materialized views (implements #9127)

  • Loading branch information
jef-n committed Dec 3, 2013
1 parent f1f2e16 commit a4c365c7cf9f4bb0a5811712d3c514a267363975
Showing with 10 additions and 10 deletions.
  1. +10 −10 python/plugins/db_manager/db_plugins/postgis/connector.py
@@ -79,7 +79,7 @@ def _checkRaster(self):
return self.has_raster

def _checkGeometryColumnsTable(self):
c = self._execute(None, u"SELECT relkind = 'v' FROM pg_class WHERE relname = 'geometry_columns' AND relkind IN ('v', 'r')")
c = self._execute(None, u"SELECT relkind = 'v' OR relkind = 'm' FROM pg_class WHERE relname = 'geometry_columns' AND relkind IN ('v', 'r', 'm')")
res = self._fetchone(c)
self._close_cursor(c)
self.has_geometry_columns = (res != None and len(res) != 0)
@@ -94,7 +94,7 @@ def _checkGeometryColumnsTable(self):
return self.has_geometry_columns

def _checkRasterColumnsTable(self):
c = self._execute(None, u"SELECT relkind = 'v' FROM pg_class WHERE relname = 'raster_columns' AND relkind IN ('v', 'r')")
c = self._execute(None, u"SELECT relkind = 'v' OR relkind = 'm' FROM pg_class WHERE relname = 'raster_columns' AND relkind IN ('v', 'r', 'm')")
res = self._fetchone(c)
self._close_cursor(c)
self.has_raster_columns = (res != None and len(res) != 0)
@@ -238,12 +238,12 @@ def getTables(self, schema=None):

# get all tables and views
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v',
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
pg_get_userbyid(relowner), reltuples, relpages,
pg_catalog.obj_description(cla.oid)
FROM pg_class AS cla
JOIN pg_namespace AS nsp ON nsp.oid = cla.relnamespace
WHERE cla.relkind IN ('v', 'r') """ + schema_where + """
WHERE cla.relkind IN ('v', 'r', 'm') """ + schema_where + """
ORDER BY nsp.nspname, cla.relname"""

c = self._execute(None, sql)
@@ -296,7 +296,7 @@ def getVectorTables(self, schema=None):

# discovery of all tables and whether they contain a geometry column
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v',
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
pg_get_userbyid(relowner), cla.reltuples, cla.relpages,
pg_catalog.obj_description(cla.oid),
""" + geometry_fields_select + """
@@ -312,7 +312,7 @@ def getVectorTables(self, schema=None):
""" + geometry_column_from + """
WHERE cla.relkind IN ('v', 'r') """ + schema_where + """
WHERE cla.relkind IN ('v', 'r', 'm') """ + schema_where + """
ORDER BY nsp.nspname, cla.relname, att.attname"""

items = []
@@ -369,7 +369,7 @@ def getRasterTables(self, schema=None):

# discovery of all tables and whether they contain a raster column
sql = u"""SELECT
cla.relname, nsp.nspname, cla.relkind = 'v',
cla.relname, nsp.nspname, cla.relkind = 'v' OR cla.relkind = 'm',
pg_get_userbyid(relowner), cla.reltuples, cla.relpages,
pg_catalog.obj_description(cla.oid),
""" + raster_fields_select + """
@@ -385,7 +385,7 @@ def getRasterTables(self, schema=None):
""" + raster_column_from + """
WHERE cla.relkind IN ('v', 'r') """ + schema_where + """
WHERE cla.relkind IN ('v', 'r', 'm') """ + schema_where + """
ORDER BY nsp.nspname, cla.relname, att.attname"""

items = []
@@ -559,7 +559,7 @@ def getViewDefinition(self, view):

sql = u"""SELECT pg_get_viewdef(c.oid) FROM pg_class c
JOIN pg_namespace nsp ON c.relnamespace = nsp.oid
WHERE relname=%s %s AND relkind='v' """ % (self.quoteString(tablename), schema_where)
WHERE relname=%s %s AND (relkind='v' OR relkind='m') """ % (self.quoteString(tablename), schema_where)

c = self._execute(None, sql)
res = self._fetchone(c)
@@ -937,7 +937,7 @@ def getSqlDictionary(self):
# get schemas, tables and field names
items = []
sql = u"""SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_' AND nspname != 'information_schema'
UNION SELECT relname FROM pg_class WHERE relkind IN ('v', 'r')
UNION SELECT relname FROM pg_class WHERE relkind IN ('v', 'r', 'm')
UNION SELECT attname FROM pg_attribute WHERE attnum > 0"""
c = self._execute(None, sql)
for row in self._fetchall(c):

0 comments on commit a4c365c

Please sign in to comment.
You can’t perform that action at this time.