diff --git a/sql-old.py b/sql-new.py
index b58d89f..a176277 100644
--- a/sql-old.py
+++ b/sql-new.py
@@ -155,12 +155,18 @@ def _split_statements(content):
     comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$")
     statements = []
     statement = []
+    infunction = False
     for line in content.split("\n"):
         cleaned_line = comment_re.sub(r"\1", line).strip()
+         
         if not cleaned_line:
             continue
         statement.append(cleaned_line)
-        if cleaned_line.endswith(";"):
+        if cleaned_line.startswith("CREATE"):
+             infunction=True
+        if "LANGUAGE" in cleaned_line:
+             infunction=False   
+        if cleaned_line.endswith(";") and not infunction:
             statements.append(" ".join(statement))
             statement = []
     return statements
@@ -214,3 +220,4 @@ def emit_post_sync_signal(created_models, verbosity, interactive, db):
         models.signals.post_syncdb.send(sender=app, app=app,
             created_models=created_models, verbosity=verbosity,
             interactive=interactive, db=db)
+
