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

[CBRD-25331] Remove unnecessary fixing page header for TDE on sort step #5169

Merged
merged 3 commits into from
May 14, 2024
Merged
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
36 changes: 23 additions & 13 deletions src/storage/external_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ static void sort_return_used_resources (THREAD_ENTRY * thread_p, SORT_PARAM * so
static int sort_add_new_file (THREAD_ENTRY * thread_p, VFID * vfid, int file_pg_cnt_est, bool force_alloc,
bool tde_encrypted);

static int sort_write_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num_pages, char *area_start);
static int sort_write_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num_pages, char *area_start,
bool tde_encrypted);
static int sort_read_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num_pages, char *area_start);

static int sort_get_num_half_tmpfiles (int tot_buffers, int input_pages);
Expand Down Expand Up @@ -2734,7 +2735,9 @@ sort_run_flush (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param, int out_file,
if (sort_spage_insert (output_buffer, &out_recdes) == NULL_SLOTID)
{
/* Output buffer is full */
error = sort_write_area (thread_p, &sort_param->temp[out_file], cur_page[out_file], 1, output_buffer);
error =
sort_write_area (thread_p, &sort_param->temp[out_file], cur_page[out_file], 1, output_buffer,
sort_param->tde_encrypted);
if (error != NO_ERROR)
{
return error;
Expand All @@ -2760,7 +2763,9 @@ sort_run_flush (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param, int out_file,
if (sort_spage_get_numrecs (output_buffer))
{
/* Flush the partially full output page */
error = sort_write_area (thread_p, &sort_param->temp[out_file], cur_page[out_file], 1, output_buffer);
error =
sort_write_area (thread_p, &sort_param->temp[out_file], cur_page[out_file], 1, output_buffer,
sort_param->tde_encrypted);
if (error != NO_ERROR)
{
return error;
Expand Down Expand Up @@ -3060,7 +3065,7 @@ sort_exphase_merge_elim_dup (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)
cur_page[act] += read_pages;
error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile],
read_pages, sort_param->internal_memory);
read_pages, sort_param->internal_memory, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -3318,7 +3323,7 @@ sort_exphase_merge_elim_dup (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)
/* Flush output section */
error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile],
out_sectsize, out_sectaddr);
out_sectsize, out_sectaddr, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -3553,7 +3558,7 @@ sort_exphase_merge_elim_dup (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)

error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile], out_act_bufno,
out_sectaddr);
out_sectaddr, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -3844,7 +3849,7 @@ sort_exphase_merge (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)
cur_page[act] += read_pages;
error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile],
read_pages, sort_param->internal_memory);
read_pages, sort_param->internal_memory, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -4082,7 +4087,7 @@ sort_exphase_merge (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)
/* Flush output section */
error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile],
out_sectsize, out_sectaddr);
out_sectsize, out_sectaddr, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -4301,7 +4306,7 @@ sort_exphase_merge (THREAD_ENTRY * thread_p, SORT_PARAM * sort_param)
out_act_bufno++; /* Since 0 refers to the first active buffer */
error =
sort_write_area (thread_p, &sort_param->temp[cur_outfile], cur_page[cur_outfile], out_act_bufno,
out_sectaddr);
out_sectaddr, sort_param->tde_encrypted);
if (error != NO_ERROR)
{
goto bailout;
Expand Down Expand Up @@ -4537,7 +4542,8 @@ sort_add_new_file (THREAD_ENTRY * thread_p, VFID * vfid, int file_pg_cnt_est, bo
* returned.
*/
static int
sort_write_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num_pages, char *area_start)
sort_write_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num_pages, char *area_start,
bool tde_encrypted)
{
PAGE_PTR page_ptr = NULL;
VPID vpid;
Expand All @@ -4546,11 +4552,15 @@ sort_write_area (THREAD_ENTRY * thread_p, VFID * vfid, int first_page, INT32 num
int ret = NO_ERROR;
TDE_ALGORITHM tde_algo = TDE_ALGORITHM_NONE;

ret = file_get_tde_algorithm (thread_p, vfid, PGBUF_UNCONDITIONAL_LATCH, &tde_algo);
if (ret != NO_ERROR)
if (tde_encrypted)
{
return ret;
ret = file_get_tde_algorithm (thread_p, vfid, PGBUF_UNCONDITIONAL_LATCH, &tde_algo);
if (ret != NO_ERROR)
{
return ret;
}
}

/* initializations */
page_no = first_page;

Expand Down
Loading