@@ -125,6 +125,10 @@ func (p *Parser) parseStatement() ast.Statement {
125125 case token .DROP :
126126 return p .parseDrop ()
127127 case token .ALTER :
128+ // Check for ALTER USER
129+ if p .peekIs (token .USER ) {
130+ return p .parseAlterUser ()
131+ }
128132 return p .parseAlter ()
129133 case token .TRUNCATE :
130134 return p .parseTruncate ()
@@ -1809,10 +1813,44 @@ func (p *Parser) parseCreateUser(create *ast.CreateQuery) {
18091813 // Parse user name
18101814 create .UserName = p .parseIdentifierName ()
18111815
1816+ // Look for authentication data (NOT IDENTIFIED or IDENTIFIED)
1817+ // Scan through tokens looking for these keywords
1818+ for ! p .currentIs (token .EOF ) && ! p .currentIs (token .SEMICOLON ) {
1819+ // Check for NOT IDENTIFIED
1820+ if p .currentIs (token .NOT ) {
1821+ p .nextToken ()
1822+ if p .currentIs (token .IDENT ) && strings .ToUpper (p .current .Value ) == "IDENTIFIED" {
1823+ create .HasAuthenticationData = true
1824+ }
1825+ continue
1826+ }
1827+ // Check for IDENTIFIED (without NOT)
1828+ if p .currentIs (token .IDENT ) && strings .ToUpper (p .current .Value ) == "IDENTIFIED" {
1829+ create .HasAuthenticationData = true
1830+ }
1831+ p .nextToken ()
1832+ }
1833+ }
1834+
1835+ func (p * Parser ) parseAlterUser () * ast.CreateQuery {
1836+ create := & ast.CreateQuery {
1837+ Position : p .current .Pos ,
1838+ CreateUser : true ,
1839+ AlterUser : true ,
1840+ }
1841+
1842+ p .nextToken () // skip ALTER
1843+ p .nextToken () // skip USER
1844+
1845+ // Parse user name
1846+ create .UserName = p .parseIdentifierName ()
1847+
18121848 // Skip the rest of the user definition (complex syntax)
18131849 for ! p .currentIs (token .EOF ) && ! p .currentIs (token .SEMICOLON ) {
18141850 p .nextToken ()
18151851 }
1852+
1853+ return create
18161854}
18171855
18181856func (p * Parser ) parseCreateGeneric (create * ast.CreateQuery ) {
@@ -3309,6 +3347,13 @@ func (p *Parser) parseShow() ast.Statement {
33093347 } else if p .currentIs (token .IDENT ) && strings .ToUpper (p .current .Value ) == "VIEW" {
33103348 show .ShowType = ast .ShowCreateView
33113349 p .nextToken ()
3350+ } else if p .currentIs (token .USER ) {
3351+ show .ShowType = ast .ShowCreateUser
3352+ p .nextToken ()
3353+ // Skip user name and host pattern - they don't affect explain output
3354+ for ! p .currentIs (token .EOF ) && ! p .currentIs (token .SEMICOLON ) {
3355+ p .nextToken ()
3356+ }
33123357 } else {
33133358 show .ShowType = ast .ShowCreate
33143359 // Handle SHOW CREATE TABLE, etc.
0 commit comments