Skip to content

Commit 9174d37

Browse files
committed
recompress_chunk_segmentwise_impl
1 parent f82fa1e commit 9174d37

3 files changed

Lines changed: 18 additions & 20 deletions

File tree

tsl/src/compression/api.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -892,25 +892,25 @@ tsl_create_compressed_chunk(PG_FUNCTION_ARGS)
892892
Datum
893893
tsl_compress_chunk(PG_FUNCTION_ARGS)
894894
{
895-
Oid uncompressed_chunk_id = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
895+
Oid uncompressed_relid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
896896
bool if_not_compressed = PG_ARGISNULL(1) ? true : PG_GETARG_BOOL(1);
897897
bool recompress = PG_ARGISNULL(2) ? false : PG_GETARG_BOOL(2);
898898

899899
ts_feature_flag_check(FEATURE_HYPERTABLE_COMPRESSION);
900900

901901
TS_PREVENT_FUNC_IF_READ_ONLY();
902-
Chunk *chunk = ts_chunk_get_by_relid(uncompressed_chunk_id, true);
902+
Chunk *chunk = ts_chunk_get_by_relid(uncompressed_relid, true);
903903
ts_hypertable_permissions_check(chunk->hypertable_relid, GetUserId());
904904

905-
uncompressed_chunk_id = tsl_compress_chunk_wrapper(chunk, if_not_compressed, recompress);
905+
uncompressed_relid = tsl_compress_chunk_wrapper(chunk, if_not_compressed, recompress);
906906

907-
PG_RETURN_OID(uncompressed_chunk_id);
907+
PG_RETURN_OID(uncompressed_relid);
908908
}
909909

910910
Oid
911911
tsl_compress_chunk_wrapper(Chunk *chunk, bool if_not_compressed, bool recompress)
912912
{
913-
Oid uncompressed_chunk_id = chunk->table_id;
913+
Oid uncompressed_relid = chunk->table_id;
914914

915915
if (ts_chunk_is_frozen(chunk))
916916
{
@@ -920,14 +920,14 @@ tsl_compress_chunk_wrapper(Chunk *chunk, bool if_not_compressed, bool recompress
920920
NameStr(chunk->fd.schema_name),
921921
NameStr(chunk->fd.table_name)),
922922
errhint("Use _timescaledb_functions.unfreeze_chunk to unfreeze.")));
923-
return uncompressed_chunk_id;
923+
return uncompressed_relid;
924924
}
925925

926926
write_logical_replication_msg_compression_start();
927927

928928
if (ts_chunk_needs_compression(chunk))
929929
{
930-
uncompressed_chunk_id = compress_chunk_impl(chunk->hypertable_relid, chunk->table_id);
930+
uncompressed_relid = compress_chunk_impl(chunk->hypertable_relid, chunk->table_id);
931931
}
932932
else if (recompress || ts_chunk_needs_recompression(chunk))
933933
{
@@ -954,21 +954,21 @@ tsl_compress_chunk_wrapper(Chunk *chunk, bool if_not_compressed, bool recompress
954954
}
955955

956956
write_logical_replication_msg_compression_end();
957-
return uncompressed_chunk_id;
957+
return uncompressed_relid;
958958
}
959959

960960
Datum
961961
tsl_decompress_chunk(PG_FUNCTION_ARGS)
962962
{
963-
Oid uncompressed_chunk_id = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
963+
Oid uncompressed_relid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
964964
bool if_compressed = PG_ARGISNULL(1) ? true : PG_GETARG_BOOL(1);
965965
int32 chunk_id;
966966

967967
ts_feature_flag_check(FEATURE_HYPERTABLE_COMPRESSION);
968968

969969
TS_PREVENT_FUNC_IF_READ_ONLY();
970970

971-
Chunk *uncompressed_chunk = ts_chunk_get_by_relid(uncompressed_chunk_id, true);
971+
Chunk *uncompressed_chunk = ts_chunk_get_by_relid(uncompressed_relid, true);
972972
chunk_id = uncompressed_chunk->fd.id;
973973

974974
Hypertable *ht = ts_hypertable_get_by_id(uncompressed_chunk->fd.hypertable_id);
@@ -986,7 +986,7 @@ tsl_decompress_chunk(PG_FUNCTION_ARGS)
986986
ereport((if_compressed ? NOTICE : ERROR),
987987
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
988988
errmsg("chunk \"%s\" is not converted to columnstore",
989-
get_rel_name(uncompressed_chunk_id))));
989+
get_rel_name(uncompressed_relid))));
990990

