From da1c0a39e9df2b7e7eea7ec59ec93fac635c35a9 Mon Sep 17 00:00:00 2001 From: motodiary Date: Wed, 29 May 2024 17:23:07 +0800 Subject: [PATCH] Replace the REPLACE function with the REGEXP_REPLACE function --- ...ACE-function-with-the-REGEXP_REPLACE.patch | 64 +++++++++++++++++++ slurm.spec | 6 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 0034-Replace-the-REPLACE-function-with-the-REGEXP_REPLACE.patch diff --git a/0034-Replace-the-REPLACE-function-with-the-REGEXP_REPLACE.patch b/0034-Replace-the-REPLACE-function-with-the-REGEXP_REPLACE.patch new file mode 100644 index 0000000..77c5094 --- /dev/null +++ b/0034-Replace-the-REPLACE-function-with-the-REGEXP_REPLACE.patch @@ -0,0 +1,64 @@ +From b89936b91cd0ebb2ba22013b5867abccf6b0971b Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Wed, 29 May 2024 17:19:45 +0800 +Subject: [PATCH] Replace the REPLACE function with the REGEXP_REPLACE function + +--- + .../accounting_storage/pgsql/as_pgsql_qos.c | 20 ++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c b/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c +index b06b1a0..0ff9180 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_qos.c +@@ -376,7 +376,7 @@ static int _setup_qos_limits(slurmdb_qos_rec_t *qos, + while ((tmp_char = list_next(preempt_itr))) { + if (tmp_char[0] == '-') { + preempt_val = xstrdup_printf( +- "REPLACE(%s, ',%s,', ',')", ++ "REGEXP_REPLACE(%s::text, ',%s,'::text, ','::text, 'g'::text)", + last_preempt ? last_preempt : "preempt", + tmp_char+1); + xfree(last_preempt); +@@ -384,8 +384,9 @@ static int _setup_qos_limits(slurmdb_qos_rec_t *qos, + preempt_val = NULL; + } else if (tmp_char[0] == '+') { + preempt_val = xstrdup_printf( +- "REPLACE(CONCAT(REPLACE(%s, " +- "',%s,', ''), ',%s,'), ',,', ',')", ++ "REPLACE(CONCAT(REGEXP_REPLACE(%s::text, " ++ "',%s,'::text, ''::text, 'g'::text), ',%s,'::text), " ++ "',,'::text, ','::text, 'g'::text)", + last_preempt ? last_preempt : "preempt", + tmp_char+1, tmp_char+1); + if (added_preempt) +@@ -687,9 +688,9 @@ extern int as_pgsql_add_qos(pgsql_conn_t *pgsql_conn, uint32_t uid, + + xstrfmtcat(query, + "INSERT INTO %s (%s) VALUES (%s) " +- "ON CONFLICT (id) DO UPDATE SET deleted=0, " +- "id=CURRVAL(pg_get_serial_sequence('%s', 'id'))%s;", +- qos_table, cols, vals, qos_table,extra); ++ "ON CONFLICT (id) DO UPDATE SET deleted=0%s;", ++// "id=CURRVAL(pg_get_serial_sequence('%s', 'id'))%s;", ++ qos_table, cols, vals, extra); + + + DB_DEBUG(DB_QOS, pgsql_conn->conn, "query\n%s", query); +@@ -1153,9 +1154,10 @@ extern List as_pgsql_remove_qos(pgsql_conn_t *pgsql_conn, uint32_t uid, + else + xstrfmtcat(assoc_char, " OR id_qos='%s'", row[0]); + xstrfmtcat(extra, +- ", qos=REPLACE(qos, ',%s,', '')" +- ", delta_qos=REPLACE(delta_qos, ',+%s,', '')" +- ", delta_qos=REPLACE(delta_qos, ',-%s,', '')", ++ ", qos=REGEXP_REPLACE(qos::text, ',%s,'::text, ''::text, 'g'::text)" ++ ", delta_qos=REGEXP_REPLACE(" ++ "(REGEXP_REPLACE(delta_qos::text, ',+%s,'::text, ''::text, 'g'::text))::text, " ++ "',-%s,'::text, ''::text, 'g'::text)", + row[0], row[0], row[0]); + + qos_rec = xmalloc(sizeof(slurmdb_qos_rec_t)); +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index 9b5a241..5505ec6 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 36 +%define rel 37 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -49,6 +49,7 @@ Patch30: 0030-Modify-the-alias-after-EXCLUDED-in-SQL-to-field-name.patch Patch31: 0031-fix-some-error-add-pgsql_escape_str-function.patch Patch32: 0032-Correcting-archive-SQL-statements-in-tables.patch Patch33: 0033-fix-pgsql_db_insert_ret_id.patch +Patch34: 0034-Replace-the-REPLACE-function-with-the-REGEXP_REPLACE.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -741,6 +742,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Wed May 29 2024 Xing Liu - 21.08.8-37 +- Replace the REPLACE function with the REGEXP_REPLACE function + * Wed May 29 2024 Xing Liu - 21.08.8-36 - fix pgsql_db_insert_ret_id -- Gitee