Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/0.0.3-pg'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
lltx committed Aug 25, 2024
2 parents bdbe29e + 2cbb289 commit 4768f26
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>nacos-datasource-plugin-kingbase</artifactId>
<version>0.0.3.PG</version>
<version>0.0.4.PG</version>
<name>nacos-datasource-plugin-kingbase</name>
<description>nacos 人大金仓存储支持插件</description>
<url>https://pig4cloud.com</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) {
String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);

String sql = "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + startRow + "," + pageSize;
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + pageSize + " offset "
+ startRow;
List<Object> paramList = CollectionUtils.list(dataId, groupId, tenantId);
return new MapperResult(sql, paramList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext conte
int startRow = context.getStartRow();
int pageSize = context.getPageSize();
String sql = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key "
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + startRow + "," + pageSize + " )"
+ " g, config_info_beta t WHERE g.id = t.id ";
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + pageSize + " offset "
+ startRow + " )" + " g, config_info_beta t WHERE g.id = t.id ";
List<Object> paramList = new ArrayList<>();
paramList.add(startRow);
paramList.add(pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,41 @@ public MapperResult findConfigInfoByAppFetchRows(MapperContext context) {
final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);
final String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
String sql = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " LIMIT " + context.getStartRow() + ","
+ context.getPageSize();
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow();
return new MapperResult(sql, CollectionUtils.list(tenantId, appName));
}

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

@Override
public MapperResult getGroupIdList(MapperContext context) {
String sql = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId()
+ "' GROUP BY group_id LIMIT " + context.getStartRow() + "," + context.getPageSize();
+ "' GROUP BY group_id LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow();
return new MapperResult(sql, Collections.emptyList());
}

@Override
public MapperResult findAllConfigKey(MapperContext context) {
String sql = " SELECT data_id,group_id,app_name FROM ( "
+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id LIMIT " + context.getPageSize()
+ " offset " + context.getStartRow() + " )"
+ " g, config_info t WHERE g.id = t.id ";
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID)));
}

@Override
public MapperResult findAllConfigInfoBaseFetchRows(MapperContext context) {
String sql = "SELECT t.id,data_id,group_id,content,md5"
+ " FROM ( SELECT id FROM config_info ORDER BY id LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
+ " FROM ( SELECT id FROM config_info ORDER BY id LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow() + " )" + " g, config_info t WHERE g.id = t.id ";
return new MapperResult(sql, Collections.emptyList());
}

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

Expand Down Expand Up @@ -111,15 +114,15 @@ public MapperResult findChangeConfigFetchRows(MapperContext context) {
}
return new MapperResult(
sqlFetchRows + where + " AND id > " + context.getWhereParameter(FieldConstant.LAST_MAX_ID)
+ " ORDER BY id ASC" + " LIMIT " + 0 + "," + context.getPageSize(),
+ " ORDER BY id ASC" + " LIMIT " + context.getPageSize(),
paramList);
}

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

Expand All @@ -146,8 +149,8 @@ public MapperResult findConfigInfoBaseLikeFetchRows(MapperContext context) {
where += " AND content LIKE ? ";
paramList.add(content);
}
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow(), paramList);
}

@Override
Expand Down Expand Up @@ -180,14 +183,14 @@ public MapperResult findConfigInfo4PageFetchRows(MapperContext context) {
where.append(" AND content LIKE ? ");
paramList.add(content);
}
return new MapperResult(sql + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow(), paramList);
}

@Override
public MapperResult findConfigInfoBaseByGroupFetchRows(MapperContext context) {
String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=?" + " LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
+ context.getPageSize() + " offset " + context.getStartRow();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.GROUP_ID),
context.getWhereParameter(FieldConstant.TENANT_ID)));
}
Expand Down Expand Up @@ -224,22 +227,24 @@ public MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) {
where.append(" AND content LIKE ? ");
paramList.add(content);
}
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow(), paramList);
}

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

@Override
public String getDataSource() {
return DataSourceConstant.KINGBASE;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class ConfigInfoTagMapperByKingbase extends KingbaseAbstractMapper implem
@Override
public MapperResult findAllConfigInfoTagForDumpAllFetchRows(MapperContext context) {
String sql = " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " ) " + "g, config_info_tag t WHERE g.id = t.id ";
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT " + context.getPageSize() + " offset "
+ context.getStartRow() + " ) " + "g, config_info_tag t WHERE g.id = t.id ";
return new MapperResult(sql, Collections.emptyList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public MapperResult findConfigInfo4PageCountRows(MapperContext context) {
paramList.add(tagArr[i]);
}
where.append(") ");
return new MapperResult(sql + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
return new MapperResult(sql + where + " LIMIT " + context.getPageSize() + " offset " + context.getStartRow(),
paramList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MapperResult removeConfigHistory(MapperContext context) {
public MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {
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 "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
+ context.getPageSize() + " offset " + context.getStartRow();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
context.getWhereParameter(FieldConstant.GROUP_ID), context.getWhereParameter(FieldConstant.TENANT_ID)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,4 @@ public String count(List<String> where) {
return sql.toString();
}

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

}

0 comments on commit 4768f26

Please sign in to comment.