pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Re: Postgres 10 partitioned tables
Date: Wed, 17 May 2017 21:42:37 +0200
Message-ID: <ofi937$eap$1@blaine.gmane.org> (raw)
In-Reply-To: <of6pgu$7kb$1@blaine.gmane.org>
References: <of6pgu$7kb$1@blaine.gmane.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

I have updated the patch to also include proper handling of the new identity columns. getColumns() now returns YES for IS_AUTOINCREMENT

I tried to find out how to do this via Github, but the Github manual only says I need to push my commit to a branch, but even if I create a local tracking branch I can't push that, so I am a bit lost (never worked with Github before and git itself doesn't like me anyway)

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Attachments:

pg10.diff (text/plain, 6.3K) download diff --git a/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java b/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java index 5df0184..a6365d3 100644 --- a/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java +++ b/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java @@ -1198,6 +1198,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " END " + " ELSE CASE c.relkind " + " WHEN 'r' THEN 'TEMPORARY TABLE' " + + " WHEN 'p' THEN 'TEMPORARY TABLE' " + " WHEN 'i' THEN 'TEMPORARY INDEX' " + " WHEN 'S' THEN 'TEMPORARY SEQUENCE' " + " WHEN 'v' THEN 'TEMPORARY VIEW' " @@ -1206,6 +1207,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " END " + " WHEN false THEN CASE c.relkind " + " WHEN 'r' THEN 'TABLE' " + + " WHEN 'p' THEN 'TABLE' " + " WHEN 'i' THEN 'INDEX' " + " WHEN 'S' THEN 'SEQUENCE' " + " WHEN 'v' THEN 'VIEW' " @@ -1255,8 +1257,8 @@ public class PgDatabaseMetaData implements DatabaseMetaData { Map<String, String> ht = new HashMap<String, String>(); tableTypeClauses.put("TABLE", ht); ht.put("SCHEMAS", - "c.relkind = 'r' AND n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'"); - ht.put("NOSCHEMAS", "c.relkind = 'r' AND c.relname !~ '^pg_'"); + "c.relkind IN ('r','p') AND n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'"); + ht.put("NOSCHEMAS", "c.relkind IN ('r','p') AND c.relname !~ '^pg_'"); ht = new HashMap<String, String>(); tableTypeClauses.put("VIEW", ht); ht.put("SCHEMAS", @@ -1303,8 +1305,8 @@ public class PgDatabaseMetaData implements DatabaseMetaData { "c.relkind = 'v' AND c.relname ~ '^pg_' AND c.relname !~ '^pg_toast_' AND c.relname !~ '^pg_temp_'"); ht = new HashMap<String, String>(); tableTypeClauses.put("TEMPORARY TABLE", ht); - ht.put("SCHEMAS", "c.relkind = 'r' AND n.nspname ~ '^pg_temp_' "); - ht.put("NOSCHEMAS", "c.relkind = 'r' AND c.relname ~ '^pg_temp_' "); + ht.put("SCHEMAS", "c.relkind IN ('p','r') AND n.nspname ~ '^pg_temp_' "); + ht.put("NOSCHEMAS", "c.relkind IN ('p','r') AND c.relname ~ '^pg_temp_' "); ht = new HashMap<String, String>(); tableTypeClauses.put("TEMPORARY INDEX", ht); ht.put("SCHEMAS", "c.relkind = 'i' AND n.nspname ~ '^pg_temp_' "); @@ -1435,6 +1437,11 @@ public class PgDatabaseMetaData implements DatabaseMetaData { sql += "a.attnum,"; } + if (connection.haveMinimumServerVersion(ServerVersion.v10)) { + sql += "nullif(a.attidentity, '') as attidentity,"; + } else { + sql += "null as attidentity,"; + } sql += "pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS adsrc,dsc.description,t.typbasetype,t.typtype " + " FROM pg_catalog.pg_namespace n " + " JOIN pg_catalog.pg_class c ON (c.relnamespace = n.oid) " @@ -1444,7 +1451,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid) " + " LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND dc.relname='pg_class') " + " LEFT JOIN pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') " - + " WHERE c.relkind in ('r','v','f','m') and a.attnum > 0 AND NOT a.attisdropped "; + + " WHERE c.relkind in ('p','r','v','f','m') and a.attnum > 0 AND NOT a.attisdropped "; if (schemaPattern != null && !schemaPattern.isEmpty()) { sql += " AND n.nspname LIKE " + escapeQuotes(schemaPattern); @@ -1503,6 +1510,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { } } } + String identity = rs.getString("attidentity"); int decimalDigits = connection.getTypeInfo().getScale(typeOid, typeMod); int columnSize = connection.getTypeInfo().getPrecision(typeOid, typeMod); @@ -1541,7 +1549,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { : connection.encodeString(Integer.toString(connection.getTypeInfo().getSQLType(baseTypeOid))); // SOURCE_DATA_TYPE String autoinc = "NO"; - if (defval != null && defval.contains("nextval(")) { + if (defval != null && defval.contains("nextval(") || identity != null) { autoinc = "YES"; } tuple[22] = connection.encodeString(autoinc); @@ -1658,7 +1666,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c, pg_catalog.pg_roles r " + " WHERE c.relnamespace = n.oid " + " AND c.relowner = r.oid " - + " AND c.relkind = 'r' "; + + " AND c.relkind IN ('p','r') "; if (schemaPattern != null && !schemaPattern.isEmpty()) { sql += " AND n.nspname LIKE " + escapeQuotes(schemaPattern); @@ -1786,6 +1794,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { sqlpriv = "INSERT"; break; case 'r': + case 'p': sqlpriv = "SELECT"; break; case 'w': @@ -2044,6 +2053,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " WHEN 'n' THEN " + DatabaseMetaData.importedKeySetNull + " WHEN 'd' THEN " + DatabaseMetaData.importedKeySetDefault + " WHEN 'r' THEN " + DatabaseMetaData.importedKeyRestrict + + " WHEN 'p' THEN " + DatabaseMetaData.importedKeyRestrict + " WHEN 'a' THEN " + DatabaseMetaData.importedKeyNoAction + " ELSE NULL END AS UPDATE_RULE, " + "CASE con.confdeltype " @@ -2051,6 +2061,7 @@ public class PgDatabaseMetaData implements DatabaseMetaData { + " WHEN 'n' THEN " + DatabaseMetaData.importedKeySetNull + " WHEN 'd' THEN " + DatabaseMetaData.importedKeySetDefault + " WHEN 'r' THEN " + DatabaseMetaData.importedKeyRestrict + + " WHEN 'p' THEN " + DatabaseMetaData.importedKeyRestrict + " WHEN 'a' THEN " + DatabaseMetaData.importedKeyNoAction + " ELSE NULL END AS DELETE_RULE, " + "con.conname AS FK_NAME, pkic.relname AS PK_NAME, "

view thread (9+ messages)  latest in thread

Message-ID: <ofi937$eap$1@blaine.gmane.org>
Permalink:  ../ofi937$eap$1@blaine.gmane.org/
Also on:    postgresql.org/message-id/ofi937$eap$1@blaine.gmane.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: Postgres 10 partitioned tables
  In-Reply-To: <ofi937$eap$1@blaine.gmane.org>
  References: <of6pgu$7kb$1@blaine.gmane.org> <ofi937$eap$1@blaine.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox