apache / cloudberry

One advanced and mature open-source MPP (Massively Parallel Processing) database. Open source alternative to Greenplum Database.
https://cloudberry.apache.org
Apache License 2.0
418 stars 104 forks source link

[Bug] \d+ for cloudberry partitioned table segfault. #697

Open reshke opened 2 weeks ago

reshke commented 2 weeks ago

Cloudberry Database version

HEAD

What happened

There is an issue with psql \d+ feature for partiotion root tables that i encountered while reviewing pr https://github.com/cloudberrydb/cloudberrydb/pull/695. Long story short:

db2=# \d+ star.trd_fct
row number 0 is out of range 0..-1
row number 0 is out of range 0..-1
cannot duplicate null pointer (internal error)

This is because psql query for partition root returns zero tuples https://github.com/cloudberrydb/cloudberrydb/blob/main/src/bin/psql/describe.c#L2297

db2=# SELECT a.compresstype, a.compresslevel, a.blocksize, a.checksum FROM pg_catalog.pg_appendonly a, pg_catalog.pg_class c WHERE c.oid = a.relid AND c.oid ='star.trd_fct'::regclass::oid;
 compresstype | compresslevel | blocksize | checksum
--------------+---------------+-----------+----------
(0 rows)

What you think should happen instead

No response

How to reproduce

CREATE TABLE star.trd_fct (
trd_date_key date NOT NULL ,
prod_key integer NOT NULL ,
cust_key integer NOT NULL ,
notional_val numeric(20,10) ,
num_of_shares integer ,
num_of_trades integer ,
trd_id bigint NOT NULL ,
ins_ts timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
)

WITH (
appendoptimized=true
,orientation=row
,compresstype=zlib
,compresslevel=5
)
DISTRIBUTED RANDOMLY
PARTITION BY RANGE (trd_date_key) (
START ('2020-01-01'::date) INCLUSIVE
END ('2027-01-01'::date) EXCLUSIVE
EVERY (interval '1 Year')
)
;

\d+ star.trd_fct

Operating System

any

Anything else

No response

Are you willing to submit PR?

Code of Conduct

reshke commented 2 weeks ago

In fact, we can avoid this by not querying this for partition root. But what info we should provide for \d+ in this case?

gfphoenix78 commented 2 weeks ago

nice catch. I'll fix it in https://github.com/cloudberrydb/cloudberrydb/pull/695