ASF Bugzilla – Attachment 12700 Details for
Bug 30760
sql task handle pl/sql with ';' in pl/sql code. (patch)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
diff of original 1.6.2 code and new patch
SQLExec.java.diff (text/plain), 4.82 KB, created by
Eric Van
on 2004-09-10 18:31:31 UTC
(
hide
)
Description:
diff of original 1.6.2 code and new patch
Filename:
MIME Type:
Creator:
Eric Van
Created:
2004-09-10 18:31:31 UTC
Size:
4.82 KB
patch
obsolete
>*** SQLExec.java.original Thu Aug 19 10:56:21 2004 >--- SQLExec.java Fri Sep 10 10:13:47 2004 >*************** >*** 74,79 **** >--- 74,85 ---- > */ > public class SQLExec extends JDBCTask { > >+ private static final String BEGIN = "BEGIN"; >+ private static final String END = "END"; >+ >+ private boolean inBlockStatement; >+ private int blockDepth; >+ > /** > * delimiters we support, "normal" and "row" > */ >*************** >*** 429,450 **** > BufferedReader in = new BufferedReader(reader); > > while ((line = in.readLine()) != null) { > if (!keepformat) { > line = line.trim(); > } > line = getProject().replaceProperties(line); >- if (!keepformat) { > if (line.startsWith("//")) { > continue; > } > if (line.startsWith("--")) { > continue; > } > StringTokenizer st = new StringTokenizer(line); > if (st.hasMoreTokens()) { > String token = st.nextToken(); > if ("REM".equalsIgnoreCase(token)) { > continue; > } > } > } >--- 435,470 ---- > BufferedReader in = new BufferedReader(reader); > > while ((line = in.readLine()) != null) { >+ // flag whether the current line is a comment >+ // or not. >+ boolean isComment = false; >+ > if (!keepformat) { > line = line.trim(); > } > line = getProject().replaceProperties(line); > if (line.startsWith("//")) { >+ if (!keepformat) { > continue; >+ }else{ >+ isComment = true; >+ } > } > if (line.startsWith("--")) { >+ if (!keepformat) { > continue; >+ }else{ >+ isComment = true; >+ } > } > StringTokenizer st = new StringTokenizer(line); > if (st.hasMoreTokens()) { > String token = st.nextToken(); > if ("REM".equalsIgnoreCase(token)) { >+ if (!keepformat) { > continue; >+ }else{ >+ isComment = true; > } > } > } >*************** >*** 463,470 **** > sql.append("\n"); > } > } > if ((delimiterType.equals(DelimiterType.NORMAL) >! && sql.toString().endsWith(delimiter)) > || > (delimiterType.equals(DelimiterType.ROW) > && line.equals(delimiter))) { >--- 483,497 ---- > sql.append("\n"); > } > } >+ >+ // determine if a block statement has started or ended. >+ if(!isComment){ >+ containsBlockStatement(line); >+ } >+ > if ((delimiterType.equals(DelimiterType.NORMAL) >! && sql.toString().endsWith(delimiter) >! && !inBlockStatement) > || > (delimiterType.equals(DelimiterType.ROW) > && line.equals(delimiter))) { >*************** >*** 479,484 **** >--- 506,548 ---- > } > } > >+ /** >+ * Determines if the supplied line starts or ends >+ * a block statement. >+ * <p/> >+ * The start of a block statement is considered to be >+ * a line that trims to "BEGIN" or "BEGIN" + delimiter (case insensitive) >+ * <br/> >+ * The end of a block statement is considered to be >+ * a line that trims to "END" or "END" + delimiter (case insensitive) >+ * >+ * @param line The line to test. >+ */ >+ protected void containsBlockStatement (String line) >+ { >+ if(line != null && line.trim().length() > 0){ >+ // trim the line and remove all spaces to simplify string compare. >+ String ln = line.trim().replaceAll("\\s\\+", ""); >+ if(ln.equalsIgnoreCase(BEGIN) || ln.equalsIgnoreCase(BEGIN + delimiter)){ >+ // if a new block is beginning then increment the depth. >+ if(inBlockStatement){ >+ blockDepth++; >+ }else{ >+ inBlockStatement = true; >+ } >+ } >+ if(ln.equalsIgnoreCase(END) || ln.equalsIgnoreCase(END + delimiter)){ >+ // this end statement is in an outer block, so decrement the depth >+ // and continue in the outer block. >+ if(blockDepth > 0){ >+ blockDepth--; >+ }else{ >+ inBlockStatement = false; >+ } >+ } >+ } >+ } >+ > > /** > * Exec the sql statement.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 30760
:
12491
| 12700