From: Pierre Date: Thu, 28 Sep 2023 09:03:56 +0000 (+0200) Subject: SONAR-20315 use pagination.offset in all paginated sql queries, and remove the concep... X-Git-Tag: 10.3.0.82913~316 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52d5664842507687db6666cfbdc4d9c829b570f1;p=sonarqube.git SONAR-20315 use pagination.offset in all paginated sql queries, and remove the concept of startRowNumber --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/OffsetBasedPagination.java b/server/sonar-db-dao/src/main/java/org/sonar/db/OffsetBasedPagination.java index 3ba9042b683..fb50adafbc5 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/OffsetBasedPagination.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/OffsetBasedPagination.java @@ -55,11 +55,6 @@ public class OffsetBasedPagination implements Pagineable { return new OffsetBasedPagination(startRowNumber - 1, pageSize); } - @Override - public int getStartRowNumber() { - return offset + 1; - } - @Override public int getOffset() { return offset; diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/Pagination.java b/server/sonar-db-dao/src/main/java/org/sonar/db/Pagination.java index 5ee079241a2..882c3a81bb9 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/Pagination.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/Pagination.java @@ -63,11 +63,6 @@ public final class Pagination implements Pagineable { return (page - 1) * pageSize; } - @Override - public int getStartRowNumber() { - return getOffset() + 1; - } - public int getEndRowNumber() { return page * pageSize; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/Pagineable.java b/server/sonar-db-dao/src/main/java/org/sonar/db/Pagineable.java index 5bba0a4d0a3..e6517bdb125 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/Pagineable.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/Pagineable.java @@ -21,8 +21,6 @@ package org.sonar.db; public interface Pagineable { - int getStartRowNumber(); - int getOffset(); int getPageSize(); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml index a532172fc60..550789850eb 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/audit/AuditMapper.xml @@ -31,7 +31,7 @@ from audits a where a.created_at >= #{start} and a.created_at < #{end} - limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER} + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only @@ -57,7 +57,7 @@ ) t ) a where - a.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER} + a.rn between (#{pagination.offset,jdbcType=INTEGER}+1) and #{pagination.endRowNumber,jdbcType=INTEGER} order by a.rn asc diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml index b7761f31771..a53f15d1d2b 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml @@ -85,7 +85,7 @@ order by ca.created_at desc, uuid desc - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - - - - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 6dffe0b6848..ba9c732ea74 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -215,7 +215,7 @@ ORDER BY LOWER(p.name), p.name, p.created_at - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - - - - - - - - - - - - @@ -918,6 +727,6 @@ order by (select null) - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/metric/MetricMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/metric/MetricMapper.xml index c77a7c45a36..8afb81bd763 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/metric/MetricMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/metric/MetricMapper.xml @@ -45,7 +45,7 @@ m.enabled=${_true} ORDER BY UPPER(m.short_name), m.short_name - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml index dd94c2f4f37..f24ccb52809 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml @@ -50,7 +50,7 @@ #{uuid,jdbcType=VARCHAR} order by p.name, uuid desc - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - - - - - - - - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditGroupsMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditGroupsMapper.xml index 4314c7ac88a..acfd537f110 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditGroupsMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditGroupsMapper.xml @@ -29,31 +29,7 @@ SELECT g.uuid as groupUuid, g.name as name, qeg.uuid as uuid ORDER BY g.name ASC - LIMIT #{pagination.pageSize,jdbcType=INTEGER} - OFFSET #{pagination.offset,jdbcType=INTEGER} - - - - - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditUsersMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditUsersMapper.xml index 74b3b512804..a8bbc1cd6d5 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditUsersMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QProfileEditUsersMapper.xml @@ -27,33 +27,7 @@ SELECT u.uuid as userUuid, u.name as name, qeu.uuid as uuid ORDER BY u.name ASC - LIMIT #{pagination.pageSize,jdbcType=INTEGER} - OFFSET #{pagination.offset,jdbcType=INTEGER} - - - - - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/GroupMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/GroupMapper.xml index dfb733bea4f..ea9f0327977 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/GroupMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/GroupMapper.xml @@ -99,7 +99,7 @@ - offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only + offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only - - - -