Index: includes/sql_lexer.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sql_parser/includes/sql_lexer.inc,v
retrieving revision 1.15
diff -u -p -r1.15 sql_lexer.inc
--- includes/sql_lexer.inc	4 Sep 2010 19:11:05 -0000	1.15
+++ includes/sql_lexer.inc	6 Sep 2010 15:12:44 -0000
@@ -224,8 +224,8 @@ class SqlLexer {
           $c = $this->get();
 
           // End of string is reached.
-          if (is_NULL($c)) {
+          if (is_null($c)) {
             $state = 1000;
             break;
           }
 
@@ -596,6 +600,9 @@ class SqlLexer {
 
         // State 999 : Unknown token.  Revert to single char.
         case 999:
+          if (is_null($c)) {
+            return NULL;
+          }
           $this->revert();
           $this->get();
           $this->setToken();
Index: includes/sql_parser.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sql_parser/includes/sql_parser.inc,v
retrieving revision 1.16
diff -u -p -r1.16 sql_parser.inc
--- includes/sql_parser.inc	4 Sep 2010 19:11:05 -0000	1.16
+++ includes/sql_parser.inc	6 Sep 2010 15:12:44 -0000
@@ -679,9 +682,9 @@ class SqlParser {
       $sql_conditional->setArg2($this->parseSearchClause());
       $sql_conditional->setNot(FALSE);
     }
-    else {
+    elseif (!is_null($this->token)) {
       $this->lexer->unget();
     }
     return $sql_conditional;
   }
 
