@@ -7,10 +7,13 @@ type Query struct {
77}
88
99type QueryTree struct {
10- Queries []Query
11- ShowTables uint
12- ShowColumns []string
13- Quit bool
10+ Queries []Query
11+
12+ ShowTables uint
13+ ShowColumns []string
14+ ShowCreateTables []string
15+
16+ Quit bool
1417}
1518
1619type QueryParser struct {
@@ -47,6 +50,10 @@ func (q *QueryParser) ParseStart(p *Parser) parseState {
4750 return q .parseShowColumns
4851 }
4952
53+ if isOfAny (c , TIntpShowCreateTable ) {
54+ return q .parseShowCreateTable
55+ }
56+
5057 if isOfAny (c , TIntpQuit ) {
5158 return q .parseQuit
5259 }
@@ -107,7 +114,7 @@ func (q *QueryParser) parseShowColumns(p *Parser) parseState {
107114 return nil
108115 }
109116 if ! isOfAny (y , TIdentifier ) {
110- p .errorUnexpectedLex (x , TIdentifier )
117+ p .errorUnexpectedLex (y , TIdentifier )
111118 return nil
112119 }
113120
@@ -116,6 +123,22 @@ func (q *QueryParser) parseShowColumns(p *Parser) parseState {
116123 return q .ParseStart
117124}
118125
126+ func (q * QueryParser ) parseShowCreateTable (p * Parser ) parseState {
127+ y , ok := p .scan ()
128+ if ! ok {
129+ p .errorUnexpectedEOF ()
130+ return nil
131+ }
132+ if ! isOfAny (y , TIdentifier ) {
133+ p .errorUnexpectedLex (y , TIdentifier )
134+ return nil
135+ }
136+
137+ q .Tree .ShowCreateTables = append (q .Tree .ShowCreateTables , identValue (y ))
138+
139+ return q .ParseStart
140+ }
141+
119142func (q * QueryParser ) parseSelect (p * Parser ) parseState {
120143 qry := & Query {
121144 Columns : make ([]string , 0 ),
0 commit comments