Skip to content

Commit 4768f26

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/0.0.3-pg'
# Conflicts: # pom.xml
2 parents bdbe29e + 2cbb289 commit 4768f26

8 files changed

+35
-34
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<modelVersion>4.0.0</modelVersion>
1212
<groupId>com.pig4cloud.plugin</groupId>
1313
<artifactId>nacos-datasource-plugin-kingbase</artifactId>
14-
<version>0.0.3.PG</version>
14+
<version>0.0.4.PG</version>
1515
<name>nacos-datasource-plugin-kingbase</name>
1616
<description>nacos 人大金仓存储支持插件</description>
1717
<url>https://pig4cloud.com</url>

src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoAggrMapperByKingbase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) {
2121
String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
2222

2323
String sql = "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
24-
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + startRow + "," + pageSize;
24+
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + pageSize + " offset "
25+
+ startRow;
2526
List<Object> paramList = CollectionUtils.list(dataId, groupId, tenantId);
2627
return new MapperResult(sql, paramList);
2728
}

src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoBetaMapperByKingbase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext conte
1616
int startRow = context.getStartRow();
1717
int pageSize = context.getPageSize();
1818
String sql = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key "
19-
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + startRow + "," + pageSize + " )"
20-
+ " g, config_info_beta t WHERE g.id = t.id ";
19+
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + pageSize + " offset "
20+
+ startRow + " )" + " g, config_info_beta t WHERE g.id = t.id ";
2121
List<Object> paramList = new ArrayList<>();
2222
paramList.add(startRow);
2323
paramList.add(pageSize);

src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoMapperByKingbase.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,41 @@ public MapperResult findConfigInfoByAppFetchRows(MapperContext context) {
2424
final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);
2525
final String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
2626
String sql = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"
27-
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " LIMIT " + context.getStartRow() + ","
28-
+ context.getPageSize();
27+
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " LIMIT " + context.getPageSize() + " offset "
28+
+ context.getStartRow();
2929
return new MapperResult(sql, CollectionUtils.list(tenantId, appName));
3030
}
3131

3232
@Override
3333
public MapperResult getTenantIdList(MapperContext context) {
3434
String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '" + NamespaceUtil.getNamespaceDefaultId()
35-
+ "' GROUP BY tenant_id LIMIT " + context.getStartRow() + "," + context.getPageSize();
35+
+ "' GROUP BY tenant_id LIMIT " + context.getPageSize() + " offset "
36+
+ context.getStartRow();
3637
return new MapperResult(sql, Collections.emptyList());
3738
}
3839

3940
@Override
4041
public MapperResult getGroupIdList(MapperContext context) {
4142
String sql = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId()
42-
+ "' GROUP BY group_id LIMIT " + context.getStartRow() + "," + context.getPageSize();
43+
+ "' GROUP BY group_id LIMIT " + context.getPageSize() + " offset "
44+
+ context.getStartRow();
4345
return new MapperResult(sql, Collections.emptyList());
4446
}
4547

4648
@Override
4749
public MapperResult findAllConfigKey(MapperContext context) {
4850
String sql = " SELECT data_id,group_id,app_name FROM ( "
49-
+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT " + context.getStartRow() + ","
50-
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
51+
+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT " + context.getPageSize()
52+
+ " offset " + context.getStartRow() + " )"
53+
+ " g, config_info t WHERE g.id = t.id ";
5154
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID)));
5255
}
5356

5457
@Override
5558
public MapperResult findAllConfigInfoBaseFetchRows(MapperContext context) {
5659
String sql = "SELECT t.id,data_id,group_id,content,md5"
57-
+ " FROM ( SELECT id FROM config_info ORDER BY id LIMIT " + context.getStartRow() + ","
58-
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
60+
+ " FROM ( SELECT id FROM config_info ORDER BY id LIMIT " + context.getPageSize() + " offset "
61+
+ context.getStartRow() + " )" + " g, config_info t WHERE g.id = t.id ";
5962
return new MapperResult(sql, Collections.emptyList());
6063
}
6164

@@ -65,7 +68,7 @@ public MapperResult findAllConfigInfoFragment(MapperContext context) {
6568
boolean needContent = contextParameter != null && Boolean.parseBoolean(contextParameter);
6669
String sql = "SELECT id,data_id,group_id,tenant_id,app_name," + (needContent ? "content," : "")
6770
+ "md5,gmt_modified,type,encrypted_data_key FROM config_info WHERE id > ? ORDER BY id ASC LIMIT "
68-
+ context.getStartRow() + "," + context.getPageSize();
71+
+ context.getPageSize() + " offset " + context.getStartRow();
6972
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID)));
7073
}
7174

@@ -111,15 +114,15 @@ public MapperResult findChangeConfigFetchRows(MapperContext context) {
111114
}
112115
return new MapperResult(
113116
sqlFetchRows + where + " AND id > " + context.getWhereParameter(FieldConstant.LAST_MAX_ID)
114-
+ " ORDER BY id ASC" + " LIMIT " + 0 + "," + context.getPageSize(),
117+
+ " ORDER BY id ASC" + " LIMIT " + context.getPageSize(),
115118
paramList);
116119
}
117120

