Fix Mantis #7805, table handler needs to look for all unique constraints.
Signed-off-by: Kevin Cozens <kevin@ve3syb.ca>LSLKeyTest
parent
5ed0993845
commit
e9b0f71575
|
@ -145,26 +145,21 @@ namespace OpenSim.Data.PGSQL
|
||||||
private List<string> GetConstraints()
|
private List<string> GetConstraints()
|
||||||
{
|
{
|
||||||
List<string> constraints = new List<string>();
|
List<string> constraints = new List<string>();
|
||||||
string query = string.Format(@"SELECT kcu.column_name
|
string query = string.Format(@"select
|
||||||
FROM information_schema.table_constraints tc
|
a.attname as column_name
|
||||||
LEFT JOIN information_schema.key_column_usage kcu
|
from
|
||||||
ON tc.constraint_catalog = kcu.constraint_catalog
|
pg_class t,
|
||||||
AND tc.constraint_schema = kcu.constraint_schema
|
pg_class i,
|
||||||
AND tc.constraint_name = kcu.constraint_name
|
pg_index ix,
|
||||||
|
pg_attribute a
|
||||||
LEFT JOIN information_schema.referential_constraints rc
|
where
|
||||||
ON tc.constraint_catalog = rc.constraint_catalog
|
t.oid = ix.indrelid
|
||||||
AND tc.constraint_schema = rc.constraint_schema
|
and i.oid = ix.indexrelid
|
||||||
AND tc.constraint_name = rc.constraint_name
|
and a.attrelid = t.oid
|
||||||
|
and a.attnum = ANY(ix.indkey)
|
||||||
LEFT JOIN information_schema.constraint_column_usage ccu
|
and t.relkind = 'r'
|
||||||
ON rc.unique_constraint_catalog = ccu.constraint_catalog
|
and ix.indisunique = true
|
||||||
AND rc.unique_constraint_schema = ccu.constraint_schema
|
and t.relname = lower('{0}')
|
||||||
AND rc.unique_constraint_name = ccu.constraint_name
|
|
||||||
|
|
||||||
where tc.table_name = lower('{0}')
|
|
||||||
and lower(tc.constraint_type) in ('primary key')
|
|
||||||
and kcu.column_name is not null
|
|
||||||
;", m_Realm);
|
;", m_Realm);
|
||||||
|
|
||||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||||
|
|
Loading…
Reference in New Issue