Permalink
Browse files

fixed index ASC/DESC for 9.6 (#569)

* fixed index ASC/DESC for 9.6

* fixed unused import checkstyle
  • Loading branch information...
davecramer committed May 19, 2016
1 parent fb2977f commit c9e5fc8bf53ead845f7b56c9cbe3c1058b636ca5
@@ -2855,7 +2855,13 @@ private static void addACLPrivileges(String acl, Map<String, Map<String, List<St
+ " trim(both '\"' from pg_catalog.pg_get_indexdef(ci.oid, (i.keys).n, false)) AS COLUMN_NAME, "
// TODO: Implement ASC_OR_DESC for PostgreSQL 9.6+
+ (connection.haveMinimumServerVersion(ServerVersion.v9_6)
? "NULL AS ASC_OR_DESC, "
? " CASE am.amname "
+ " WHEN 'btree' THEN CASE i.indoption[(i.keys).n - 1] & 1 "
+ " WHEN 1 THEN 'D' "
+ " ELSE 'A' "
+ " END "
+ " ELSE NULL "
+ " END AS ASC_OR_DESC, "
: " CASE am.amcanorder "
+ " WHEN true THEN CASE i.indoption[(i.keys).n - 1] & 1 "
+ " WHEN 1 THEN 'D' "
@@ -8,7 +8,6 @@
package org.postgresql.test.jdbc2;
import org.postgresql.core.ServerVersion;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
@@ -589,22 +588,13 @@ public void testAscDescIndexInfo() throws SQLException {
assertTrue(rs.next());
assertEquals("idx_a_d", rs.getString("INDEX_NAME"));
assertEquals("id", rs.getString("COLUMN_NAME"));
if (TestUtil.haveMinimumServerVersion(con, ServerVersion.v9_6)) {
assertNull("ASC_OR_DESC for index is not yet supported for PostgreSQL 9.6",
rs.getString("ASC_OR_DESC"));
} else {
assertEquals("A", rs.getString("ASC_OR_DESC"));
}
assertEquals("A", rs.getString("ASC_OR_DESC"));
assertTrue(rs.next());
assertEquals("idx_a_d", rs.getString("INDEX_NAME"));
assertEquals("quest", rs.getString("COLUMN_NAME"));
if (TestUtil.haveMinimumServerVersion(con, ServerVersion.v9_6)) {
assertNull("ASC_OR_DESC for index is not yet supported for PostgreSQL 9.6",
rs.getString("ASC_OR_DESC"));
} else {
assertEquals("D", rs.getString("ASC_OR_DESC"));
}
assertEquals("D", rs.getString("ASC_OR_DESC"));
}
public void testPartialIndexInfo() throws SQLException {

0 comments on commit c9e5fc8

Please sign in to comment.