Problem into the SqlSplitter class when i'm using SQL statements including 
simple and double quotes which are not opened and closed in the same line.
-----------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: MSQL-63
                 URL: http://jira.codehaus.org/browse/MSQL-63
             Project: Maven 2.x SQL Plugin
          Issue Type: Bug
            Reporter: Mickael BARON


I detect problem into the SqlSplitter class when i'm using SQL statements 
including simple and double quotes which are not opened and closed in the same 
line.
For instance, the following SQL statements are used to create a function.

{code}
CREATE FUNCTION add_rid_oid(bigint, character varying) RETURNS boolean
    AS $_$
DECLARE
 Rid    ALIAS FOR $1;
 Oid    ALIAS FOR $2;
 tuple  RECORD;
 requete VARCHAR;
 ok     INT4;
BEGIN
requete='INSERT INTO rid_oid(rid,oids)
         VALUE('||quote_literal(rid)||',' 
         ||quote_literal(Oid)||')';
EXECUTE requete;
{code}

A opened simple quote is found (requete='INSERT ...). Thus, the containsSqlEnd 
method into the SqlSplitter class is looping in infinite way because no closed 
simple quote is found in the same line.

{code}
do {
 if ( line.startsWith( quoteEscape, pos )) {
  pos += 2;
 }
} while ( !line.startsWith( quoteChar, pos++ ) );
{code}

I propose to modify the previous code by this one

{code}
do {
 if (pos > line.length()) {
  return NO_END;
 }
 if ( line.startsWith( quoteEscape, pos ) ) {
  pos += 2;
 }
} while ( !line.startsWith( quoteChar, pos++ ) );
{code}
                        
Mickael


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to