118121
@Override
119122
public MapperResult listGroupKeyMd5ByPageFetchRows(MapperContext context) {
120123
String sql = "SELECT t.id,data_id,group_id,tenant_id,app_name,md5,type,gmt_modified,encrypted_data_key FROM "
121-
+ "( SELECT id FROM config_info ORDER BY id LIMIT " + context.getStartRow() + ","
122-
+ context.getPageSize() + " ) g, config_info t WHERE g.id = t.id";
124+
+ "( SELECT id FROM config_info ORDER BY id LIMIT " + context.getPageSize() + " offset "
125+
+ context.getStartRow() + " ) g, config_info t WHERE g.id = t.id";
123126
return new MapperResult(sql, Collections.emptyList());
124127
}
125128

@@ -146,8 +149,8 @@ public MapperResult findConfigInfoBaseLikeFetchRows(MapperContext context) {
146149
where += " AND content LIKE ? ";
147150
paramList.add(content);
148151
}
149-
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
150-
paramList);
152+
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset "
153+
+ context.getStartRow(), paramList);
151154
}
152155

153156
@Override
@@ -180,14 +183,14 @@ public MapperResult findConfigInfo4PageFetchRows(MapperContext context) {
180183
where.append(" AND content LIKE ? ");
181184
paramList.add(content);
182185
}
183-
return new MapperResult(sql + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
184-
paramList);
186+
return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset "
187+
+ context.getStartRow(), paramList);
185188
}
186189

187190
@Override
188191
public MapperResult findConfigInfoBaseByGroupFetchRows(MapperContext context) {
189192
String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=?" + " LIMIT "
190-
+ context.getStartRow() + "," + context.getPageSize();
193+
+ context.getPageSize() + " offset " + context.getStartRow();
191194
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.GROUP_ID),
192195
context.getWhereParameter(FieldConstant.TENANT_ID)));
193196
}
@@ -224,22 +227,24 @@ public MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) {
224227
where.append(" AND content LIKE ? ");
225228
paramList.add(content);
226229
}
227-
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
228-
paramList);
230+
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset "
231+
+ context.getStartRow(), paramList);
229232
}
230233

231234
@Override
232235
public MapperResult findAllConfigInfoFetchRows(MapperContext context) {
233236
String sql = "SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5 "
234-
+ " FROM ( SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT ?,? )"
237+
+ " FROM ( SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT ? offset ? )"
235238
+ " g, config_info t WHERE g.id = t.id ";
236239
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID),
237-
context.getStartRow(), context.getPageSize()));
240+
context.getPageSize(), context.getStartRow()));
238241
}
239242

240243
@Override
241244
public String getDataSource() {
242245
return DataSourceConstant.KINGBASE;
243246
}
244247

248+
249+
245250
}

src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigInfoTagMapperByKingbase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class ConfigInfoTagMapperByKingbase extends KingbaseAbstractMapper implem
1313
@Override
1414
public MapperResult findAllConfigInfoTagForDumpAllFetchRows(MapperContext context) {
1515
String sql = " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "
16-
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT " + context.getStartRow() + ","
17-
+ context.getPageSize() + " ) " + "g, config_info_tag t WHERE g.id = t.id ";
16+
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT " + context.getPageSize() + " offset "
17+
+ context.getStartRow() + " ) " + "g, config_info_tag t WHERE g.id = t.id ";
1818
return new MapperResult(sql, Collections.emptyList());
1919
}
2020

src/main/java/com/pig4cloud/plugin/impl/kingbase/ConfigTagsRelationMapperByKingbase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public MapperResult findConfigInfo4PageCountRows(MapperContext context) {
5656
paramList.add(tagArr[i]);
5757
}
5858
where.append(") ");
59-
return new MapperResult(sql + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
59+
return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset " + context.getStartRow(),
6060
paramList);
6161
}
6262

src/main/java/com/pig4cloud/plugin/impl/kingbase/HistoryConfigInfoMapperByKingbase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public MapperResult removeConfigHistory(MapperContext context) {
2121
public MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {
2222
String sql = "SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info "
2323
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC LIMIT "
24-
+ context.getStartRow() + "," + context.getPageSize();
24+
+ context.getPageSize() + " offset " + context.getStartRow();
2525
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
2626
context.getWhereParameter(FieldConstant.GROUP_ID), context.getWhereParameter(FieldConstant.TENANT_ID)));
2727
}

src/main/java/com/pig4cloud/plugin/impl/kingbase/KingbaseAbstractMapper.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,4 @@ public String count(List<String> where) {
152152
return sql.toString();
153153
}
154154

155-
public String buildPaginationSql(String originalSql, int startRow, int pageSize) {
156-
return "SELECT * FROM ( SELECT TMP2.* FROM (SELECT TMP.*, ROWNUM ROW_ID FROM ( " + originalSql
157-
+ " ) TMP) TMP2 WHERE ROWNUM <=" + (startRow + pageSize) + ") WHERE ROW_ID > " + startRow;
158-
}
159-
160155
}

0 commit comments

Comments
 (0)