Skip to content

SET clause with alias not parsed #1314

Description

@rptr

Describe the bug

I found this query in the MySQL 8.0 Reference Manual page 2678

To Reproduce
1. INSERT INTO t1 SET a=1,b=2,c=3 AS new(m,n,p) ON DUPLICATE KEY UPDATE c = m+n;
2. CCJSqlParserUtil.parse(query)
3. Exception:

net.sf.jsqlparser.JSQLParserException
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:65)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:40)
	Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "AS" "AS"
    at line 1, column 32.
    Was expecting one of:
    "&"
    ","
    "::"
    ";"
    "<<"
    ">>"
    "COLLATE"
    "ON"
    "RETURNING"
    "["
    "^"
    "|"
    <EOF>

Expected behavior
I expected example queries from the MySQL manual to be parsed correctly.

System

  • MySQL
  • Java 8 (OpenJDK)
  • JSqlParser 4.1

Activity

  1. manticore-projects commented on Aug 26, 2021

    @manticore-projects
    Contributor

    Greetings.

    the as new(m, n, p,) is MySQL specific and not supported.
    Please see the allowed/understood syntax here: http://217.160.215.75:8080/jsqlformatter/_static/railroad_diagram.xhtml#Update

  2. minleejae commented on Sep 7, 2026

    @minleejae
    Contributor

    @manticore-projects I retested the exact statement from this issue on master 6c726d88, and it now parses and round-trips successfully:

    INSERT INTO t1 SET a=1,b=2,c=3 AS new(m,n,p)
    ON DUPLICATE KEY UPDATE c = m+n;

    Row-alias support was added in #2383. The resulting Insert has three SET assignments, getRowAlias().getName() == "new", alias columns m, n, p, and one duplicate-key update assignment. Both toString() and StatementDeParser preserve the alias and update expression, and their output reparses with the same fields.

    I checked default parsing and withUnsupportedStatements(false). Related regression coverage is in InsertTest's row-alias and SET/deparser tests, and the full Gradle check passed.

    This appears resolved for the reported syntax. Could you consider closing it if there are no remaining failing examples on master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions