From aa8b89f99d4abc1536eba4746d175612a3232e16 Mon Sep 17 00:00:00 2001 From: motodiary Date: Mon, 13 May 2024 14:47:14 +0800 Subject: [PATCH] Adjusting the implementation of last_affect_row --- ...he-implementation-of-last_affect_row.patch | 154 ++++++++++++++++++ slurm.spec | 6 +- 2 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 0011-Adjusting-the-implementation-of-last_affect_row.patch diff --git a/0011-Adjusting-the-implementation-of-last_affect_row.patch b/0011-Adjusting-the-implementation-of-last_affect_row.patch new file mode 100644 index 0000000..4fe7003 --- /dev/null +++ b/0011-Adjusting-the-implementation-of-last_affect_row.patch @@ -0,0 +1,154 @@ +From ea7948bed00410bb949e54832ff7ecdf778ebd00 Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Mon, 13 May 2024 14:40:48 +0800 +Subject: [PATCH] Adjusting the implementation of last_affect_row + +--- + src/database/pgsql_common.c | 50 +++++++++++++++++-- + .../accounting_storage/pgsql/as_pgsql_acct.c | 2 +- + .../accounting_storage/pgsql/as_pgsql_assoc.c | 2 +- + .../pgsql/as_pgsql_cluster.c | 1 + + .../accounting_storage/pgsql/as_pgsql_tres.c | 2 +- + .../accounting_storage/pgsql/as_pgsql_user.c | 2 +- + 6 files changed, 51 insertions(+), 8 deletions(-) + +diff --git a/src/database/pgsql_common.c b/src/database/pgsql_common.c +index ccda9db..1f95330 100755 +--- a/src/database/pgsql_common.c ++++ b/src/database/pgsql_common.c +@@ -1309,11 +1309,29 @@ extern int pgsql_db_create_table(pgsql_conn_t *pgsql_conn, char *table_name, + * This only gets called by a non-threaded connection, so there is no + * need to worry about locks. + */ ++// extern int last_affected_rows(SQLHSTMT stmt) { ++// SQLLEN rows; ++// SQLRETURN rc; ++// ++// _get_last_result(stmt); ++// rc = SQLRowCount(stmt, &rows); ++// if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { ++// SQLCHAR state[PGSQL_STATE_LEN + 1]; ++// PGSQL_HANDLE_ERROR("SQLRowCount", rc, SQL_HANDLE_STMT, stmt, state); ++// rc = SLURM_ERROR; ++// rows = 0; ++// } else { ++// rc = SLURM_SUCCESS; ++// } ++// ++// debug4("%s rows %d", __func__, rows); ++// return rows; ++// } ++ + extern int last_affected_rows(SQLHSTMT stmt) { +- SQLLEN rows; +- SQLRETURN rc; +- +- _get_last_result(stmt); ++ SQLLEN rows = 0; ++ SQLRETURN rc = SLURM_SUCCESS; ++ + rc = SQLRowCount(stmt, &rows); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + SQLCHAR state[PGSQL_STATE_LEN + 1]; +@@ -1324,10 +1342,34 @@ extern int pgsql_db_create_table(pgsql_conn_t *pgsql_conn, char *table_name, + rc = SLURM_SUCCESS; + } + ++ while (1) { ++ rc = SQLMoreResults(stmt); ++ if (rc == SQL_NO_DATA) { ++ // arrive the last ++ break; ++ } else if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { ++ SQLCHAR state[PGSQL_STATE_LEN + 1]; ++ PGSQL_HANDLE_ERROR("SQLMorestmts", rc, SQL_HANDLE_STMT, stmt, state); ++ break; ++ } else { ++ rc = SQLRowCount(stmt, &rows); ++ if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { ++ SQLCHAR state[PGSQL_STATE_LEN + 1]; ++ PGSQL_HANDLE_ERROR("SQLRowCount", rc, SQL_HANDLE_STMT, stmt, state); ++ rc = SLURM_ERROR; ++ rows = 0; ++ } else { ++ rc = SLURM_SUCCESS; ++ } ++ ++ } ++ } ++ + debug4("%s rows %d", __func__, rows); + return rows; + } + ++ + extern bool pgsql_db_match_state(char* state, char* pg_err_code) + { + if (state) { +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_acct.c b/src/plugins/accounting_storage/pgsql/as_pgsql_acct.c +index 0aadd11..9364844 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_acct.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_acct.c +@@ -214,7 +214,7 @@ extern int as_pgsql_add_accts(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); + + if (txn_query) + xstrfmtcat(txn_query, +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c b/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c +index a135293..777c66e 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_assoc.c +@@ -2930,7 +2930,7 @@ extern int as_pgsql_add_assocs(pgsql_conn_t *pgsql_conn, uint32_t uid, + + if (xstrcmp(object->cluster, tmp_cluster_name)) { + /* 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); + if (txn_query) + xstrfmtcat(txn_query, + ", (%ld, %d, 'id_assoc=%d', " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c b/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c +index 6232e64..971ec31 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_cluster.c +@@ -361,6 +361,7 @@ extern int as_pgsql_add_clusters(pgsql_conn_t *pgsql_conn, uint32_t uid, + } + + if (!external_cluster) { ++ info("add root account for cluster %s", object->name); + /* Add root account */ + xstrfmtcat(query, + "INSERT INTO \"%s_%s\" (%s, lft, rgt) " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c b/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c +index 72b13e4..55bec2f 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_tres.c +@@ -138,7 +138,7 @@ extern int as_pgsql_add_tres(pgsql_conn_t *pgsql_conn, + continue; + } + +- tmp_extra = slurm_add_slash_to_quotes(extra); ++ tmp_extra = pgsql_handle_quotes(extra); + + xstrfmtcat(query, + "insert into %s " +diff --git a/src/plugins/accounting_storage/pgsql/as_pgsql_user.c b/src/plugins/accounting_storage/pgsql/as_pgsql_user.c +index f1d41b0..b3460ee 100755 +--- a/src/plugins/accounting_storage/pgsql/as_pgsql_user.c ++++ b/src/plugins/accounting_storage/pgsql/as_pgsql_user.c +@@ -360,7 +360,7 @@ extern int as_pgsql_add_users(pgsql_conn_t *pgsql_conn, uint32_t uid, + list_remove(itr); + + /* 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); + + if (txn_query) + xstrfmtcat(txn_query, +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index e554629..ec94013 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 13 +%define rel 14 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -26,6 +26,7 @@ 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 +Patch11: 0011-Adjusting-the-implementation-of-last_affect_row.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -718,6 +719,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Mon May 13 2024 Xing Liu - 21.08.8-14 +- Adjusting the implementation of last_affect_row + * Mon May 13 2024 Xing Liu - 21.08.8-13 - use pgsql_handle_quotes to replace old method -- Gitee