diff options
author | jakefeasel <jfeasel@gmail.com> | 2012-12-09 09:21:50 -0800 |
---|---|---|
committer | jakefeasel <jfeasel@gmail.com> | 2012-12-09 09:21:50 -0800 |
commit | a1a4009dcfbcd461127cdc5c7d2c2a15774ee8e3 (patch) | |
tree | f7d9fbef89acd6ab0f82566cf07bf672eb284aa1 | |
parent | 05913b457e43c4e348e81c3301a3a120b5ae19fc (diff) | |
download | sqlfiddle-a1a4009dcfbcd461127cdc5c7d2c2a15774ee8e3.zip sqlfiddle-a1a4009dcfbcd461127cdc5c7d2c2a15774ee8e3.tar.gz sqlfiddle-a1a4009dcfbcd461127cdc5c7d2c2a15774ee8e3.tar.bz2 |
Fixing https://github.com/jakefeasel/sqlfiddle/issues/56
Using savepoints before and after attempting to get the execution plan,
in order to preserve the integrity of the transaction. Using "explain"
with DDL would break the transaction.
-rw-r--r-- | src/main/webapp/models/Query.cfc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/webapp/models/Query.cfc b/src/main/webapp/models/Query.cfc index 6c1ad05..244fdd1 100644 --- a/src/main/webapp/models/Query.cfc +++ b/src/main/webapp/models/Query.cfc @@ -80,17 +80,34 @@ <cfset local.executionPlanBatchList = local.executionPlanSQL> </cfif> + <cfif this.schema_def.db_type.simple_name IS "PostgreSQL"> + <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#" name="savepoint"> + SAVEPOINT sp; + </cfquery> + </cfif> <cfloop list="#local.executionPlanBatchList#" index="executionPlanStatement" delimiters="#chr(7)#"> <cftry> <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#" name="executionPlan">#PreserveSingleQuotes(executionPlanStatement)#</cfquery> <cfcatch> + <cfif this.schema_def.db_type.simple_name IS "PostgreSQL"> + <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#" name="savepoint"> + ROLLBACK TO sp; + </cfquery> + </cfif> + <!--- execution plan failed! Oh well, carry on.... ---> <cfset local.executionPlan = QueryNew("")> </cfcatch> - </cftry> + </cftry> </cfloop> + + <cfif this.schema_def.db_type.simple_name IS "PostgreSQL" AND local.executionPlan.recordCount> + <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#" name="savepoint"> + RELEASE SAVEPOINT sp; + </cfquery> + </cfif> <cfset local.executionPlanRaw = Duplicate(local.executionPlan)> |