@@ -129,7 +129,6 @@ public AbstractParser<T> setRequest(JSONObject request) {
129129 }
130130
131131
132- protected Verifier <T > verifier ;
133132 protected RequestRole globleRole ;
134133 public AbstractParser <T > setGlobleRole (RequestRole globleRole ) {
135134 this .globleRole = globleRole ;
@@ -199,9 +198,18 @@ public AbstractParser<T> setNoVerifyContent(boolean noVerifyContent) {
199198
200199
201200 protected SQLExecutor sqlExecutor ;
201+ protected Verifier <T > verifier ;
202202 protected Map <String , Object > queryResultMap ;//path-result
203203
204-
204+ @ Override
205+ public SQLExecutor getSQLExecutor () {
206+ return sqlExecutor ;
207+ }
208+ @ Override
209+ public Verifier <T > getVerifier () {
210+ return verifier ;
211+ }
212+
205213 /**解析请求json并获取对应结果
206214 * @param request
207215 * @return
@@ -240,7 +248,6 @@ public JSONObject parseResponse(String request) {
240248 }
241249
242250 private int queryDepth ;
243- private int sqlCount ;
244251
245252 /**解析请求json并获取对应结果
246253 * @param request
@@ -301,19 +308,22 @@ public JSONObject parseResponse(JSONObject request) {
301308 sqlExecutor = createSQLExecutor ();
302309 try {
303310 queryDepth = 0 ;
304- sqlCount = 0 ;
305311 requestObject = onObjectParse (request , null , null , null , false );
306312 } catch (Exception e ) {
307313 e .printStackTrace ();
308314 error = e ;
309315 }
310- sqlExecutor .close ();
311- sqlExecutor = null ;
312-
313316
314317 requestObject = error == null ? extendSuccessResult (requestObject ) : extendErrorResult (requestObject , error );
315318
316-
319+ if (Log .DEBUG ) {
320+ requestObject .put ("query:depth/max" , queryDepth + "/" + getMaxQueryDepth ());
321+ requestObject .put ("sql:generate/cache/execute/maxExecute" , sqlExecutor .getGeneratedSQLCount () + "/" + sqlExecutor .getCachedSQLCount () + "/" + sqlExecutor .getExecutedSQLCount () + "/" + getMaxSQLCount ());
322+ }
323+
324+ sqlExecutor .close ();
325+ sqlExecutor = null ;
326+
317327 queryResultMap .clear ();
318328
319329 //会不会导致原来的session = null? session = null;
@@ -329,11 +339,6 @@ public JSONObject parseResponse(JSONObject request) {
329339 Log .d (TAG , "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime )
330340 + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n \n \n " );
331341
332- if (Log .DEBUG ) {
333- requestObject .put ("query:depth/max" , queryDepth + "/" + getMaxQueryDepth ());
334- requestObject .put ("sql:count/max" , sqlCount + "/" + getMaxSQLCount ());
335- }
336-
337342 return globleFormat && JSONResponse .isSuccess (requestObject ) ? new JSONResponse (requestObject ) : requestObject ;
338343 }
339344
@@ -1274,28 +1279,37 @@ public static JSONObject getJSONObject(JSONObject object, String key) {
12741279 * @throws Exception
12751280 */
12761281 @ Override
1277- public synchronized JSONObject executeSQL (@ NotNull SQLConfig config , boolean isSubquery ) throws Exception {
1282+ public JSONObject executeSQL (SQLConfig config , boolean isSubquery ) throws Exception {
1283+ if (config == null ) {
1284+ Log .d (TAG , "executeSQL config == null >> return null;" );
1285+ return null ;
1286+ }
1287+
12781288 if (isSubquery ) {
12791289 JSONObject sqlObj = new JSONObject (true );
12801290 sqlObj .put (KEY_CONFIG , config );
12811291 return sqlObj ;//容易丢失信息 JSON.parseObject(config);
12821292 }
12831293
1284- sqlCount += 1 ;//config.isMain() ? 1 : 0;
1285- int maxSQLCount = getMaxSQLCount ();
1286- Log .d (TAG , "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< \n \n \n 已生成 " + sqlCount + "/" + maxSQLCount + "条 SQL \n \n \n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
1287- if (sqlCount > maxSQLCount ) {
1288- throw new IllegalArgumentException ("截至 " + config .getTable () + " 已生成 " + sqlCount + "条 SQL,数量已超限,必须在 0-" + maxSQLCount + " 内 !" );
1289- }
1290-
12911294 try {
12921295 return parseCorrectResponse (config .getTable (), sqlExecutor .execute (config , false ));
1293- } catch (Exception e ) {
1296+ }
1297+ catch (Exception e ) {
12941298 if (Log .DEBUG == false && e instanceof SQLException ) {
12951299 throw new SQLException ("数据库驱动执行异常SQLException,非 Log.DEBUG 模式下不显示详情,避免泄漏真实模式名、表名等隐私信息" , e );
12961300 }
12971301 throw e ;
12981302 }
1303+ finally {
1304+ if (config .getPosition () == 0 ) {
1305+ int maxSQLCount = getMaxSQLCount ();
1306+ int sqlCount = sqlExecutor .getExecutedSQLCount ();
1307+ Log .d (TAG , "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< \n \n \n 已执行 " + sqlCount + "/" + maxSQLCount + " 条 SQL \n \n \n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
1308+ if (sqlCount > maxSQLCount ) {
1309+ throw new IllegalArgumentException ("截至 " + config .getTable () + " 已执行 " + sqlCount + " 条 SQL,数量已超限,必须在 0-" + maxSQLCount + " 内 !" );
1310+ }
1311+ }
1312+ }
12991313 }
13001314
13011315
0 commit comments