Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ CREATE
-- verify_cpu_usage: calculate each QE's average cpu usage using all the data in
-- the table cpu_usage_sample. And compare the average value to the expected value.
-- return true if the practical value is close to the expected value.
CREATE OR REPLACE FUNCTION verify_cpu_usage(groupname TEXT, expect_cpu_usage INT, err_rate INT) RETURNS BOOL AS $$ import json import functools
all_info = plpy.execute(''' SELECT sample::json->'{name}' AS cpu FROM cpu_usage_samples '''.format(name=groupname)) usage = float(all_info[0]['cpu'])
CREATE OR REPLACE FUNCTION verify_cpu_usage(groupname TEXT, expect_cpu_usage INT, err_rate INT) RETURNS BOOL AS $$ import json
all_info = plpy.execute(''' SELECT sample::json->'{name}' AS cpu FROM cpu_usage_samples '''.format(name=groupname)) usage = sum(float(row['cpu']) for row in all_info) / len(all_info)
return abs(usage - expect_cpu_usage) <= err_rate $$ LANGUAGE plpython3u;
CREATE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ $$ LANGUAGE plpython3u;
CREATE OR REPLACE FUNCTION verify_cpu_usage(groupname TEXT, expect_cpu_usage INT, err_rate INT)
RETURNS BOOL AS $$
import json
import functools

all_info = plpy.execute('''
SELECT sample::json->'{name}' AS cpu FROM cpu_usage_samples
'''.format(name=groupname))
usage = float(all_info[0]['cpu'])
usage = sum(float(row['cpu']) for row in all_info) / len(all_info)

