Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backpatch pr#2245 fixes case where duplicate tables are returned if there are duplicate descriptions oids are not guaranteed to be unique in the catalog #2248

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1311,9 +1311,7 @@ public ResultSet getTables(@Nullable String catalog, @Nullable String schemaPatt
+ " '' as TYPE_CAT, '' as TYPE_SCHEM, '' as TYPE_NAME, "
+ "'' AS SELF_REFERENCING_COL_NAME, '' AS REF_GENERATION "
+ " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c "
+ " LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = 0) "
+ " LEFT JOIN pg_catalog.pg_class dc ON (d.classoid=dc.oid AND dc.relname='pg_class') "
+ " LEFT JOIN pg_catalog.pg_namespace dn ON (dn.oid=dc.relnamespace AND dn.nspname='pg_catalog') "
+ " LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = 0 and d.classoid = 'pg_class'::regclass) "
+ " WHERE c.relnamespace = n.oid ";

if (schemaPattern != null && !schemaPattern.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static Iterable<Object[]> data() {

@Before
public void setUp() throws Exception {
Connection conPriv = TestUtil.openPrivilegedDB();
if (binaryMode == BinaryMode.FORCE) {
final Properties props = new Properties();
PGProperty.PREPARE_THRESHOLD.set(props, -1);
Expand All @@ -87,6 +88,13 @@ public void setUp() throws Exception {
TestUtil.createCompositeType(con, "custom", "i int", false);
TestUtil.createCompositeType(con, "_custom", "f float", false);

// create a table and multiple comments on it
TestUtil.createTable(con, "duplicate", "x text");
TestUtil.execute("comment on table duplicate is 'duplicate table'", con);
TestUtil.execute("create or replace function bar() returns integer language sql as $$ select 1 $$", con);
TestUtil.execute("comment on function bar is 'bar function'", con);
TestUtil.execute("update pg_description set objoid = 'duplicate'::regclass where objoid = 'bar'::regproc",conPriv);

// 8.2 does not support arrays of composite types
TestUtil.createTable(con, "customtable", "c1 custom, c2 _custom"
+ (TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3) ? ", c3 custom[], c4 _custom[]" : ""));
Expand Down Expand Up @@ -125,6 +133,8 @@ public void tearDown() throws Exception {
// metadatatest table's type
Statement stmt = con.createStatement();
stmt.execute("DROP FUNCTION f4(int)");
TestUtil.execute("drop function bar()", con);
TestUtil.dropTable(con, "duplicate");

TestUtil.dropView(con, "viewtest");
TestUtil.dropTable(con, "metadatatest");
Expand Down