SELECT attname FROM pg_index JOIN pg_class ON (indrelid = pg_class.oid) JOIN pg_attribute ON (attrelid = pg_class.oid) WHERE indisprimary IS TRUE AND (attnum = indkey[0] OR attnum = indkey[1] OR attnum = indkey[2]) AND relname = '$table'; Orion
SELECT attname FROM pg_index JOIN pg_class ON (indrelid = pg_class.oid) JOIN pg_attribute ON (attrelid = pg_class.oid) WHERE indisprimary IS TRUE AND (attnum = indkey[0] OR attnum = indkey[1] OR attnum = indkey[2]) AND relname = '$table'; Orion