return abs(usage - expect_cpu_usage) <= err_rate
$$ LANGUAGE plpython3u;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- start_matchsubs
-- m/\(cluster.c:\d+\)/
-- s/\(cluster.c:\d+\)/\(cluster.c:###\)/
-- end_matchsubs
-- ALTER TABLE ... SET DISTRIBUTED BY
-- This is the main interface for system expansion
\set DATA values(1, 2), (2, 3), (3, 4)
Expand Down Expand Up @@ -171,7 +175,7 @@ ERROR: permission denied: "pg_class" is a system catalog
create table atsdb (i int, j text) distributed by (j);
insert into atsdb select i, i::text from generate_series(1, 10) i;
alter table atsdb set with(appendonly = true);
ERROR: PAX not allow swap relation files for different AM (cluster.c:1535)
ERROR: PAX not allow swap relation files for different AM (cluster.c:###)
select relname, segrelid != 0, reloptions from pg_class, pg_appendonly where pg_class.oid =
'atsdb'::regclass and relid = pg_class.oid;
relname | ?column? | reloptions
Expand Down Expand Up @@ -316,7 +320,7 @@ select * from distcheck where rel = 'atsdb';

alter table atsdb drop column n;
alter table atsdb set with(appendonly = true, compresslevel = 3);
ERROR: PAX not allow swap relation files for different AM (cluster.c:1535)
ERROR: PAX not allow swap relation files for different AM (cluster.c:###)
select relname, segrelid != 0, reloptions from pg_class, pg_appendonly where pg_class.oid =
'atsdb'::regclass and relid = pg_class.oid;
relname | ?column? | reloptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- start_matchsubs
-- m/\(cluster.c:\d+\)/
-- s/\(cluster.c:\d+\)/\(cluster.c:###\)/
-- end_matchsubs
-- ALTER TABLE ... SET DISTRIBUTED BY
-- This is the main interface for system expansion
\set DATA values(1, 2), (2, 3), (3, 4)
Expand Down Expand Up @@ -171,7 +175,7 @@ ERROR: permission denied: "pg_class" is a system catalog
create table atsdb (i int, j text) distributed by (j);
insert into atsdb select i, i::text from generate_series(1, 10) i;
alter table atsdb set with(appendonly = true);
ERROR: PAX not allow swap relation files for different AM (cluster.c:1535)
ERROR: PAX not allow swap relation files for different AM (cluster.c:###)
select relname, segrelid != 0, reloptions from pg_class, pg_appendonly where pg_class.oid =
'atsdb'::regclass and relid = pg_class.oid;
relname | ?column? | reloptions
Expand Down Expand Up @@ -316,7 +320,7 @@ select * from distcheck where rel = 'atsdb';

alter table atsdb drop column n;
alter table atsdb set with(appendonly = true, compresslevel = 3);
ERROR: PAX not allow swap relation files for different AM (cluster.c:1535)
ERROR: PAX not allow swap relation files for different AM (cluster.c:###)
select relname, segrelid != 0, reloptions from pg_class, pg_appendonly where pg_class.oid =
'atsdb'::regclass and relid = pg_class.oid;
relname | ?column? | reloptions
Expand Down
15 changes: 5 additions & 10 deletions contrib/pax_storage/src/test/regress/expected/rowtypes.out
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,36 @@ LINE 1: select '(Joe,Blow) /'::fullname;
^
DETAIL: Junk after right parenthesis.
-- test non-error-throwing API
-- MERGE16_FIXME:
-- The greenplum implement complex type by itself, postgres implement
-- it now. should we use the complex type implemented by postgres.
-- start_ignore
SELECT pg_input_is_valid('(1,2)', 'complex');
SELECT pg_input_is_valid('(1,2)', 'complex_t');
pg_input_is_valid
-------------------
t
(1 row)

SELECT pg_input_is_valid('(1,2', 'complex');
SELECT pg_input_is_valid('(1,2', 'complex_t');
pg_input_is_valid
-------------------
f
(1 row)

SELECT pg_input_is_valid('(1,zed)', 'complex');
SELECT pg_input_is_valid('(1,zed)', 'complex_t');
pg_input_is_valid
-------------------
f
(1 row)

SELECT * FROM pg_input_error_info('(1,zed)', 'complex');
SELECT * FROM pg_input_error_info('(1,zed)', 'complex_t');
message | detail | hint | sql_error_code
-------------------------------------------------------+--------+------+----------------
invalid input syntax for type double precision: "zed" | | | 22P02
(1 row)

SELECT * FROM pg_input_error_info('(1,1e400)', 'complex');
SELECT * FROM pg_input_error_info('(1,1e400)', 'complex_t');
message | detail | hint | sql_error_code
---------------------------------------------------+--------+------+----------------
"1e400" is out of range for type double precision | | | 22003
(1 row)

-- end_ignore
create temp table quadtable(f1 int, q quad);
insert into quadtable values (1, ((3.3,4.4),(5.5,6.6)));
insert into quadtable values (2, ((null,4.4),(5.5,6.6)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,36 @@ LINE 1: select '(Joe,Blow) /'::fullname;
^
DETAIL: Junk after right parenthesis.
-- test non-error-throwing API
-- MERGE16_FIXME:
-- The greenplum implement complex type by itself, postgres implement
-- it now. should we use the complex type implemented by postgres.
-- start_ignore
SELECT pg_input_is_valid('(1,2)', 'complex');
SELECT pg_input_is_valid('(1,2)', 'complex_t');
pg_input_is_valid
-------------------
t
(1 row)

SELECT pg_input_is_valid('(1,2', 'complex');
SELECT pg_input_is_valid('(1,2', 'complex_t');
pg_input_is_valid
-------------------
f
(1 row)

SELECT pg_input_is_valid('(1,zed)', 'complex');
SELECT pg_input_is_valid('(1,zed)', 'complex_t');
pg_input_is_valid
-------------------
f
(1 row)

SELECT * FROM pg_input_error_info('(1,zed)', 'complex');
SELECT * FROM pg_input_error_info('(1,zed)', 'complex_t');
message | detail | hint | sql_error_code
-------------------------------------------------------+--------+------+----------------
invalid input syntax for type double precision: "zed" | | | 22P02
(1 row)

SELECT * FROM pg_input_error_info('(1,1e400)', 'complex');
SELECT * FROM pg_input_error_info('(1,1e400)', 'complex_t');
message | detail | hint | sql_error_code
---------------------------------------------------+--------+------+----------------
"1e400" is out of range for type double precision | | | 22003
(1 row)

-- end_ignore
create temp table quadtable(f1 int, q quad);
insert into quadtable values (1, ((3.3,4.4),(5.5,6.6)));
insert into quadtable values (2, ((null,4.4),(5.5,6.6)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- start_matchsubs
-- m/\(cluster.c:\d+\)/
-- s/\(cluster.c:\d+\)/\(cluster.c:###\)/
-- end_matchsubs
-- ALTER TABLE ... SET DISTRIBUTED BY
-- This is the main interface for system expansion
\set DATA values(1, 2), (2, 3), (3, 4)
Expand Down
15 changes: 5 additions & 10 deletions contrib/pax_storage/src/test/regress/sql/rowtypes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,11 @@ select ' (Joe,Blow) '::fullname; -- ok, extra whitespace
select '(Joe,Blow) /'::fullname; -- bad

-- test non-error-throwing API
-- MERGE16_FIXME:
-- The greenplum implement complex type by itself, postgres implement
-- it now. should we use the complex type implemented by postgres.
-- start_ignore
SELECT pg_input_is_valid('(1,2)', 'complex');
SELECT pg_input_is_valid('(1,2', 'complex');
SELECT pg_input_is_valid('(1,zed)', 'complex');
SELECT * FROM pg_input_error_info('(1,zed)', 'complex');
SELECT * FROM pg_input_error_info('(1,1e400)', 'complex');
-- end_ignore
SELECT pg_input_is_valid('(1,2)', 'complex_t');
SELECT pg_input_is_valid('(1,2', 'complex_t');
SELECT pg_input_is_valid('(1,zed)', 'complex_t');
SELECT * FROM pg_input_error_info('(1,zed)', 'complex_t');
SELECT * FROM pg_input_error_info('(1,1e400)', 'complex_t');

create temp table quadtable(f1 int, q quad);

Expand Down
29 changes: 5 additions & 24 deletions src/backend/access/aocs/aocsam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,8 +1462,6 @@ aoco_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
int natts;
Datum *values;
bool *isnull;
TransactionId FreezeXid;
MultiXactId MultiXactCutoff;
Tuplesortstate *tuplesort;
PGRUsage ru0;

Expand Down Expand Up @@ -1523,29 +1521,12 @@ aoco_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
Assert(RelationGetTargetBlock(NewHeap) == InvalidBlockNumber);

/*
* Compute sane values for FreezeXid and CutoffMulti with regular
* VACUUM machinery to avoidconfising existing CLUSTER code.
* AO/AOCO tables have no per-tuple xmin/xmax, so freeze limits don't
* apply. Return Invalid values so that relfrozenxid and relminmxid
* remain unchanged after CLUSTER.
*/
vacuum_set_xid_limits(OldHeap, 0, 0, 0, 0,
&OldestXmin, &FreezeXid, NULL, &MultiXactCutoff,
NULL);

/*
* FreezeXid will become the table's new relfrozenxid, and that mustn't go
* backwards, so take the max.
*/
if (TransactionIdPrecedes(FreezeXid, OldHeap->rd_rel->relfrozenxid))
FreezeXid = OldHeap->rd_rel->relfrozenxid;

/*
* MultiXactCutoff, similarly, shouldn't go backwards either.
*/
if (MultiXactIdPrecedes(MultiXactCutoff, OldHeap->rd_rel->relminmxid))
MultiXactCutoff = OldHeap->rd_rel->relminmxid;

/* return selected values to caller */
*xid_cutoff = FreezeXid;
*multi_cutoff = MultiXactCutoff;
*xid_cutoff = InvalidTransactionId;
*multi_cutoff = InvalidMultiXactId;

tuplesort = tuplesort_begin_cluster(oldTupDesc, OldIndex,
maintenance_work_mem, NULL, false);
Expand Down
29 changes: 5 additions & 24 deletions src/backend/access/appendonly/appendonlyam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,6 @@ appendonly_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
int natts;
Datum *values;
bool *isnull;
TransactionId FreezeXid;
MultiXactId MultiXactCutoff;
Tuplesortstate *tuplesort;
PGRUsage ru0;

Expand Down Expand Up @@ -1380,29 +1378,12 @@ appendonly_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
Assert(RelationGetTargetBlock(NewHeap) == InvalidBlockNumber);

/*
* Compute sane values for FreezeXid and CutoffMulti with regular
* VACUUM machinery to avoidconfising existing CLUSTER code.
* AO/AOCO tables have no per-tuple xmin/xmax, so freeze limits don't
* apply. Return Invalid values so that relfrozenxid and relminmxid
* remain unchanged after CLUSTER.
*/
vacuum_set_xid_limits(OldHeap, 0, 0, 0, 0,
&OldestXmin, &FreezeXid, NULL, &MultiXactCutoff,
NULL);

/*
* FreezeXid will become the table's new relfrozenxid, and that mustn't go
* backwards, so take the max.
*/
if (TransactionIdPrecedes(FreezeXid, OldHeap->rd_rel->relfrozenxid))
FreezeXid = OldHeap->rd_rel->relfrozenxid;

/*
* MultiXactCutoff, similarly, shouldn't go backwards either.
*/
if (MultiXactIdPrecedes(MultiXactCutoff, OldHeap->rd_rel->relminmxid))
MultiXactCutoff = OldHeap->rd_rel->relminmxid;

/* return selected values to caller */
*xid_cutoff = FreezeXid;
*multi_cutoff = MultiXactCutoff;
*xid_cutoff = InvalidTransactionId;
*multi_cutoff = InvalidMultiXactId;

tuplesort = tuplesort_begin_cluster(oldTupDesc, OldIndex,
maintenance_work_mem, NULL, false);
Expand Down
13 changes: 10 additions & 3 deletions src/backend/commands/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,17 +1486,24 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
Assert(!TransactionIdIsValid(frozenXid) ||
TransactionIdIsNormal(frozenXid));
relform1->relfrozenxid = frozenXid;
Assert(MultiXactIdIsValid(cutoffMulti));
Assert(!MultiXactIdIsValid(cutoffMulti) ||
MultiXactIdPrecedesOrEquals(FirstMultiXactId, cutoffMulti));
relform1->relminmxid = cutoffMulti;
}
/*
* Cloudberry: append-optimized tables do not have a valid relfrozenxid.
* Overwrite the entry for both relations.
* Cloudberry: append-optimized tables do not have a valid relfrozenxid
* or relminmxid. Overwrite the entry for both relations.
*/
if (relform1->relkind != RELKIND_INDEX && IsAccessMethodAO(relform1->relam))
{
relform1->relfrozenxid = InvalidTransactionId;
relform1->relminmxid = InvalidMultiXactId;
}
if (relform2->relkind != RELKIND_INDEX && IsAccessMethodAO(relform2->relam))
{
relform2->relfrozenxid = InvalidTransactionId;
relform2->relminmxid = InvalidMultiXactId;
}

/* swap size statistics too, since new rel has freshly-updated stats */
if (swap_stats)
Expand Down
Loading
Loading