aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
diff options
context:
space:
mode:
authorTomDataworks2016-01-12 22:44:43 -0500
committerKevin Cozens2016-04-25 12:11:03 -0400
commite9b0f7157546a25a39a3e4e7a5ca6bd5db4c4728 (patch)
tree64c66328fdce352ab923ad04ad1c31d50a8dfbb2 /OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
parentRemoved trailing whitespace in prebuild.xml (diff)
downloadopensim-SC_OLD-e9b0f7157546a25a39a3e4e7a5ca6bd5db4c4728.zip
opensim-SC_OLD-e9b0f7157546a25a39a3e4e7a5ca6bd5db4c4728.tar.gz
opensim-SC_OLD-e9b0f7157546a25a39a3e4e7a5ca6bd5db4c4728.tar.bz2
opensim-SC_OLD-e9b0f7157546a25a39a3e4e7a5ca6bd5db4c4728.tar.xz
Fix Mantis #7805, table handler needs to look for all unique constraints.
Signed-off-by: Kevin Cozens <kevin@ve3syb.ca>
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs37
1 files changed, 16 insertions, 21 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
index 826c6fc..061de22 100644
--- a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
+++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
@@ -145,27 +145,22 @@ namespace OpenSim.Data.PGSQL
145 private List<string> GetConstraints() 145 private List<string> GetConstraints()
146 { 146 {
147 List<string> constraints = new List<string>(); 147 List<string> constraints = new List<string>();
148 string query = string.Format(@"SELECT kcu.column_name 148 string query = string.Format(@"select
149 FROM information_schema.table_constraints tc 149 a.attname as column_name
150 LEFT JOIN information_schema.key_column_usage kcu 150 from
151 ON tc.constraint_catalog = kcu.constraint_catalog 151 pg_class t,
152 AND tc.constraint_schema = kcu.constraint_schema 152 pg_class i,
153 AND tc.constraint_name = kcu.constraint_name 153 pg_index ix,
154 154 pg_attribute a
155 LEFT JOIN information_schema.referential_constraints rc 155 where
156 ON tc.constraint_catalog = rc.constraint_catalog 156 t.oid = ix.indrelid
157 AND tc.constraint_schema = rc.constraint_schema 157 and i.oid = ix.indexrelid
158 AND tc.constraint_name = rc.constraint_name 158 and a.attrelid = t.oid
159 159 and a.attnum = ANY(ix.indkey)
160 LEFT JOIN information_schema.constraint_column_usage ccu 160 and t.relkind = 'r'
161 ON rc.unique_constraint_catalog = ccu.constraint_catalog 161 and ix.indisunique = true
162 AND rc.unique_constraint_schema = ccu.constraint_schema 162 and t.relname = lower('{0}')
163 AND rc.unique_constraint_name = ccu.constraint_name 163 ;", m_Realm);
164
165 where tc.table_name = lower('{0}')
166 and lower(tc.constraint_type) in ('primary key')
167 and kcu.column_name is not null
168 ;", m_Realm);
169 164
170 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 165 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
171 using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) 166 using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))