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
The dd.partition_parents and dd.partition_children views are broken when partitions exist.
What I did
cargo pgrx run
Create extension & query view (default empty)
(localhost 🐘) ryanlambert@pgdd=# create extension pgdd;
CREATE EXTENSION
Time: 63.543 ms
(localhost 🐘) ryanlambert@pgdd=# select * from dd.partition_parents;
(0 rows)
Load test partition data
(localhost 🐘) ryanlambert@pgdd=# \i ~/git/pgdd/tests/test-partition-data.sql
psql:/home/ryanlambert/git/pgdd/tests/test-partition-data.sql:5: NOTICE: schema "pgdd_test" does not exist, skipping
DROP SCHEMA
Time: 1.053 ms
CREATE SCHEMA
Time: 2.004 ms
CREATE TABLE
Time: 2.069 ms
CREATE TABLE
Time: 5.403 ms
CREATE TABLE
Time: 5.205 ms
CREATE TABLE
Time: 5.409 ms
INSERT 0 15
Time: 2.895 ms
Then tried query against partition view again. It fails with a type error.
select* from dd.partition_parents;
ERROR: Datum error: Postgres type bigint oid={#20, builtin: INT8OID} is not compatible with the Rust type pgrx_pg_sys::submodules::oids::Oid oid={#26, builtin: OIDOID}
Findings so far...
But... it is oid
The code behind the dd.partition_parent() function is pretty straight foward and should be returning an OID. After all, it's pulling directly from pg_catalog.pg_class.oid. While a CTE isn't helpful at all there, that also shouldn't impact the data type. I double checked the type returned via pg_typeof() to be paranoid.
SELECT pg_typeof(c.oid), c.oid,
n.nspname::TEXTAS s_name,
c.relname::TEXTAS t_name,
CASE WHEN pt.partrelidIS NOT NULL THEN 'declarative'
WHEN c.relkind='r' THEN 'inheritance'
ELSE 'unknown' END AS partition_type,
COUNT(i.inhrelid) AS partitions
FROMpg_catalog.pg_class c
INNER JOINpg_catalog.pg_inherits i ONc.oid=i.inhparentLEFT JOINpg_catalog.pg_partitioned_table pt
ONc.oid=pt.partrelidLEFT JOIN pg_namespace n ONn.oid=c.relnamespaceWHEREc.relkind!='I'-- Exclude partitioned indexesGROUP BYc.relkind, c.oid, pt.partrelid, n.nspname::TEXT, c.relname::TEXT
;
I don't see any obvious differences in the Rust code used regarding how we are handling the OID. Example, no issue here.
SELECToid, pg_typeof(oid), *FROMdd.tables;
Comparing what is done for the tables function vs the partition functions, I don't see any obvious differences.
Functional tables code does this (here and here):
name!(oid, Result<Option<pg_sys::Oid>, pgrx::spi::Error>)
...
let oid = row["oid"].value::<pg_sys::Oid>();
The broken partition_parents version does the same things (here and here)
name!(oid, Result<Option<pg_sys::Oid>, pgrx::spi::Error>),
...
let oid = row["oid"].value::<pg_sys::Oid>();
The text was updated successfully, but these errors were encountered:
Details
The
dd.partition_parents
anddd.partition_children
views are broken when partitions exist.What I did
Create extension & query view (default empty)
Load test partition data
Then tried query against partition view again. It fails with a type error.
Findings so far...
But... it is
oid
The code behind the
dd.partition_parent()
function is pretty straight foward and should be returning anOID
. After all, it's pulling directly frompg_catalog.pg_class.oid
. While a CTE isn't helpful at all there, that also shouldn't impact the data type. I double checked the type returned viapg_typeof()
to be paranoid.Rust code
I don't see any obvious differences in the Rust code used regarding how we are handling the OID. Example, no issue here.
Comparing what is done for the tables function vs the partition functions, I don't see any obvious differences.
Functional tables code does this (here and here):
The broken partition_parents version does the same things (here and here)
The text was updated successfully, but these errors were encountered: