summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakefeasel <jfeasel@gmail.com>2013-02-16 14:05:56 -0800
committerjakefeasel <jfeasel@gmail.com>2013-02-16 14:05:56 -0800
commit7eb55832281e01a6333ba44195ea7478bc879881 (patch)
treec5672846715d9204478f3c1f402f0c70f5a4a55c
parent37c8a19c839e19b8ed5da1e577b4bce131408a79 (diff)
downloadsqlfiddle-7eb55832281e01a6333ba44195ea7478bc879881.zip
sqlfiddle-7eb55832281e01a6333ba44195ea7478bc879881.tar.gz
sqlfiddle-7eb55832281e01a6333ba44195ea7478bc879881.tar.bz2
Fixing PostgreSQL explicit commits using deferred constraints
https://github.com/jakefeasel/sqlfiddle/issues/61
-rw-r--r--src/main/webapp/models/Query.cfc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/webapp/models/Query.cfc b/src/main/webapp/models/Query.cfc
index 2607eea..388eb41 100644
--- a/src/main/webapp/models/Query.cfc
+++ b/src/main/webapp/models/Query.cfc
@@ -44,13 +44,12 @@
<cfset sqlBatchList = REReplaceNoCase(sqlBatchList, "#escaped_separator#\s*(\r?\n|$)", "#chr(7)#", "all")>
- <cfif this.schema_def.db_type.simple_name IS "Oracle">
- <cfset local.deferred_table = "DEFERRED_#this.schema_def.db_type_id#_#this.schema_def.short_code#">
- <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#">
- INSERT INTO system.#local.deferred_table# VALUES (2)
- </cfquery>
- </cfif>
-
+ <cfif ListFind("Oracle,PostgreSQL",this.schema_def.db_type.simple_name)>
+ <cfset local.deferred_table = "DEFERRED_#this.schema_def.db_type_id#_#this.schema_def.short_code#">
+ <cfquery datasource="#this.schema_def.db_type_id#_#this.schema_def.short_code#">
+ INSERT INTO <cfif this.schema_def.db_type.simple_name IS "Oracle">system.</cfif>#local.deferred_table# VALUES (2)
+ </cfquery>
+ </cfif>
<cftry>
<cfloop list="#sqlBatchList#" index="statement" delimiters="#chr(7)#">
@@ -217,6 +216,14 @@
})>
<cfelseif this.schema_def.db_type.simple_name IS "PostgreSQL" AND
+ REFindNoCase("insert or update on table ""#local.deferred_table#"" violates foreign key constraint ""#local.deferred_table#_ref""", cfcatch.message)>
+
+ <cfset ArrayAppend(returnVal["sets"], {
+ succeeded = false,
+ errorMessage = "Explicit commits are not allowed within the query panel."
+ })>
+
+ <cfelseif this.schema_def.db_type.simple_name IS "PostgreSQL" AND
REFindNoCase("current transaction is aborted, commands ignored until end of transaction block$", cfcatch.message)>
<!--- The last query statement produced an error, but the real error was hidden by PostgreSQL