From d3049d10dab49960ec2ff00cbf3a14a97e420a3c Mon Sep 17 00:00:00 2001 From: motodiary Date: Tue, 14 May 2024 09:24:00 +0800 Subject: [PATCH] fix some sql statements Signed-off-by: motodiary --- 0012-fix-some-sql-statements.patch | 43 ++++++++++++++++++++++++++++++ slurm.spec | 6 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0012-fix-some-sql-statements.patch diff --git a/0012-fix-some-sql-statements.patch b/0012-fix-some-sql-statements.patch new file mode 100644 index 0000000..c80af5f --- /dev/null +++ b/0012-fix-some-sql-statements.patch @@ -0,0 +1,43 @@ +From 4a17effdd25fd8b8d2b77f959d561b1f1dcda8ba Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Tue, 14 May 2024 09:20:30 +0800 +Subject: [PATCH] fix some sql statements + +--- + src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c | 2 +- + src/plugins/accounting_storage/pgsql/as_pgsql_tres.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c b/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c +index 777c66e..f983d96 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c +@@ -906,7 +906,7 @@ static int _modify_unset_users(pgsql_conn_t *pgsql_conn, + /* We want all the sub accounts and user accounts */ + query = xstrdup_printf("select distinct %s from \"%s_%s\" " + "where deleted=0 " +- "AND lft between %d and %d AND " ++ "AND (lft between %d and %d) AND " + "((\"user\" = '' AND parent_acct = '%s') OR " + "(\"user\" != '' AND acct = '%s')) " + "order by lft;", +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c b/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c +index 55bec2f..5734cac 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c +@@ -95,9 +95,9 @@ extern int as_pgsql_add_tres(pgsql_conn_t *pgsql_conn, + + xstrfmtcat(query, + "insert into %s (%s) values (%s) " +- "on conflict (id) do update set deleted=0," +- "id=LASTVAL();", +- tres_table, cols, vals); ++ "on conflict (type,name) do update set deleted=0," ++ "id=currval(pg_get_serial_sequence('%s', 'id'));", ++ tres_table, cols, vals, tres_table); + + DB_DEBUG(DB_TRES, pgsql_conn->conn, "query\n%s", query); + // object->id = (uint32_t)pgsql_db_insert_ret_id( +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index ec94013..24b7692 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 14 +%define rel 15 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -27,6 +27,7 @@ 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 Patch11: 0011-Adjusting-the-implementation-of-last_affect_row.patch +Patch12: 0012-fix-some-sql-statements.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -719,6 +720,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Tue May 14 2024 Xing Liu - 21.08.8-15 +- fix some sql statements + * Mon May 13 2024 Xing Liu - 21.08.8-14 - Adjusting the implementation of last_affect_row -- Gitee