Skip to content

Commit 3273f75

Browse files
committed
Fix: alter PAX table will got cast problem
PAX needs to define the StdRdOptions instead of vl_len. Because many places in CBDB assume that option in relation can be cast into StdRdOptions.
1 parent 6ee66fe commit 3273f75

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

contrib/pax_storage/expected/ddl.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ vacuum pax_test.t1;
6363
vacuum full pax_test.t1;
6464
drop table pax_test.t1;
6565
drop table pax_test.t2;
66+
-- alter column with options
67+
create table pax_test.t3 (v1 numeric(100,1)) with(compresstype=zstd, compresslevel=1);
68+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Cloudberry Database data distribution key for this table.
69+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
70+
alter table pax_test.t3 alter column v1 type numeric;
71+
drop table pax_test.t3;

contrib/pax_storage/sql/ddl.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ vacuum full pax_test.t1;
4141
drop table pax_test.t1;
4242
drop table pax_test.t2;
4343

44+
-- alter column with options
45+
create table pax_test.t3 (v1 numeric(100,1)) with(compresstype=zstd, compresslevel=1);
46+
alter table pax_test.t3 alter column v1 type numeric;
47+
drop table pax_test.t3;

contrib/pax_storage/src/cpp/access/paxc_rel_options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ namespace paxc {
3131

3232
// plain structure used by reloptions, can be accessed from C++ code.
3333
struct PaxOptions {
34-
int32 vl_len; /* varlena header (do not touch directly!) */
34+
// Pax needs to define the StdRdOptions instead of just vl_len.
35+
// This is because many places in the CBDB assume that option in
36+
// relation can be cast into StdRdOptions.
37+
StdRdOptions rd_options;
3538
char storage_format[16];
3639
char compress_type[16];
3740
int compress_level;

0 commit comments

Comments
 (0)