|
85 | 85 | import net.sf.jsqlparser.statement.create.usermapping.CreateUserMapping; |
86 | 86 | import net.sf.jsqlparser.statement.create.view.AlterView; |
87 | 87 | import net.sf.jsqlparser.statement.create.view.CreateView; |
| 88 | +import net.sf.jsqlparser.statement.cursor.CloseCursorStatement; |
| 89 | +import net.sf.jsqlparser.statement.cursor.DeclareCursorStatement; |
| 90 | +import net.sf.jsqlparser.statement.cursor.FetchCursorStatement; |
88 | 91 | import net.sf.jsqlparser.statement.delete.Delete; |
89 | 92 | import net.sf.jsqlparser.statement.drop.Drop; |
90 | 93 | import net.sf.jsqlparser.statement.drop.DropPolicy; |
@@ -1083,6 +1086,33 @@ public <S> Void visit(DiscardStatement discard, S context) { |
1083 | 1086 | return null; |
1084 | 1087 | } |
1085 | 1088 |
|
| 1089 | + @Override |
| 1090 | + public <S> Void visit(DeclareCursorStatement declareCursor, S context) { |
| 1091 | + // opens a cursor of the session over its query, which reads as the cursor is fetched |
| 1092 | + analysis.claimTopLevel(); |
| 1093 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1094 | + if (declareCursor.getQuery() != null) { |
| 1095 | + declareCursor.getQuery().accept(analysis.selects, context); |
| 1096 | + } |
| 1097 | + return null; |
| 1098 | + } |
| 1099 | + |
| 1100 | + @Override |
| 1101 | + public <S> Void visit(FetchCursorStatement fetchCursor, S context) { |
| 1102 | + // moves the cursor and runs its query that far; only FETCH returns the rows |
| 1103 | + if (analysis.claimTopLevel() && fetchCursor.getKind() == FetchCursorStatement.Kind.FETCH) { |
| 1104 | + analysis.certain(StmtFeature.RETURNS_RESULT_SET); |
| 1105 | + } |
| 1106 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1107 | + analysis.possible(StmtFeature.READS_DATA); |
| 1108 | + return null; |
| 1109 | + } |
| 1110 | + |
| 1111 | + @Override |
| 1112 | + public <S> Void visit(CloseCursorStatement closeCursor, S context) { |
| 1113 | + return sessionOnly(); |
| 1114 | + } |
| 1115 | + |
1086 | 1116 | @Override |
1087 | 1117 | public <S> Void visit(AlterSystemStatement alterSystemStatement, S context) { |
1088 | 1118 | analysis.claimTopLevel(); |
|
0 commit comments