1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBASE_ODbaseDatabaseMetaData_HXX_ 33*cdf0e10cSrcweir #include "dbase/DDatabaseMetaData.hxx" 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> 42*cdf0e10cSrcweir #include <tools/urlobj.hxx> 43*cdf0e10cSrcweir #include "FDatabaseMetaDataResultSet.hxx" 44*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 45*cdf0e10cSrcweir #include "dbase/DIndex.hxx" 46*cdf0e10cSrcweir #include "connectivity/FValue.hxx" 47*cdf0e10cSrcweir #include <comphelper/extract.hxx> 48*cdf0e10cSrcweir #include <comphelper/types.hxx> 49*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 50*cdf0e10cSrcweir #include <rtl/logfile.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::comphelper; 53*cdf0e10cSrcweir using namespace connectivity::dbase; 54*cdf0e10cSrcweir using namespace connectivity; 55*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 56*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 57*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 58*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 59*cdf0e10cSrcweir using namespace ::com::sun::star::container; 60*cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 61*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir ODbaseDatabaseMetaData::ODbaseDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::ODbaseDatabaseMetaData" ); 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir // ------------------------------------------------------------------------- 68*cdf0e10cSrcweir ODbaseDatabaseMetaData::~ODbaseDatabaseMetaData() 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir // ------------------------------------------------------------------------- 72*cdf0e10cSrcweir Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_getTypeInfo_throw" ); 75*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); 78*cdf0e10cSrcweir Reference< XResultSet > xRef = pResult; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir static ODatabaseMetaDataResultSet::ORows aRows; 81*cdf0e10cSrcweir if(aRows.empty()) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ORow aRow; 84*cdf0e10cSrcweir aRow.reserve(18); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); 87*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"))); 88*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); 89*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); 90*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); 91*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); 92*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length"))); 93*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); 94*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); 95*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); 96*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); 97*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); 98*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); 99*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C")))); 100*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); 101*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); 102*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); 103*cdf0e10cSrcweir aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); 104*cdf0e10cSrcweir aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir aRows.push_back(aRow); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR")); 109*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); 110*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)2147483647); 111*cdf0e10cSrcweir aRow[6] = new ORowSetValueDecorator(); 112*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("M"))); 113*cdf0e10cSrcweir aRows.push_back(aRow); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); 116*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::DATE); 117*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)10); 118*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D"))); 119*cdf0e10cSrcweir aRows.push_back(aRow); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOLEAN")); 122*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::BIT); 123*cdf0e10cSrcweir aRow[3] = ODatabaseMetaDataResultSet::get1Value(); 124*cdf0e10cSrcweir aRow[4] = ODatabaseMetaDataResultSet::getEmptyValue(); 125*cdf0e10cSrcweir aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); 126*cdf0e10cSrcweir aRow[6] = new ORowSetValueDecorator(::rtl::OUString()); 127*cdf0e10cSrcweir aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); 128*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L"))); 129*cdf0e10cSrcweir aRows.push_back(aRow); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE")); 132*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); 133*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)8); 134*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("B"))); 135*cdf0e10cSrcweir aRows.push_back(aRow); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir aRow[11] = new ORowSetValueDecorator(sal_True); 138*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("Y")); 139*cdf0e10cSrcweir aRows.push_back(aRow); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); 142*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP); 143*cdf0e10cSrcweir aRow[11] = new ORowSetValueDecorator(sal_False); 144*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("T"))); 145*cdf0e10cSrcweir aRows.push_back(aRow); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER")); 148*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::INTEGER); 149*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)10); 150*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("I"))); 151*cdf0e10cSrcweir aRows.push_back(aRow); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL")); 154*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); 155*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)20); 156*cdf0e10cSrcweir aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length,scale")); 157*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("F"))); 158*cdf0e10cSrcweir aRows.push_back(aRow); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC")); 161*cdf0e10cSrcweir aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); 162*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator((sal_Int32)16); 163*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("N"))); 164*cdf0e10cSrcweir aRow[15] = new ORowSetValueDecorator((sal_Int32)16); 165*cdf0e10cSrcweir aRows.push_back(aRow); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir pResult->setRows(aRows); 169*cdf0e10cSrcweir return xRef; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir // ------------------------------------------------------------------------- 172*cdf0e10cSrcweir Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( 173*cdf0e10cSrcweir const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern, 174*cdf0e10cSrcweir const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getColumns" ); 177*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); 181*cdf0e10cSrcweir if(!xTables.is()) 182*cdf0e10cSrcweir throw SQLException(); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir Reference< XNameAccess> xNames = xTables->getTables(); 185*cdf0e10cSrcweir if(!xNames.is()) 186*cdf0e10cSrcweir throw SQLException(); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ORows aRows; 189*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ORow aRow(19); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir aRow[10] = new ORowSetValueDecorator((sal_Int32)10); 192*cdf0e10cSrcweir Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames()); 193*cdf0e10cSrcweir const ::rtl::OUString* pTabBegin = aTabNames.getConstArray(); 194*cdf0e10cSrcweir const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength(); 195*cdf0e10cSrcweir for(;pTabBegin != pTabEnd;++pTabBegin) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir if(match(tableNamePattern,*pTabBegin,'\0')) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir Reference< XColumnsSupplier> xTable; 200*cdf0e10cSrcweir ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin)); 201*cdf0e10cSrcweir OSL_ENSURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!"); 202*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator(*pTabBegin); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir Reference< XNameAccess> xColumns = xTable->getColumns(); 205*cdf0e10cSrcweir if(!xColumns.is()) 206*cdf0e10cSrcweir throw SQLException(); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir const ::rtl::OUString* pBegin = aColNames.getConstArray(); 211*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); 212*cdf0e10cSrcweir Reference< XPropertySet> xColumn; 213*cdf0e10cSrcweir for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir if(match(columnNamePattern,*pBegin,'\0')) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir aRow[4] = new ORowSetValueDecorator(*pBegin); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); 220*cdf0e10cSrcweir OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); 221*cdf0e10cSrcweir aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); 222*cdf0e10cSrcweir aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); 223*cdf0e10cSrcweir aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); 224*cdf0e10cSrcweir aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); 225*cdf0e10cSrcweir aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); 226*cdf0e10cSrcweir aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); 227*cdf0e10cSrcweir switch((sal_Int32)aRow[5]->getValue()) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir case DataType::CHAR: 230*cdf0e10cSrcweir case DataType::VARCHAR: 231*cdf0e10cSrcweir aRow[16] = new ORowSetValueDecorator((sal_Int32)254); 232*cdf0e10cSrcweir break; 233*cdf0e10cSrcweir case DataType::LONGVARCHAR: 234*cdf0e10cSrcweir aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); 235*cdf0e10cSrcweir break; 236*cdf0e10cSrcweir default: 237*cdf0e10cSrcweir aRow[16] = new ORowSetValueDecorator((sal_Int32)0); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir aRow[17] = new ORowSetValueDecorator(i); 240*cdf0e10cSrcweir switch(sal_Int32(aRow[11]->getValue())) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir case ColumnValue::NO_NULLS: 243*cdf0e10cSrcweir aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); 244*cdf0e10cSrcweir break; 245*cdf0e10cSrcweir case ColumnValue::NULLABLE: 246*cdf0e10cSrcweir aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES")); 247*cdf0e10cSrcweir break; 248*cdf0e10cSrcweir default: 249*cdf0e10cSrcweir aRow[18] = new ORowSetValueDecorator(::rtl::OUString()); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir aRows.push_back(aRow); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); 257*cdf0e10cSrcweir Reference< XResultSet > xRef = pResult; 258*cdf0e10cSrcweir pResult->setRows(aRows); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir return xRef; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir // ------------------------------------------------------------------------- 263*cdf0e10cSrcweir Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( 264*cdf0e10cSrcweir const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& table, 265*cdf0e10cSrcweir sal_Bool unique, sal_Bool /*approximate*/ ) throw(SQLException, RuntimeException) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getIndexInfo" ); 268*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); 271*cdf0e10cSrcweir if(!xTables.is()) 272*cdf0e10cSrcweir throw SQLException(); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir Reference< XNameAccess> xNames = xTables->getTables(); 275*cdf0e10cSrcweir if(!xNames.is()) 276*cdf0e10cSrcweir throw SQLException(); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ORows aRows; 279*cdf0e10cSrcweir ODatabaseMetaDataResultSet::ORow aRow(14); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir aRow[5] = new ORowSetValueDecorator(::rtl::OUString()); 282*cdf0e10cSrcweir aRow[10] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("A")); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir Reference< XIndexesSupplier> xTable; 285*cdf0e10cSrcweir ::cppu::extractInterface(xTable,xNames->getByName(table)); 286*cdf0e10cSrcweir aRow[3] = new ORowSetValueDecorator(table); 287*cdf0e10cSrcweir aRow[7] = new ORowSetValueDecorator((sal_Int32)3); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir Reference< XNameAccess> xIndexes = xTable->getIndexes(); 290*cdf0e10cSrcweir if(!xIndexes.is()) 291*cdf0e10cSrcweir throw SQLException(); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir Sequence< ::rtl::OUString> aIdxNames(xIndexes->getElementNames()); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir const ::rtl::OUString* pBegin = aIdxNames.getConstArray(); 296*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + aIdxNames.getLength(); 297*cdf0e10cSrcweir Reference< XPropertySet> xIndex; 298*cdf0e10cSrcweir for(;pBegin != pEnd;++pBegin) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir ::cppu::extractInterface(xIndex,xIndexes->getByName(*pBegin)); 301*cdf0e10cSrcweir OSL_ENSURE(xIndex.is(),"Indexes contains a column who isn't a fastpropertyset!"); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if(unique && !getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))) 304*cdf0e10cSrcweir continue; 305*cdf0e10cSrcweir aRow[4] = new ORowSetValueDecorator(getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))); 306*cdf0e10cSrcweir aRow[6] = new ORowSetValueDecorator(*pBegin); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir Reference< XUnoTunnel> xTunnel(xIndex,UNO_QUERY); 309*cdf0e10cSrcweir if(xTunnel.is()) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) ); 312*cdf0e10cSrcweir if(pIndex) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir aRow[11] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_maxkeys); 315*cdf0e10cSrcweir aRow[12] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_pagecount); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir Reference<XColumnsSupplier> xColumnsSup(xIndex,UNO_QUERY); 320*cdf0e10cSrcweir Reference< XNameAccess> xColumns = xColumnsSup->getColumns(); 321*cdf0e10cSrcweir Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir const ::rtl::OUString* pColBegin = aColNames.getConstArray(); 324*cdf0e10cSrcweir const ::rtl::OUString* pColEnd = pColBegin + aColNames.getLength(); 325*cdf0e10cSrcweir Reference< XPropertySet> xColumn; 326*cdf0e10cSrcweir for(sal_Int32 j=1;pColBegin != pColEnd;++pColBegin,++j) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir // xColumns->getByName(*pColBegin) >>= xColumn; 329*cdf0e10cSrcweir aRow[8] = new ORowSetValueDecorator(j); 330*cdf0e10cSrcweir aRow[9] = new ORowSetValueDecorator(*pColBegin); 331*cdf0e10cSrcweir aRows.push_back(aRow); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo); 336*cdf0e10cSrcweir Reference< XResultSet > xRef = pResult; 337*cdf0e10cSrcweir pResult->setRows(aRows); 338*cdf0e10cSrcweir return xRef; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir // ------------------------------------------------------------------------- 341*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODbaseDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getURL" ); 344*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 345*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) + m_pConnection->getURL(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir // ------------------------------------------------------------------------- 348*cdf0e10cSrcweir sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxBinaryLiteralLength" ); 351*cdf0e10cSrcweir return STRING_MAXLEN; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir // ------------------------------------------------------------------------- 354*cdf0e10cSrcweir sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxCharLiteralLength" ); 357*cdf0e10cSrcweir return 254; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir // ------------------------------------------------------------------------- 360*cdf0e10cSrcweir sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnNameLength" ); 363*cdf0e10cSrcweir return 10; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir // ------------------------------------------------------------------------- 366*cdf0e10cSrcweir sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnsInIndex" ); 369*cdf0e10cSrcweir return 1; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir // ------------------------------------------------------------------------- 372*cdf0e10cSrcweir sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnsInTable" ); 375*cdf0e10cSrcweir return 128; 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 378*cdf0e10cSrcweir sal_Bool SAL_CALL ODbaseDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::supportsAlterTableWithAddColumn" ); 381*cdf0e10cSrcweir return sal_True; 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir // ------------------------------------------------------------------------- 384*cdf0e10cSrcweir sal_Bool SAL_CALL ODbaseDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::supportsAlterTableWithDropColumn" ); 387*cdf0e10cSrcweir return sal_False; 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 390*cdf0e10cSrcweir sal_Bool SAL_CALL ODbaseDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::isReadOnly" ); 393*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir sal_Bool bReadOnly = sal_False; 396*cdf0e10cSrcweir static ::rtl::OUString sReadOnly = ::rtl::OUString::createFromAscii("IsReadOnly"); 397*cdf0e10cSrcweir ::ucbhelper::Content aFile(m_pConnection->getContent(),Reference< XCommandEnvironment >()); 398*cdf0e10cSrcweir aFile.getPropertyValue(sReadOnly) >>= bReadOnly; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir return bReadOnly; 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 403*cdf0e10cSrcweir sal_Bool ODbaseDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw" ); 406*cdf0e10cSrcweir return sal_True; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 409*cdf0e10cSrcweir sal_Bool ODbaseDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw" ); 412*cdf0e10cSrcweir return sal_True; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir 417