991991
PG_RETURN_NULL();
992992
}
@@ -1001,7 +1001,7 @@ tsl_decompress_chunk(PG_FUNCTION_ARGS)
10011001
*/
10021002
ts_chunk_column_stats_reset_by_chunk_id(chunk_id);
10031003

1004-
PG_RETURN_OID(uncompressed_chunk_id);
1004+
PG_RETURN_OID(uncompressed_relid);
10051005
}
10061006

10071007
static bool
@@ -1079,9 +1079,9 @@ extern Datum
10791079
tsl_get_compressed_chunk_index_for_recompression(PG_FUNCTION_ARGS)
10801080
{
10811081
ts_feature_flag_check(FEATURE_HYPERTABLE_COMPRESSION);
1082-
Oid uncompressed_chunk_id = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
1082+
Oid uncompressed_relid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
10831083

1084-
Chunk *uncompressed_chunk = ts_chunk_get_by_relid(uncompressed_chunk_id, true);
1084+
Chunk *uncompressed_chunk = ts_chunk_get_by_relid(uncompressed_relid, true);
10851085

10861086
Oid index_oid = get_compressed_chunk_index_for_recompression(uncompressed_chunk);
10871087

tsl/src/compression/recompress.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ tsl_recompress_chunk_segmentwise(PG_FUNCTION_ARGS)
126126
NameStr(chunk->fd.schema_name),
127127
NameStr(chunk->fd.table_name));
128128
}
129-
uncompressed_relid = recompress_chunk_segmentwise_impl(chunk, nullable_orderby);
129+
recompress_chunk_segmentwise_impl(chunk, nullable_orderby);
130130
}
131131

132132
PG_RETURN_OID(uncompressed_relid);
@@ -235,7 +235,7 @@ free_chunk_recompress_ctx(RecompressContext *recompress_ctx)
235235
pfree(recompress_ctx);
236236
}
237237

238-
Oid
238+
void
239239
recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk,
240240
bool fullrecompress /* do full decompress/compress segmentwise */)
241241
{
@@ -307,7 +307,7 @@ recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk,
307307
table_close(uncompressed_chunk_rel, NoLock);
308308
table_close(compressed_chunk_rel, NoLock);
309309

310-
PG_RETURN_OID(uncompressed_relid);
310+
return;
311311
}
312312
}
313313

@@ -739,8 +739,6 @@ recompress_chunk_segmentwise_impl(Chunk *uncompressed_chunk,
739739

740740
table_close(uncompressed_chunk_rel, NoLock);
741741
table_close(compressed_chunk_rel, NoLock);
742-
743-
PG_RETURN_OID(uncompressed_relid);
744742
}
745743

746744
/*

tsl/src/compression/recompress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct RecompressContext
3030

3131
extern Datum tsl_recompress_chunk_segmentwise(PG_FUNCTION_ARGS);
3232

33-
Oid recompress_chunk_segmentwise_impl(Chunk *chunk, bool fullrecompress);
33+
void recompress_chunk_segmentwise_impl(Chunk *chunk, bool fullrecompress);
3434
bool recompress_chunk_in_memory_impl(Chunk *uncompressed_chunk);
3535

3636
/* Result of matching an uncompressed tuple against a compressed batch */

0 commit comments

Comments
 (0)