|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TSqlParser2 class. "DBMS Security" related - full support. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "UQ_STD.H" |
|
19 |
|
20 /** |
|
21 This method is used to extract the table name from a particular sql |
|
22 string - aTableName parameter. Also, the function determines the sql string type - |
|
23 Sql::EDDL, Sql::EDML or Sql::ENone (SELECT sql string). |
|
24 */ |
|
25 void TSqlParser2::ParseL(const TDesC& aSql) |
|
26 { |
|
27 TSqlParser sqlParser(aSql); |
|
28 iStatementType = sqlParser.Type(); |
|
29 iTableName.Set(NULL, 0); |
|
30 switch(iStatementType) |
|
31 { |
|
32 case Sql::ENone: |
|
33 //It may be a "SELECT" statement. Check the sql and get the table name. |
|
34 if(sqlParser.ParseL(ESqlKeyword_select) == ESqlAsterisk) |
|
35 { |
|
36 sqlParser.NextToken(); |
|
37 } |
|
38 else |
|
39 { |
|
40 for(;;) |
|
41 { |
|
42 TSqlTokenType t = sqlParser.NextToken(); |
|
43 if(t != ESqlComma) |
|
44 break; |
|
45 sqlParser.NextToken(); |
|
46 } |
|
47 } |
|
48 sqlParser.ParseL(ESqlKeyword_from); |
|
49 sqlParser.IdentifierL(iTableName); |
|
50 break; |
|
51 case Sql::EDDL: |
|
52 //CREATE/DROP/ALTER statement. There is a table name, but we do not need it. |
|
53 //The caller has to have "SCHEMA" access level, so we do not bother with the table name. |
|
54 break; |
|
55 case Sql::EDML: |
|
56 //INSERT/UPDATE/DELETE statement. Get the table name. |
|
57 if(sqlParser.Parse(ESqlKeyword_insert)) |
|
58 { |
|
59 sqlParser.ParseL(ESqlKeyword_into); |
|
60 } |
|
61 else if(sqlParser.Parse(ESqlKeyword_update)) |
|
62 { |
|
63 } |
|
64 else |
|
65 { |
|
66 sqlParser.ParseL(ESqlKeyword_delete); |
|
67 sqlParser.ParseL(ESqlKeyword_from); |
|
68 } |
|
69 sqlParser.IdentifierL(iTableName); |
|
70 break; |
|
71 default: |
|
72 __ASSERT(EFalse); |
|
73 break; |
|
74 } |
|
75 } |