From 6a30ab6003c7b8dc7f3d256cb9f58355137af6a4 Mon Sep 17 00:00:00 2001 From: motodiary Date: Tue, 7 May 2024 15:54:51 +0800 Subject: [PATCH] replace && and || in sql in some file --- 0007-replace-and-in-sql-in-some-file.patch | 187 +++++++++++++++++++++ slurm.spec | 6 +- 2 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 0007-replace-and-in-sql-in-some-file.patch diff --git a/0007-replace-and-in-sql-in-some-file.patch b/0007-replace-and-in-sql-in-some-file.patch new file mode 100644 index 0000000..5d15bac --- /dev/null +++ b/0007-replace-and-in-sql-in-some-file.patch @@ -0,0 +1,187 @@ +From 5b7e89361d384db66fba9bde7451c4accc255da2 Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Tue, 7 May 2024 09:50:37 +0800 +Subject: [PATCH] replace && and || in sql in some file + +--- + .../pgsql/accounting_storage_pgsql.c | 20 +++++++++---------- + .../accounting_storage/pgsql/as_pgsql_job.c | 16 +++++++-------- + .../pgsql/as_pgsql_resource.c | 2 +- + 3 files changed, 19 insertions(+), 19 deletions(-) + +diff --git a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c +index 79147c1..6de9589 100755 +--- a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c ++++ b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c +@@ -706,7 +706,7 @@ static int _as_pgsql_acct_check_tables(pgsql_conn_t *pgsql_conn) + \n \ + @my_acct_new := parent_acct\n \ + FROM ' || cluster || '_' || my_table || '\n \ +- WHERE acct = ''' || my_acct || ''' AND user = ''''');\n \ ++ WHERE acct = ''' OR my_acct OR ''' AND user = ''''');\n \ + \n \ + EXECUTE s;\n \ + \n \ +@@ -2004,7 +2004,7 @@ extern int modify_common(pgsql_conn_t *pgsql_conn, + xassert(cluster_name); + xstrfmtcat(query, + "update \"%s_%s\" set mod_time=%ld%s " +- "where deleted=0 && %s;", ++ "where deleted=0 AND %s;", + cluster_name, table, now, vals, cond_char); + xstrfmtcat(query, + "insert into %s " +@@ -2108,12 +2108,12 @@ extern int remove_common(pgsql_conn_t *pgsql_conn, + if (!has_jobs && table != assoc_table) { + if (cluster_centric) { + query = xstrdup_printf("delete from \"%s_%s\" where " +- "creation_time>%ld && (%s);", ++ "creation_time>%ld AND (%s);", + cluster_name, table, day_old, + name_char); + } else { + query = xstrdup_printf("delete from %s where " +- "creation_time>%ld && (%s);", ++ "creation_time>%ld AND (%s);", + table, day_old, name_char); + } + } +@@ -2122,14 +2122,14 @@ extern int remove_common(pgsql_conn_t *pgsql_conn, + if (cluster_centric) { + xstrfmtcat(query, + "update \"%s_%s\" set mod_time=%ld, " +- "deleted=1 where deleted=0 && (%s);", ++ "deleted=1 where deleted=0 AND (%s);", + cluster_name, table, now, name_char); + } else if (table == federation_table) { + xstrfmtcat(query, + "update %s set " + "mod_time=%ld, deleted=1, " + "flags=DEFAULT " +- "where deleted=0 && (%s);", ++ "where deleted=0 AND (%s);", + federation_table, now, + name_char); + } else if (table == qos_table) { +@@ -2164,12 +2164,12 @@ extern int remove_common(pgsql_conn_t *pgsql_conn, + "usage_factor=DEFAULT, " + "usage_thres=DEFAULT, " + "limit_factor=DEFAULT " +- "where deleted=0 && (%s);", ++ "where deleted=0 AND (%s);", + qos_table, now, name_char); + } else { + xstrfmtcat(query, + "update %s set mod_time=%ld, deleted=1 " +- "where deleted=0 && (%s);", ++ "where deleted=0 AND (%s);", + table, now, name_char); + } + } +@@ -2310,7 +2310,7 @@ extern int remove_common(pgsql_conn_t *pgsql_conn, + * the first place. + */ + query = xstrdup_printf("select id_assoc from \"%s_%s\" as t1 where " +- "creation_time>%ld && (%s);", ++ "creation_time>%ld AND (%s);", + cluster_name, assoc_table, + day_old, loc_assoc_char); + +@@ -2730,7 +2730,7 @@ extern int acct_storage_p_commit(pgsql_conn_t *pgsql_conn, bool commit) + + xstrfmtcat(query, "select control_host, control_port, " + "name, rpc_version, flags " +- "from %s where deleted=0 && control_port != 0", ++ "from %s where deleted=0 AND control_port != 0", + cluster_table); + result = pgsql_db_query_ret(pgsql_conn, query, 0); + xfree(query); +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_job.c b/src/plugins/accounting_storage/pgsql/as_pgsql_job.c +index db742f9..fcc7c93 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_job.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_job.c +@@ -942,7 +942,7 @@ extern List as_pgsql_modify_job(pgsql_conn_t *pgsql_conn, uint32_t uid, + } + + time_str = xstrdup_printf( +- "(time_start < %ld && time_start >= %ld)", ++ "(time_start < %ld AND time_start >= %ld)", + usage_end, usage_start); + + itr = list_iterator_create(id_switch_list); +@@ -971,7 +971,7 @@ extern List as_pgsql_modify_job(pgsql_conn_t *pgsql_conn, uint32_t uid, + query = xstrdup_printf( + "INSERT INTO \"%s\" (creation_time, mod_time, id, id_tres, time_start, alloc_secs) " + "SELECT creation_time, %ld, %u, id_tres, time_start, SUM(alloc_secs) AS ASUM from \"%s\" where " +- "(id=%u || id=%u) && %s group by id_tres, time_start ON CONFLICT (id, id_tres, time_start) DO UPDATE SET alloc_secs=ASUM;", ++ "(id=%u OR id=%u) AND %s group by id_tres, time_start ON CONFLICT (id, id_tres, time_start) DO UPDATE SET alloc_secs=ASUM;", + use_table, + now, id_switch->old, use_table, + id_switch->new, id_switch->old, +@@ -979,12 +979,12 @@ extern List as_pgsql_modify_job(pgsql_conn_t *pgsql_conn, uint32_t uid, + + /* Delete all traces of the new id */ + xstrfmtcat(query, +- "delete from \"%s\" where id=%u && %s;", ++ "delete from \"%s\" where id=%u AND %s;", + use_table, id_switch->new, time_str); + + /* Now we just need to switch the ids */ + xstrfmtcat(query, +- "update \"%s\" set mod_time=%ld, id=%u where id=%u && %s;", ++ "update \"%s\" set mod_time=%ld, id=%u where id=%u AND %s;", + use_table, now, id_switch->new, id_switch->old, time_str); + + +@@ -1632,7 +1632,7 @@ extern int as_pgsql_suspend(pgsql_conn_t *pgsql_conn, uint64_t old_db_inx, + job_db_inx = old_db_inx; + xstrfmtcat(query, + "update \"%s_%s\" set time_end=%d where " +- "job_db_inx=%"PRIu64" && time_end=0;", ++ "job_db_inx=%"PRIu64" AND time_end=0;", + pgsql_conn->cluster_name, suspend_table, + (int)job_ptr->suspend_time, job_db_inx); + +@@ -1660,7 +1660,7 @@ extern int as_pgsql_suspend(pgsql_conn_t *pgsql_conn, uint64_t old_db_inx, + else + xstrfmtcat(query, + "update \"%s_%s\" set time_end=%d where " +- "job_db_inx=%"PRIu64" && time_end=0;", ++ "job_db_inx=%"PRIu64" AND time_end=0;", + pgsql_conn->cluster_name, suspend_table, + (int)job_ptr->suspend_time, job_ptr->db_index); + DB_DEBUG(DB_JOB, pgsql_conn->conn, "query\n%s", query); +@@ -1672,7 +1672,7 @@ extern int as_pgsql_suspend(pgsql_conn_t *pgsql_conn, uint64_t old_db_inx, + xstrfmtcat(query, + "update \"%s_%s\" set " + "time_suspended=%u-time_suspended, " +- "state=%d where job_db_inx=%"PRIu64" and time_end=0", ++ "state=%d where job_db_inx=%"PRIu64" AND time_end=0", + pgsql_conn->cluster_name, step_table, + (int)job_ptr->suspend_time, + job_ptr->job_state, job_ptr->db_index); +@@ -1752,7 +1752,7 @@ again: + event_time, suspended_char); + xstrfmtcat(query, + "update \"%s_%s\" set time_end=%ld where (%s) " +- "&& time_end=0;", ++ "AND time_end=0;", + pgsql_conn->cluster_name, suspend_table, + event_time, suspended_char); + xfree(suspended_char); +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c b/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c +index 07f79fc..13fe71a 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_resource.c +@@ -367,7 +367,7 @@ static int _fill_in_res_rec(pgsql_conn_t *pgsql_conn, slurmdb_res_rec_t *res) + + query = xstrdup_printf("SELECT DISTINCT %s FROM %s AS t1 " + "left outer join " +- "%s AS t2 on (res_id=id && " ++ "%s AS t2 on (res_id=id AND " + "t2.deleted=0) " + "WHERE id=%u group by id", + tmp, res_table, clus_res_table, res->id); +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index 038af58..fda96bb 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 9 +%define rel 10 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -22,6 +22,7 @@ Patch3: 0003-replace-with-AND-in-as_pgsql_resource.patch Patch4: 0004-fix-some-sql-bug.patch Patch5: 0005-replace-in-as_pgsql_jobacct_process.patch Patch6: 0006-add-return-value-SQL_NO_DATA-in-sql-api.patch +Patch7: 0007-replace-and-in-sql-in-some-file.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -714,6 +715,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Tue May 07 2024 motodiary - 21.08.8-10 +- replace && and || in sql in some file + * Mon May 06 2024 Xing Liu - 21.08.8-9 - add return value SQL_NO_DATA in sql api -- Gitee