Guest User

Untitled

a guest
Jul 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. diff -Naur ./src/henplus/commands/SQLCommand.java ../henplus-0.9.8-mresult/src/henplus/commands/SQLCommand.java
  2. --- ./src/henplus/commands/SQLCommand.java 2009-05-02 00:46:51.000000000 +1000
  3. +++ ../henplus-0.9.8-mresult/src/henplus/commands/SQLCommand.java 2010-09-09 16:19:00.056898424 +1000
  4. @@ -12,10 +12,10 @@
  5. import henplus.PropertyRegistry;
  6. import henplus.SQLSession;
  7. import henplus.SigIntHandler;
  8. -import henplus.property.PropertyHolder;
  9. import henplus.property.BooleanPropertyHolder;
  10. -import henplus.view.util.NameCompleter;
  11. +import henplus.property.PropertyHolder;
  12. import henplus.view.util.CancelWriter;
  13. +import henplus.view.util.NameCompleter;
  14.  
  15. import java.sql.ResultSet;
  16. import java.sql.Statement;
  17. @@ -39,6 +39,7 @@
  18. /**
  19. * returns the command-strings this command can handle.
  20. */
  21. +
  22. public String[] getCommandList() {
  23. return new String[] {
  24. // provide tab-completion at least for these command starts..
  25. @@ -92,6 +93,7 @@
  26. * don't show the commands available in the toplevel
  27. * command completion list ..
  28. */
  29. +
  30. public boolean participateInCommandCompletion() { return false; }
  31.  
  32. /**
  33. @@ -103,6 +105,7 @@
  34. * kind of statements complete with a single slash ('/') at the
  35. * beginning of a line.
  36. */
  37. +
  38. public boolean isComplete(String command) {
  39. command = command.toUpperCase(); // fixme: expensive.
  40. if (command.startsWith("COMMIT")
  41. @@ -168,6 +171,7 @@
  42. */
  43. private final class CurrentStatementCancelTarget
  44. implements StatementCanceller.CancelTarget {
  45. +
  46. public void cancelRunningStatement() {
  47. try {
  48. HenPlus.msg().println("cancel statement...");
  49. @@ -200,6 +204,7 @@
  50. /**
  51. * execute the command given.
  52. */
  53. +
  54. public int execute(SQLSession session, String cmd, String param) {
  55. String command = cmd + " " + param;
  56. //boolean background = false;
  57. @@ -214,7 +219,7 @@
  58. // background = true;
  59. // }
  60.  
  61. - final long startTime = System.currentTimeMillis();
  62. + long startTime = System.currentTimeMillis();
  63. long lapTime = -1;
  64. long execTime = -1;
  65. ResultSet rset = null;
  66. @@ -242,16 +247,17 @@
  67.  
  68. _statementCanceller.arm();
  69. _longRunningDisplay.arm();
  70. - final boolean hasResultSet = _stmt.execute(command);
  71. + _stmt.execute(command);
  72. _longRunningDisplay.disarm();
  73.  
  74. if (!_running) {
  75. HenPlus.msg().println("cancelled");
  76. return SUCCESS;
  77. }
  78. -
  79. - if (hasResultSet) {
  80. - rset = _stmt.getResultSet();
  81. + rset = _stmt.getResultSet();
  82. + boolean moreResults = true;
  83. + while(moreResults) {
  84. + if (rset != null) {
  85. ResultSetRenderer renderer;
  86. renderer = new ResultSetRenderer(rset,
  87. getColumnDelimiter(),
  88. @@ -294,6 +300,15 @@
  89. TimeRenderer.printTime(execTime, HenPlus.msg());
  90. }
  91. session.println(")");
  92. +
  93. + // check for more results
  94. + moreResults = ! ((_stmt.getMoreResults() == false) && (_stmt.getUpdateCount() == -1));
  95. + if (moreResults) {
  96. + rset = _stmt.getResultSet();
  97. + startTime = System.currentTimeMillis();
  98. + session.println("");
  99. + }
  100. + }
  101. }
  102.  
  103. // be smart and retrigger hashing of the tablenames.
  104. @@ -333,6 +348,7 @@
  105. // very simple completer: try to determine wether we can complete a
  106. // table name. that is: if some keyword has been found before, switch to
  107. // table-completer-mode :-)
  108. +
  109. public Iterator complete(CommandDispatcher disp,
  110. String partialCommand, final String lastWord)
  111. {
  112. @@ -496,10 +512,12 @@
  113. return result;
  114. }
  115.  
  116. +
  117. public void shutdown() {
  118. _statementCanceller.stopThread();
  119. }
  120.  
  121. +
  122. public String getSynopsis(String cmd) {
  123. cmd = cmd.toLowerCase();
  124. String syn = null;
  125. @@ -523,6 +541,7 @@
  126. return syn;
  127. }
  128.  
  129. +
  130. public String getLongDescription(String cmd) {
  131. String dsc;
  132. dsc="\t'" + cmd + "': this is not a build-in command, so would be\n"
  133. @@ -571,19 +590,23 @@
  134. super(SQLCommand.this.getColumnDelimiter());
  135. }
  136.  
  137. +
  138. protected String propertyChanged(String newValue) {
  139. SQLCommand.this.setColumnDelimiter(newValue);
  140. return newValue;
  141. }
  142.  
  143. +
  144. public String getShortDescription() {
  145. return "modify column separator in query results";
  146. }
  147.  
  148. +
  149. public String getDefaultValue() {
  150. return "|";
  151. }
  152.  
  153. +
  154. public String getLongDescription() {
  155. String dsc;
  156. dsc= "\tSet another string that is used to separate columns in\n"
  157. @@ -598,6 +621,7 @@
  158. super(String.valueOf(SQLCommand.this.getRowLimit()));
  159. }
  160.  
  161. +
  162. protected String propertyChanged(String newValue) throws Exception {
  163. newValue = newValue.trim();
  164. int newIntValue;
  165. @@ -615,10 +639,12 @@
  166. return newValue;
  167. }
  168.  
  169. +
  170. public String getDefaultValue() {
  171. return "2000";
  172. }
  173.  
  174. +
  175. public String getShortDescription() {
  176. return "set the maximum number of rows printed";
  177. }
  178. @@ -630,10 +656,12 @@
  179. super(true);
  180. }
  181.  
  182. +
  183. public void booleanPropertyChanged(boolean value){
  184. setShowHeader( value );
  185. }
  186.  
  187. +
  188. public String getDefaultValue() {
  189. return "on";
  190. }
  191. @@ -641,6 +669,7 @@
  192. /**
  193. * return a short descriptive string.
  194. */
  195. +
  196. public String getShortDescription() {
  197. return "switches if header in selected tables should be shown";
  198. }
  199. @@ -652,10 +681,12 @@
  200. super(true);
  201. }
  202.  
  203. +
  204. public void booleanPropertyChanged(boolean value){
  205. setShowFooter( value );
  206. }
  207.  
  208. +
  209. public String getDefaultValue() {
  210. return "on";
  211. }
  212. @@ -663,6 +694,7 @@
  213. /**
  214. * return a short descriptive string.
  215. */
  216. +
  217. public String getShortDescription() {
  218. return "switches if footer in selected tables should be shown";
  219. }
Add Comment
Please, Sign In to add comment