You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query: "select distinct relnamespace from pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname=$1;",
1345
+
BindVars: []any{"testschema"},
1346
+
Expected: []sql.Row{{2638679668}},
1347
+
},
1348
+
// TODO: when this test is run in isolation without the query above, the below query returns no rows. This is
1349
+
// because the process of converting an OID to its internal ID can only proceed in one direction: from internal
1350
+
// to OID. When the above query runs, it causes the internal ID for the testschema namespace to be cached,
1351
+
// allowing the reverse lookup to succeed in subsequent queries. For OIDs that have not yet been cached in this
1352
+
// manner, lookups by their OID will fail. This doesn't impact all queries since many of them get an index
1353
+
// lookup on OID, which has the side effect of converting everything to numeric IDs anyway. But for queries
1354
+
// that use a normal comparison function for an OID literal value, the conversion to an internal ID of the
1355
+
// appropriate type (e.g. id.Namespace) cannot happen in the |oidin| function in some cases because the internal
1356
+
// to OID mapping hasn't yet been established for that schema element, so the comparison fails, yielding
1357
+
// incorrect results.
1358
+
// To fix this, we need to correctly seed the internal ID cache with all schema elements in the database.
1359
+
{
1360
+
Query: `SELECT c.oid,pg_catalog.pg_get_expr(c.relpartbound, c.oid) as partition_expr, pg_catalog.pg_get_partkeydef(c.oid) as partition_key
1361
+
FROM pg_catalog.pg_class c
1362
+
WHERE c.relnamespace=$1 AND c.relkind not in ('i','I','c') and c.oid not in (select oid from pg_catalog.pg_class where left(relname, 5) = 'dolt_');`,
1363
+
BindVars: []any{2638679668},
1364
+
Expected: []sql.Row{{1712283605, nil, ""}},
1365
+
},
1366
+
{
1346
1367
Query: `SELECT c.oid,d.description,pg_catalog.pg_get_expr(c.relpartbound, c.oid) as partition_expr, pg_catalog.pg_get_partkeydef(c.oid) as partition_key
1347
1368
FROM pg_catalog.pg_class c
1348
1369
LEFT OUTER JOIN pg_catalog.pg_description d ON d.objoid=c.oid AND d.objsubid=0 AND d.classoid='pg_class'::regclass
@@ -1351,10 +1372,8 @@ WHERE c.relnamespace=$1 AND c.relkind not in ('i','I','c') and c.oid not in (sel
Query: `SELECT d.description from pg_catalog.pg_description d WHERE d.classoid='pg_class'::regclass`,
1357
-
// TODO: add expected values
1376
+
// TODO: add expected values (pg_description not yet implemented)
1358
1377
},
1359
1378
{
1360
1379
Query: `select c.oid,pg_catalog.pg_total_relation_size(c.oid) as total_rel_size,pg_catalog.pg_relation_size(c.oid) as rel_size FROM pg_class c WHERE c.relnamespace=$1 and c.oid not in (select oid from pg_catalog.pg_class where left(relname, 5) = 'dolt_');`,
0 commit comments