@@ -1198,6 +1198,7 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
1198
1198
+ " END "
1199
1199
+ " ELSE CASE c.relkind "
1200
1200
+ " WHEN 'r' THEN 'TEMPORARY TABLE' "
1201
+ + " WHEN 'p' THEN 'TEMPORARY TABLE' "
1201
1202
+ " WHEN 'i' THEN 'TEMPORARY INDEX' "
1202
1203
+ " WHEN 'S' THEN 'TEMPORARY SEQUENCE' "
1203
1204
+ " WHEN 'v' THEN 'TEMPORARY VIEW' "
@@ -1206,6 +1207,7 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
1206
1207
+ " END "
1207
1208
+ " WHEN false THEN CASE c.relkind "
1208
1209
+ " WHEN 'r' THEN 'TABLE' "
1210
+ + " WHEN 'p' THEN 'TABLE' "
1209
1211
+ " WHEN 'i' THEN 'INDEX' "
1210
1212
+ " WHEN 'S' THEN 'SEQUENCE' "
1211
1213
+ " WHEN 'v' THEN 'VIEW' "
@@ -1255,8 +1257,8 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
1255
1257
Map <String , String > ht = new HashMap <String , String >();
1256
1258
tableTypeClauses .put ("TABLE" , ht );
1257
1259
ht .put ("SCHEMAS" ,
1258
- "c.relkind = 'r' AND n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'" );
1259
- ht .put ("NOSCHEMAS" , "c.relkind = 'r' AND c.relname !~ '^pg_'" );
1260
+ "c.relkind IN ( 'r','p') AND n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'" );
1261
+ ht .put ("NOSCHEMAS" , "c.relkind IN ( 'r','p') AND c.relname !~ '^pg_'" );
1260
1262
ht = new HashMap <String , String >();
1261
1263
tableTypeClauses .put ("VIEW" , ht );
1262
1264
ht .put ("SCHEMAS" ,
@@ -1303,8 +1305,8 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
1303
1305
"c.relkind = 'v' AND c.relname ~ '^pg_' AND c.relname !~ '^pg_toast_' AND c.relname !~ '^pg_temp_'" );
1304
1306
ht = new HashMap <String , String >();
1305
1307
tableTypeClauses .put ("TEMPORARY TABLE" , ht );
1306
- ht .put ("SCHEMAS" , "c.relkind = 'r' AND n.nspname ~ '^pg_temp_' " );
1307
- ht .put ("NOSCHEMAS" , "c.relkind = 'r' AND c.relname ~ '^pg_temp_' " );
1308
+ ht .put ("SCHEMAS" , "c.relkind IN ( 'r','p') AND n.nspname ~ '^pg_temp_' " );
1309
+ ht .put ("NOSCHEMAS" , "c.relkind IN ( 'r','p') AND c.relname ~ '^pg_temp_' " );
1308
1310
ht = new HashMap <String , String >();
1309
1311
tableTypeClauses .put ("TEMPORARY INDEX" , ht );
1310
1312
ht .put ("SCHEMAS" , "c.relkind = 'i' AND n.nspname ~ '^pg_temp_' " );
@@ -1435,6 +1437,11 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
1435
1437
sql += "a.attnum," ;
1436
1438
}
1437
1439
1440
+ if (connection .haveMinimumServerVersion (ServerVersion .v10 )) {
1441
+ sql += "nullif(a.attidentity, '') as attidentity," ;
1442
+ } else {
1443
+ sql += "null as attidentity," ;
1444
+ }
1438
1445
sql += "pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype "
1439
1446
+ " FROM pg_catalog.pg_namespace n "
1440
1447
+ " JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) "
@@ -1444,7 +1451,7 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
1444
1451
+ " LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) "
1445
1452
+ " LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname='pg_class') "
1446
1453
+ " LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') "
1447
- + " WHERE c.relkind in ('r','v','f','m') and a.attnum > 0 AND NOT a.attisdropped " ;
1454
+ + " WHERE c.relkind in ('r','p',' v','f','m') and a.attnum > 0 AND NOT a.attisdropped " ;
1448
1455
1449
1456
if (schemaPattern != null && !schemaPattern .isEmpty ()) {
1450
1457
sql += " AND n.nspname LIKE " + escapeQuotes (schemaPattern );
@@ -1503,6 +1510,7 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
1503
1510
}
1504
1511
}
1505
1512
}
1513
+ String identity = rs .getString ("attidentity" );
1506
1514
1507
1515
int decimalDigits = connection .getTypeInfo ().getScale (typeOid , typeMod );
1508
1516
int columnSize = connection .getTypeInfo ().getPrecision (typeOid , typeMod );
@@ -1541,7 +1549,7 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
1541
1549
: connection .encodeString (Integer .toString (connection .getTypeInfo ().getSQLType (baseTypeOid ))); // SOURCE_DATA_TYPE
1542
1550
1543
1551
String autoinc = "NO" ;
1544
- if (defval != null && defval .contains ("nextval(" )) {
1552
+ if (defval != null && defval .contains ("nextval(" ) || identity != null ) {
1545
1553
autoinc = "YES" ;
1546
1554
}
1547
1555
tuple [22 ] = connection .encodeString (autoinc );
@@ -1658,7 +1666,7 @@ public ResultSet getTablePrivileges(String catalog, String schemaPattern,
1658
1666
+ " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c, pg_catalog.pg_roles r "
1659
1667
+ " WHERE c.relnamespace = n.oid "
1660
1668
+ " AND c.relowner = r.oid "
1661
- + " AND c.relkind = 'r' " ;
1669
+ + " AND c.relkind IN ( 'r','p') " ;
1662
1670
1663
1671
if (schemaPattern != null && !schemaPattern .isEmpty ()) {
1664
1672
sql += " AND n.nspname LIKE " + escapeQuotes (schemaPattern );
@@ -1786,6 +1794,7 @@ private static void addACLPrivileges(String acl, Map<String, Map<String, List<St
1786
1794
sqlpriv = "INSERT" ;
1787
1795
break ;
1788
1796
case 'r' :
1797
+ case 'p' :
1789
1798
sqlpriv = "SELECT" ;
1790
1799
break ;
1791
1800
case 'w' :
@@ -2044,13 +2053,15 @@ protected ResultSet getImportedExportedKeys(String primaryCatalog, String primar
2044
2053
+ " WHEN 'n' THEN " + DatabaseMetaData .importedKeySetNull
2045
2054
+ " WHEN 'd' THEN " + DatabaseMetaData .importedKeySetDefault
2046
2055
+ " WHEN 'r' THEN " + DatabaseMetaData .importedKeyRestrict
2056
+ + " WHEN 'p' THEN " + DatabaseMetaData .importedKeyRestrict
2047
2057
+ " WHEN 'a' THEN " + DatabaseMetaData .importedKeyNoAction
2048
2058
+ " ELSE NULL END AS UPDATE_RULE, "
2049
2059
+ "CASE con.confdeltype "
2050
2060
+ " WHEN 'c' THEN " + DatabaseMetaData .importedKeyCascade
2051
2061
+ " WHEN 'n' THEN " + DatabaseMetaData .importedKeySetNull
2052
2062
+ " WHEN 'd' THEN " + DatabaseMetaData .importedKeySetDefault
2053
2063
+ " WHEN 'r' THEN " + DatabaseMetaData .importedKeyRestrict
2064
+ + " WHEN 'p' THEN " + DatabaseMetaData .importedKeyRestrict
2054
2065
+ " WHEN 'a' THEN " + DatabaseMetaData .importedKeyNoAction
2055
2066
+ " ELSE NULL END AS DELETE_RULE, "
2056
2067
+ "con.conname AS FK_NAME, pkic.relname AS PK_NAME, "
0 commit comments