Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove C language recompress_chunk #3896

Merged
merged 1 commit into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/cross_module_fn.c
Expand Up @@ -67,7 +67,6 @@ CROSSMODULE_WRAPPER(array_compressor_append);
CROSSMODULE_WRAPPER(array_compressor_finish);
CROSSMODULE_WRAPPER(compress_chunk);
CROSSMODULE_WRAPPER(decompress_chunk);
CROSSMODULE_WRAPPER(recompress_chunk);

/* continous aggregate */
CROSSMODULE_WRAPPER(continuous_agg_invalidation_trigger);
Expand Down Expand Up @@ -390,7 +389,6 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = {
.process_compress_table = process_compress_table_default,
.compress_chunk = error_no_default_fn_pg_community,
.decompress_chunk = error_no_default_fn_pg_community,
.recompress_chunk = error_no_default_fn_pg_community,
.compressed_data_decompress_forward = error_no_default_fn_pg_community,
.compressed_data_decompress_reverse = error_no_default_fn_pg_community,
.deltadelta_compressor_append = error_no_default_fn_pg_community,
Expand Down
1 change: 0 additions & 1 deletion src/cross_module_fn.h
Expand Up @@ -124,7 +124,6 @@ typedef struct CrossModuleFunctions
void (*process_rename_cmd)(Oid relid, Cache *hcache, const RenameStmt *stmt);
PGFunction compress_chunk;
PGFunction decompress_chunk;
PGFunction recompress_chunk;
/* The compression functions below are not installed in SQL as part of create extension;
* They are installed and tested during testing scripts. They are exposed in cross-module
* functions because they may be very useful for debugging customer problems if the sql
Expand Down
101 changes: 0 additions & 101 deletions tsl/src/compression/compress_utils.c
Expand Up @@ -504,71 +504,6 @@ tsl_decompress_chunk(PG_FUNCTION_ARGS)
PG_RETURN_OID(uncompressed_chunk_id);
}

/* setup FunctionCallInfo for compress_chunk/decompress_chunk
* alloc memory for decompfn_fcinfo and init it.
*/
static void
get_compression_fcinfo(char *fname, FmgrInfo *decompfn, FunctionCallInfo *decompfn_fcinfo,
FunctionCallInfo orig_fcinfo)
{
/* compress_chunk, decompress_chunk have the same args */
Oid argtyp[] = { REGCLASSOID, BOOLOID };
fmNodePtr cxt =
orig_fcinfo->context; /* pass in the context from the current FunctionCallInfo */

Oid decomp_func_oid =
LookupFuncName(list_make1(makeString(fname)), lengthof(argtyp), argtyp, false);

fmgr_info(decomp_func_oid, decompfn);
*decompfn_fcinfo = HEAP_FCINFO(2);
InitFunctionCallInfoData(**decompfn_fcinfo,
decompfn,
2,
InvalidOid, /* collation */
cxt,
NULL);
FC_ARG(*decompfn_fcinfo, 0) = FC_ARG(orig_fcinfo, 0);
FC_NULL(*decompfn_fcinfo, 0) = FC_NULL(orig_fcinfo, 0);
FC_ARG(*decompfn_fcinfo, 1) = FC_ARG(orig_fcinfo, 1);
FC_NULL(*decompfn_fcinfo, 1) = FC_NULL(orig_fcinfo, 1);
}

static Datum
tsl_recompress_remote_chunk(Chunk *uncompressed_chunk, FunctionCallInfo fcinfo, bool if_compressed)
{
FmgrInfo decompfn;
FmgrInfo compfn;
FunctionCallInfo decompfn_fcinfo;
FunctionCallInfo compfn_fcinfo;
get_compression_fcinfo(DECOMPRESS_CHUNK_FUNCNAME, &decompfn, &decompfn_fcinfo, fcinfo);

FunctionCallInvoke(decompfn_fcinfo);
if (decompfn_fcinfo->isnull)
{
ereport((if_compressed ? NOTICE : ERROR),
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("decompression failed for chunk \"%s\"",
get_rel_name(uncompressed_chunk->table_id)),
errdetail("The compression status for the chunk is %d",
uncompressed_chunk->fd.status)));

PG_RETURN_NULL();
}
get_compression_fcinfo(COMPRESS_CHUNK_FUNCNAME, &compfn, &compfn_fcinfo, fcinfo);
Datum compoid = FunctionCallInvoke(compfn_fcinfo);
if (compfn_fcinfo->isnull)
{
ereport((if_compressed ? NOTICE : ERROR),
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("compression failed for chunk \"%s\"",
get_rel_name(uncompressed_chunk->table_id)),
errdetail("The compression status for the chunk is %d",
uncompressed_chunk->fd.status)));
PG_RETURN_NULL();
}
return compoid;
}

bool
tsl_recompress_chunk_wrapper(Chunk *uncompressed_chunk)
{
Expand All @@ -585,39 +520,3 @@ tsl_recompress_chunk_wrapper(Chunk *uncompressed_chunk)
tsl_compress_chunk_wrapper(chunk, false);
return true;
}

Datum
tsl_recompress_chunk(PG_FUNCTION_ARGS)
{
Oid uncompressed_chunk_id = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
bool if_compressed = PG_ARGISNULL(1) ? false : PG_GETARG_BOOL(1);
TS_PREVENT_FUNC_IF_READ_ONLY();

Chunk *uncompressed_chunk =
ts_chunk_get_by_relid(uncompressed_chunk_id, true /* fail_if_not_found */);
if (!ts_chunk_is_unordered(uncompressed_chunk))
{
if (!ts_chunk_is_compressed(uncompressed_chunk))
{
ereport((if_compressed ? NOTICE : ERROR),
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("call compress_chunk instead of recompress_chunk")));
PG_RETURN_NULL();
}
else
{
ereport((if_compressed ? NOTICE : ERROR),
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("nothing to recompress in chunk \"%s\" ",
get_rel_name(uncompressed_chunk->table_id))));
PG_RETURN_NULL();
}
}
if (uncompressed_chunk->relkind == RELKIND_FOREIGN_TABLE)
return tsl_recompress_remote_chunk(uncompressed_chunk, fcinfo, if_compressed);
else
{
tsl_recompress_chunk_wrapper(uncompressed_chunk);
PG_RETURN_OID(uncompressed_chunk_id);
}
}
1 change: 0 additions & 1 deletion tsl/src/init.c
Expand Up @@ -162,7 +162,6 @@ CrossModuleFunctions tsl_cm_functions = {
.process_rename_cmd = tsl_process_rename_cmd,
.compress_chunk = tsl_compress_chunk,
.decompress_chunk = tsl_decompress_chunk,
.recompress_chunk = tsl_recompress_chunk,
.compress_row_init = compress_row_init,
.compress_row_exec = compress_row_exec,
.compress_row_end = compress_row_end,
Expand Down