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