From 0a702c6c33546f3ae8fb74d46446e98544473cd5 Mon Sep 17 00:00:00 2001 From: motodiary Date: Mon, 13 May 2024 09:50:39 +0800 Subject: [PATCH] use pgsql_handle_quotes to replace old method --- ..._handle_quotes-to-replace-old-method.patch | 135 ++++++++++++++++++ slurm.spec | 6 +- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 0010-use-pgsql_handle_quotes-to-replace-old-method.patch diff --git a/0010-use-pgsql_handle_quotes-to-replace-old-method.patch b/0010-use-pgsql_handle_quotes-to-replace-old-method.patch new file mode 100644 index 0000000..520fcae --- /dev/null +++ b/0010-use-pgsql_handle_quotes-to-replace-old-method.patch @@ -0,0 +1,135 @@ +From 617c36cc76e26ba3e35cc4a38fac8e2a6d4c5d23 Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Mon, 13 May 2024 09:46:12 +0800 +Subject: [PATCH] use pgsql_handle_quotes to replace old method + +--- + src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c | 2 +- + src/plugins/accounting_storage/pgsql/as_pgsql_federation.c | 2 +- + src/plugins/accounting_storage/pgsql/as_pgsql_qos.c | 2 +- + src/plugins/accounting_storage/pgsql/as_pgsql_resource.c | 4 ++-- + src/plugins/accounting_storage/pgsql/as_pgsql_wckey.c | 2 +- + src/plugins/jobcomp/pgsql/jobcomp_pgsql.c | 2 +- + src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c | 6 +++--- + 7 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c b/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c +index c93c355..6232e64 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c +@@ -395,7 +395,7 @@ extern int as_pgsql_add_clusters(pgsql_conn_t *pgsql_conn, uint32_t uid, + xfree(features); + + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + + xstrfmtcat(query, + "INSERT INTO %s " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_federation.c b/src/plugins/accounting_storage/pgsql/as_pgsql_federation.c +index 58fd122..0350419 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_federation.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_federation.c +@@ -388,7 +388,7 @@ extern int as_pgsql_add_federations(pgsql_conn_t *pgsql_conn, uint32_t uid, + + /* Add Transaction */ + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + + xstrfmtcat(query, + "INSERT INTO %s " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c b/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c +index 55e4c5e..b06b1a0 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c +@@ -719,7 +719,7 @@ extern int as_pgsql_add_qos(pgsql_conn_t *pgsql_conn, uint32_t uid, + } + + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + + xstrfmtcat(query, + "INSERT INTO %s " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c b/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c +index 13fe71a..4decc21 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c +@@ -472,7 +472,7 @@ static int _add_res(pgsql_conn_t *pgsql_conn, slurmdb_res_rec_t *object, + } + + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + + xstrfmtcat(query, + "INSERT INTO %s " +@@ -553,7 +553,7 @@ static int _add_clus_res(pgsql_conn_t *pgsql_conn, slurmdb_res_rec_t *res, + } + + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + name = xstrdup_printf("%u@%s", res->id, object->cluster); + + xstrfmtcat(query, +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_wckey.c b/src/plugins/accounting_storage/pgsql/as_pgsql_wckey.c +index f0a9d39..862cf70 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_wckey.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_wckey.c +@@ -604,7 +604,7 @@ extern int as_pgsql_add_wckeys(pgsql_conn_t *pgsql_conn, uint32_t uid, + list_append(local_cluster_list, object->cluster); + + /* we always have a ', ' as the first 2 chars */ +- tmp_extra = slurm_add_slash_to_quotes(extra+2); ++ tmp_extra = pgsql_handle_quotes(extra+2); + + xstrfmtcat(query, + "INSERT INTO %s " +diff --git a/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c b/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c +index bd99dd5..8a3edaf 100755 +--- a/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c ++++ b/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c +@@ -289,7 +289,7 @@ extern int jobcomp_p_log_record(job_record_t *job_ptr) + } + + if (job_ptr->name && job_ptr->name[0]) +- jname = slurm_add_slash_to_quotes(job_ptr->name); ++ jname = pgsql_handle_quotes(job_ptr->name); + else + jname = xstrdup("allocation"); + +diff --git a/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c +index 3fdb6d4..91770d4 100755 +--- a/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c ++++ b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c +@@ -71,7 +71,7 @@ extern List pgsql_jobcomp_process_get_jobs(slurmdb_job_cond_t *job_cond) + itr = list_iterator_create(job_cond->step_list); + while ((selected_step = list_next(itr))) { + if (set) +- xstrcat(extra, " || "); ++ xstrcat(extra, " OR "); + tmp = xstrdup_printf("jobid=%u", + selected_step->step_id.job_id); + xstrcat(extra, tmp); +@@ -85,14 +85,14 @@ extern List pgsql_jobcomp_process_get_jobs(slurmdb_job_cond_t *job_cond) + if (job_cond->partition_list && list_count(job_cond->partition_list)) { + set = 0; + if (extra) +- xstrcat(extra, " && ("); ++ xstrcat(extra, " AND ("); + else + xstrcat(extra, " where ("); + + itr = list_iterator_create(job_cond->partition_list); + while ((selected_part = list_next(itr))) { + if (set) +- xstrcat(extra, " || "); ++ xstrcat(extra, " OR "); + tmp = xstrdup_printf("`partition`='%s'", + selected_part); + xstrcat(extra, tmp); +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index 347aca0..e554629 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 12 +%define rel 13 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -25,6 +25,7 @@ Patch6: 0006-add-return-value-SQL_NO_DATA-in-sql-api.patch Patch7: 0007-replace-and-in-sql-in-some-file.patch Patch8: 0008-change-sql-datatype.patch Patch9: 0009-fix-the-default-value-type.patch +Patch10: 0010-use-pgsql_handle_quotes-to-replace-old-method.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -717,6 +718,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Mon May 13 2024 Xing Liu - 21.08.8-13 +- use pgsql_handle_quotes to replace old method + * Sat May 11 2024 Xing Liu - 21.08.8-12 - fix the default value type -- Gitee