|
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; |
@@ -1019,6 +1022,33 @@ public <S> Void visit(DiscardStatement discard, S context) { |
1019 | 1022 | return null; |
1020 | 1023 | } |
1021 | 1024 |
|
| 1025 | + @Override |
| 1026 | + public <S> Void visit(DeclareCursorStatement declareCursor, S context) { |
| 1027 | + // opens a cursor of the session over its query, which reads as the cursor is fetched |
| 1028 | + analysis.claimTopLevel(); |
| 1029 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1030 | + if (declareCursor.getQuery() != null) { |
| 1031 | + declareCursor.getQuery().accept(analysis.selects, context); |
| 1032 | + } |
| 1033 | + return null; |
| 1034 | + } |
| 1035 | + |
| 1036 | + @Override |
| 1037 | + public <S> Void visit(FetchCursorStatement fetchCursor, S context) { |
| 1038 | + // moves the cursor and runs its query that far; only FETCH returns the rows |
| 1039 | + if (analysis.claimTopLevel() && fetchCursor.getKind() == FetchCursorStatement.Kind.FETCH) { |
| 1040 | + analysis.certain(StmtFeature.RETURNS_RESULT_SET); |
| 1041 | + } |
| 1042 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1043 | + analysis.possible(StmtFeature.READS_DATA); |
| 1044 | + return null; |
| 1045 | + } |
| 1046 | + |
| 1047 | + @Override |
| 1048 | + public <S> Void visit(CloseCursorStatement closeCursor, S context) { |
| 1049 | + return sessionOnly(); |
| 1050 | + } |
| 1051 | + |
1022 | 1052 | @Override |
1023 | 1053 | public <S> Void visit(AlterSystemStatement alterSystemStatement, S context) { |
1024 | 1054 | analysis.claimTopLevel(); |
|
0 commit comments