Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcsPP-0003kI-1g for pgsql-jdbc@arkaria.postgresql.org; Wed, 11 Nov 2020 15:51:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kcsPN-0008IW-VM for pgsql-jdbc@arkaria.postgresql.org; Wed, 11 Nov 2020 15:51:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcsOT-0006Yi-03 for pgsql-jdbc@lists.postgresql.org; Wed, 11 Nov 2020 15:50:45 +0000 Received: from out-21.smtp.github.com ([192.30.252.204] helo=smtp.github.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcsOQ-0004EK-Hy for pgsql-jdbc@lists.postgresql.org; Wed, 11 Nov 2020 15:50:43 +0000 Received: from github.com (hubbernetes-node-7491de7.ac4-iad.github.net [10.52.112.55]) by smtp.github.com (Postfix) with ESMTPA id 67FD7520026 for ; Wed, 11 Nov 2020 07:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1605109841; bh=0mNkk5gmICNi3bQOCpGYxXPdOQZDFTBuNBx/TRhzSCk=; h=Date:From:To:Subject:From; b=Eb11c34HrwgQzwiQoja4mMYUGqTr3gc1FZOpn0zTOQtbHpqDQ79IjHjKLcco5Gpa4 4P0Rj3Z+NhM9IIcaY55CMyKun+yn8/aUoKo+lKAzAqqo1lT+9T5HEQZVomECbh4lLu zl7Wcv+074rcf+qw6dKwoFzf30XdRjS8RpxaXbhA= Date: Wed, 11 Nov 2020 07:50:41 -0800 From: MMeent To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] 375cb3: Fix: Rework sql type gathering to use OID instead ... Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: 375cb3795c3330f9434cee9353f0791b86125914 https://github.com/pgjdbc/pgjdbc/commit/375cb3795c3330f9434cee9353f0791b86125914 Author: MMeent Date: 2020-11-11 (Wed, 11 Nov 2020) Changed paths: M pgjdbc/src/main/java/org/postgresql/core/TypeInfo.java M pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java M pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java M pgjdbc/src/test/java/org/postgresql/test/jdbc42/DatabaseMetaDataTest.java Log Message: ----------- Fix: Rework sql type gathering to use OID instead of typname. This does not have the issue of name shadowing / qual-names, and has the added benefit of fixing #1948. (#1949) Types that are not on the search path (e.g. they are shadowed, or in a schema that is not included in the search path) are stored in the caches as fully qualified type names and OIDs. As we cannot easily query the pg_type catalog using qualified type names, we replace the pgTypeName with the oid of the type name to query properties of the type. Testcases are added to improve coverage of correctly detecting SQL types that are not on the path, but are available through OID or qualified lookup. These types are stored internally as a fully qualified type, but we cannot use this name for lookup in pg_type. Special consideration has been given to Oid.UNSPECIFIED, as that needs to be mapped to Types.OTHER without first hitting the database. That mapping is static, but is not in `types` because it is not an actual type. Fixes #1948 Co-authored-by: Matthias van de Meent