Skip to content

Commit

Permalink
Fixed autopartitioning for simulations.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Dec 7, 2022
1 parent 7b73fae commit 9921b44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ CREATE OR REPLACE FUNCTION m_simulation_result_create_partition() RETURNS trigge
DECLARE
partition TEXT;
BEGIN
partition := 'm_simulation_result_processed_object_' || REPLACE(new.oid::text,'-','_');
partition := 'm_sr_processed_object_' || REPLACE(new.oid::text,'-','_');
IF new.partitioned AND NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been created %',partition;
EXECUTE 'CREATE TABLE ' || partition || ' partition of ' || 'm_simulation_result_processed_object' || ' for values in (''' || new.oid|| ''');';
Expand All @@ -245,7 +245,7 @@ CREATE OR REPLACE FUNCTION m_simulation_result_delete_partition() RETURNS trigge
DECLARE
partition TEXT;
BEGIN
partition := 'm_simulation_result_processed_object_' || REPLACE(OLD.oid::text,'-','_');
partition := 'm_sr_processed_object_' || REPLACE(OLD.oid::text,'-','_');
IF OLD.partitioned AND EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been deleted %',partition;
EXECUTE 'DROP TABLE IF EXISTS ' || partition || ';';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ protected QSimulationResult newAliasInstance(String alias) {
}


@Override
public @NotNull MSimulationResult toRowObjectWithoutFullObject(SimulationResultType schemaObject,
JdbcSession jdbcSession) {
MSimulationResult row = super.toRowObjectWithoutFullObject(schemaObject, jdbcSession);

row.partitioned = schemaObject.isUseOwnPartitionForProcessedObjects();
return row;
}

@Override
public MSimulationResult newRowObject() {
return new MSimulationResult();
Expand Down

0 comments on commit 9921b44

Please sign in to comment.