|
84 | 84 | import net.sf.jsqlparser.statement.create.usermapping.CreateUserMapping; |
85 | 85 | import net.sf.jsqlparser.statement.create.view.AlterView; |
86 | 86 | import net.sf.jsqlparser.statement.create.view.CreateView; |
| 87 | +import net.sf.jsqlparser.statement.cursor.CloseCursorStatement; |
| 88 | +import net.sf.jsqlparser.statement.cursor.DeclareCursorStatement; |
| 89 | +import net.sf.jsqlparser.statement.cursor.FetchCursorStatement; |
87 | 90 | import net.sf.jsqlparser.statement.delete.Delete; |
88 | 91 | import net.sf.jsqlparser.statement.drop.Drop; |
89 | 92 | import net.sf.jsqlparser.statement.drop.DropPolicy; |
@@ -981,6 +984,33 @@ public <S> Void visit(DeclareStatement declareStatement, S context) { |
981 | 984 | return sessionOnly(); |
982 | 985 | } |
983 | 986 |
|
| 987 | + @Override |
| 988 | + public <S> Void visit(DeclareCursorStatement declareCursor, S context) { |
| 989 | + // opens a cursor of the session over its query, which reads as the cursor is fetched |
| 990 | + analysis.claimTopLevel(); |
| 991 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 992 | + if (declareCursor.getQuery() != null) { |
| 993 | + declareCursor.getQuery().accept(analysis.selects, context); |
| 994 | + } |
| 995 | + return null; |
| 996 | + } |
| 997 | + |
| 998 | + @Override |
| 999 | + public <S> Void visit(FetchCursorStatement fetchCursor, S context) { |
| 1000 | + // moves the cursor and runs its query that far; only FETCH returns the rows |
| 1001 | + if (analysis.claimTopLevel() && fetchCursor.getKind() == FetchCursorStatement.Kind.FETCH) { |
| 1002 | + analysis.certain(StmtFeature.RETURNS_RESULT_SET); |
| 1003 | + } |
| 1004 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1005 | + analysis.possible(StmtFeature.READS_DATA); |
| 1006 | + return null; |
| 1007 | + } |
| 1008 | + |
| 1009 | + @Override |
| 1010 | + public <S> Void visit(CloseCursorStatement closeCursor, S context) { |
| 1011 | + return sessionOnly(); |
| 1012 | + } |
| 1013 | + |
984 | 1014 | @Override |
985 | 1015 | public <S> Void visit(AlterSystemStatement alterSystemStatement, S context) { |
986 | 1016 | analysis.claimTopLevel(); |
|
0 commit comments