namespace com::sun::star::sdbc { class XConnection; } namespace com::sun::star::beans { class XPropertySet; }
namespace connectivity
{ enumclass TraversalParts
{
Parameters = 0x0001,
TableNames = 0x0002,
SelectColumns = 0x0006, // note that this includes TableNames. No SelectColumns without TableNames
// Those are not implemented currently // GroupColumns = 0x0008, // OrderColumns = 0x0010, // SelectColumns = 0x0020, // CreateColumns = 0x0040,
class OSQLParseTreeIterator final
{ private:
std::optional<css::sdbc::SQLException> m_xErrors; // contains the error while iterating through the statement const OSQLParseNode* m_pParseTree; // current ParseTree const OSQLParser& m_rParser; // if set used for general error messages from the context
OSQLStatementType m_eStatementType;
::rtl::Reference<OSQLColumns> m_aSelectColumns; // all columns from the Select clause
::rtl::Reference<OSQLColumns> m_aParameters; // all parameters
::rtl::Reference<OSQLColumns> m_aGroupColumns; // the group by columns
::rtl::Reference<OSQLColumns> m_aOrderColumns; // the order by columns
::rtl::Reference<OSQLColumns> m_aCreateColumns; // the columns for Create table clause
const OSQLParseNode* getTableNode( OSQLTables& _rTables, const OSQLParseNode* pTableRef, OUString& aTableRange ); void getQualified_join( OSQLTables& _rTables, const OSQLParseNode *pTableRef, OUString& aTableRange ); void getSelect_statement(OSQLTables& _rTables,const OSQLParseNode* pSelect); // get all the column names of m_aSelectColumns and return in a vector sorted by a UStringMixLess that's constructed from // isCaseSensitive()
std::vector<OUString> getSelectColumnNames() const; // rColumnNames is expected to be sorted as returned by getSelectColumnNames
OUString getUniqueColumnName(const std::vector<OUString>& rColumnNames, const OUString & rColumnName) const;
/** finds the column with a given name, belonging to a given table, in a given tables collection @param_rTables thetablescollectiontolookin @paramrColumnName thecolumnnametolookfor @paramrTableRange thetablealiasname;ifempty,lookinalltables @return thedesiredcolumnobject,or<NULL/>ifnosuchcolumncouldbefound
*/ static css::uno::Reference< css::beans::XPropertySet > findColumn( const OSQLTables& _rTables, const OUString & rColumnName, OUString & rTableRange );
/** finds a column with a given name, belonging to a given table @paramrColumnName thecolumnnametolookfor @paramrTableRange thetablealiasname;ifempty,lookinalltables @param_bLookInSubTables <TRUE/>ifandonlyifnotonlyourdirecttables,butalsooursubtables(fromsubselects) shouldbesearched @return
*/
css::uno::Reference< css::beans::XPropertySet > findColumn( const OUString & rColumnName, OUString & rTableRange, bool _bLookInSubTables );
/** finds a column with a given name among the select columns @paramrColumnName thecolumnnametolookfor @return
*/
css::uno::Reference< css::beans::XPropertySet > findSelectColumn(
std::u16string_view rColumnName );
void setSelectColumnName(const OUString& rColumnName, const OUString& rColumnAlias, const OUString& rTableRange, bool bFkt = false, sal_Int32 _nType = css::sdbc::DataType::VARCHAR, bool bAggFkt = false); void appendColumns(const OUString& _rTableAlias, const OSQLTable& _rTable); // Other member variables that should be available in the "set" functions // can be defined in the derived class. They can be initialized // in its constructor and, after the "traverse" routines have been used, // they can be queried using other functions.
OOO_DLLPUBLIC_DBTOOLS void dispose();
OOO_DLLPUBLIC_DBTOOLS bool isCaseSensitive() const; // The parse tree to be analysed/traversed: // If NULL is passed, the current parse tree will be deleted and the error status cleared.
OOO_DLLPUBLIC_DBTOOLS void setParseTree(const OSQLParseNode * pNewParseTree); const OSQLParseNode * getParseTree() const { return m_pParseTree; };
// subtrees in case of a select statement
OOO_DLLPUBLIC_DBTOOLS const OSQLParseNode* getWhereTree() const;
OOO_DLLPUBLIC_DBTOOLS const OSQLParseNode* getOrderTree() const; const OSQLParseNode* getGroupByTree() const; const OSQLParseNode* getHavingTree() const;
/** return the alias name of a column @param_pDerivedColumn TheparsenodewhereSQL_ISRULE(_pDerivedColumn,derived_column)mustbetrue @return Thealiasnameofthecolumnoranemptystring.
*/
OOO_DLLPUBLIC_DBTOOLS static OUString getColumnAlias(const OSQLParseNode* _pDerivedColumn);
/** return the columname and the table range @param_pColumnRef Thecolumnrefparsenode. @param_xMetaData Thedatabasemetadata. @param_rColumnName Thecolumnnametobeset. @param_rTableRange Thetablerangetobeset.
*/
OOO_DLLPUBLIC_DBTOOLS staticvoid getColumnRange( const OSQLParseNode* _pColumnRef, const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
OUString &_rColumnName,
OUString& _rTableRange);
// return true when the tableNode is a rule like catalog_name, schema_name or table_name
OOO_DLLPUBLIC_DBTOOLS staticbool isTableNode(const OSQLParseNode* _pTableNode);
// tries to find the correct type of the function
sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode );
// returns a lis of all joined columns
OOO_DLLPUBLIC_DBTOOLS ::std::vector< TNodePair >& getJoinConditions() const;
private:
/** traverses the list of table names, and fills _rTables
*/ bool traverseTableNames( OSQLTables& _rTables );
/// traverses columns in a SELECT statement bool traverseSelectColumnNames(const OSQLParseNode* pSelectNode); /// traverses columns in a CREATE TABLE statement void traverseCreateColumns(const OSQLParseNode* pSelectNode);
/** constructs a new iterator, which inherits some of the settings from a parent iterator
*/
OSQLParseTreeIterator( const OSQLParseTreeIterator& _rParentIterator, const OSQLParser& _rParser, const OSQLParseNode* pRoot );
/** creates a table object and inserts it into our tables collection
/** appends an SQLException corresponding to the given error code to our error collection
*/ void impl_appendError( const css::sdbc::SQLException& _rError );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.