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