1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/usql/UQ_PARSE2.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,75 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// TSqlParser2 class. "DBMS Security" related - full support.
1.18 +//
1.19 +//
1.20 +
1.21 +#include "UQ_STD.H"
1.22 +
1.23 +/**
1.24 +This method is used to extract the table name from a particular sql
1.25 +string - aTableName parameter. Also, the function determines the sql string type -
1.26 +Sql::EDDL, Sql::EDML or Sql::ENone (SELECT sql string).
1.27 +*/
1.28 +void TSqlParser2::ParseL(const TDesC& aSql)
1.29 + {
1.30 + TSqlParser sqlParser(aSql);
1.31 + iStatementType = sqlParser.Type();
1.32 + iTableName.Set(NULL, 0);
1.33 + switch(iStatementType)
1.34 + {
1.35 + case Sql::ENone:
1.36 + //It may be a "SELECT" statement. Check the sql and get the table name.
1.37 + if(sqlParser.ParseL(ESqlKeyword_select) == ESqlAsterisk)
1.38 + {
1.39 + sqlParser.NextToken();
1.40 + }
1.41 + else
1.42 + {
1.43 + for(;;)
1.44 + {
1.45 + TSqlTokenType t = sqlParser.NextToken();
1.46 + if(t != ESqlComma)
1.47 + break;
1.48 + sqlParser.NextToken();
1.49 + }
1.50 + }
1.51 + sqlParser.ParseL(ESqlKeyword_from);
1.52 + sqlParser.IdentifierL(iTableName);
1.53 + break;
1.54 + case Sql::EDDL:
1.55 + //CREATE/DROP/ALTER statement. There is a table name, but we do not need it.
1.56 + //The caller has to have "SCHEMA" access level, so we do not bother with the table name.
1.57 + break;
1.58 + case Sql::EDML:
1.59 + //INSERT/UPDATE/DELETE statement. Get the table name.
1.60 + if(sqlParser.Parse(ESqlKeyword_insert))
1.61 + {
1.62 + sqlParser.ParseL(ESqlKeyword_into);
1.63 + }
1.64 + else if(sqlParser.Parse(ESqlKeyword_update))
1.65 + {
1.66 + }
1.67 + else
1.68 + {
1.69 + sqlParser.ParseL(ESqlKeyword_delete);
1.70 + sqlParser.ParseL(ESqlKeyword_from);
1.71 + }
1.72 + sqlParser.IdentifierL(iTableName);
1.73 + break;
1.74 + default:
1.75 + __ASSERT(EFalse);
1.76 + break;
1.77 + }
1.78 + }