1 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
2 +++ connectivity/source/drivers/postgresql/DataAccess.xcu 2007-08-26 22:40:40.000000000 +0200
4 +<?xml version="1.0" encoding="UTF-8"?>
5 +<oor:node xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="DataAccess" oor:package="org.openoffice.Office">
6 + <node oor:name="UserDefinedDriverSettings">
7 + <node oor:name="Postgresql Driver" oor:op="replace">
8 + <prop oor:name="DriverPageDisplayName">
9 + <value>Postgresql-SDBC Driver V PQ_SDBC_MAJOR.PQ_SDBC_MINOR.PQ_SDBC_MICRO</value>
11 + <prop oor:name="DriverTypeDisplayName">
12 + <value>postgresql</value>
14 + <prop oor:name="DriverDsnPrefix">
15 + <value>sdbc:postgresql:</value>
20 \ Kein Zeilenumbruch am Dateiende.
21 --- /dev/null 2008-11-25 09:24:02.506388553 +0100
22 +++ connectivity/source/drivers/postgresql/makefile.mk 2008-07-07 23:37:11.000000000 +0200
24 +#*************************************************************************
26 +# $RCSfile: makefile.mk,v $
28 +# $Revision: 1.1.2.14 $
30 +# last change: $Author: jbu $ $Date: 2008/07/07 21:37:11 $
32 +# The Contents of this file are made available subject to the terms of
33 +# either of the following licenses
35 +# - GNU Lesser General Public License Version 2.1
36 +# - Sun Industry Standards Source License Version 1.1
38 +# Sun Microsystems Inc., October, 2000
40 +# GNU Lesser General Public License Version 2.1
41 +# =============================================
42 +# Copyright 2000 by Sun Microsystems, Inc.
43 +# 901 San Antonio Road, Palo Alto, CA 94303, USA
45 +# This library is free software; you can redistribute it and/or
46 +# modify it under the terms of the GNU Lesser General Public
47 +# License version 2.1, as published by the Free Software Foundation.
49 +# This library is distributed in the hope that it will be useful,
50 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
51 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
52 +# Lesser General Public License for more details.
54 +# You should have received a copy of the GNU Lesser General Public
55 +# License along with this library; if not, write to the Free Software
56 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
60 +# Sun Industry Standards Source License Version 1.1
61 +# =================================================
62 +# The contents of this file are subject to the Sun Industry Standards
63 +# Source License Version 1.1 (the "License"); You may not use this file
64 +# except in compliance with the License. You may obtain a copy of the
65 +# License at http://www.openoffice.org/license.html.
67 +# Software provided under this License is provided on an "AS IS" basis,
68 +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
69 +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
70 +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
71 +# See the License for the specific provisions governing your rights and
72 +# obligations concerning the Software.
74 +# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
76 +# Copyright: 2000 by Sun Microsystems, Inc.
78 +# All Rights Reserved.
80 +# Contributor(s): _______________________________________
84 +#*************************************************************************
89 +ENABLE_EXCEPTIONS=TRUE
94 +# --- Settings -----------------------------------------------------
96 +.INCLUDE : settings.mk
97 +.IF "$(SYSTEM_POSTGRESQL)" != "YES"
98 +.INCLUDE : $(SOLARINCDIR)$/postgresql/postgresql-version.mk
100 +#-------------------------------------------------------------------
102 +# uno component naming scheme
108 +.IF "$(SYSTEM_POSTGRESQL)" == "YES"
109 +POSTGRESQL_MAJOR=`pg_config --version | awk '{ print $$2 }' | cut -d. -f1`
110 +POSTGRESQL_MINOR=`pg_config --version | awk '{ print $$2 }' | cut -d. -f2`
111 +POSTGRESQL_MICRO=`pg_config --version | awk '{ print $$2 }' | cut -d. -f3`
114 +.IF "$(SYSTEM_POSTGRESQL)" != "YES"
115 +POSTGRESQL_INCLUDES=-I$(SOLARINCDIR)$/postgresql
117 +POSTGRESQL_INCLUDES=-I`pg_config --includedir`
120 +CFLAGS+=$(POSTGRESQL_INCLUDES) \
121 + -DPOSTGRESQL_MAJOR=$(POSTGRESQL_MAJOR) \
122 + -DPOSTGRESQL_MINOR=$(POSTGRESQL_MINOR) \
123 + -DPOSTGRESQL_MICRO=$(POSTGRESQL_MICRO) \
124 + -DPQ_SDBC_MAJOR=$(PQ_SDBC_MAJOR) \
125 + -DPQ_SDBC_MINOR=$(PQ_SDBC_MINOR) \
126 + -DPQ_SDBC_MICRO=$(PQ_SDBC_MICRO)
128 +SHL1TARGET=postgresql-sdbc.uno
129 +LIB1TARGET=$(SLB)$/$(SHL1TARGET).lib
131 + $(SLO)$/pq_driver.obj
138 +SHL1LIBS= $(LIB1TARGET)
139 +SHL1DEF= $(MISC)$/$(SHL1TARGET).def
140 +DEF1NAME= $(SHL1TARGET)
141 +SHL1VERSIONMAP=$(SOLARENV)$/src$/component.map
143 +# use the static version
145 +PQLIB=libpq.lib wsock32.lib advapi32.lib
149 +SHL2TARGET=postgresql-sdbc-impl.uno
150 +LIB2TARGET=$(SLB)$/$(SHL2TARGET).lib
152 + $(SLO)$/pq_connection.obj \
153 + $(SLO)$/pq_statement.obj \
154 + $(SLO)$/pq_resultset.obj \
155 + $(SLO)$/pq_preparedstatement.obj \
156 + $(SLO)$/pq_resultsetmetadata.obj \
157 + $(SLO)$/pq_databasemetadata.obj \
158 + $(SLO)$/pq_sequenceresultset.obj \
159 + $(SLO)$/pq_baseresultset.obj \
160 + $(SLO)$/pq_statics.obj \
161 + $(SLO)$/pq_xtable.obj \
162 + $(SLO)$/pq_xcontainer.obj \
163 + $(SLO)$/pq_xbase.obj \
164 + $(SLO)$/pq_xtables.obj \
165 + $(SLO)$/pq_xcolumns.obj \
166 + $(SLO)$/pq_xcolumn.obj \
167 + $(SLO)$/pq_tools.obj \
168 + $(SLO)$/pq_xkey.obj \
169 + $(SLO)$/pq_xkeys.obj \
170 + $(SLO)$/pq_xkeycolumn.obj \
171 + $(SLO)$/pq_xkeycolumns.obj \
172 + $(SLO)$/pq_xuser.obj \
173 + $(SLO)$/pq_xusers.obj \
174 + $(SLO)$/pq_xview.obj \
175 + $(SLO)$/pq_xviews.obj \
176 + $(SLO)$/pq_xindex.obj \
177 + $(SLO)$/pq_xindexes.obj \
178 + $(SLO)$/pq_xindexcolumn.obj \
179 + $(SLO)$/pq_xindexcolumns.obj \
180 + $(SLO)$/pq_updateableresultset.obj \
181 + $(SLO)$/pq_fakedupdateableresultset.obj \
182 + $(SLO)$/pq_array.obj \
183 + $(SLO)$/pq_sequenceresultsetmetadata.obj
193 +SHL2LIBS= $(LIB2TARGET)
194 +SHL2DEF= $(MISC)$/$(SHL2TARGET).def
195 +DEF2NAME= $(SHL2TARGET)
196 +SHL2VERSIONMAP=$(SOLARENV)$/src$/component.map
199 +SLOFILES= $(LIB1OBJFILES) $(LIB2OBJFILES)
202 +DRIVERNAME=postgresql-sdbc-$(PQ_SDBC_MAJOR).$(PQ_SDBC_MINOR).$(PQ_SDBC_MICRO).zip
203 +ALLTAR : $(DLLDEST)$/$(DRIVERNAME)
205 +# --- Targets ------------------------------------------------------
206 +.INCLUDE : target.mk
208 +.IF "$(GUI)" == "UNX"
214 +$(DLLDEST)$/$(SHL1TARGET)$(INI_EXT): $(SHL1TARGET)
218 +$(DLLDEST)$/$(DRIVERNAME): \
219 + $(DLLDEST)$/DataAccess.xcu \
220 + $(DLLDEST)$/$(SHL1TARGET)$(DLLPOST) \
221 + $(DLLDEST)$/$(SHL2TARGET)$(DLLPOST) \
222 + $(DLLDEST)$/$(SHL1TARGET)$(INI_EXT)
223 + +cd $(DLLDEST) && \
224 + zip -r $(DRIVERNAME) \
225 + $(SHL1TARGET)$(DLLPOST) \
226 + $(SHL2TARGET)$(DLLPOST) \
227 + $(SHL1TARGET)$(INI_EXT) \
230 +$(DLLDEST)$/DataAccess.xcu : DataAccess.xcu
232 + cat DataAccess.xcu | \
233 + sed s/PQ_SDBC_MAJOR/$(PQ_SDBC_MAJOR)/ | \
234 + sed s/PQ_SDBC_MINOR/$(PQ_SDBC_MINOR)/ | \
235 + sed s/PQ_SDBC_MICRO/$(PQ_SDBC_MICRO)/ > $@
240 + strip $(DLLDEST)$/$(SHL1TARGET)$(DLLPOST) $(DLLDEST)$/$(SHL2TARGET)$(DLLPOST)
242 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
243 +++ connectivity/source/drivers/postgresql/postgresql-sdbc.uno 2004-06-10 17:34:28.000000000 +0200
247 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
248 +++ connectivity/source/drivers/postgresql/pq_allocator.hxx 2007-08-28 23:24:00.000000000 +0200
250 +/*************************************************************************
252 + * $RCSfile: pq_allocator.hxx,v $
254 + * $Revision: 1.1.2.3 $
256 + * last change: $Author: jbu $ $Date: 2007/08/28 21:24:00 $
258 + * The Contents of this file are made available subject to the terms of
259 + * either of the following licenses
261 + * - GNU Lesser General Public License Version 2.1
262 + * - Sun Industry Standards Source License Version 1.1
264 + * Sun Microsystems Inc., October, 2000
266 + * GNU Lesser General Public License Version 2.1
267 + * =============================================
268 + * Copyright 2000 by Sun Microsystems, Inc.
269 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
271 + * This library is free software; you can redistribute it and/or
272 + * modify it under the terms of the GNU Lesser General Public
273 + * License version 2.1, as published by the Free Software Foundation.
275 + * This library is distributed in the hope that it will be useful,
276 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
277 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
278 + * Lesser General Public License for more details.
280 + * You should have received a copy of the GNU Lesser General Public
281 + * License along with this library; if not, write to the Free Software
282 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
283 + * MA 02111-1307 USA
286 + * Sun Industry Standards Source License Version 1.1
287 + * =================================================
288 + * The contents of this file are subject to the Sun Industry Standards
289 + * Source License Version 1.1 (the "License"); You may not use this file
290 + * except in compliance with the License. You may obtain a copy of the
291 + * License at http://www.openoffice.org/license.html.
293 + * Software provided under this License is provided on an "AS IS" basis,
294 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
295 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
296 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
297 + * See the License for the specific provisions governing your rights and
298 + * obligations concerning the Software.
300 + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
302 + * Copyright: 2002 by Sun Microsystems, Inc.
304 + * All Rights Reserved.
306 + * Contributor(s): _______________________________________
309 + ************************************************************************/
311 +#ifndef _PQ_ALLOCATOR_
312 +#define _PQ_ALLOCATOR_
315 +#include "sal/types.h"
317 +/** jbu: This source has been copied from sal/inc/internal/allocator.hxx,
318 + because it is not a public interface. Thx a lot for figuring this
322 +//######################################################
323 +// This is no general purpose STL allocator but one
324 +// necessary to use STL for some implementation but
325 +// avoid linking sal against the STLPort library!!!
326 +// For more information on when and how to define a
327 +// custom stl allocator have a look at Scott Meyers:
328 +// "Effective STL", Nicolai M. Josuttis:
329 +// "The C++ Standard Library - A Tutorial and Reference"
330 +// and at http://www.josuttis.com/cppcode/allocator.html
332 +namespace pq_sdbc_driver {
338 + typedef T value_type;
339 + typedef T* pointer;
340 + typedef const T* const_pointer;
341 + typedef T& reference;
342 + typedef const T& const_reference;
343 + typedef ::std::size_t size_type;
344 + typedef ::std::ptrdiff_t difference_type;
346 + //-----------------------------------------
350 + typedef Allocator<U> other;
353 + //-----------------------------------------
354 + pointer address (reference value) const
359 + //-----------------------------------------
360 + const_pointer address (const_reference value) const
365 + //-----------------------------------------
366 + Allocator() SAL_THROW(())
369 + //-----------------------------------------
371 + Allocator (const Allocator<U>&) SAL_THROW(())
374 + //-----------------------------------------
375 + Allocator(const Allocator&) SAL_THROW(())
378 + //-----------------------------------------
379 + ~Allocator() SAL_THROW(())
382 + //-----------------------------------------
383 + size_type max_size() const SAL_THROW(())
385 + return size_type(-1)/sizeof(T);
388 + //-----------------------------------------
389 + /* Normally the code for allocate should
390 + throw a std::bad_alloc exception if the
391 + requested memory could not be allocated:
392 + (C++ standard 20.4.1.1):
394 + pointer allocate (size_type n, const void* hint = 0)
396 + pointer p = reinterpret_cast<pointer>(
397 + rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
400 + throw ::std::bad_alloc();
405 + but some compilers do not compile it if exceptions
406 + are not enabled, e.g. GCC under Linux and it is
407 + in general not desired to compile sal with exceptions
409 + pointer allocate (size_type n, const void* hint = 0)
411 + return reinterpret_cast<pointer>(
412 + rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
415 + //-----------------------------------------
416 + void deallocate (pointer p, size_type n)
421 + //-----------------------------------------
422 + void construct (pointer p, const T& value)
424 + new ((void*)p)T(value);
427 + //-----------------------------------------
428 + void destroy (pointer p)
434 +//######################################################
435 +// Custom STL allocators must be stateless (see
436 +// references above) that's why the operators below
437 +// return always true or false
438 +template<class T, class U>
439 +inline bool operator== (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
444 +template<class T, class U>
445 +inline bool operator!= (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
450 +} /* namespace sal */
452 +//######################################################
453 +/* REQUIRED BY STLPort (see stlport '_alloc.h'):
454 + Hack for compilers that do not support member
455 + template classes (e.g. MSVC 6) */
456 +#if defined (_MSC_VER)
457 +#if (_MSC_VER < 1400) // MSVC 6
462 + template<class T, class U>
463 + inline pq_sdbc_driver::Allocator<U> & __stl_alloc_rebind (
464 + pq_sdbc_driver::Allocator<T> & a, U const *)
466 + return (pq_sdbc_driver::Allocator<U>&)(a);
468 +#if defined (_MSC_VER)
469 +#if (_MSC_VER < 1400) // MSVC 6
474 +#endif /* INCLUDED_SAL_INTERNAL_ALLOCATOR_HXX */
475 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
476 +++ connectivity/source/drivers/postgresql/pq_array.cxx 2004-08-29 10:33:27.000000000 +0200
478 +#include <rtl/ustrbuf.hxx>
480 +#include <com/sun/star/sdbc/XArray.hpp>
481 +#include <com/sun/star/sdbc/DataType.hpp>
484 +#include "pq_array.hxx"
485 +#include "pq_statics.hxx"
486 +#include "pq_sequenceresultset.hxx"
488 +using rtl::OUString;
490 +using com::sun::star::sdbc::SQLException;
491 +using com::sun::star::uno::Any;
493 +using com::sun::star::uno::Sequence;
494 +namespace pq_sdbc_driver
498 +::rtl::OUString Array::getBaseTypeName( )
499 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
501 + return OUString( RTL_CONSTASCII_USTRINGPARAM( "varchar" ) );
504 +sal_Int32 Array::getBaseType( )
505 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
507 + return com::sun::star::sdbc::DataType::VARCHAR;
510 +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Array::getArray(
511 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
512 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
517 +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Array::getArrayAtIndex(
520 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
521 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
523 + checkRange( index, count );
524 + return Sequence< Any > ( &m_data[index-1], count );
527 +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > Array::getResultSet(
528 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
529 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
531 + return getResultSetAtIndex( 0 , m_data.getLength() , typeMap );
534 +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > Array::getResultSetAtIndex(
537 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
538 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
540 + checkRange( index, count );
541 + Sequence< Sequence< Any > > ret( count );
543 + for( int i = 0 ; i < count ; i ++ )
545 + Sequence< Any > row( 2 );
546 + row[0] <<= (sal_Int32) ( i + index );
547 + row[1] = m_data[i+index-1];
551 + return new SequenceResultSet(
552 + m_refMutex, m_owner, getStatics().resultSetArrayColumnNames, ret, m_tc );
556 +void Array::checkRange( sal_Int32 index, sal_Int32 count )
558 + if( index >= 1 && index -1 + count <= m_data.getLength() )
560 + rtl::OUStringBuffer buf;
561 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Array::getArrayAtIndex(): allowed range for index + count " ) );
562 + buf.append( m_data.getLength() );
563 + buf.appendAscii( ", got " );
564 + buf.append( index );
565 + buf.appendAscii( " + " );
566 + buf.append( count );
568 + throw SQLException( buf.makeStringAndClear() , *this, rtl::OUString(), 1, Any());
573 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
574 +++ connectivity/source/drivers/postgresql/pq_array.hxx 2004-08-29 10:33:28.000000000 +0200
576 +/*************************************************************************
578 + * $RCSfile: pq_array.hxx,v $
580 + * $Revision: 1.1.2.1 $
582 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:28 $
584 + * The Contents of this file are made available subject to the terms of
585 + * either of the following licenses
587 + * - GNU Lesser General Public License Version 2.1
588 + * - Sun Industry Standards Source License Version 1.1
590 + * Sun Microsystems Inc., October, 2000
592 + * GNU Lesser General Public License Version 2.1
593 + * =============================================
594 + * Copyright 2000 by Sun Microsystems, Inc.
595 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
597 + * This library is free software; you can redistribute it and/or
598 + * modify it under the terms of the GNU Lesser General Public
599 + * License version 2.1, as published by the Free Software Foundation.
601 + * This library is distributed in the hope that it will be useful,
602 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
603 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
604 + * Lesser General Public License for more details.
606 + * You should have received a copy of the GNU Lesser General Public
607 + * License along with this library; if not, write to the Free Software
608 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
609 + * MA 02111-1307 USA
612 + * Sun Industry Standards Source License Version 1.1
613 + * =================================================
614 + * The contents of this file are subject to the Sun Industry Standards
615 + * Source License Version 1.1 (the "License"); You may not use this file
616 + * except in compliance with the License. You may obtain a copy of the
617 + * License at http://www.openoffice.org/license.html.
619 + * Software provided under this License is provided on an "AS IS" basis,
620 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
621 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
622 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
623 + * See the License for the specific provisions governing your rights and
624 + * obligations concerning the Software.
626 + * The Initial Developer of the Original Code is: Joerg Budischewski
628 + * Copyright: 2000 by Sun Microsystems, Inc.
630 + * All Rights Reserved.
632 + * Contributor(s): Joerg Budischewski
635 + ************************************************************************/
637 +#ifndef HEADER_PQ_ARRAY_HXX
638 +#define HEADER_PQ_ARRAY_HXX
639 +#include <cppuhelper/implbase1.hxx>
640 +#include <com/sun/star/sdbc/XArray.hpp>
642 +#include "pq_connection.hxx"
644 +namespace pq_sdbc_driver
647 +class Array : public cppu::WeakImplHelper1< com::sun::star::sdbc::XArray >
649 + com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_data;
650 + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_owner;
651 + com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > m_tc;
652 + rtl::Reference< RefCountedMutex > m_refMutex;
656 + const rtl::Reference< RefCountedMutex > & mutex,
657 + const com::sun::star::uno::Sequence< com::sun::star::uno::Any > & data,
658 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & owner,
659 + const com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > &tc) :
660 + m_refMutex( mutex ),
669 + virtual ::rtl::OUString SAL_CALL getBaseTypeName( )
670 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
672 + virtual sal_Int32 SAL_CALL getBaseType( )
673 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
675 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getArray(
676 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
677 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
679 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getArrayAtIndex(
682 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
683 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
685 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
687 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
688 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
690 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSetAtIndex(
693 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
694 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
697 + void checkRange( sal_Int32 index, sal_Int32 count );
704 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
705 +++ connectivity/source/drivers/postgresql/pq_baseresultset.cxx 2004-08-29 10:33:28.000000000 +0200
707 +/*************************************************************************
709 + * $RCSfile: pq_baseresultset.cxx,v $
711 + * $Revision: 1.1.2.4 $
713 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:28 $
715 + * The Contents of this file are made available subject to the terms of
716 + * either of the following licenses
718 + * - GNU Lesser General Public License Version 2.1
719 + * - Sun Industry Standards Source License Version 1.1
721 + * Sun Microsystems Inc., October, 2000
723 + * GNU Lesser General Public License Version 2.1
724 + * =============================================
725 + * Copyright 2000 by Sun Microsystems, Inc.
726 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
728 + * This library is free software; you can redistribute it and/or
729 + * modify it under the terms of the GNU Lesser General Public
730 + * License version 2.1, as published by the Free Software Foundation.
732 + * This library is distributed in the hope that it will be useful,
733 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
734 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
735 + * Lesser General Public License for more details.
737 + * You should have received a copy of the GNU Lesser General Public
738 + * License along with this library; if not, write to the Free Software
739 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
740 + * MA 02111-1307 USA
743 + * Sun Industry Standards Source License Version 1.1
744 + * =================================================
745 + * The contents of this file are subject to the Sun Industry Standards
746 + * Source License Version 1.1 (the "License"); You may not use this file
747 + * except in compliance with the License. You may obtain a copy of the
748 + * License at http://www.openoffice.org/license.html.
750 + * Software provided under this License is provided on an "AS IS" basis,
751 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
752 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
753 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
754 + * See the License for the specific provisions governing your rights and
755 + * obligations concerning the Software.
757 + * The Initial Developer of the Original Code is: Joerg Budischewski
759 + * Copyright: 2000 by Sun Microsystems, Inc.
761 + * All Rights Reserved.
763 + * Contributor(s): Joerg Budischewski
766 + ************************************************************************/
768 +#include <osl/thread.h>
770 +#include <rtl/ustrbuf.hxx>
772 +#include <cppuhelper/typeprovider.hxx>
773 +#include <cppuhelper/queryinterface.hxx>
775 +#include "pq_tools.hxx"
776 +#include "pq_array.hxx"
777 +#include "pq_statement.hxx"
778 +#include "pq_baseresultset.hxx"
779 +#include "pq_resultsetmetadata.hxx"
781 +#include <com/sun/star/lang/DisposedException.hpp>
784 +using osl::MutexGuard;
786 +using rtl::OUString;
787 +using rtl::OUStringToOString;
788 +using rtl::OUStringBuffer;
791 +using com::sun::star::beans::XPropertySetInfo;
792 +using com::sun::star::beans::XPropertySet;
793 +using com::sun::star::beans::XMultiPropertySet;
794 +using com::sun::star::beans::XFastPropertySet;
796 +using com::sun::star::uno::Any;
797 +using com::sun::star::uno::makeAny;
798 +using com::sun::star::uno::Type;
799 +using com::sun::star::uno::RuntimeException;
800 +using com::sun::star::uno::Exception;
801 +using com::sun::star::uno::Sequence;
802 +using com::sun::star::uno::Reference;
803 +using com::sun::star::uno::XInterface;
805 +using com::sun::star::lang::IllegalArgumentException;
807 +using com::sun::star::sdbc::XWarningsSupplier;
808 +using com::sun::star::sdbc::XCloseable;
809 +using com::sun::star::sdbc::XStatement;
810 +using com::sun::star::sdbc::XResultSet;
811 +using com::sun::star::sdbc::XConnection;
812 +using com::sun::star::sdbc::SQLException;
813 +using com::sun::star::sdbc::XRow;
814 +using com::sun::star::sdbc::XColumnLocate;
815 +using com::sun::star::sdbc::XResultSetMetaData;
816 +using com::sun::star::sdbc::XResultSetMetaDataSupplier;
819 +using com::sun::star::beans::Property;
821 +namespace pq_sdbc_driver
823 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
825 +static ::cppu::IPropertyArrayHelper & getResultSetPropertyArrayHelper()
827 + static ::cppu::IPropertyArrayHelper *pArrayHelper;
828 + if( ! pArrayHelper )
830 + MutexGuard guard( Mutex::getGlobalMutex() );
831 + if( ! pArrayHelper )
833 + static Property aTable[] =
836 + OUString( RTL_CONSTASCII_USTRINGPARAM("CursorName") ), 0,
837 + ::getCppuType( (OUString *)0) , 0 ),
839 + OUString( RTL_CONSTASCII_USTRINGPARAM("EscapeProcessing") ), 0,
840 + ::getBooleanCppuType() , 0 ),
842 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchDirection") ), 0,
843 + ::getCppuType( (sal_Int32 *)0) , 0 ),
845 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchSize") ), 0,
846 + ::getCppuType( (sal_Int32 *)0) , 0 ),
848 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetConcurrency") ), 0,
849 + ::getCppuType( (sal_Int32 *)0) , 0 ),
851 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetType") ), 0,
852 + ::getCppuType( (sal_Int32 *)0) , 0 )
854 + OSL_ASSERT( sizeof(aTable) / sizeof(Property) == BASERESULTSET_SIZE );
855 + static ::cppu::OPropertyArrayHelper arrayHelper( aTable, BASERESULTSET_SIZE, sal_True );
856 + pArrayHelper = &arrayHelper;
859 + return *pArrayHelper;
862 +BaseResultSet::BaseResultSet(
863 + const ::rtl::Reference< RefCountedMutex > & refMutex,
864 + const Reference< XInterface > & owner,
865 + sal_Int32 rowCount,
866 + sal_Int32 colCount,
867 + const Reference< com::sun::star::script::XTypeConverter > & tc )
868 + : OComponentHelper( refMutex->mutex ),
869 + OPropertySetHelper( OComponentHelper::rBHelper ),
870 + m_refMutex( refMutex ),
873 + m_rowCount( rowCount ),
874 + m_fieldCount( colCount ),
877 + POSTGRE_TRACE( "ctor BaseResultSet" );
880 +BaseResultSet::~BaseResultSet()
882 + POSTGRE_TRACE( "dtor BaseResultSet" );
885 +Any BaseResultSet::queryInterface( const Type & reqType ) throw (RuntimeException)
889 + ret = OComponentHelper::queryInterface( reqType );
890 + if( ! ret.hasValue() )
891 + ret = ::cppu::queryInterface( reqType,
892 + static_cast< XResultSet * > ( this ),
893 + static_cast< XResultSetMetaDataSupplier * > ( this ),
894 + static_cast< XRow * > ( this ),
895 + static_cast< XColumnLocate * > ( this ),
896 + static_cast< XCloseable * > ( this ),
897 + static_cast< XPropertySet * > ( this ),
898 + static_cast< XMultiPropertySet * > ( this ),
899 + static_cast< XFastPropertySet * > ( this ) );
903 +// void BaseResultSet::close( ) throw (SQLException, RuntimeException)
905 +// Reference< XInterface > owner;
907 +// ResultSetGuard guard(*this);
910 +// PQclear(m_result );
919 +Sequence<Type > BaseResultSet::getTypes() throw( RuntimeException )
921 + static cppu::OTypeCollection *pCollection;
922 + if( ! pCollection )
924 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
927 + static cppu::OTypeCollection collection(
928 + getCppuType( (Reference< XResultSet> *) 0 ),
929 + getCppuType( (Reference< XResultSetMetaDataSupplier> *) 0 ),
930 + getCppuType( (Reference< XRow> *) 0 ),
931 + getCppuType( (Reference< XColumnLocate> *) 0 ),
932 + getCppuType( (Reference< XCloseable> *) 0 ),
933 + getCppuType( (Reference< XPropertySet >*) 0 ),
934 + getCppuType( (Reference< XFastPropertySet > *) 0 ),
935 + getCppuType( (Reference< XMultiPropertySet > *) 0 ),
936 + OComponentHelper::getTypes());
937 + pCollection = &collection;
940 + return pCollection->getTypes();
943 +Sequence< sal_Int8> BaseResultSet::getImplementationId() throw( RuntimeException )
945 + static cppu::OImplementationId *pId;
948 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
951 + static cppu::OImplementationId id(sal_False);
955 + return pId->getImplementationId();
958 +// Reference< XResultSetMetaData > BaseResultSet::getMetaData( ) throw (SQLException, RuntimeException)
960 +// ResultSetGuard guard(*this);
962 +// return new ResultSetMetaData( m_refMutex, this, &m_result );
965 +sal_Bool BaseResultSet::next( ) throw (SQLException, RuntimeException)
967 + MutexGuard guard( m_refMutex->mutex );
970 + return m_row < m_rowCount;
973 +sal_Bool BaseResultSet::isBeforeFirst( ) throw (SQLException, RuntimeException)
975 + MutexGuard guard( m_refMutex->mutex );
977 + return m_row == -1;
980 +sal_Bool BaseResultSet::isAfterLast( ) throw (SQLException, RuntimeException)
982 + MutexGuard guard( m_refMutex->mutex );
984 + return m_row >= m_rowCount;
987 +sal_Bool BaseResultSet::isFirst( ) throw (SQLException, RuntimeException)
989 + MutexGuard guard( m_refMutex->mutex );
991 + return m_row == 0 && m_rowCount;
994 +sal_Bool BaseResultSet::isLast( ) throw (SQLException, RuntimeException)
996 + MutexGuard guard( m_refMutex->mutex );
998 + return m_row >= 0 && m_row + 1 == m_rowCount;
1001 +void BaseResultSet::beforeFirst( ) throw (SQLException, RuntimeException)
1003 + MutexGuard guard( m_refMutex->mutex );
1008 +void BaseResultSet::afterLast( ) throw (SQLException, RuntimeException)
1010 + MutexGuard guard( m_refMutex->mutex );
1012 + m_row = m_rowCount;
1015 +sal_Bool BaseResultSet::first( ) throw (SQLException, RuntimeException)
1017 + MutexGuard guard( m_refMutex->mutex );
1019 + sal_Bool bRet = ( m_rowCount > 0 );
1025 +sal_Bool BaseResultSet::last( ) throw (SQLException, RuntimeException)
1027 + MutexGuard guard( m_refMutex->mutex );
1029 + sal_Bool bRet = ( m_rowCount > 0 );
1031 + m_row = m_rowCount -1;
1035 +sal_Int32 BaseResultSet::getRow( ) throw (SQLException, RuntimeException)
1037 + MutexGuard guard( m_refMutex->mutex );
1042 +sal_Bool BaseResultSet::absolute( sal_Int32 row ) throw (SQLException, RuntimeException)
1044 + MutexGuard guard( m_refMutex->mutex );
1049 + if( m_row > m_rowCount )
1050 + m_row = m_rowCount;
1054 + m_row = m_rowCount + row;
1061 +sal_Bool BaseResultSet::relative( sal_Int32 rows ) throw (SQLException, RuntimeException)
1063 + MutexGuard guard( m_refMutex->mutex );
1067 + if( m_row > m_rowCount )
1068 + m_row = m_rowCount;
1069 + else if ( m_row < -1 )
1074 +sal_Bool BaseResultSet::previous( ) throw (SQLException, RuntimeException)
1076 + MutexGuard guard( m_refMutex->mutex );
1078 + sal_Bool bRet = ( m_row != -1 );
1084 +void BaseResultSet::refreshRow( ) throw (SQLException, RuntimeException)
1086 + // TODO: not supported for now
1089 +sal_Bool BaseResultSet::rowUpdated( ) throw (SQLException, RuntimeException)
1094 +sal_Bool BaseResultSet::rowInserted( ) throw (SQLException, RuntimeException)
1099 +sal_Bool BaseResultSet::rowDeleted( ) throw (SQLException, RuntimeException)
1104 +Reference< XInterface > BaseResultSet::getStatement() throw (SQLException, RuntimeException)
1106 + MutexGuard guard( m_refMutex->mutex );
1112 +//----------------- XRow interface ----------------------------------------------------
1114 +sal_Bool BaseResultSet::wasNull( ) throw (SQLException, RuntimeException)
1119 +Any BaseResultSet::convertTo( const Any & val , const Type & type )
1124 + aRet = m_tc->convertTo( val , type );
1126 + catch( com::sun::star::lang::IllegalArgumentException & e )
1128 + catch( com::sun::star::script::CannotConvertException & e )
1133 +sal_Bool BaseResultSet::getBoolean( sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
1135 + MutexGuard guard( m_refMutex->mutex );
1137 + checkColumnIndex( columnIndex );
1138 + checkRowIndex( sal_True /* must be on row */ );
1140 + sal_Bool b = sal_False;
1142 + OUString str = getString( columnIndex );
1144 + if( str.getLength() > 0 )
1160 +sal_Int8 BaseResultSet::getByte( sal_Int32 columnIndex )
1161 + throw (SQLException, RuntimeException)
1163 + MutexGuard guard( m_refMutex->mutex );
1165 + checkColumnIndex( columnIndex );
1166 + checkRowIndex( sal_True /* must be on row */ );
1168 + convertTo( getValue( columnIndex ), getCppuType( &b )) >>= b;
1172 +sal_Int16 BaseResultSet::getShort( sal_Int32 columnIndex )
1173 + throw (SQLException, RuntimeException)
1175 + MutexGuard guard( m_refMutex->mutex );
1177 + checkColumnIndex( columnIndex );
1178 + checkRowIndex( sal_True /* must be on row */ );
1180 + convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
1184 +OUString BaseResultSet::getString( sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
1186 + MutexGuard guard(m_refMutex->mutex);
1188 + checkColumnIndex( columnIndex );
1189 + checkRowIndex( sal_True /* must be on row */ );
1191 + convertTo( getValue( columnIndex ), getCppuType( &ret ) ) >>= ret;
1192 +// printf( "BaseResultSet::getString() %s\n" , OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ).getStr() );
1196 +sal_Int32 BaseResultSet::getInt( sal_Int32 columnIndex )
1197 + throw (SQLException, RuntimeException)
1199 + MutexGuard guard( m_refMutex->mutex );
1201 + checkColumnIndex( columnIndex );
1202 + checkRowIndex( sal_True /* must be on row */ );
1204 + convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
1208 +sal_Int64 BaseResultSet::getLong( sal_Int32 columnIndex )
1209 + throw (SQLException, RuntimeException)
1211 + MutexGuard guard( m_refMutex->mutex );
1213 + checkColumnIndex( columnIndex );
1214 + checkRowIndex( sal_True /* must be on row */ );
1216 + convertTo( getValue( columnIndex ), getCppuType( &i )) >>= i;
1220 +float BaseResultSet::getFloat( sal_Int32 columnIndex )
1221 + throw (SQLException, RuntimeException)
1223 + MutexGuard guard( m_refMutex->mutex );
1225 + checkColumnIndex( columnIndex );
1226 + checkRowIndex( sal_True /* must be on row */ );
1228 + convertTo( getValue( columnIndex ), getCppuType( &f )) >>= f;
1232 +double BaseResultSet::getDouble( sal_Int32 columnIndex )
1233 + throw (SQLException, RuntimeException)
1235 + MutexGuard guard( m_refMutex->mutex );
1237 + checkColumnIndex( columnIndex );
1239 + convertTo( getValue( columnIndex ), getCppuType( &d )) >>= d;
1243 +Sequence< sal_Int8 > BaseResultSet::getBytes( sal_Int32 columnIndex )
1244 + throw (SQLException, RuntimeException)
1246 + MutexGuard guard( m_refMutex->mutex );
1248 + checkColumnIndex( columnIndex );
1249 + checkRowIndex( sal_True /* must be on row */ );
1251 + Sequence< sal_Int8 > ret;
1253 + if( ! (getValue( columnIndex ) >>= ustr) )
1257 + // if this is a binary, it must contain escaped data !
1258 + OString val = rtl::OUStringToOString( ustr, RTL_TEXTENCODING_ASCII_US );
1261 + char * res = (char*) PQunescapeBytea( (unsigned char *)val.getStr() , &length);
1262 + ret = Sequence< sal_Int8 > ( (sal_Int8*)res, length );
1270 +::com::sun::star::util::Date BaseResultSet::getDate( sal_Int32 columnIndex )
1271 + throw (SQLException, RuntimeException)
1273 + return string2Date( getString( columnIndex ) );
1276 +::com::sun::star::util::Time BaseResultSet::getTime( sal_Int32 columnIndex )
1277 + throw (SQLException, RuntimeException)
1279 + return string2Time( getString( columnIndex ) );
1282 +::com::sun::star::util::DateTime BaseResultSet::getTimestamp( sal_Int32 columnIndex )
1283 + throw (SQLException, RuntimeException)
1285 + return string2DateTime( getString( columnIndex ) );
1288 +Reference< ::com::sun::star::io::XInputStream > BaseResultSet::getBinaryStream( sal_Int32 columnIndex )
1289 + throw (SQLException, RuntimeException)
1294 +Reference< ::com::sun::star::io::XInputStream > BaseResultSet::getCharacterStream( sal_Int32 columnIndex )
1295 + throw (SQLException, RuntimeException)
1300 +Any BaseResultSet::getObject(
1301 + sal_Int32 columnIndex,
1302 + const Reference< ::com::sun::star::container::XNameAccess >& typeMap )
1303 + throw (SQLException, RuntimeException)
1308 +Reference< ::com::sun::star::sdbc::XRef > BaseResultSet::getRef( sal_Int32 columnIndex )
1309 + throw (SQLException, RuntimeException)
1311 + return Reference< com::sun::star::sdbc::XRef > ();
1314 +Reference< ::com::sun::star::sdbc::XBlob > BaseResultSet::getBlob( sal_Int32 columnIndex )
1315 + throw (SQLException, RuntimeException)
1317 + return Reference< com::sun::star::sdbc::XBlob > ();
1320 +Reference< ::com::sun::star::sdbc::XClob > BaseResultSet::getClob( sal_Int32 columnIndex )
1321 + throw (SQLException, RuntimeException)
1323 + return Reference< com::sun::star::sdbc::XClob > ();
1326 +Reference< ::com::sun::star::sdbc::XArray > BaseResultSet::getArray( sal_Int32 columnIndex )
1327 + throw (SQLException, RuntimeException)
1329 + return new Array( m_refMutex, parseArray( getString( columnIndex ) ), *this, m_tc );
1333 +::cppu::IPropertyArrayHelper & BaseResultSet::getInfoHelper()
1335 + return getResultSetPropertyArrayHelper();
1339 +sal_Bool BaseResultSet::convertFastPropertyValue(
1340 + Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue )
1341 + throw (IllegalArgumentException)
1346 + case BASERESULTSET_CURSOR_NAME:
1349 + bRet = ( rValue >>= val );
1350 + m_props[nHandle] = makeAny( val );
1353 + case BASERESULTSET_ESCAPE_PROCESSING:
1356 + bRet = ( rValue >>= val );
1357 + m_props[nHandle] = makeAny( val );
1360 + case BASERESULTSET_FETCH_DIRECTION:
1361 + case BASERESULTSET_FETCH_SIZE:
1362 + case BASERESULTSET_RESULT_SET_CONCURRENCY:
1363 + case BASERESULTSET_RESULT_SET_TYPE:
1366 + bRet = ( rValue >>= val );
1367 + m_props[nHandle] = makeAny( val );
1372 + OUStringBuffer buf(128);
1373 + buf.appendAscii( "pq_resultset: Invalid property handle (" );
1374 + buf.append( nHandle );
1375 + buf.appendAscii( ")" );
1376 + throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
1383 +void BaseResultSet::setFastPropertyValue_NoBroadcast(
1384 + sal_Int32 nHandle,const Any& rValue ) throw (Exception)
1386 + m_props[nHandle] = rValue;
1389 +void BaseResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
1391 + rValue = m_props[nHandle];
1394 +Reference < XPropertySetInfo > BaseResultSet::getPropertySetInfo()
1395 + throw(RuntimeException)
1397 + return OPropertySetHelper::createPropertySetInfo( getResultSetPropertyArrayHelper() );
1400 +void BaseResultSet::disposing()
1405 +void BaseResultSet::checkColumnIndex(sal_Int32 index ) throw ( SQLException, RuntimeException )
1407 + if( index < 1 || index > m_fieldCount )
1409 + OUStringBuffer buf(128);
1410 + buf.appendAscii( "pq_resultset: index out of range (" );
1411 + buf.append( index );
1412 + buf.appendAscii( ", allowed range is 1 to " );
1413 + buf.append( m_fieldCount );
1414 + buf.appendAscii( ")" );
1415 + throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
1420 +void BaseResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
1422 + OUStringBuffer buf( 128 );
1423 + buf.appendAscii( "pq_baseresultset: row index out of range, allowed is " );
1424 + if( mustBeOnValidRow )
1426 + if( m_row < 0 || m_row >= m_rowCount )
1428 + buf.appendAscii( "0 to " );
1429 + buf.append( ((sal_Int32)(m_rowCount -1)) );
1430 + buf.appendAscii( ", got " );
1431 + buf.append( m_row );
1432 + throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
1437 + if( m_row < -1 || m_row > m_rowCount )
1439 + buf.appendAscii( "-1 to " );
1440 + buf.append( m_rowCount );
1441 + buf.appendAscii( ", got " );
1442 + buf.append( m_row );
1443 + throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
1449 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
1450 +++ connectivity/source/drivers/postgresql/pq_baseresultset.hxx 2007-08-26 22:40:40.000000000 +0200
1452 +/*************************************************************************
1454 + * $RCSfile: pq_baseresultset.hxx,v $
1456 + * $Revision: 1.1.2.3 $
1458 + * last change: $Author: jbu $ $Date: 2007/08/26 20:40:40 $
1460 + * The Contents of this file are made available subject to the terms of
1461 + * either of the following licenses
1463 + * - GNU Lesser General Public License Version 2.1
1464 + * - Sun Industry Standards Source License Version 1.1
1466 + * Sun Microsystems Inc., October, 2000
1468 + * GNU Lesser General Public License Version 2.1
1469 + * =============================================
1470 + * Copyright 2000 by Sun Microsystems, Inc.
1471 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1473 + * This library is free software; you can redistribute it and/or
1474 + * modify it under the terms of the GNU Lesser General Public
1475 + * License version 2.1, as published by the Free Software Foundation.
1477 + * This library is distributed in the hope that it will be useful,
1478 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1479 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1480 + * Lesser General Public License for more details.
1482 + * You should have received a copy of the GNU Lesser General Public
1483 + * License along with this library; if not, write to the Free Software
1484 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1485 + * MA 02111-1307 USA
1488 + * Sun Industry Standards Source License Version 1.1
1489 + * =================================================
1490 + * The contents of this file are subject to the Sun Industry Standards
1491 + * Source License Version 1.1 (the "License"); You may not use this file
1492 + * except in compliance with the License. You may obtain a copy of the
1493 + * License at http://www.openoffice.org/license.html.
1495 + * Software provided under this License is provided on an "AS IS" basis,
1496 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
1497 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
1498 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
1499 + * See the License for the specific provisions governing your rights and
1500 + * obligations concerning the Software.
1502 + * The Initial Developer of the Original Code is: Joerg Budischewski
1504 + * Copyright: 2000 by Sun Microsystems, Inc.
1506 + * All Rights Reserved.
1508 + * Contributor(s): Joerg Budischewski
1511 + ************************************************************************/
1513 +#ifndef _PG_BASERESULTSET_HXX_
1514 +#define _PG_BASERESULTSET_HXX_
1516 +#include <cppuhelper/propshlp.hxx>
1517 +#include <cppuhelper/component.hxx>
1519 +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
1520 +#include <com/sun/star/sdbc/XRow.hpp>
1521 +#include <com/sun/star/sdbc/XCloseable.hpp>
1522 +#include <com/sun/star/sdbc/XColumnLocate.hpp>
1523 +#include "pq_connection.hxx"
1525 +namespace pq_sdbc_driver
1528 +static const sal_Int32 BASERESULTSET_CURSOR_NAME = 0;
1529 +static const sal_Int32 BASERESULTSET_ESCAPE_PROCESSING = 1;
1530 +static const sal_Int32 BASERESULTSET_FETCH_DIRECTION = 2;
1531 +static const sal_Int32 BASERESULTSET_FETCH_SIZE = 3;
1532 +static const sal_Int32 BASERESULTSET_RESULT_SET_CONCURRENCY = 4;
1533 +static const sal_Int32 BASERESULTSET_RESULT_SET_TYPE = 5;
1535 +#define BASERESULTSET_SIZE 6
1537 +class BaseResultSet : public cppu::OComponentHelper,
1538 + public cppu::OPropertySetHelper,
1539 + public com::sun::star::sdbc::XCloseable,
1540 + public com::sun::star::sdbc::XResultSetMetaDataSupplier,
1541 + public com::sun::star::sdbc::XResultSet,
1542 + public com::sun::star::sdbc::XRow,
1543 + public com::sun::star::sdbc::XColumnLocate
1546 + com::sun::star::uno::Any m_props[BASERESULTSET_SIZE];
1547 + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_owner;
1548 + com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > m_tc;
1549 + ::rtl::Reference< RefCountedMutex > m_refMutex;
1551 + sal_Int32 m_rowCount;
1552 + sal_Int32 m_fieldCount;
1553 + sal_Bool m_wasNull;
1556 + inline cppu::OBroadcastHelper & getRBHelper() { return OComponentHelper::rBHelper;}
1559 + /** mutex should be locked before called
1561 + virtual void checkClosed()
1562 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException ) = 0;
1563 + virtual void checkColumnIndex( sal_Int32 index )
1564 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
1565 + virtual void checkRowIndex( sal_Bool mustBeOnValidRow );
1567 + virtual ::com::sun::star::uno::Any getValue( sal_Int32 columnIndex ) = 0;
1568 + com::sun::star::uno::Any convertTo(
1569 + const ::com::sun::star::uno::Any &str, const com::sun::star::uno::Type &type );
1573 + const ::rtl::Reference< RefCountedMutex > & mutex,
1574 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
1575 + sal_Int32 rowCount,
1576 + sal_Int32 columnCount,
1577 + const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > &tc );
1580 +public: // XInterface
1581 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
1582 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
1583 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
1584 + const com::sun::star::uno::Type & reqType )
1585 + throw (com::sun::star::uno::RuntimeException);
1587 +public: // XCloseable
1588 +// virtual void SAL_CALL close( )
1589 +// throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
1591 +public: // XTypeProvider, first implemented by OPropertySetHelper
1592 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
1593 + throw( com::sun::star::uno::RuntimeException );
1594 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
1595 + throw( com::sun::star::uno::RuntimeException );
1597 +public: // XResultSetMetaDataSupplier
1598 +// virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
1599 +// throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
1601 +public: // XResultSet
1603 + virtual sal_Bool SAL_CALL next( )
1604 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1605 + virtual sal_Bool SAL_CALL isBeforeFirst( )
1606 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1607 + virtual sal_Bool SAL_CALL isAfterLast( )
1608 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1609 + virtual sal_Bool SAL_CALL isFirst( )
1610 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1611 + virtual sal_Bool SAL_CALL isLast( )
1612 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1613 + virtual void SAL_CALL beforeFirst( )
1614 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1615 + virtual void SAL_CALL afterLast( )
1616 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1617 + virtual sal_Bool SAL_CALL first( )
1618 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1619 + virtual sal_Bool SAL_CALL last( )
1620 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1621 + virtual sal_Int32 SAL_CALL getRow( )
1622 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1623 + virtual sal_Bool SAL_CALL absolute( sal_Int32 row )
1624 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1625 + virtual sal_Bool SAL_CALL relative( sal_Int32 rows )
1626 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1627 + virtual sal_Bool SAL_CALL previous( )
1628 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1629 + virtual void SAL_CALL refreshRow( )
1630 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1631 + virtual sal_Bool SAL_CALL rowUpdated( )
1632 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1633 + virtual sal_Bool SAL_CALL rowInserted( )
1634 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1635 + virtual sal_Bool SAL_CALL rowDeleted( )
1636 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1637 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement()
1638 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1642 + virtual sal_Bool SAL_CALL wasNull( )
1643 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1644 + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex )
1645 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1646 + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex )
1647 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1648 + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex )
1649 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1650 + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex )
1651 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1652 + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex )
1653 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1654 + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex )
1655 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1656 + virtual float SAL_CALL getFloat( sal_Int32 columnIndex )
1657 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1658 + virtual double SAL_CALL getDouble( sal_Int32 columnIndex )
1659 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1660 + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex )
1661 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1662 + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex )
1663 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1664 + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex )
1665 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1666 + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex )
1667 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1668 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex )
1669 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1670 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex )
1671 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1672 + virtual ::com::sun::star::uno::Any SAL_CALL getObject(
1673 + sal_Int32 columnIndex,
1674 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
1675 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1676 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex )
1677 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1678 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex )
1679 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1680 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex )
1681 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1682 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex )
1683 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
1685 +public: // XColumnLocate
1686 +// virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName )
1687 +// throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
1689 +public: // OPropertySetHelper
1690 + virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
1692 + virtual sal_Bool SAL_CALL convertFastPropertyValue(
1693 + ::com::sun::star::uno::Any & rConvertedValue,
1694 + ::com::sun::star::uno::Any & rOldValue,
1695 + sal_Int32 nHandle,
1696 + const ::com::sun::star::uno::Any& rValue )
1697 + throw (::com::sun::star::lang::IllegalArgumentException);
1699 + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
1700 + sal_Int32 nHandle,
1701 + const ::com::sun::star::uno::Any& rValue )
1702 + throw (::com::sun::star::uno::Exception);
1704 + virtual void SAL_CALL getFastPropertyValue(
1705 + ::com::sun::star::uno::Any& rValue,
1706 + sal_Int32 nHandle ) const;
1709 + ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
1710 + throw(com::sun::star::uno::RuntimeException);
1712 +public: // OComponentHelper
1713 + virtual void SAL_CALL disposing();
1720 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
1721 +++ connectivity/source/drivers/postgresql/pq_connection.cxx 2007-01-07 14:50:37.000000000 +0100
1723 +/*************************************************************************
1725 + * $RCSfile: pq_connection.cxx,v $
1727 + * $Revision: 1.1.2.5 $
1729 + * last change: $Author: jbu $ $Date: 2007/01/07 13:50:37 $
1731 + * The Contents of this file are made available subject to the terms of
1732 + * either of the following licenses
1734 + * - GNU Lesser General Public License Version 2.1
1735 + * - Sun Industry Standards Source License Version 1.1
1737 + * Sun Microsystems Inc., October, 2000
1739 + * GNU Lesser General Public License Version 2.1
1740 + * =============================================
1741 + * Copyright 2000 by Sun Microsystems, Inc.
1742 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1744 + * This library is free software; you can redistribute it and/or
1745 + * modify it under the terms of the GNU Lesser General Public
1746 + * License version 2.1, as published by the Free Software Foundation.
1748 + * This library is distributed in the hope that it will be useful,
1749 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1750 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1751 + * Lesser General Public License for more details.
1753 + * You should have received a copy of the GNU Lesser General Public
1754 + * License along with this library; if not, write to the Free Software
1755 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1756 + * MA 02111-1307 USA
1759 + * Sun Industry Standards Source License Version 1.1
1760 + * =================================================
1761 + * The contents of this file are subject to the Sun Industry Standards
1762 + * Source License Version 1.1 (the "License"); You may not use this file
1763 + * except in compliance with the License. You may obtain a copy of the
1764 + * License at http://www.openoffice.org/license.html.
1766 + * Software provided under this License is provided on an "AS IS" basis,
1767 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
1768 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
1769 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
1770 + * See the License for the specific provisions governing your rights and
1771 + * obligations concerning the Software.
1773 + * The Initial Developer of the Original Code is: Joerg Budischewski
1775 + * Copyright: 2000 by Sun Microsystems, Inc.
1777 + * All Rights Reserved.
1779 + * Contributor(s): Joerg Budischewski
1782 + ************************************************************************/
1787 +#include <string.h>
1789 +#include "pq_connection.hxx"
1790 +#include "pq_statement.hxx"
1791 +#include "pq_preparedstatement.hxx"
1792 +#include "pq_databasemetadata.hxx"
1793 +#include "pq_xcontainer.hxx"
1794 +#include "pq_statics.hxx"
1795 +#include "pq_xtables.hxx"
1796 +#include "pq_xviews.hxx"
1797 +#include "pq_xusers.hxx"
1799 +#include <rtl/ustrbuf.hxx>
1800 +#include <rtl/strbuf.hxx>
1801 +#include <rtl/uuid.h>
1802 +#include <rtl/bootstrap.hxx>
1803 +#include <osl/module.h>
1805 +#include <cppuhelper/implementationentry.hxx>
1806 +#include <cppuhelper/implbase1.hxx>
1808 +#include <com/sun/star/beans/PropertyValue.hpp>
1809 +#include <com/sun/star/sdbc/XRow.hpp>
1811 +using rtl::OUStringBuffer;
1812 +using rtl::OUString;
1813 +using rtl::OString;
1814 +using rtl::OStringBuffer;
1815 +using rtl::OUStringToOString;
1816 +using osl::MutexGuard;
1818 +using com::sun::star::container::XNameAccess;
1820 +using com::sun::star::lang::XComponent;
1821 +using com::sun::star::lang::XInitialization;
1822 +using com::sun::star::lang::IllegalArgumentException;
1824 +using com::sun::star::script::XTypeConverter;
1826 +using com::sun::star::uno::RuntimeException;
1827 +using com::sun::star::uno::Exception;
1828 +using com::sun::star::uno::Sequence;
1829 +using com::sun::star::uno::Reference;
1830 +using com::sun::star::uno::XInterface;
1831 +using com::sun::star::uno::UNO_QUERY;
1832 +using com::sun::star::uno::XComponentContext;
1833 +using com::sun::star::uno::Any;
1834 +using com::sun::star::uno::makeAny;
1836 +using com::sun::star::beans::PropertyValue;
1837 +using com::sun::star::beans::XPropertySet;
1839 +using com::sun::star::sdbc::XConnection;
1840 +using com::sun::star::sdbc::XResultSet;
1841 +using com::sun::star::sdbc::XRow;
1842 +using com::sun::star::sdbc::XCloseable;
1843 +using com::sun::star::sdbc::SQLException;
1844 +using com::sun::star::sdbc::XWarningsSupplier;
1845 +using com::sun::star::sdbc::XPreparedStatement;
1846 +using com::sun::star::sdbc::XStatement;
1847 +using com::sun::star::sdbc::XDatabaseMetaData;
1849 +namespace pq_sdbc_driver
1852 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
1855 +// ______________________________________________________________________________
1856 +// Helper class for statement lifetime management
1857 +class ClosableReference : public cppu::WeakImplHelper1< com::sun::star::uno::XReference >
1859 + Connection *m_conn;
1860 + ::rtl::ByteSequence m_id;
1862 + ClosableReference( const ::rtl::ByteSequence & id , Connection *that )
1863 + : m_id( id ), m_conn( that )
1868 + virtual ~ClosableReference()
1871 + m_conn->release();
1874 + virtual void SAL_CALL dispose() throw ()
1878 + m_conn->removeFromWeakMap(m_id);
1879 + m_conn->release();
1885 +OUString ConnectionGetImplementationName()
1887 + return OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.connectivity.pq.Connection" ) );
1889 +com::sun::star::uno::Sequence<rtl::OUString> ConnectionGetSupportedServiceNames(void)
1891 + OUString serv( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.Connection" ) );
1892 + return Sequence< OUString> (&serv,1);
1895 +static sal_Int32 readLogLevelFromConfiguration()
1897 + sal_Int32 loglevel = LogLevel::NONE;
1898 + OUString fileName;
1899 + osl_getModuleURLFromAddress(
1900 + (void*) readLogLevelFromConfiguration, (rtl_uString **) &fileName );
1901 + fileName = OUString( fileName.getStr(), fileName.lastIndexOf( '/' )+1 );
1902 + fileName += OUString::createFromAscii( SAL_CONFIGFILE("postgresql-sdbc.uno") );
1903 + rtl::Bootstrap bootstrapHandle( fileName );
1906 + if( bootstrapHandle.getFrom( ASCII_STR( "PQ_LOGLEVEL" ), str ) )
1908 + if( str.equalsAscii( "NONE" ) )
1909 + loglevel = LogLevel::NONE;
1910 + else if( str.equalsAscii( "ERROR" ) )
1911 + loglevel = LogLevel::ERROR;
1912 + else if( str.equalsAscii( "SQL" ) )
1913 + loglevel = LogLevel::SQL;
1914 + else if( str.equalsAscii( "INFO" ) )
1915 + loglevel = LogLevel::SQL;
1918 + fprintf( stderr, "unknown loglevel %s\n",
1919 + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
1925 +Connection::Connection(
1926 + const rtl::Reference< RefCountedMutex > &refMutex,
1927 + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & ctx )
1928 + : ConnectionBase( refMutex->mutex ),
1930 + m_refMutex( refMutex )
1932 + m_settings.loglevel = readLogLevelFromConfiguration();
1934 + if( m_settings.loglevel > LogLevel::NONE )
1936 + m_settings.logFile = fopen( "sdbc-pqsql.log", "a" );
1937 + if( m_settings.logFile )
1939 + setvbuf( m_settings.logFile, 0, _IONBF, 0 );
1940 + log( &m_settings, m_settings.loglevel , "set this loglevel" );
1944 + fprintf( stderr, "Couldn't open sdbc-pqsql.log file\n" );
1949 +Connection::~Connection()
1951 + POSTGRE_TRACE( "dtor connection" );
1952 + if( m_settings.pConnection )
1954 + PQfinish( m_settings.pConnection );
1955 + m_settings.pConnection = 0;
1957 + if( m_settings.logFile )
1959 + fclose( m_settings.logFile );
1960 + m_settings.logFile = 0;
1963 +typedef ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XCloseable > ,
1964 + ::pq_sdbc_driver::Allocator < ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XCloseable > > > CloseableList;
1966 +typedef ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > ,
1967 + ::pq_sdbc_driver::Allocator < ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > > > DisposeableList;
1969 +void Connection::close() throw ( SQLException, RuntimeException )
1971 + CloseableList lst;
1972 + DisposeableList lstDispose;
1974 + MutexGuard guard( m_refMutex->mutex );
1975 + // silently ignore, if the connection has been closed already
1976 + if( m_settings.pConnection )
1978 + log( &m_settings, LogLevel::INFO, "closing connection" );
1979 + PQfinish( m_settings.pConnection );
1980 + m_settings.pConnection = 0;
1983 + lstDispose.push_back( Reference< XComponent > ( m_settings.users, UNO_QUERY ) );
1984 + lstDispose.push_back( Reference< XComponent > ( m_settings.tables , UNO_QUERY ) );
1985 + lstDispose.push_back( Reference< XComponent > ( m_meta, UNO_QUERY ) );
1987 + m_settings.tables.clear();
1988 + m_settings.users.clear();
1990 + for( WeakHashMap::iterator ii = m_myStatements.begin() ;
1991 + ii != m_myStatements.end() ;
1994 + Reference< XCloseable > r = ii->second;
1996 + lst.push_back( r );
2000 + // close all created statements
2001 + for( CloseableList::iterator ii = lst.begin(); ii != lst.end() ; ++ii )
2002 + ii->get()->close();
2004 + // close all created statements
2005 + for( DisposeableList::iterator iiDispose = lstDispose.begin();
2006 + iiDispose != lstDispose.end() ; ++iiDispose )
2008 + if( iiDispose->is() )
2009 + iiDispose->get()->dispose();
2014 +void Connection::removeFromWeakMap( const ::rtl::ByteSequence & id )
2016 + // shrink the list !
2017 + MutexGuard guard( m_refMutex->mutex );
2018 + WeakHashMap::iterator ii = m_myStatements.find( id );
2019 + if( ii != m_myStatements.end() )
2020 + m_myStatements.erase( ii );
2023 +Reference< XStatement > Connection::createStatement( ) throw (SQLException, RuntimeException)
2025 + MutexGuard guard( m_refMutex->mutex );
2028 + Statement *stmt = new Statement( m_refMutex, this , &m_settings );
2029 + Reference< XStatement > ret( stmt );
2030 + ::rtl::ByteSequence id( 16 );
2031 + rtl_createUuid( (sal_uInt8*) id.getConstArray(), 0 , sal_False );
2032 + m_myStatements[ id ] = Reference< XCloseable > ( stmt );
2033 + stmt->queryAdapter()->addReference( new ClosableReference( id, this ) );
2037 +Reference< XPreparedStatement > Connection::prepareStatement( const ::rtl::OUString& sql )
2038 + throw (SQLException, RuntimeException)
2040 + MutexGuard guard( m_refMutex->mutex );
2043 + rtl::OString byteSql = OUStringToOString( sql, m_settings.encoding );
2044 + PreparedStatement *stmt = new PreparedStatement( m_refMutex, this, &m_settings, byteSql );
2045 + Reference< XPreparedStatement > ret = stmt;
2047 + ::rtl::ByteSequence id( 16 );
2048 + rtl_createUuid( (sal_uInt8*) id.getConstArray(), 0 , sal_False );
2049 + m_myStatements[ id ] = Reference< XCloseable > ( stmt );
2050 + stmt->queryAdapter()->addReference( new ClosableReference( id, this ) );
2054 +Reference< XPreparedStatement > Connection::prepareCall( const ::rtl::OUString& sql )
2055 + throw (SQLException, RuntimeException)
2057 + throw SQLException(
2059 + RTL_CONSTASCII_USTRINGPARAM( "pq_driver: Callable statements not supported" ) ),
2060 + Reference< XInterface > (), OUString() , 1, Any() );
2064 +::rtl::OUString Connection::nativeSQL( const ::rtl::OUString& sql )
2065 + throw (SQLException, RuntimeException)
2070 +void Connection::setAutoCommit( sal_Bool autoCommit ) throw (SQLException, RuntimeException)
2075 +sal_Bool Connection::getAutoCommit( ) throw (SQLException, RuntimeException)
2081 +void Connection::commit( ) throw (SQLException, RuntimeException)
2086 +void Connection::rollback( ) throw (SQLException, RuntimeException)
2091 +sal_Bool Connection::isClosed( ) throw (SQLException, RuntimeException)
2093 + return m_settings.pConnection == 0;
2096 +Reference< XDatabaseMetaData > Connection::getMetaData( )
2097 + throw (SQLException, RuntimeException)
2099 + MutexGuard guard( m_refMutex->mutex );
2101 + if( ! m_meta.is() )
2102 + m_meta = new DatabaseMetaData( m_refMutex, this, &m_settings );
2106 +void Connection::setReadOnly( sal_Bool readOnly ) throw (SQLException, RuntimeException)
2112 +sal_Bool Connection::isReadOnly( ) throw (SQLException, RuntimeException)
2118 +void Connection::setCatalog( const ::rtl::OUString& catalog )
2119 + throw (SQLException, RuntimeException)
2124 +::rtl::OUString Connection::getCatalog( ) throw (SQLException, RuntimeException)
2127 + MutexGuard ( m_refMutex->mutex );
2128 + if( m_settings.pConnection == 0 )
2130 + throw SQLException( ASCII_STR( "pq_connection: connection is closed" ), *this,
2131 + OUString(), 1, Any() );
2133 + char * p = PQdb(m_settings.pConnection );
2134 + return OUString( p, strlen(p) , m_settings.encoding );
2137 +void Connection::setTransactionIsolation( sal_Int32 level )
2138 + throw (SQLException, RuntimeException)
2143 +sal_Int32 Connection::getTransactionIsolation( ) throw (SQLException, RuntimeException)
2149 +Reference< XNameAccess > Connection::getTypeMap( ) throw (SQLException, RuntimeException)
2151 + Reference< XNameAccess > t;
2153 + MutexGuard guard( m_refMutex->mutex );
2159 +void Connection::setTypeMap( const Reference< XNameAccess >& typeMap )
2160 + throw (SQLException, RuntimeException)
2162 + MutexGuard guard( m_refMutex->mutex );
2163 + m_typeMap = typeMap;
2165 +Any Connection::getWarnings( ) throw (SQLException, RuntimeException)
2170 +void Connection::clearWarnings( ) throw (SQLException, RuntimeException)
2175 +static OString properties2String( const OString initialString,
2176 + const Sequence< PropertyValue > & args,
2177 + const Reference< XTypeConverter> &tc )
2179 + OStringBuffer ret;
2181 + ret.append( initialString );
2182 + if( initialString.getLength() )
2183 + ret.append( " " );
2185 + bool initial = false;
2186 + for( int i = 0; i < args.getLength() ; i ++)
2188 + bool append = true;
2189 + if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "password" ) ) )
2191 + ret.append( "password=" );
2193 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "user" ) ) )
2195 + ret.append( "user=" );
2197 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "port" ) ) )
2199 + ret.append( "port=" );
2201 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "dbname" ) ) )
2203 + ret.append( "dbname=" );
2205 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "connect_timeout" ) ) )
2207 + ret.append( "connect_timeout=" );
2209 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "options" ) ) )
2211 + ret.append( "options=" );
2213 + else if( args[i].Name.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "requiressl" ) ) )
2215 + ret.append( "requiressl=" );
2225 + tc->convertTo( args[i].Value ,getCppuType( &value) ) >>= value;
2226 + ret.append( OUStringToOString( value, RTL_TEXTENCODING_UTF8) );
2227 + ret.append( " " );
2231 + return ret.makeStringAndClear();
2234 +void Connection::initialize( const Sequence< Any >& aArguments )
2235 + throw (Exception, RuntimeException)
2238 + Sequence< PropertyValue > args;
2240 + Reference< XTypeConverter > tc( m_ctx->getServiceManager()->createInstanceWithContext(
2241 + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" ) ), m_ctx ),
2245 + throw RuntimeException(
2246 + OUString( RTL_CONSTASCII_USTRINGPARAM("pq_driver: Couldn't instantiate converter service" )),
2247 + Reference< XInterface > () );
2249 + if( aArguments.getLength() != 2 )
2251 + OUStringBuffer buf(128);
2252 + buf.appendAscii( "pq_driver: expected 2 arguments, got " );
2253 + buf.append( aArguments.getLength( ) );
2254 + throw IllegalArgumentException(buf.makeStringAndClear(), Reference< XInterface > () , 0 );
2257 + if( ! (aArguments[0] >>= url) )
2259 + OUStringBuffer buf(128);
2260 + buf.appendAscii( "pq_driver: expected string as first argument, got " );
2261 + buf.append( aArguments[0].getValueType().getTypeName() );
2262 + throw IllegalArgumentException( buf.makeStringAndClear() , *this, 0 );
2265 + tc->convertTo( aArguments[1], getCppuType( &args ) ) >>= args;
2268 + int nColon = url.indexOf( ':' );
2269 + if( nColon != -1 )
2271 + nColon = url.indexOf( ':' , 1+ nColon );
2272 + if( nColon != -1 )
2274 + o = OUStringToOString( url.getStr()+nColon+1, m_settings.encoding );
2277 + o = properties2String( o , args , tc );
2279 + m_settings.pConnection = PQconnectdb( o.getStr() );
2280 + if( ! m_settings.pConnection )
2281 + throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM( "pq_driver: out of memory" ) ),
2282 + Reference< XInterface > () );
2283 + if( PQstatus( m_settings.pConnection ) == CONNECTION_BAD )
2285 + OUStringBuffer buf( 128 );
2287 + const char * error = PQerrorMessage( m_settings.pConnection );
2288 + OUString errorMessage( error, strlen( error) , RTL_TEXTENCODING_ASCII_US );
2289 + buf.appendAscii( "Couldn't establish database connection to '" );
2290 + buf.append( url );
2291 + buf.appendAscii( "' (" );
2292 + buf.append( errorMessage );
2293 + buf.appendAscii( ")" );
2294 + PQfinish( m_settings.pConnection );
2295 + m_settings.pConnection = 0;
2296 + throw SQLException( buf.makeStringAndClear(), *this, errorMessage, CONNECTION_BAD, Any() );
2298 + PQsetClientEncoding( m_settings.pConnection, "UNICODE" );
2299 + char *p = PQuser( m_settings.pConnection );
2300 + m_settings.user = OUString( p, strlen(p), RTL_TEXTENCODING_UTF8);
2301 + p = PQdb( m_settings.pConnection );
2302 + m_settings.catalog = OUString( p, strlen(p), RTL_TEXTENCODING_UTF8);
2303 + m_settings.tc = tc;
2305 + if( isLog( &m_settings, LogLevel::INFO ) )
2307 + OUStringBuffer buf( 128 );
2308 + buf.appendAscii( "connection to '" );
2309 + buf.append( url );
2310 + buf.appendAscii( "' successfully opened" );
2311 + log( &m_settings, LogLevel::INFO, buf.makeStringAndClear() );
2315 +void Connection::disposing()
2320 +void Connection::checkClosed() throw ( SQLException, RuntimeException )
2322 + if( !m_settings.pConnection )
2323 + throw SQLException( ASCII_STR( "pq_connection: Connection already closed" ),
2324 + *this, OUString(), 1, Any() );
2327 +Reference< XNameAccess > Connection::getTables( )
2328 + throw (::com::sun::star::uno::RuntimeException)
2330 + if( isLog( &m_settings, LogLevel::INFO ) )
2332 + log( &m_settings, LogLevel::INFO, "Connection::getTables() got called" );
2334 + MutexGuard guard( m_refMutex->mutex );
2335 + if( !m_settings.tables.is() )
2336 + m_settings.tables = Tables::create( m_refMutex, this, &m_settings , &m_settings.pTablesImpl);
2338 + // TODO: how to overcome the performance problem ?
2339 + Reference< com::sun::star::util::XRefreshable > ( m_settings.tables, UNO_QUERY )->refresh();
2340 + return m_settings.tables;
2343 +Reference< XNameAccess > Connection::getViews( )
2344 + throw (::com::sun::star::uno::RuntimeException)
2346 + if( isLog( &m_settings, LogLevel::INFO ) )
2348 + log( &m_settings, LogLevel::INFO, "Connection::getViews() got called" );
2350 + MutexGuard guard( m_refMutex->mutex );
2351 + if( !m_settings.views.is() )
2352 + m_settings.views = Views::create( m_refMutex, this, &m_settings, &(m_settings.pViewsImpl) );
2354 + // TODO: how to overcome the performance problem ?
2355 + Reference< com::sun::star::util::XRefreshable > ( m_settings.views, UNO_QUERY )->refresh();
2356 + return m_settings.views;
2361 +Reference< XNameAccess > Connection::getUsers( )
2362 + throw (::com::sun::star::uno::RuntimeException)
2364 + if( isLog( &m_settings, LogLevel::INFO ) )
2366 + log( &m_settings, LogLevel::INFO, "Connection::getUsers() got called" );
2369 + MutexGuard guard( m_refMutex->mutex );
2370 + if( !m_settings.users.is() )
2371 + m_settings.users = Users::create( m_refMutex, this, &m_settings );
2372 + return m_settings.users;
2376 +Reference< XInterface > ConnectionCreateInstance(
2377 + const Reference< XComponentContext > & ctx ) throw (Exception)
2379 + ::rtl::Reference< RefCountedMutex > ref = new RefCountedMutex();
2380 + return * new Connection( ref, ctx );
2385 +bool isLog( ConnectionSettings *settings, int loglevel )
2387 + return settings->loglevel >= loglevel && settings->logFile;
2390 +void log( ConnectionSettings *settings, sal_Int32 level, const OUString &logString )
2392 + log( settings, level, OUStringToOString( logString, settings->encoding ).getStr() );
2394 +void log( ConnectionSettings *settings, sal_Int32 level, const char *str )
2396 + if( isLog( settings, level ) )
2398 + static const char *strLevel[] = { "NONE", "ERROR", "SQL", "INFO", "DATA" };
2400 + time_t t = ::time( 0 );
2403 + pString = asctime( localtime( &t ) );
2405 + struct tm timestruc;
2407 + memset( timestr, 0 , 50);
2408 + pString = timestr;
2409 + ::localtime_r( &t , ×truc );
2410 + asctime_r( ×truc, timestr );
2412 + for( int i = 0 ; pString[i] ; i ++ )
2414 + if( pString[i] <= 13 )
2420 + fprintf( settings->logFile, "%s [%s]: %s\n", pString, strLevel[level], str );
2429 +static struct cppu::ImplementationEntry g_entries[] =
2432 + pq_sdbc_driver::ConnectionCreateInstance, pq_sdbc_driver::ConnectionGetImplementationName,
2433 + pq_sdbc_driver::ConnectionGetSupportedServiceNames, cppu::createSingleComponentFactory,
2436 + { 0, 0, 0, 0, 0, 0 }
2443 +//==================================================================================================
2444 +void SAL_CALL component_getImplementationEnvironment(
2445 + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
2447 + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
2449 +//==================================================================================================
2450 +sal_Bool SAL_CALL component_writeInfo(
2451 + void * pServiceManager, void * pRegistryKey )
2453 + return cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries );
2455 +//==================================================================================================
2456 +void * SAL_CALL component_getFactory(
2457 + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
2459 + return cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
2464 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
2465 +++ connectivity/source/drivers/postgresql/pq_connection.hxx 2004-06-10 17:26:55.000000000 +0200
2467 +/*************************************************************************
2469 + * $RCSfile: pq_connection.hxx,v $
2471 + * $Revision: 1.1.2.4 $
2473 + * last change: $Author: jbu $ $Date: 2004/06/10 15:26:55 $
2475 + * The Contents of this file are made available subject to the terms of
2476 + * either of the following licenses
2478 + * - GNU Lesser General Public License Version 2.1
2479 + * - Sun Industry Standards Source License Version 1.1
2481 + * Sun Microsystems Inc., October, 2000
2483 + * GNU Lesser General Public License Version 2.1
2484 + * =============================================
2485 + * Copyright 2000 by Sun Microsystems, Inc.
2486 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
2488 + * This library is free software; you can redistribute it and/or
2489 + * modify it under the terms of the GNU Lesser General Public
2490 + * License version 2.1, as published by the Free Software Foundation.
2492 + * This library is distributed in the hope that it will be useful,
2493 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2494 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2495 + * Lesser General Public License for more details.
2497 + * You should have received a copy of the GNU Lesser General Public
2498 + * License along with this library; if not, write to the Free Software
2499 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2500 + * MA 02111-1307 USA
2503 + * Sun Industry Standards Source License Version 1.1
2504 + * =================================================
2505 + * The contents of this file are subject to the Sun Industry Standards
2506 + * Source License Version 1.1 (the "License"); You may not use this file
2507 + * except in compliance with the License. You may obtain a copy of the
2508 + * License at http://www.openoffice.org/license.html.
2510 + * Software provided under this License is provided on an "AS IS" basis,
2511 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
2512 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
2513 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
2514 + * See the License for the specific provisions governing your rights and
2515 + * obligations concerning the Software.
2517 + * The Initial Developer of the Original Code is: Joerg Budischewski
2519 + * Copyright: 2000 by Sun Microsystems, Inc.
2521 + * All Rights Reserved.
2523 + * Contributor(s): Joerg Budischewski
2526 + ************************************************************************/
2528 +#ifndef _PQ_CONNECTION_HXX_
2529 +#define _PQ_CONNECTION_HXX_
2530 +#include <hash_map>
2531 +#include <com/sun/star/uno/XComponentContext.hpp>
2533 +#include <com/sun/star/lang/XInitialization.hpp>
2535 +#include <com/sun/star/script/XTypeConverter.hpp>
2537 +#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
2538 +#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
2539 +#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
2540 +#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
2541 +#include <com/sun/star/sdbc/XConnection.hpp>
2543 +#include <com/sun/star/container/XNameAccess.hpp>
2545 +#include <rtl/ref.hxx>
2546 +#include <rtl/byteseq.hxx>
2548 +#include <salhelper/simplereferenceobject.hxx>
2550 +#include <cppuhelper/weakref.hxx>
2551 +#include <cppuhelper/compbase6.hxx>
2553 +#include <libpq-fe.h>
2554 +#include "pq_allocator.hxx"
2556 +namespace pq_sdbc_driver
2558 +#ifdef POSTGRE_TRACE
2559 +#define POSTGRE_TRACE( x ) printf( "%s\n" , x )
2560 +#define POSTGRE_TRACE_1( x ,y) printf( "%s %s\n" , x ,y )
2562 +#define POSTGRE_TRACE(x) ((void)0)
2563 +#define POSTGRE_TRACE_1(x,y) ((void)0)
2566 +class RefCountedMutex : public salhelper::SimpleReferenceObject
2572 +struct ConnectionSettings;
2576 +//--------------------------------------------------
2578 +//--------------------------------------------------
2581 +// when you add a loglevel, extend the log function !
2582 +static const sal_Int32 NONE = 0;
2583 +static const sal_Int32 ERROR = 1;
2584 +static const sal_Int32 SQL = 2;
2585 +static const sal_Int32 INFO = 3;
2586 +static const sal_Int32 DATA = 4;
2588 +bool isLog( ConnectionSettings *settings, int loglevel );
2589 +void log( ConnectionSettings *settings, sal_Int32 level, const rtl::OUString &logString );
2590 +void log( ConnectionSettings *settings, sal_Int32 level, const char *str );
2591 +//--------------------------------------------------
2595 +struct ConnectionSettings
2597 + ConnectionSettings() :
2598 + showSystemColumns( sal_False ),
2600 + encoding( RTL_TEXTENCODING_UTF8),
2602 + loglevel( LogLevel::INFO )
2604 + rtl_TextEncoding encoding;
2605 + PGconn *pConnection;
2606 + ::com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > tc;
2607 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > tables;
2608 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > users;
2609 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > views;
2610 + Tables *pTablesImpl; // needed to implement renaming of tables / views
2611 + Views *pViewsImpl; // needed to implement renaming of tables / views
2612 + ::rtl::OUString user;
2613 + ::rtl::OUString catalog;
2614 + sal_Bool showSystemColumns;
2616 + sal_Int32 loglevel;
2619 +//--------------------------------------------------
2620 +typedef cppu::WeakComponentImplHelper6<
2621 + com::sun::star::sdbc::XConnection,
2622 + com::sun::star::sdbc::XWarningsSupplier,
2623 + com::sun::star::lang::XInitialization,
2624 + com::sun::star::sdbcx::XTablesSupplier,
2625 + com::sun::star::sdbcx::XViewsSupplier,
2626 + com::sun::star::sdbcx::XUsersSupplier > ConnectionBase;
2629 +struct HashByteSequence
2631 + sal_Int32 operator () ( const ::rtl::ByteSequence & seq ) const
2633 + return *(sal_Int32*) seq.getConstArray();
2637 +typedef ::std::hash_map<
2638 + ::rtl::ByteSequence,
2639 + ::com::sun::star::uno::WeakReference< com::sun::star::sdbc::XCloseable >,
2641 + ::std::equal_to< ::rtl::ByteSequence >,
2642 + Allocator< std::pair< const ::rtl::ByteSequence,::com::sun::star::uno::WeakReference< com::sun::star::sdbc::XCloseable > > >
2644 +typedef ::std::vector< rtl::OString, Allocator< ::rtl::OString > > OStringVector;
2648 +typedef std::hash_map
2652 + ::std::hash< sal_Int32 >,
2653 + ::std::equal_to< sal_Int32 >,
2654 + Allocator< ::std::pair< sal_Int32, ::rtl::OUString > >
2657 +class Connection : public ConnectionBase
2659 + ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_ctx;
2660 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_typeMap;
2661 + ConnectionSettings m_settings;
2662 + ::rtl::Reference< RefCountedMutex > m_refMutex;
2663 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XDatabaseMetaData > m_meta;
2664 + WeakHashMap m_myStatements;
2667 + void checkClosed()
2668 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
2672 + const rtl::Reference< RefCountedMutex > &refMutex,
2673 + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & ctx );
2677 +public: // XCloseable
2678 + virtual void SAL_CALL close()
2679 + throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
2681 +public: // XConnection
2683 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( )
2684 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
2685 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement(
2686 + const ::rtl::OUString& sql )
2687 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2688 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall(
2689 + const ::rtl::OUString& sql )
2690 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2691 + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql )
2692 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2693 + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit )
2694 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2695 + virtual sal_Bool SAL_CALL getAutoCommit( )
2696 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2697 + virtual void SAL_CALL commit( )
2698 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2699 + virtual void SAL_CALL rollback( )
2700 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2701 + virtual sal_Bool SAL_CALL isClosed( )
2702 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2703 + virtual ::com::sun::star::uno::Reference< com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( )
2704 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2705 + virtual void SAL_CALL setReadOnly( sal_Bool readOnly )
2706 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2707 + virtual sal_Bool SAL_CALL isReadOnly( )
2708 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2709 + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog )
2710 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2711 + virtual ::rtl::OUString SAL_CALL getCatalog( )
2712 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2713 + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level )
2714 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2715 + virtual sal_Int32 SAL_CALL getTransactionIsolation( )
2716 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2717 + virtual ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( )
2718 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2719 + virtual void SAL_CALL setTypeMap(
2720 + const ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >& typeMap )
2721 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2723 +public: // XWarningsSupplier
2724 + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( )
2725 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2726 + virtual void SAL_CALL clearWarnings( )
2727 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
2729 +public: // XInitialization
2730 + virtual void SAL_CALL initialize(
2731 + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
2732 + throw (com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
2734 +public: // XTablesSupplier
2735 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw (::com::sun::star::uno::RuntimeException);
2737 +public: // XUsersSupplier
2738 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw (::com::sun::star::uno::RuntimeException);
2740 +public: // XViewsSupplier
2741 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews( ) throw (::com::sun::star::uno::RuntimeException);
2744 + virtual void SAL_CALL disposing();
2746 +public: // helper function
2747 + void removeFromWeakMap( const ::rtl::ByteSequence & seq );
2752 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
2753 +++ connectivity/source/drivers/postgresql/pq_databasemetadata.cxx 2007-02-15 21:04:47.000000000 +0100
2755 +/*************************************************************************
2757 + * $RCSfile: pq_databasemetadata.cxx,v $
2759 + * $Revision: 1.1.2.11 $
2761 + * last change: $Author: jbu $ $Date: 2007/02/15 20:04:47 $
2763 + * The Contents of this file are made available subject to the terms of
2764 + * either of the following licenses
2766 + * - GNU Lesser General Public License Version 2.1
2767 + * - Sun Industry Standards Source License Version 1.1
2769 + * Sun Microsystems Inc., October, 2000
2771 + * GNU Lesser General Public License Version 2.1
2772 + * =============================================
2773 + * Copyright 2000 by Sun Microsystems, Inc.
2774 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
2776 + * This library is free software; you can redistribute it and/or
2777 + * modify it under the terms of the GNU Lesser General Public
2778 + * License version 2.1, as published by the Free Software Foundation.
2780 + * This library is distributed in the hope that it will be useful,
2781 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2782 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2783 + * Lesser General Public License for more details.
2785 + * You should have received a copy of the GNU Lesser General Public
2786 + * License along with this library; if not, write to the Free Software
2787 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2788 + * MA 02111-1307 USA
2791 + * Sun Industry Standards Source License Version 1.1
2792 + * =================================================
2793 + * The contents of this file are subject to the Sun Industry Standards
2794 + * Source License Version 1.1 (the "License"); You may not use this file
2795 + * except in compliance with the License. You may obtain a copy of the
2796 + * License at http://www.openoffice.org/license.html.
2798 + * Software provided under this License is provided on an "AS IS" basis,
2799 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
2800 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
2801 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
2802 + * See the License for the specific provisions governing your rights and
2803 + * obligations concerning the Software.
2805 + * The Initial Developer of the Original Code is: Joerg Budischewski
2807 + * Copyright: 2000 by Sun Microsystems, Inc.
2809 + * All Rights Reserved.
2811 + * Contributor(s): Joerg Budischewski
2814 + ************************************************************************/
2815 +#include <algorithm>
2816 +#include "pq_databasemetadata.hxx"
2817 +#include "pq_driver.hxx"
2818 +#include "pq_sequenceresultset.hxx"
2819 +#include "pq_statics.hxx"
2820 +#include "pq_tools.hxx"
2822 +#include <rtl/ustrbuf.hxx>
2824 +#include<com/sun/star/sdbc/TransactionIsolation.hpp>
2825 +#include<com/sun/star/sdbc/ResultSetType.hpp>
2826 +#include<com/sun/star/sdbc/XPreparedStatement.hpp>
2827 +#include<com/sun/star/sdbc/XParameters.hpp>
2828 +#include<com/sun/star/sdbc/DataType.hpp>
2829 +#include<com/sun/star/sdbc/IndexType.hpp>
2830 +#include<com/sun/star/sdbc/ColumnValue.hpp>
2831 +#include<com/sun/star/sdbc/ColumnSearch.hpp>
2833 +using ::osl::MutexGuard;
2835 +using ::rtl::OUString;
2837 +using com::sun::star::sdbc::SQLException;
2838 +using com::sun::star::sdbc::XStatement;
2839 +using com::sun::star::sdbc::XResultSet;
2840 +using com::sun::star::sdbc::XRow;
2841 +using com::sun::star::sdbc::XCloseable;
2842 +using com::sun::star::sdbc::XParameters;
2843 +using com::sun::star::sdbc::XPreparedStatement;
2844 +// using com::sun::star::sdbc::IndexType;
2845 +// using com::sun::star::sdbc::DataType;
2847 +using com::sun::star::uno::RuntimeException;
2848 +using com::sun::star::uno::Sequence;
2850 +using com::sun::star::uno::Reference;
2851 +using com::sun::star::uno::Sequence;
2852 +using com::sun::star::uno::Any;
2853 +using com::sun::star::uno::makeAny;
2854 +using com::sun::star::uno::UNO_QUERY;
2856 +namespace pq_sdbc_driver
2861 + com::sun::star::uno::Sequence< com::sun::star::uno::Any >,
2862 + Allocator< com::sun::star::uno::Sequence< com::sun::star::uno::Any > >
2863 +> SequenceAnyVector;
2866 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
2868 +static const int MAX_COLUMNS_IN_GROUPBY = 16;
2869 +static const int MAX_COLUMNS_IN_INDEX = 32;
2870 +static const int MAX_COLUMNS_IN_ORDER_BY = 16;
2871 +static const int MAX_COLUMNS_IN_SELECT = 1024;
2872 +static const int MAX_IDENTIFIER_LENGTH = 63;
2873 +static const int MAX_COLUMNS_IN_TABLE = 1024;
2874 +static const int MAX_CONNECTIONS = 0xffff;
2875 +static const int MAX_STATEMENTS = 0xffff;
2876 +static const int MAX_STATEMENT_LENGTH = -1;
2877 +static const int MAX_TABLES_IN_SELECT = 0xffff;
2878 +static const int MAX_USER_NAME_LENGTH = MAX_IDENTIFIER_LENGTH;
2881 +// alphabetically ordered !
2882 +static const int PRIVILEGE_CREATE = 0x1;
2883 +static const int PRIVILEGE_DELETE = 0x2;
2884 +static const int PRIVILEGE_EXECUTE = 0x4;
2885 +static const int PRIVILEGE_INSERT = 0x8;
2886 +static const int PRIVILEGE_REFERENCES = 0x10;
2887 +static const int PRIVILEGE_RULE = 0x20;
2888 +static const int PRIVILEGE_SELECT = 0x40;
2889 +static const int PRIVILEGE_TEMPORARY = 0x80;
2890 +static const int PRIVILEGE_TRIGGER = 0x100;
2891 +static const int PRIVILEGE_UPDATE = 0x200;
2892 +static const int PRIVILEGE_USAGE = 0x400;
2893 +static const int PRIVILEGE_MAX = PRIVILEGE_USAGE;
2895 +void DatabaseMetaData::checkClosed()
2896 + throw (SQLException, RuntimeException)
2900 +DatabaseMetaData::DatabaseMetaData(
2901 + const ::rtl::Reference< RefCountedMutex > & refMutex,
2902 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
2903 + ConnectionSettings *pSettings )
2904 + : m_pSettings( pSettings ),
2905 + m_origin( origin ),
2906 + m_refMutex( refMutex )
2912 +sal_Bool DatabaseMetaData::allProceduresAreCallable( ) throw (SQLException, RuntimeException)
2918 +sal_Bool DatabaseMetaData::allTablesAreSelectable( ) throw (SQLException, RuntimeException)
2923 +OUString DatabaseMetaData::getURL( ) throw (SQLException, RuntimeException)
2926 + return OUString();
2929 +OUString DatabaseMetaData::getUserName( ) throw (SQLException, RuntimeException)
2931 + return m_pSettings->user;
2934 +sal_Bool DatabaseMetaData::isReadOnly( ) throw (SQLException, RuntimeException)
2940 +sal_Bool DatabaseMetaData::nullsAreSortedHigh( ) throw (SQLException, RuntimeException)
2945 +sal_Bool DatabaseMetaData::nullsAreSortedLow( ) throw (SQLException, RuntimeException)
2947 + return ! nullsAreSortedHigh();
2950 +sal_Bool DatabaseMetaData::nullsAreSortedAtStart( ) throw (SQLException, RuntimeException)
2952 + return ! nullsAreSortedHigh();
2955 +sal_Bool DatabaseMetaData::nullsAreSortedAtEnd( ) throw (SQLException, RuntimeException)
2957 + return nullsAreSortedHigh();
2960 +OUString DatabaseMetaData::getDatabaseProductName( ) throw (SQLException, RuntimeException)
2962 + return ASCII_STR( "postgresql");
2965 +OUString DatabaseMetaData::getDatabaseProductVersion( ) throw (SQLException, RuntimeException)
2967 + return ASCII_STR( POSTGRESQL_VERSION );
2969 +OUString DatabaseMetaData::getDriverName( ) throw (SQLException, RuntimeException)
2971 + return ASCII_STR( "postgresql-sdbc" );
2974 +OUString DatabaseMetaData::getDriverVersion( ) throw (SQLException, RuntimeException)
2976 + return ASCII_STR( PQ_SDBC_DRIVER_VERSION );
2979 +sal_Int32 DatabaseMetaData::getDriverMajorVersion( ) throw (RuntimeException)
2981 + return PQ_SDBC_MAJOR;
2984 +sal_Int32 DatabaseMetaData::getDriverMinorVersion( ) throw (RuntimeException)
2986 + return PQ_SDBC_MINOR;
2989 +sal_Bool DatabaseMetaData::usesLocalFiles( ) throw (SQLException, RuntimeException)
2994 +sal_Bool DatabaseMetaData::usesLocalFilePerTable( ) throw (SQLException, RuntimeException)
2999 +sal_Bool DatabaseMetaData::supportsMixedCaseIdentifiers( ) throw (SQLException, RuntimeException)
3004 +sal_Bool DatabaseMetaData::storesUpperCaseIdentifiers( ) throw (SQLException, RuntimeException)
3009 +sal_Bool DatabaseMetaData::storesLowerCaseIdentifiers( ) throw (SQLException, RuntimeException)
3015 +sal_Bool DatabaseMetaData::storesMixedCaseIdentifiers( ) throw (SQLException, RuntimeException)
3021 +sal_Bool DatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw (SQLException, RuntimeException)
3026 +sal_Bool DatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw (SQLException, RuntimeException)
3032 +sal_Bool DatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw (SQLException, RuntimeException)
3038 +sal_Bool DatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw (SQLException, RuntimeException)
3044 +OUString DatabaseMetaData::getIdentifierQuoteString( ) throw (SQLException, RuntimeException)
3046 + return ASCII_STR( "\"" );
3049 +OUString DatabaseMetaData::getSQLKeywords( ) throw (SQLException, RuntimeException)
3062 +OUString DatabaseMetaData::getNumericFunctions( ) throw (SQLException, RuntimeException)
3065 + return OUString();
3068 +OUString DatabaseMetaData::getStringFunctions( ) throw (SQLException, RuntimeException)
3071 + return OUString();
3074 +OUString DatabaseMetaData::getSystemFunctions( ) throw (SQLException, RuntimeException)
3077 + return OUString();
3079 +OUString DatabaseMetaData::getTimeDateFunctions( ) throw (SQLException, RuntimeException)
3082 + return OUString();
3084 +OUString DatabaseMetaData::getSearchStringEscape( ) throw (SQLException, RuntimeException)
3086 + return ASCII_STR( "\\" );
3088 +OUString DatabaseMetaData::getExtraNameCharacters( ) throw (SQLException, RuntimeException)
3091 + return OUString();
3094 +sal_Bool DatabaseMetaData::supportsAlterTableWithAddColumn( ) throw (SQLException, RuntimeException)
3099 +sal_Bool DatabaseMetaData::supportsAlterTableWithDropColumn( ) throw (SQLException, RuntimeException)
3104 +sal_Bool DatabaseMetaData::supportsColumnAliasing( ) throw (SQLException, RuntimeException)
3109 +sal_Bool DatabaseMetaData::nullPlusNonNullIsNull( ) throw (SQLException, RuntimeException)
3114 +sal_Bool DatabaseMetaData::supportsTypeConversion( ) throw (SQLException, RuntimeException) // TODO, DON'T KNOW
3119 +sal_Bool DatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw (SQLException, RuntimeException) // TODO
3124 +sal_Bool DatabaseMetaData::supportsTableCorrelationNames( ) throw (SQLException, RuntimeException) // TODO, don't know
3130 +sal_Bool DatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw (SQLException, RuntimeException) // TODO, don't know
3135 +sal_Bool DatabaseMetaData::supportsExpressionsInOrderBy( ) throw (SQLException, RuntimeException)
3140 +sal_Bool DatabaseMetaData::supportsOrderByUnrelated( ) throw (SQLException, RuntimeException)
3145 +sal_Bool DatabaseMetaData::supportsGroupBy( ) throw (SQLException, RuntimeException)
3150 +sal_Bool DatabaseMetaData::supportsGroupByUnrelated( ) throw (SQLException, RuntimeException) // TODO, DONT know
3156 +sal_Bool DatabaseMetaData::supportsGroupByBeyondSelect( ) throw (SQLException, RuntimeException) // TODO, DON'T know
3162 +sal_Bool DatabaseMetaData::supportsLikeEscapeClause( ) throw (SQLException, RuntimeException)
3167 +sal_Bool DatabaseMetaData::supportsMultipleResultSets( ) throw (SQLException, RuntimeException)
3172 +sal_Bool DatabaseMetaData::supportsMultipleTransactions( ) throw (SQLException, RuntimeException)
3177 +sal_Bool DatabaseMetaData::supportsNonNullableColumns( ) throw (SQLException, RuntimeException)
3183 +sal_Bool DatabaseMetaData::supportsMinimumSQLGrammar( ) throw (SQLException, RuntimeException)
3188 +sal_Bool DatabaseMetaData::supportsCoreSQLGrammar( ) throw (SQLException, RuntimeException)
3193 +sal_Bool DatabaseMetaData::supportsExtendedSQLGrammar( ) throw (SQLException, RuntimeException)
3198 +sal_Bool DatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw (SQLException, RuntimeException)
3203 +sal_Bool DatabaseMetaData::supportsANSI92IntermediateSQL( ) throw (SQLException, RuntimeException)
3208 +sal_Bool DatabaseMetaData::supportsANSI92FullSQL( ) throw (SQLException, RuntimeException)
3213 +sal_Bool DatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw (SQLException, RuntimeException)
3219 +sal_Bool DatabaseMetaData::supportsOuterJoins( ) throw (SQLException, RuntimeException)
3224 +sal_Bool DatabaseMetaData::supportsFullOuterJoins( ) throw (SQLException, RuntimeException)
3229 +sal_Bool DatabaseMetaData::supportsLimitedOuterJoins( ) throw (SQLException, RuntimeException)
3235 +OUString DatabaseMetaData::getSchemaTerm( ) throw (SQLException, RuntimeException)
3237 + return ASCII_STR( "SCHEMA" );
3240 +OUString DatabaseMetaData::getProcedureTerm( ) throw (SQLException, RuntimeException)
3243 + return OUString();
3246 +OUString DatabaseMetaData::getCatalogTerm( ) throw (SQLException, RuntimeException)
3248 + // TODO is this correct ?
3249 + return ASCII_STR( "DATABASE" );
3252 +sal_Bool DatabaseMetaData::isCatalogAtStart( ) throw (SQLException, RuntimeException) // TODO don't know
3258 +OUString DatabaseMetaData::getCatalogSeparator( ) throw (SQLException, RuntimeException)
3260 + // TODO don't know
3261 + return ASCII_STR( "." );
3264 +sal_Bool DatabaseMetaData::supportsSchemasInDataManipulation( ) throw (SQLException, RuntimeException)
3269 +sal_Bool DatabaseMetaData::supportsSchemasInProcedureCalls( ) throw (SQLException, RuntimeException)
3274 +sal_Bool DatabaseMetaData::supportsSchemasInTableDefinitions( ) throw (SQLException, RuntimeException)
3279 +sal_Bool DatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw (SQLException, RuntimeException)
3284 +sal_Bool DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw (SQLException, RuntimeException)
3289 +sal_Bool DatabaseMetaData::supportsCatalogsInDataManipulation( ) throw (SQLException, RuntimeException)
3294 +sal_Bool DatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw (SQLException, RuntimeException)
3299 +sal_Bool DatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw (SQLException, RuntimeException)
3305 +sal_Bool DatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw (SQLException, RuntimeException)
3311 +sal_Bool DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw (SQLException, RuntimeException)
3317 +sal_Bool DatabaseMetaData::supportsPositionedDelete( ) throw (SQLException, RuntimeException)
3323 +sal_Bool DatabaseMetaData::supportsPositionedUpdate( ) throw (SQLException, RuntimeException)
3330 +sal_Bool DatabaseMetaData::supportsSelectForUpdate( ) throw (SQLException, RuntimeException)
3337 +sal_Bool DatabaseMetaData::supportsStoredProcedures( ) throw (SQLException, RuntimeException)
3344 +sal_Bool DatabaseMetaData::supportsSubqueriesInComparisons( ) throw (SQLException, RuntimeException)
3346 + // TODO , don't know
3350 +sal_Bool DatabaseMetaData::supportsSubqueriesInExists( ) throw (SQLException, RuntimeException)
3352 + // TODO , don't know
3356 +sal_Bool DatabaseMetaData::supportsSubqueriesInIns( ) throw (SQLException, RuntimeException)
3358 + // TODO , don't know
3362 +sal_Bool DatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw (SQLException, RuntimeException)
3364 + // TODO , don't know
3368 +sal_Bool DatabaseMetaData::supportsCorrelatedSubqueries( ) throw (SQLException, RuntimeException)
3370 + // TODO , don't know
3373 +sal_Bool DatabaseMetaData::supportsUnion( ) throw (SQLException, RuntimeException)
3378 +sal_Bool DatabaseMetaData::supportsUnionAll( ) throw (SQLException, RuntimeException)
3383 +sal_Bool DatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw (SQLException, RuntimeException)
3385 + // TODO, don't know
3389 +sal_Bool DatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw (SQLException, RuntimeException)
3391 + // TODO, don't know
3395 +sal_Bool DatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw (SQLException, RuntimeException)
3397 + // TODO, don't know
3400 +sal_Bool DatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw (SQLException, RuntimeException)
3402 + // TODO, don't know
3406 +sal_Int32 DatabaseMetaData::getMaxBinaryLiteralLength( ) throw (SQLException, RuntimeException)
3408 + // TODO, don't know
3412 +sal_Int32 DatabaseMetaData::getMaxCharLiteralLength( ) throw (SQLException, RuntimeException)
3417 +sal_Int32 DatabaseMetaData::getMaxColumnNameLength( ) throw (SQLException, RuntimeException) //TODO, don't know
3419 + return MAX_IDENTIFIER_LENGTH;
3422 +sal_Int32 DatabaseMetaData::getMaxColumnsInGroupBy( ) throw (SQLException, RuntimeException) //TODO, don't know
3424 + return MAX_COLUMNS_IN_GROUPBY;
3427 +sal_Int32 DatabaseMetaData::getMaxColumnsInIndex( ) throw (SQLException, RuntimeException) //TODO, don't know
3429 + return MAX_COLUMNS_IN_INDEX;
3432 +sal_Int32 DatabaseMetaData::getMaxColumnsInOrderBy( ) throw (SQLException, RuntimeException) //TODO, don't know
3434 + return MAX_COLUMNS_IN_ORDER_BY;
3437 +sal_Int32 DatabaseMetaData::getMaxColumnsInSelect( ) throw (SQLException, RuntimeException) //TODO, don't know
3439 + return MAX_COLUMNS_IN_SELECT;
3442 +sal_Int32 DatabaseMetaData::getMaxColumnsInTable( ) throw (SQLException, RuntimeException) //TODO, don't know
3444 + return MAX_COLUMNS_IN_TABLE;
3447 +sal_Int32 DatabaseMetaData::getMaxConnections( ) throw (SQLException, RuntimeException) //TODO, don't know
3449 + return MAX_CONNECTIONS;
3452 +sal_Int32 DatabaseMetaData::getMaxCursorNameLength( ) throw (SQLException, RuntimeException) //TODO, don't know
3454 + return MAX_IDENTIFIER_LENGTH;
3457 +sal_Int32 DatabaseMetaData::getMaxIndexLength( ) throw (SQLException, RuntimeException) //TODO, don't know
3459 + return MAX_IDENTIFIER_LENGTH;
3462 +sal_Int32 DatabaseMetaData::getMaxSchemaNameLength( ) throw (SQLException, RuntimeException)
3464 + return MAX_IDENTIFIER_LENGTH;
3467 +sal_Int32 DatabaseMetaData::getMaxProcedureNameLength( ) throw (SQLException, RuntimeException)
3469 + return MAX_IDENTIFIER_LENGTH;
3472 +sal_Int32 DatabaseMetaData::getMaxCatalogNameLength( ) throw (SQLException, RuntimeException)
3474 + return MAX_IDENTIFIER_LENGTH;
3477 +sal_Int32 DatabaseMetaData::getMaxRowSize( ) throw (SQLException, RuntimeException)
3482 +sal_Bool DatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw (SQLException, RuntimeException)
3487 +sal_Int32 DatabaseMetaData::getMaxStatementLength( ) throw (SQLException, RuntimeException) //TODO, don't know
3489 + return MAX_STATEMENT_LENGTH;
3492 +sal_Int32 DatabaseMetaData::getMaxStatements( ) throw (SQLException, RuntimeException) //TODO, don't know
3494 + return MAX_STATEMENTS;
3497 +sal_Int32 DatabaseMetaData::getMaxTableNameLength( ) throw (SQLException, RuntimeException)
3499 + return MAX_IDENTIFIER_LENGTH;
3502 +sal_Int32 DatabaseMetaData::getMaxTablesInSelect( ) throw (SQLException, RuntimeException)
3504 + return MAX_TABLES_IN_SELECT;
3507 +sal_Int32 DatabaseMetaData::getMaxUserNameLength( ) throw (SQLException, RuntimeException)
3509 + return MAX_USER_NAME_LENGTH;
3512 +sal_Int32 DatabaseMetaData::getDefaultTransactionIsolation( ) throw (SQLException, RuntimeException)
3514 + return com::sun::star::sdbc::TransactionIsolation::READ_COMMITTED;
3517 +sal_Bool DatabaseMetaData::supportsTransactions( ) throw (SQLException, RuntimeException)
3522 +sal_Bool DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw (SQLException, RuntimeException)
3527 +sal_Bool DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
3528 + throw (SQLException, RuntimeException)
3533 +sal_Bool DatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw (SQLException, RuntimeException)
3538 +sal_Bool DatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw (SQLException, RuntimeException)
3544 +sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLException, RuntimeException)
3549 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getProcedures(
3550 + const ::com::sun::star::uno::Any& catalog,
3551 + const OUString& schemaPattern,
3552 + const OUString& procedureNamePattern ) throw (SQLException, RuntimeException)
3554 +// 1. PROCEDURE_CAT string => procedure catalog (may be NULL )
3555 +// 2. PROCEDURE_SCHEM string => procedure schema (may be NULL )
3556 +// 3. PROCEDURE_NAME string => procedure name
3557 +// 4. reserved for future use
3558 +// 5. reserved for future use
3559 +// 6. reserved for future use
3560 +// 7. REMARKS string => explanatory comment on the procedure
3561 +// 8. PROCEDURE_TYPE short => kind of procedure:
3562 +// * UNKNOWN - May return a result
3563 +// * NO - Does not return a result
3564 +// * RETURN - Returns a result
3566 + MutexGuard guard( m_refMutex->mutex );
3568 + return new SequenceResultSet(
3569 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
3572 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getProcedureColumns(
3573 + const ::com::sun::star::uno::Any& catalog,
3574 + const OUString& schemaPattern,
3575 + const OUString& procedureNamePattern,
3576 + const OUString& columnNamePattern ) throw (SQLException, RuntimeException)
3578 + MutexGuard guard( m_refMutex->mutex );
3580 + return new SequenceResultSet(
3581 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
3584 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTables(
3585 + const ::com::sun::star::uno::Any& catalog,
3586 + const OUString& schemaPattern,
3587 + const OUString& tableNamePattern,
3588 + const ::com::sun::star::uno::Sequence< OUString >& types )
3589 + throw (SQLException, RuntimeException)
3591 + Statics &statics = getStatics();
3593 + MutexGuard guard( m_refMutex->mutex );
3596 + if( isLog( m_pSettings, LogLevel::INFO ) )
3598 + rtl::OUStringBuffer buf( 128 );
3599 + buf.appendAscii( "DatabaseMetaData::getTables got called with " );
3600 + buf.append( schemaPattern );
3601 + buf.appendAscii( "." );
3602 + buf.append( tableNamePattern );
3603 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
3605 + // ignore catalog, as a single pq connection does not support multiple catalogs
3607 + Reference< XPreparedStatement > statement = m_origin->prepareStatement(
3610 + "DISTINCT ON (pg_namespace.nspname, relname ) " // avoid duplicates (pg_settings !)
3611 + "pg_namespace.nspname, relname, relkind, pg_description.description "
3612 + "FROM pg_namespace, pg_class LEFT JOIN pg_description ON pg_class.oid = pg_description.objoid "
3613 + "WHERE relnamespace = pg_namespace.oid "
3614 + "AND ( relkind = 'r' OR relkind = 'v') "
3615 + "AND pg_namespace.nspname LIKE ? "
3616 + "AND relname LIKE ? "
3617 +// "ORDER BY pg_namespace.nspname || relname"
3620 + Reference< XParameters > parameters( statement, UNO_QUERY );
3621 + parameters->setString( 1 , schemaPattern );
3622 + parameters->setString( 2 , tableNamePattern );
3624 + Reference< XResultSet > rs = statement->executeQuery();
3625 + Reference< XRow > xRow( rs, UNO_QUERY );
3626 + SequenceAnyVector vec;
3628 + while( rs->next() )
3630 + Sequence< Any > row( 5 );
3632 + row[0] <<= m_pSettings->catalog;
3633 + row[1] <<= xRow->getString( 1 );
3634 + row[2] <<= xRow->getString( 2 );
3635 + OUString type = xRow->getString(3);
3636 + if( 0 == type.compareToAscii( "r" ) )
3638 + if( 0 == xRow->getString(1).compareToAscii( "pg_catalog" ) )
3640 + row[3] <<= statics.SYSTEM_TABLE;
3644 + row[3] <<= statics.TABLE;
3647 + else if( 0 == type.compareToAscii( "v" ) )
3649 + row[3] <<= statics.VIEW;
3653 + row[3] <<= statics.UNKNOWN;
3655 + row[4] <<= xRow->getString(4);
3657 + // no description in postgresql AFAIK
3658 + vec.push_back( row );
3660 + Reference< XCloseable > closeable( statement, UNO_QUERY );
3661 + if( closeable.is() )
3662 + closeable->close();
3664 + return new SequenceResultSet(
3665 + m_refMutex, *this, statics.tablesRowNames,
3666 + Sequence< Sequence< Any > > ( &vec[0],vec.size() ), m_pSettings->tc );
3669 +struct SortInternalSchemasLastAndPublicFirst
3671 + bool operator () ( const Sequence< Any > & a, const Sequence< Any > & b )
3678 + if( valueA.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "public" ) ) == 0 )
3682 + else if( valueB.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "public" ) ) == 0 )
3686 + else if( valueA.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "pg_" ) ) &&
3687 + valueB.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "pg_" ) ) )
3689 + ret = valueA.compareTo( valueB ) < 0; // sorts equal !
3691 + else if( valueA.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "pg_" ) ))
3693 + ret = false; // sorts last !
3695 + else if( valueB.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "pg_" ) ) )
3697 + ret = true; // sorts dorst !
3702 + ret = (valueA.compareTo( valueB ) < 0);
3708 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getSchemas( )
3709 + throw (SQLException, RuntimeException)
3711 + MutexGuard guard( m_refMutex->mutex );
3714 + if( isLog( m_pSettings, LogLevel::INFO ) )
3716 + log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getSchemas() got called" );
3718 + // <b>TABLE_SCHEM</b> string =&gt; schema name
3719 + Reference< XStatement > statement = m_origin->createStatement();
3720 + Reference< XResultSet > rs = statement->executeQuery(
3721 + ASCII_STR("SELECT nspname from pg_namespace") );
3723 + Reference< XRow > xRow( rs, UNO_QUERY );
3724 + SequenceAnyVector vec;
3725 + while( rs->next() )
3727 + Sequence<Any> row(1);
3728 + row[0] <<= xRow->getString(1);
3729 + vec.push_back( row );
3732 + // sort public first, sort internal schemas last, sort rest in alphabetic order
3733 + std::sort( vec.begin(), vec.end(), SortInternalSchemasLastAndPublicFirst() );
3735 + Reference< XCloseable > closeable( statement, UNO_QUERY );
3736 + if( closeable.is() )
3737 + closeable->close();
3738 + return new SequenceResultSet(
3739 + m_refMutex, *this, getStatics().schemaNames,
3740 + Sequence< Sequence< Any > > ( &vec[0], vec.size() ), m_pSettings->tc );
3743 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getCatalogs( )
3744 + throw (SQLException, RuntimeException)
3746 + MutexGuard guard( m_refMutex->mutex );
3748 + return new SequenceResultSet(
3749 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
3752 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTableTypes( )
3753 + throw (SQLException, RuntimeException)
3755 + MutexGuard guard( m_refMutex->mutex );
3757 + return new SequenceResultSet(
3758 + m_refMutex, *this, getStatics().tableTypeNames, getStatics().tableTypeData,
3759 + m_pSettings->tc );
3763 +/** returns the constant from sdbc.DataType
3765 +sal_Int32 typeNameToDataType( const OUString &typeName, const OUString &typtype )
3767 +// sal_Int32 ret = com::sun::star::sdbc::DataType::DISTINCT;
3768 + // map all unknown types to memo (longvarchar). This allows to show them in
3769 + // string representation. Additionally, the edit-table-type-selection-box
3770 + // is not so unuseable anymore.
3771 + sal_Int32 ret = com::sun::star::sdbc::DataType::LONGVARCHAR;
3772 + if( 0 == typtype.compareToAscii( "b" ) )
3774 + // as long as the OOo framework does not support arrays,
3775 + // the user is better of with interpreting arrays as strings !
3776 +// if( typeName.getLength() && '_' == typeName[0] )
3778 +// its just a naming convention, but as long as we don't have anything better,
3779 +// we take it as granted
3780 +// ret = com::sun::star::sdbc::DataType::ARRAY;
3783 + Statics &statics = getStatics();
3784 + BaseTypeMap::iterator ii = statics.baseTypeMap.find( typeName );
3785 + if( ii != statics.baseTypeMap.end() )
3790 + else if( 0 == typtype.compareToAscii( "c" ) )
3792 + ret = com::sun::star::sdbc::DataType::STRUCT;
3794 + else if( 0 == typtype.compareToAscii( "d" ) )
3796 + ret = com::sun::star::sdbc::DataType::LONGVARCHAR;
3801 +static bool isSystemColumn( const OUString &columnName )
3804 + columnName.compareToAscii( "oid" ) == 0 ||
3805 + columnName.compareToAscii( "tableoid" ) == 0 ||
3806 + columnName.compareToAscii( "xmin" ) == 0 ||
3807 + columnName.compareToAscii( "cmin" ) == 0 ||
3808 + columnName.compareToAscii( "xmax" ) == 0 ||
3809 + columnName.compareToAscii( "cmax" ) == 0 ||
3810 + columnName.compareToAscii( "ctid" ) == 0;
3813 +// is not exported by the postgres header
3814 +const static int PQ_VARHDRSZ = sizeof( sal_Int32 );
3816 +static void extractPrecisionAndScale(
3817 + sal_Int32 dataType, sal_Int32 atttypmod, sal_Int32 *precision, sal_Int32 *scale )
3819 + if( atttypmod < PQ_VARHDRSZ )
3826 + switch( dataType )
3828 + case com::sun::star::sdbc::DataType::NUMERIC:
3829 + case com::sun::star::sdbc::DataType::DECIMAL:
3831 + *precision = ( ( atttypmod - PQ_VARHDRSZ ) >> 16 ) & 0xffff;
3832 + *scale = (atttypmod - PQ_VARHDRSZ ) & 0xffff;
3836 + *precision = atttypmod - PQ_VARHDRSZ;
3842 +struct DatabaseTypeDescription
3844 + DatabaseTypeDescription()
3846 + DatabaseTypeDescription( const OUString &name, const OUString & type ) :
3850 + DatabaseTypeDescription( const DatabaseTypeDescription &source ) :
3851 + typeName( source.typeName ),
3852 + typeType( source.typeType )
3854 + DatabaseTypeDescription & operator = ( const DatabaseTypeDescription & source )
3856 + typeName = source.typeName;
3857 + typeType = source.typeType;
3860 + OUString typeName;
3861 + OUString typeType;
3864 +typedef std::hash_map
3867 + DatabaseTypeDescription,
3868 + ::std::hash< sal_Int32 >,
3869 + ::std::equal_to< sal_Int32 >,
3870 + Allocator< ::std::pair< sal_Int32, DatabaseTypeDescription > >
3871 +> Oid2DatabaseTypeDescriptionMap;
3873 +static void columnMetaData2DatabaseTypeDescription(
3874 + Oid2DatabaseTypeDescriptionMap &oidMap,
3875 + const Reference< XResultSet > &rs,
3876 + const Reference< XStatement > &stmt )
3878 + Reference< XRow > row( rs, UNO_QUERY );
3880 + rtl::OUStringBuffer queryBuf(128);
3881 + queryBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT oid,typtype,typname FROM pg_TYPE WHERE " ) );
3882 + while( rs->next() )
3884 + if( row->getString( 9 ).equalsAscii( "d" ) && oidMap.find( row->getInt( 12 ) ) == oidMap.end() )
3886 + oidMap[row->getInt(12)] = DatabaseTypeDescription();
3888 + queryBuf.appendAscii( " OR " );
3889 + queryBuf.appendAscii( "oid = " );
3890 + queryBuf.append( row->getInt(12 ), 10 );
3894 + rs->beforeFirst();
3898 + Reference< XResultSet > rsDomain = stmt->executeQuery( queryBuf.makeStringAndClear() );
3899 + row = Reference< XRow >( rsDomain, UNO_QUERY );
3900 + while( rsDomain->next() )
3902 + oidMap[row->getInt(1)] = DatabaseTypeDescription(row->getString(3), row->getString(2) );
3904 + disposeNoThrow( stmt );
3911 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getColumns(
3912 + const ::com::sun::star::uno::Any& catalog,
3913 + const OUString& schemaPattern,
3914 + const OUString& tableNamePattern,
3915 + const OUString& columnNamePattern ) throw (SQLException, RuntimeException)
3917 + Statics &statics = getStatics();
3920 + MutexGuard guard( m_refMutex->mutex );
3923 + if( isLog( m_pSettings, LogLevel::INFO ) )
3925 + rtl::OUStringBuffer buf( 128 );
3926 + buf.appendAscii( "DatabaseMetaData::getColumns got called with " );
3927 + buf.append( schemaPattern );
3928 + buf.appendAscii( "." );
3929 + buf.append( tableNamePattern );
3930 + buf.appendAscii( "." );
3931 + buf.append( columnNamePattern );
3932 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
3935 + // ignore catalog, as a single pq connection
3936 + // does not support multiple catalogs eitherway
3938 + // 1. TABLE_CAT string => table catalog (may be NULL)
3939 + // => not supported
3940 + // 2. TABLE_SCHEM string => table schema (may be NULL)
3941 + // => pg_namespace.nspname
3942 + // 3. TABLE_NAME string => table name
3943 + // => pg_class.relname
3944 + // 4. COLUMN_NAME string => column name
3945 + // => pg_attribure.attname
3946 + // 5. DATA_TYPE short => SQL type from java.sql.Types
3947 + // => pg_type.typname => sdbc.DataType
3948 + // 6. TYPE_NAME string => Data source dependent type name, for a UDT the
3949 + // type name is fully qualified
3950 + // => pg_type.typname
3951 + // 7. COLUMN_SIZE long => column size. For char or date types this is
3952 + // the maximum number of characters, for numeric
3953 + // or decimal types this is precision.
3954 + // => pg_attribute.atttypmod
3955 + // 8. BUFFER_LENGTH is not used.
3957 + // 9. DECIMAL_DIGITS long => the number of fractional digits
3958 + // => don't know ! TODO !
3959 + // 10. NUM_PREC_RADIX long => Radix (typically either 10 or 2)
3961 + // 11. NULLABLE long => is NULL allowed?
3962 + // NO_NULLS - might not allow NULL values
3963 + // NULABLE - definitely allows NULL values
3964 + // NULLABLE_UNKNOWN - nullability unknown
3965 + // => pg_attribute.attnotnull
3966 + // 12. REMARKS string => comment describing column (may be NULL )
3967 + // => Don't know, there does not seem to exist something like
3968 + // that in postgres
3969 + // 13. COLUMN_DEF string => default value (may be NULL)
3970 + // => pg_type.typdefault
3971 + // 14. SQL_DATA_TYPE long => unused
3973 + // 15. SQL_DATETIME_SUB long => unused
3975 + // 16. CHAR_OCTET_LENGTH long => for char types the maximum number of
3976 + // bytes in the column
3977 + // => pg_type.typlen
3978 + // 17. ORDINAL_POSITION int => index of column in table (starting at 1)
3979 + // pg_attribute.attnum
3980 + // 18. IS_NULLABLE string => "NO" means column definitely does not allow
3981 + // NULL values; "YES" means the column might
3982 + // allow NULL values. An empty string means
3984 + // => pg_attribute.attnotnull
3985 +// select objoid,description,objsubid,pg_attribute.attname from pg_attribute LEFT JOIN pg_description ON pg_attribute.attrelid=pg_description.objoid and pg_attribute.attnum = pg_description.objsubid
3987 + Reference< XPreparedStatement > statement = m_origin->prepareStatement(
3990 + "SELECT pg_namespace.nspname, " // 1
3991 + "pg_class.relname, " // 2
3992 + "pg_attribute.attname, " // 3
3993 + "pg_type.typname, " // 4
3994 + "pg_attribute.atttypmod, " // 5
3995 + "pg_attribute.attnotnull, " // 6
3996 + "pg_type.typdefault, " // 7
3997 + "pg_attribute.attnum, " // 8
3998 + "pg_type.typtype, " // 9
3999 + "pg_attrdef.adsrc, " // 10
4000 + "pg_description.description, " // 11
4001 + "pg_type.typbasetype " // 12
4003 + "pg_attribute LEFT JOIN pg_attrdef ON pg_attribute.attrelid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum "
4004 + "LEFT JOIN pg_description ON pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum=pg_description.objsubid,"
4005 + " pg_type, pg_namespace "
4006 + "WHERE pg_attribute.attrelid = pg_class.oid "
4007 + "AND pg_attribute.atttypid = pg_type.oid "
4008 + "AND pg_class.relnamespace = pg_namespace.oid "
4009 + "AND pg_namespace.nspname LIKE ? "
4010 + "AND pg_class.relname LIKE ? "
4011 + "AND pg_attribute.attname LIKE ? "
4012 + "ORDER BY pg_namespace.nspname || pg_class.relname || pg_attribute.attnum"
4015 + Reference< XParameters > parameters( statement, UNO_QUERY );
4016 + parameters->setString( 1 , schemaPattern );
4017 + parameters->setString( 2 , tableNamePattern );
4018 + parameters->setString( 3 , columnNamePattern );
4020 + Reference< XResultSet > rs = statement->executeQuery();
4021 + Reference< XRow > xRow( rs, UNO_QUERY );
4022 + SequenceAnyVector vec;
4024 + Oid2DatabaseTypeDescriptionMap domainMap;
4025 + Reference< XStatement > domainTypeStmt = m_origin->createStatement();
4026 + columnMetaData2DatabaseTypeDescription( domainMap, rs, domainTypeStmt );
4028 + while( rs->next() )
4030 + OUString columnName = xRow->getString(3);
4031 + if( m_pSettings->showSystemColumns || ! isSystemColumn( columnName ) )
4033 + sal_Int32 precision, scale, type;
4034 + Sequence< Any > row( 18 );
4035 + row[0] <<= m_pSettings->catalog;
4036 + row[1] <<= xRow->getString(1); //
4037 + row[2] <<= xRow->getString(2);
4038 + row[3] <<= columnName;
4039 + if( xRow->getString(9).equalsAscii( "d" ) )
4041 + DatabaseTypeDescription desc( domainMap[xRow->getInt(12)] );
4042 + type = typeNameToDataType( desc.typeName, desc.typeType );
4046 + type = typeNameToDataType( xRow->getString(4), xRow->getString(9) );
4048 + extractPrecisionAndScale( type, xRow->getInt(5) , &precision, &scale );
4050 + row[5] <<= xRow->getString(4);
4051 + row[6] <<= precision;
4053 + if( xRow->getBoolean( 6 ) && ! isSystemColumn(xRow->getString(3)) )
4055 + row[10] <<= OUString::valueOf(com::sun::star::sdbc::ColumnValue::NO_NULLS);
4056 + row[17] <<= statics.NO;
4060 + row[10] <<= OUString::valueOf(com::sun::star::sdbc::ColumnValue::NULLABLE);
4061 + row[17] <<= statics.YES;
4064 + row[11] <<= xRow->getString( 11 ); // comment
4065 + row[12] <<= xRow->getString(10); // COLUMN_DEF = pg_type.typdefault
4066 + row[15] <<= precision;
4067 + row[16] <<= xRow->getString(8) ;
4069 + // no description in postgresql AFAIK
4070 + vec.push_back( row );
4073 + Reference< XCloseable > closeable( statement, UNO_QUERY );
4074 + if( closeable.is() )
4075 + closeable->close();
4077 + return new SequenceResultSet(
4078 + m_refMutex, *this, statics.columnRowNames,
4079 + Sequence< Sequence< Any > > ( &vec[0],vec.size() ), m_pSettings->tc );
4082 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getColumnPrivileges(
4083 + const ::com::sun::star::uno::Any& catalog,
4084 + const OUString& schema,
4085 + const OUString& table,
4086 + const OUString& columnNamePattern ) throw (SQLException, RuntimeException)
4088 + MutexGuard guard( m_refMutex->mutex );
4090 + return new SequenceResultSet(
4091 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
4094 +static void addPrivilegesToVector(
4095 + sal_Int32 privilege, const OUString &catalog, const OUString & schema,
4096 + const OUString &tableName, const OUString &grantor, const OUString &grantee,
4097 + bool grantable, SequenceAnyVector &vec )
4099 + Statics & statics = getStatics();
4100 + for( int index = 1; index <= PRIVILEGE_MAX ; index = index << 1 )
4102 + OUString privname;
4103 + switch( privilege & index )
4105 + case PRIVILEGE_SELECT:
4106 + privname = statics.SELECT; break;
4107 + case PRIVILEGE_UPDATE:
4108 + privname = statics.UPDATE; break;
4109 + case PRIVILEGE_INSERT:
4110 + privname = statics.INSERT; break;
4111 + case PRIVILEGE_DELETE:
4112 + privname = statics.DELETE; break;
4113 + case PRIVILEGE_RULE:
4114 + privname = statics.RULE; break;
4115 + case PRIVILEGE_REFERENCES:
4116 + privname = statics.REFERENCES; break;
4117 + case PRIVILEGE_TRIGGER:
4118 + privname = statics.TRIGGER; break;
4119 + case PRIVILEGE_EXECUTE:
4120 + privname = statics.EXECUTE; break;
4121 + case PRIVILEGE_USAGE:
4122 + privname = statics.USAGE; break;
4123 + case PRIVILEGE_CREATE:
4124 + privname = statics.CREATE; break;
4125 + case PRIVILEGE_TEMPORARY:
4126 + privname = statics.TEMPORARY; break;
4131 + Sequence< Any > seq( 7 );
4132 + seq[0] <<= catalog;
4133 + seq[1] <<= schema;
4134 + seq[2] <<= tableName;
4135 + seq[3] <<= grantor;
4136 + seq[4] <<= grantee;
4137 + seq[5] <<= privname;
4138 + seq[6] <<= (grantable ? statics.YES : statics.NO );
4139 + vec.push_back( seq );
4144 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTablePrivileges(
4145 + const ::com::sun::star::uno::Any& catalog,
4146 + const OUString& schemaPattern,
4147 + const OUString& tableNamePattern ) throw (SQLException, RuntimeException)
4149 + MutexGuard guard( m_refMutex->mutex );
4152 + if( isLog( m_pSettings, LogLevel::INFO ) )
4154 + rtl::OUStringBuffer buf( 128 );
4155 + buf.appendAscii( "DatabaseMetaData::getTablePrivileges got called with " );
4156 + buf.append( schemaPattern );
4157 + buf.appendAscii( "." );
4158 + buf.append( tableNamePattern );
4159 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
4164 + // get the pg_class.relact item for the concrete table
4165 + // get userid for username from pg_shadow (or pg_user view)
4166 + // get the group names mentioned in pg_class.relact from pg_group
4167 + // identify, which groups the current user belongs to
4168 + // calculate the union of all permissions (1 public, 1 user, n groups)
4170 + // 1. TABLE_CAT string => table catalog (may be NULL )
4171 + // 2. TABLE_SCHEM string => table schema (may be NULL )
4172 + // 3. TABLE_NAME string => table name
4173 + // 4. GRANTOR => grantor of access (may be NULL )
4174 + // 5. GRANTEE string => grantee of access
4175 + // 6. PRIVILEGE string => name of access (SELECT, INSERT, UPDATE, REFERENCES, ...)
4176 + // 7. IS_GRANTABLE string => "YES" if grantee is permitted to grant to
4177 + // others; "NO" if not; NULL if unknown
4179 + Reference< XPreparedStatement > statement = m_origin->prepareStatement(
4181 + "SELECT pg_namespace.nspname, "
4182 + "pg_class.relname, "
4183 + "pg_class.relacl, "
4184 + "pg_user.usename "
4185 + "FROM pg_class, pg_user, pg_namespace "
4186 + "WHERE pg_class.relowner = pg_user.usesysid "
4187 + "AND ( pg_class.relkind = 'r' OR pg_class.relkind = 'v' ) "
4188 + "AND pg_class.relnamespace = pg_namespace.oid "
4189 + "AND pg_namespace.nspname LIKE ? "
4190 + "AND pg_class.relname LIKE ?"
4191 + "ORDER BY pg_namespace.nspname || pg_class.relname "
4194 + Reference< XParameters > parameters( statement, UNO_QUERY );
4195 + parameters->setString( 1 , schemaPattern );
4196 + parameters->setString( 2 , tableNamePattern );
4198 + Reference< XResultSet > rs = statement->executeQuery();
4199 + Reference< XRow > xRow( rs, UNO_QUERY );
4200 + SequenceAnyVector vec;
4201 + while( rs->next() )
4203 + // TODO calculate privileges !
4204 + sal_Int32 privilege = 0;
4206 + PRIVILEGE_SELECT | PRIVILEGE_UPDATE | PRIVILEGE_INSERT |
4207 + PRIVILEGE_DELETE | PRIVILEGE_RULE | PRIVILEGE_REFERENCES |
4208 + PRIVILEGE_TRIGGER| PRIVILEGE_EXECUTE| PRIVILEGE_USAGE |
4209 + PRIVILEGE_CREATE |PRIVILEGE_TEMPORARY;
4211 + addPrivilegesToVector( privilege,
4212 + m_pSettings->catalog,
4213 + xRow->getString( 1 ),
4214 + xRow->getString( 2 ),
4215 + xRow->getString( 4 ),
4216 + m_pSettings->user,
4217 + m_pSettings->user == xRow->getString( 4 ),
4221 + return new SequenceResultSet(
4222 + m_refMutex, *this, getStatics().tablePrivilegesNames,
4223 + Sequence< Sequence< Any > > ( &vec[0], vec.size() ), m_pSettings->tc );
4226 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getBestRowIdentifier(
4227 + const ::com::sun::star::uno::Any& catalog,
4228 + const OUString& schema,
4229 + const OUString& table,
4231 + sal_Bool nullable ) throw (SQLException, RuntimeException)
4233 + MutexGuard guard( m_refMutex->mutex );
4235 + return new SequenceResultSet(
4236 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
4239 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getVersionColumns(
4240 + const ::com::sun::star::uno::Any& catalog,
4241 + const OUString& schema,
4242 + const OUString& table ) throw (SQLException, RuntimeException)
4244 + MutexGuard guard( m_refMutex->mutex );
4246 + return new SequenceResultSet(
4247 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
4250 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getPrimaryKeys(
4251 + const ::com::sun::star::uno::Any& catalog,
4252 + const OUString& schema,
4253 + const OUString& table ) throw (SQLException, RuntimeException)
4255 + MutexGuard guard( m_refMutex->mutex );
4258 +// 1. TABLE_CAT string => table catalog (may be NULL )
4259 +// 2. TABLE_SCHEM string => table schema (may be NULL )
4260 +// 3. TABLE_NAME string => table name
4261 +// 4. COLUMN_NAME string => column name
4262 +// 5. KEY_SEQ short => sequence number within primary key
4263 +// 6. PK_NAME string => primary key name (may be NULL )
4265 + if( isLog( m_pSettings, LogLevel::INFO ) )
4267 + rtl::OUStringBuffer buf( 128 );
4268 + buf.appendAscii( "DatabaseMetaData::getPrimaryKeys got called with " );
4269 + buf.append( schema );
4270 + buf.appendAscii( "." );
4271 + buf.append( table );
4272 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
4275 + Reference< XPreparedStatement > statement = m_origin->prepareStatement(
4277 + "SELECT nmsp.nspname, "
4282 + "FROM pg_constraint as con,pg_class as cl, pg_namespace as nmsp "
4283 + "WHERE con.connamespace = nmsp.oid AND con.conrelid = cl.oid AND con.contype = 'p' "
4284 + "AND nmsp.nspname LIKE ? AND cl.relname LIKE ?" ) );
4286 + Reference< XParameters > parameters( statement, UNO_QUERY );
4287 + parameters->setString( 1 , schema );
4288 + parameters->setString( 2 , table );
4290 + Reference< XResultSet > rs = statement->executeQuery();
4291 + Reference< XRow > xRow( rs, UNO_QUERY );
4292 + SequenceAnyVector vec;
4294 + while( rs->next() )
4296 + Sequence< Any > row( 6 );
4297 + row[0] <<= m_pSettings->catalog;
4298 + row[1] <<= xRow->getString(1); //
4299 + row[2] <<= xRow->getString(2);
4300 + OUString array = xRow->getString(3);
4301 + row[4] <<= xRow->getString(5); // the relid
4302 + row[5] <<= xRow->getString(4);
4305 + // now retrieve the columns information
4306 + // unfortunately, postgresql does not allow array of variable size in
4307 + // WHERE clauses (in the default installation), so we have to choose
4308 + // this expensive and somewhat ugly way
4309 + // annotation: postgresql shouldn't have choosen an array here, instead they
4310 + // should have multiple rows per table
4311 + while( array[i] && '}' != array[i] )
4315 + while( array[i] && array[i] != '}' && array[i] != ',' ) i++;
4316 + row[3] <<= OUString( &array[start], i - start );
4317 + vec.push_back( row );
4321 + Reference< XCloseable > closeable( statement, UNO_QUERY );
4322 + if( closeable.is() )
4323 + closeable->close();
4326 + SequenceAnyVector::iterator ii = vec.begin();
4327 + OUString lastTableOid;
4329 + Sequence< Sequence< Any > > ret( vec.size() );
4331 + for( ; ii != vec.end() ; ++ ii )
4334 + Sequence< Any > row = *ii;
4335 + OUString tableOid;
4338 + row[4] >>= tableOid;
4339 + row[3] >>= attnum;
4340 + statement = m_origin->prepareStatement(
4342 + "SELECT att.attname FROM "
4343 + "pg_attribute AS att, pg_class AS cl WHERE "
4344 + "att.attrelid = ? AND att.attnum = ?" ));
4346 + parameters = Reference< XParameters >( statement, UNO_QUERY );
4347 + parameters->setString( 1 , tableOid );
4348 + parameters->setString( 2 , attnum );
4350 + rs = statement->executeQuery();
4351 + xRow = Reference< XRow >( rs, UNO_QUERY );
4355 + row[3] <<= xRow->getString( 1 );
4356 + if( tableOid != lastTableOid )
4358 + lastTableOid = tableOid;
4359 + row[4] <<= OUString::valueOf( index );
4362 + Reference< XCloseable > closeable( statement, UNO_QUERY );
4363 + if( closeable.is() )
4364 + closeable->close();
4365 + ret[elements] = row;
4368 + return new SequenceResultSet(
4369 + m_refMutex, *this, getStatics().primaryKeyNames, ret , m_pSettings->tc );
4372 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getImportedKeys(
4373 + const ::com::sun::star::uno::Any& catalog,
4374 + const OUString& schema,
4375 + const OUString& table ) throw (SQLException, RuntimeException)
4377 +// MutexGuard guard( m_refMutex->mutex );
4380 +// Statics &st = getStatics();
4381 +// Int2StringMap mainMap;
4382 +// fillAttnum2attnameMap( mainMap, m_origin, m_schemaName, m_tableName );
4384 +// Reference< XPreparedStatement > stmt = m_origin->prepareStatement(
4386 +// "SELECT conname, " // 1
4387 +// "confupdtype, " // 2
4388 +// "confdeltype, " // 3
4389 +// "class2.relname, " // 4
4390 +// "nmsp2.nspname, " // 5
4393 +// "FROM pg_constraint INNER JOIN pg_class ON conrelid = pg_class.oid "
4394 +// "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
4395 +// "LEFT JOIN pg_class AS class2 ON confrelid = class2.oid "
4396 +// "LEFT JOIN pg_namespace AS nmsp2 ON class2.relnamespace=nmsp2.oid "
4397 +// "WHERE pg_class.relname = ? AND "
4398 +// "pg_namespace.nspname = ? "
4399 +// "AND contype = 'f'"));
4401 +// Reference< XResultSet > rs = stmt->executeQuery();
4402 +// Reference< XRow > row( rs, UNO_QUERY );
4403 +// while( rs->next() )
4406 +// static const PKTABLE_CAT = 0;
4407 +// static const PKTABLE_SCHEM = 1;
4408 +// static const PKTABLE_NAME = 2;
4409 +// static const PKCOLUMN_NAME = 3;
4410 +// static const FKTABLE_CAT = 4;
4411 +// static const FKTABLE_SCHEM = 5;
4412 +// static const FKTABLE_NAME = 6;
4413 +// static const FKCOLUMN_NAME = 7;
4414 +// static const KEY_SEQ = 8;
4415 +// static const UPDATE_RULE = 9;
4416 +// static const DELETE_RULE = 10;
4417 +// static const FK_NAME = 11;
4418 +// static const PK_NAME = 12;
4419 +// static const DEFERRABILITY = 13;
4421 +// OUString pkSchema = xRow->getString(6);
4422 +// OUString pkTable = xRow->getString(5);
4424 +// Int2StringMap foreignMap;
4425 +// fillAttnum2attnameMap( foreignMap, m_origin,pkSchema, pkTable);
4427 +// Sequence< rtl::OUString > pkColNames =
4428 +// convertMappedIntArray2StringArray(
4429 +// foreignMap, string2intarray( row->getString( 7 ) ) );
4430 +// Sequence< rtl::OUString > fkColNames =
4431 +// convertMappedIntArray2StringArray(
4432 +// mainMap, string2intarray( row->getString( 6 ) ) );
4434 +// for( sal_Int32 i = 0 ; i < pkColNames.getLength() ; i ++ )
4436 +// Sequence< Any > theRow( 14 );
4438 +// theRow[PKTABLE_SCHEM] = makeAny( pkSchema );
4439 +// theRow[PKTABLE_NAME] = makeAny( pkTable );
4440 +// theRow[PKCOLUMN_NAME] = makeAny( pkColNames[i] );
4441 +// theRow[FKTABLE_SCHEM] = makeAny( schema );
4442 +// theRow[FKTABLE_NAME] = makeAny( table );
4443 +// theRow[FKCOLUMN_NAME] = makeAny( fkColNames[i] );
4444 +// theRow[KEY_SEQ] = makeAny( OUString::valueOf( i ) );
4448 +// pKey->setPropertyValue_NoBroadcast_public(
4449 +// st.PRIVATE_FOREIGN_COLUMNS,
4450 +// makeAny( resolveColumnNames(foreignMap, xRow->getString(8) ) ) );
4453 + // fake the getImportedKey() function call in
4454 + // dbaccess/source/ui/relationdesigin/RelationController.cxx
4455 + // it seems to be the only place in the office, where this function is needed
4456 + return new SequenceResultSet(
4457 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (1), m_pSettings->tc );
4460 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getExportedKeys(
4461 + const ::com::sun::star::uno::Any& catalog,
4462 + const OUString& schema,
4463 + const OUString& table ) throw (SQLException, RuntimeException)
4465 + throw ::com::sun::star::sdbc::SQLException(
4466 + ASCII_STR( "pq_databasemetadata: imported keys from tables not supported " ),
4468 + OUString(), 1, Any() );
4471 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getCrossReference(
4472 + const ::com::sun::star::uno::Any& primaryCatalog,
4473 + const OUString& primarySchema,
4474 + const OUString& primaryTable,
4475 + const ::com::sun::star::uno::Any& foreignCatalog,
4476 + const OUString& foreignSchema,
4477 + const OUString& foreignTable ) throw (SQLException, RuntimeException)
4479 + MutexGuard guard( m_refMutex->mutex );
4481 + return new SequenceResultSet(
4482 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
4486 +struct TypeInfoByDataTypeSorter
4488 + bool operator () ( const Sequence< Any > & a, const Sequence< Any > & b )
4492 + a[1 /*DATA_TYPE*/] >>= valueA;
4493 + b[1 /*DATA_TYPE*/] >>= valueB;
4494 + if( valueB.toInt32() == valueA.toInt32() )
4498 + a[0 /*TYPE_NAME*/] >>= nameA;
4499 + b[0 /*TYPE_NAME*/] >>= nameB;
4500 + if( nameA.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "int4" ) ) == 0 )
4502 + if( nameB.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "int4" ) ) == 0 )
4504 + return nameA.compareTo( nameB ) < 0;
4507 + return valueA.toInt32() < valueB.toInt32();
4508 +// sal_Int32 valueA;
4509 +// sal_Int32 valueB;
4510 +// a[1 /*DATA_TYPE*/] >>= valueA;
4511 +// b[1 /*DATA_TYPE*/] >>= valueB;
4512 +// if( valueB == valueA )
4516 +// a[0 /*TYPE_NAME*/] >>= nameA;
4517 +// b[0 /*TYPE_NAME*/] >>= nameB;
4518 +// return nameA.compareTo( nameB ) < 0;
4521 +// return valueA < valueB;
4525 +static sal_Int32 calcSearchable( sal_Int32 dataType )
4527 + sal_Int32 ret = com::sun::star::sdbc::ColumnSearch::FULL;
4528 + if( com::sun::star::sdbc::DataType::BINARY == dataType ||
4529 + com::sun::star::sdbc::DataType::VARBINARY == dataType ||
4530 + com::sun::star::sdbc::DataType::LONGVARBINARY == dataType )
4531 + sal_Int32 ret = com::sun::star::sdbc::ColumnSearch::NONE;
4536 +static sal_Int32 getMaxScale( sal_Int32 dataType )
4538 + sal_Int32 ret = 0;
4539 + if( dataType == com::sun::star::sdbc::DataType::NUMERIC )
4540 + ret = 1000; // see pg-docs DataType/numeric
4541 +// else if( dataType == DataType::DOUBLE )
4543 +// else if( dataType == DataType::FLOAT )
4551 + const char * typeName;
4552 + const char * createParam;
4553 + sal_Int32 sdbcType;
4554 + sal_Int32 precision;
4555 + sal_Int32 nullable;
4556 + bool caseSensitive;
4557 + sal_Int32 searchable;
4560 +static void pgTypeInfo2ResultSet(
4561 + SequenceAnyVector &vec,
4562 + const Reference< XResultSet > &rs )
4564 + static const sal_Int32 TYPE_NAME = 0; // string Type name
4565 + static const sal_Int32 DATA_TYPE = 1; // short SQL data type from java.sql.Types
4566 + static const sal_Int32 PRECISION = 2; // long maximum precision
4567 + static const sal_Int32 CREATE_PARAMS = 5; // string => parameters used in creating the type (may be NULL )
4568 + static const sal_Int32 NULLABLE = 6; // short ==> can you use NULL for this type?
4569 + // - NO_NULLS - does not allow NULL values
4570 + // - NULLABLE - allows NULL values
4571 + // - NULLABLE_UNKNOWN - nullability unknown
4573 + static const sal_Int32 CASE_SENSITIVE = 7; // boolean==> is it case sensitive
4574 + static const sal_Int32 SEARCHABLE = 8; // short ==>; can you use
4575 + // "WHERE" based on this type:
4576 + // - NONE - No support
4577 + // - CHAR - Only supported with WHERE .. LIKE
4578 + // - BASIC - Supported except for WHERE .. LIKE
4579 + // - FULL - Supported for all WHERE ..
4580 + static const sal_Int32 UNSIGNED_ATTRIBUTE = 9; // boolean ==> is it unsigned?
4581 + static const sal_Int32 FIXED_PREC_SCALE = 10; // boolean ==> can it be a money value?
4582 + static const sal_Int32 AUTO_INCREMENT = 11; // boolean ==> can it be used for
4583 + // an auto-increment value?
4584 + static const sal_Int32 MINIMUM_SCALE = 13; // short ==> minimum scale supported
4585 + static const sal_Int32 MAXIMUM_SCALE = 14; // short ==> maximum scale supported
4586 + static const sal_Int32 NUM_PREC_RADIX = 17; // long ==> usually 2 or 10
4588 + /* not filled so far
4589 + 3. LITERAL_PREFIX string ==> prefix used to quote a literal
4591 + 4, LITERAL_SUFFIX string ==> suffix used to quote a literal
4593 + 5. CREATE_PARAMS string ==> parameters used in creating thw type (may be <NULL/>)
4594 + 12. LOCAL_TYPE_NAME string ==> localized version of type name (may be <NULL/>)
4595 + 15, SQL_DATA_TYPE long ==> unused
4596 + 16. SQL_DATETIME_SUB long ==> unused
4598 + Reference< XRow > xRow( rs, UNO_QUERY );
4599 + while( rs->next() )
4601 + Sequence< Any > row(18);
4603 + sal_Int32 dataType =typeNameToDataType(xRow->getString(5),xRow->getString(2));
4604 + sal_Int32 precision = xRow->getString(3).toInt32();
4606 + if( dataType == com::sun::star::sdbc::DataType::CHAR ||
4607 + dataType == com::sun::star::sdbc::DataType::VARCHAR &&
4608 + xRow->getString(TYPE_NAME+1).equalsIgnoreAsciiCaseAscii( "varchar") )
4610 + // reflect varchar as varchar with upper limit !
4611 + //NOTE: the sql spec requires varchar to have an upper limit, however
4612 + // in postgresql the upper limit is optional, no limit means unlimited
4614 + precision = 0x40000000; // about 1 GB, see character type docs in postgresql
4615 + row[CREATE_PARAMS] <<= ASCII_STR( "length" );
4617 + else if( dataType == com::sun::star::sdbc::DataType::NUMERIC )
4620 + row[CREATE_PARAMS] <<= ASCII_STR( "length, scale" );
4623 + row[TYPE_NAME] <<= xRow->getString(1);
4624 + row[DATA_TYPE] <<= OUString::valueOf(dataType);
4625 + row[PRECISION] <<= OUString::valueOf( precision );
4626 + sal_Int32 nullable = xRow->getBoolean(4) ?
4627 + com::sun::star::sdbc::ColumnValue::NO_NULLS :
4628 + com::sun::star::sdbc::ColumnValue::NULLABLE;
4629 + row[NULLABLE] <<= OUString::valueOf(nullable);
4630 + row[CASE_SENSITIVE] <<= OUString::valueOf((sal_Int32)1);
4631 + row[SEARCHABLE] <<= OUString::valueOf( calcSearchable( dataType ) );
4632 + row[UNSIGNED_ATTRIBUTE] <<= ASCII_STR( "0" ); //
4633 + if( com::sun::star::sdbc::DataType::INTEGER == dataType ||
4634 + com::sun::star::sdbc::DataType::BIGINT == dataType )
4635 + row[AUTO_INCREMENT] <<= ASCII_STR( "1" ); // TODO
4637 + row[AUTO_INCREMENT] <<= ASCII_STR( "0" ); // TODO
4638 + row[MINIMUM_SCALE] <<= ASCII_STR( "0" ); // TODO: what is this ?
4639 + row[MAXIMUM_SCALE] <<= OUString::valueOf( getMaxScale( dataType ) );
4640 + row[NUM_PREC_RADIX] <<= ASCII_STR( "10" ); // TODO: what is this ?
4641 + vec.push_back( row );
4647 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTypeInfo( )
4648 + throw (SQLException, RuntimeException)
4650 + // Note: Indexes start at 0 (in the API doc, they start at 1)
4651 + MutexGuard guard( m_refMutex->mutex );
4654 + if( isLog( m_pSettings, LogLevel::INFO ) )
4656 + log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getTypeInfo() got called" );
4659 + Reference< XStatement > statement = m_origin->createStatement();
4660 + Reference< XResultSet > rs = statement->executeQuery(
4662 + "SELECT pg_type.typname AS typname," //1
4663 + "pg_type.typtype AS typtype," //2
4664 + "pg_type.typlen AS typlen," //3
4665 + "pg_type.typnotnull AS typnotnull," //4
4666 + "pg_type.typname AS typname " //5
4668 + "WHERE pg_type.typtype = 'b' "
4669 + "OR pg_type.typtype = 'p'"
4672 + SequenceAnyVector vec;
4673 + pgTypeInfo2ResultSet( vec, rs );
4675 + // check for domain types
4676 + rs = statement->executeQuery(
4678 + "SELECT t1.typname as typname,"
4679 + "t2.typtype AS typtype,"
4680 + "t2.typlen AS typlen,"
4681 + "t2.typnotnull AS typnotnull,"
4682 + "t2.typname as realtypname "
4683 + "FROM pg_type as t1 LEFT JOIN pg_type AS t2 ON t1.typbasetype=t2.oid "
4684 + "WHERE t1.typtype = 'd'" ) );
4685 + pgTypeInfo2ResultSet( vec, rs );
4687 + std::sort( vec.begin(), vec.end(), TypeInfoByDataTypeSorter() );
4689 + return new SequenceResultSet(
4692 + getStatics().typeinfoColumnNames,
4693 + Sequence< Sequence< Any > > ( &vec[0] , vec.size() ),
4695 + &( getStatics().typeInfoMetaData ));
4699 +static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value )
4701 + sal_Int32 ret = -1;
4702 + for( int i = 0; i < seq.getLength(); i ++ )
4704 + if( seq[i] == value )
4713 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getIndexInfo(
4714 + const ::com::sun::star::uno::Any& catalog,
4715 + const OUString& schema,
4716 + const OUString& table,
4718 + sal_Bool approximate ) throw (SQLException, RuntimeException)
4720 + MutexGuard guard( m_refMutex->mutex );
4724 + 1. TABLE_CAT string -> table catalog (may be NULL )
4725 + 2. TABLE_SCHEM string -> table schema (may be NULL )
4726 + 3. TABLE_NAME string -> table name
4727 + 4. NON_UNIQUE boolean -> Can index values be non-unique?
4728 + false when TYPE is tableIndexStatistic
4729 + 5. INDEX_QUALIFIER string -> index catalog (may be NULL );
4730 + NULL when TYPE is tableIndexStatistic
4731 + 6. INDEX_NAME string -> index name; NULL when TYPE is tableIndexStatistic
4732 + 7. TYPE short -> index type:
4733 + * 0 - this identifies table statistics that are returned
4734 + in conjuction with a table's index descriptions
4735 + * CLUSTERED - this is a clustered index
4736 + * HASHED - this is a hashed index
4737 + * OTHER - this is some other style of index
4738 + 8. ORDINAL_POSITION short -> column sequence number within index;
4739 + zero when TYPE is tableIndexStatistic
4740 + 9. COLUMN_NAME string -> column name; NULL when TYPE is tableIndexStatistic
4741 + 10. ASC_OR_DESC string -> column sort sequence, "A"= ascending,
4742 + "D" = descending, may be NULL if sort sequence
4743 + is not supported; NULL when TYPE is tableIndexStatistic
4744 + 11. CARDINALITY long -> When TYPE is tableIndexStatistic, then this is
4745 + the number of rows in the table; otherwise, it
4746 + is the number of unique values in the index.
4747 + 12. PAGES long -> When TYPE is tableIndexStatisic then this is
4748 + the number of pages used for the table, otherwise
4749 + it is the number of pages used for the current index.
4750 + 13. FILTER_CONDITION string -> Filter condition, if any. (may be NULL )
4753 + static const sal_Int32 C_SCHEMA = 1;
4754 + static const sal_Int32 C_TABLENAME = 2;
4755 + static const sal_Int32 C_INDEXNAME = 3;
4756 + static const sal_Int32 C_IS_CLUSTERED = 4;
4757 + static const sal_Int32 C_IS_UNIQUE = 5;
4758 + static const sal_Int32 C_IS_PRIMARY = 6;
4759 + static const sal_Int32 C_COLUMNS = 7;
4761 + static const sal_Int32 R_TABLE_SCHEM = 1;
4762 + static const sal_Int32 R_TABLE_NAME = 2;
4763 + static const sal_Int32 R_NON_UNIQUE = 3;
4764 + static const sal_Int32 R_INDEX_NAME = 5;
4765 + static const sal_Int32 R_TYPE = 6;
4766 + static const sal_Int32 R_ORDINAL_POSITION = 7;
4767 + static const sal_Int32 R_COLUMN_NAME = 8;
4769 + Reference< XPreparedStatement > stmt = m_origin->prepareStatement(
4771 + "SELECT nspname, " // 1
4772 + "pg_class.relname, " // 2
4773 + "class2.relname, " // 3
4774 + "indisclustered, " // 4
4775 + "indisunique, " // 5
4776 + "indisprimary, " // 6
4778 + "FROM pg_index INNER JOIN pg_class ON indrelid = pg_class.oid "
4779 + "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
4780 + "INNER JOIN pg_class as class2 ON pg_index.indexrelid = class2.oid "
4781 + "WHERE nspname = ? AND pg_class.relname = ?" ) );
4783 + Reference< XParameters > param ( stmt, UNO_QUERY );
4784 + param->setString( 1, schema );
4785 + param->setString( 2, table );
4786 + Reference< XResultSet > rs = stmt->executeQuery();
4787 + Reference< XRow > xRow ( rs, UNO_QUERY );
4789 + SequenceAnyVector vec;
4790 + while( rs->next() )
4792 + Sequence< sal_Int32 > columns = parseIntArray( xRow->getString(C_COLUMNS) );
4793 + Reference< XPreparedStatement > columnsStmt = m_origin->prepareStatement(
4795 + "SELECT attnum, attname "
4796 + "FROM pg_attribute "
4797 + " INNER JOIN pg_class ON attrelid = pg_class.oid "
4798 + " INNER JOIN pg_namespace ON pg_class.relnamespace=pg_namespace.oid "
4799 + " WHERE pg_namespace.nspname=? AND pg_class.relname=?" ) );
4800 + Reference< XParameters > paramColumn ( columnsStmt, UNO_QUERY );
4801 + OUString currentSchema = xRow->getString( C_SCHEMA );
4802 + OUString currentTable = xRow->getString( C_TABLENAME );
4803 + OUString currentIndexName = xRow->getString( C_INDEXNAME );
4804 + sal_Bool isNonUnique = ! xRow->getBoolean( C_IS_UNIQUE );
4805 + sal_Bool isPrimary = xRow->getBoolean( C_IS_PRIMARY );
4806 + sal_Int32 indexType = xRow->getBoolean( C_IS_CLUSTERED ) ?
4807 + com::sun::star::sdbc::IndexType::CLUSTERED :
4808 + com::sun::star::sdbc::IndexType::HASHED;
4810 + paramColumn->setString( C_SCHEMA, currentSchema );
4811 + paramColumn->setString( C_TABLENAME, currentTable );
4813 + Reference< XResultSet > rsColumn = columnsStmt->executeQuery();
4814 + Reference< XRow > rowColumn( rsColumn, UNO_QUERY );
4815 + while( rsColumn->next() )
4817 + sal_Int32 pos = seqContains( columns, rowColumn->getInt( 1 ) );
4818 + if( pos >= 0 && ( ! isNonUnique || ! unique ) )
4820 + Sequence< Any > result( 13 );
4821 + result[R_TABLE_SCHEM] = makeAny(currentSchema);
4822 + result[R_TABLE_NAME] = makeAny(currentTable);
4823 + result[R_INDEX_NAME] = makeAny(currentIndexName);
4824 + result[R_NON_UNIQUE] =
4825 + Any( &isNonUnique, getBooleanCppuType() );
4826 + result[R_TYPE] = makeAny( indexType );
4827 + result[R_COLUMN_NAME] = makeAny( rowColumn->getString(2) );
4828 + sal_Int32 nPos = ((sal_Int32)pos+1); // MSVC++ nonsense
4829 + result[R_ORDINAL_POSITION] = makeAny( nPos );
4830 + vec.push_back( result );
4834 + return new SequenceResultSet(
4835 + m_refMutex, *this, getStatics().indexinfoColumnNames,
4836 + Sequence< Sequence< Any > > ( &vec[0] , vec.size() ),
4837 + m_pSettings->tc );
4840 +sal_Bool DatabaseMetaData::supportsResultSetType( sal_Int32 setType )
4841 + throw (SQLException, RuntimeException)
4844 + setType == com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE ||
4845 + setType == com::sun::star::sdbc::ResultSetType::FORWARD_ONLY;
4848 +sal_Bool DatabaseMetaData::supportsResultSetConcurrency(
4849 + sal_Int32 setType, sal_Int32 concurrency ) throw (SQLException, RuntimeException)
4851 + return supportsResultSetType( setType ) &&
4852 + (concurrency == com::sun::star::sdbc::TransactionIsolation::READ_COMMITTED ||
4853 + concurrency == com::sun::star::sdbc::TransactionIsolation::SERIALIZABLE );
4856 +sal_Bool DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4861 +sal_Bool DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4866 +sal_Bool DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4871 +sal_Bool DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4876 +sal_Bool DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4881 +sal_Bool DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw (SQLException, RuntimeException)
4886 +sal_Bool DatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw (SQLException, RuntimeException)
4891 +sal_Bool DatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw (SQLException, RuntimeException)
4895 +sal_Bool DatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw (SQLException, RuntimeException)
4900 +sal_Bool DatabaseMetaData::supportsBatchUpdates( ) throw (SQLException, RuntimeException)
4905 +::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getUDTs( const ::com::sun::star::uno::Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw (SQLException, RuntimeException)
4907 + MutexGuard guard( m_refMutex->mutex );
4909 + return new SequenceResultSet(
4910 + m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc );
4913 +::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > DatabaseMetaData::getConnection()
4914 + throw (SQLException, RuntimeException)
4919 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
4920 +++ connectivity/source/drivers/postgresql/pq_databasemetadata.hxx 2003-06-03 23:48:28.000000000 +0200
4922 +/*************************************************************************
4924 + * $RCSfile: pq_databasemetadata.hxx,v $
4926 + * $Revision: 1.1.2.1 $
4928 + * last change: $Author: jbu $ $Date: 2003/06/03 21:48:28 $
4930 + * The Contents of this file are made available subject to the terms of
4931 + * either of the following licenses
4933 + * - GNU Lesser General Public License Version 2.1
4934 + * - Sun Industry Standards Source License Version 1.1
4936 + * Sun Microsystems Inc., October, 2000
4938 + * GNU Lesser General Public License Version 2.1
4939 + * =============================================
4940 + * Copyright 2000 by Sun Microsystems, Inc.
4941 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
4943 + * This library is free software; you can redistribute it and/or
4944 + * modify it under the terms of the GNU Lesser General Public
4945 + * License version 2.1, as published by the Free Software Foundation.
4947 + * This library is distributed in the hope that it will be useful,
4948 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4949 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4950 + * Lesser General Public License for more details.
4952 + * You should have received a copy of the GNU Lesser General Public
4953 + * License along with this library; if not, write to the Free Software
4954 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4955 + * MA 02111-1307 USA
4958 + * Sun Industry Standards Source License Version 1.1
4959 + * =================================================
4960 + * The contents of this file are subject to the Sun Industry Standards
4961 + * Source License Version 1.1 (the "License"); You may not use this file
4962 + * except in compliance with the License. You may obtain a copy of the
4963 + * License at http://www.openoffice.org/license.html.
4965 + * Software provided under this License is provided on an "AS IS" basis,
4966 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
4967 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
4968 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
4969 + * See the License for the specific provisions governing your rights and
4970 + * obligations concerning the Software.
4972 + * The Initial Developer of the Original Code is: Joerg Budischewski
4974 + * Copyright: 2000 by Sun Microsystems, Inc.
4976 + * All Rights Reserved.
4978 + * Contributor(s): Joerg Budischewski
4981 + ************************************************************************/
4983 +#ifndef _PQ_DATABASEMETADATA_HXX_
4984 +#define _PQ_DATABASEMETADATA_HXX_
4986 +#include "pq_connection.hxx"
4987 +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
4989 +#include <cppuhelper/implbase1.hxx>
4991 +namespace pq_sdbc_driver
4994 +class DatabaseMetaData :
4995 + public ::cppu::WeakImplHelper1 < com::sun::star::sdbc::XDatabaseMetaData >
4997 + ::rtl::Reference< RefCountedMutex > m_refMutex;
4998 + ConnectionSettings *m_pSettings;
4999 + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_origin;
5001 + void checkClosed()
5002 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5005 + const ::rtl::Reference< RefCountedMutex > & reMutex,
5006 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
5007 + ConnectionSettings *pSettings
5012 + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5013 + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5014 + virtual ::rtl::OUString SAL_CALL getURL( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5015 + virtual ::rtl::OUString SAL_CALL getUserName( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5016 + virtual sal_Bool SAL_CALL isReadOnly( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5017 + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5018 + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5019 + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5020 + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5021 + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5022 + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5023 + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5024 + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5025 + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw (::com::sun::star::uno::RuntimeException);
5026 + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw (::com::sun::star::uno::RuntimeException);
5027 + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5028 + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5029 + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5030 + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5031 + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5032 + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5033 + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5034 + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5035 + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5036 + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5037 + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5038 + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5039 + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5040 + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5041 + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5042 + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5043 + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5044 + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5045 + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5046 + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5047 + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5048 + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5049 + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5050 + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5051 + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5052 + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5053 + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5054 + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5055 + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5056 + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5057 + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5058 + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5059 + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5060 + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5061 + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5062 + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5063 + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5064 + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5065 + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5066 + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5067 + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5068 + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5069 + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5070 + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5071 + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5072 + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5073 + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5074 + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5075 + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5076 + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5077 + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5078 + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5079 + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5080 + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5081 + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5082 + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5083 + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5084 + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5085 + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5086 + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5087 + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5088 + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5089 + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5090 + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5091 + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5092 + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5093 + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5094 + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5095 + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5096 + virtual sal_Bool SAL_CALL supportsUnion( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5097 + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5098 + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5099 + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5100 + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5101 + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5102 + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5103 + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5104 + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5105 + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5106 + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5107 + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5108 + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5109 + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5110 + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5111 + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5112 + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5113 + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5114 + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5115 + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5116 + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5117 + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5118 + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5119 + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5120 + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5121 + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5122 + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5123 + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5124 + virtual sal_Bool SAL_CALL supportsTransactions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5125 + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5126 + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5127 + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5128 + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5129 + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5130 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5131 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5132 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5133 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5134 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5135 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5136 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5137 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5138 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5139 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5140 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5141 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5142 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5143 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5144 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5145 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5146 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5147 + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5148 + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5149 + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5150 + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5151 + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5152 + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5153 + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5154 + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5155 + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5156 + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5157 + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5158 + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5159 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5160 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5166 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
5167 +++ connectivity/source/drivers/postgresql/pq_driver.cxx 2004-05-09 21:47:13.000000000 +0200
5169 +/*************************************************************************
5171 + * $RCSfile: pq_driver.cxx,v $
5173 + * $Revision: 1.1.2.2 $
5175 + * last change: $Author: jbu $ $Date: 2004/05/09 19:47:13 $
5177 + * The Contents of this file are made available subject to the terms of
5178 + * either of the following licenses
5180 + * - GNU Lesser General Public License Version 2.1
5181 + * - Sun Industry Standards Source License Version 1.1
5183 + * Sun Microsystems Inc., October, 2000
5185 + * GNU Lesser General Public License Version 2.1
5186 + * =============================================
5187 + * Copyright 2000 by Sun Microsystems, Inc.
5188 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
5190 + * This library is free software; you can redistribute it and/or
5191 + * modify it under the terms of the GNU Lesser General Public
5192 + * License version 2.1, as published by the Free Software Foundation.
5194 + * This library is distributed in the hope that it will be useful,
5195 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5196 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197 + * Lesser General Public License for more details.
5199 + * You should have received a copy of the GNU Lesser General Public
5200 + * License along with this library; if not, write to the Free Software
5201 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5202 + * MA 02111-1307 USA
5205 + * Sun Industry Standards Source License Version 1.1
5206 + * =================================================
5207 + * The contents of this file are subject to the Sun Industry Standards
5208 + * Source License Version 1.1 (the "License"); You may not use this file
5209 + * except in compliance with the License. You may obtain a copy of the
5210 + * License at http://www.openoffice.org/license.html.
5212 + * Software provided under this License is provided on an "AS IS" basis,
5213 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
5214 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
5215 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
5216 + * See the License for the specific provisions governing your rights and
5217 + * obligations concerning the Software.
5219 + * The Initial Developer of the Original Code is: Joerg Budischewski
5221 + * Copyright: 2000 by Sun Microsystems, Inc.
5223 + * All Rights Reserved.
5225 + * Contributor(s): Joerg Budischewski
5228 + ************************************************************************/
5232 +#include <cppuhelper/factory.hxx>
5233 +#include <cppuhelper/compbase1.hxx>
5234 +#include <cppuhelper/compbase2.hxx>
5235 +#include <cppuhelper/implementationentry.hxx>
5237 +#include <com/sun/star/beans/XPropertySet.hpp>
5239 +#include "pq_driver.hxx"
5241 +using rtl::OUString;
5242 +using rtl::OUStringToOString;
5243 +using osl::MutexGuard;
5245 +using cppu::WeakComponentImplHelper2;
5247 +using com::sun::star::lang::XSingleComponentFactory;
5248 +using com::sun::star::lang::XServiceInfo;
5249 +using com::sun::star::lang::XComponent;
5251 +using com::sun::star::uno::RuntimeException;
5252 +using com::sun::star::uno::Exception;
5253 +using com::sun::star::uno::Sequence;
5254 +using com::sun::star::uno::Reference;
5255 +using com::sun::star::uno::XInterface;
5256 +using com::sun::star::uno::UNO_QUERY;
5257 +using com::sun::star::uno::XComponentContext;
5258 +using com::sun::star::uno::Any;
5260 +using com::sun::star::beans::PropertyValue;
5261 +using com::sun::star::beans::XPropertySet;
5263 +using com::sun::star::sdbc::XConnection;
5264 +using com::sun::star::sdbc::SQLException;
5265 +using com::sun::star::sdbc::DriverPropertyInfo;
5267 +using com::sun::star::sdbcx::XTablesSupplier;
5270 +namespace pq_sdbc_driver
5272 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
5274 +OUString DriverGetImplementationName()
5276 + static OUString *p;
5279 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5280 + static OUString instance(
5281 + RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.connectivity.pq.Driver" ) );
5287 +Sequence< OUString > DriverGetSupportedServiceNames()
5289 + static Sequence< OUString > *p;
5292 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5293 + OUString tmp( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.Driver" ) );
5294 + static Sequence< OUString > instance( &tmp,1 );
5300 +Reference< XConnection > Driver::connect(
5301 + const OUString& url,const Sequence< PropertyValue >& info )
5302 + throw (SQLException, RuntimeException)
5304 + if( ! acceptsURL( url ) ) // XDriver spec tells me to do so ...
5305 + return Reference< XConnection > ();
5307 + Sequence< Any > seq ( 2 );
5310 + return Reference< XConnection> (
5311 + m_smgr->createInstanceWithArgumentsAndContext(
5312 + OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.connectivity.pq.Connection" ) ),
5317 +sal_Bool Driver::acceptsURL( const ::rtl::OUString& url )
5318 + throw (SQLException, RuntimeException)
5320 + return url.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "sdbc:postgresql:" ) ) == 0;
5323 +Sequence< DriverPropertyInfo > Driver::getPropertyInfo(
5324 + const OUString& url,const Sequence< PropertyValue >& info )
5325 + throw (SQLException, RuntimeException)
5327 + return Sequence< DriverPropertyInfo > ();
5330 +sal_Int32 Driver::getMajorVersion( ) throw (RuntimeException)
5332 + return PQ_SDBC_MAJOR;
5336 +sal_Int32 Driver::getMinorVersion( ) throw (RuntimeException)
5338 + return PQ_SDBC_MINOR;
5342 +OUString SAL_CALL Driver::getImplementationName()
5343 + throw(::com::sun::star::uno::RuntimeException)
5345 + return DriverGetImplementationName();
5348 +sal_Bool Driver::supportsService(const OUString& ServiceName)
5349 + throw(::com::sun::star::uno::RuntimeException)
5351 + Sequence< OUString > serviceNames = DriverGetSupportedServiceNames();
5352 + for( int i = 0 ; i < serviceNames.getLength() ; i ++ )
5353 + if( serviceNames[i] == ServiceName )
5358 +Sequence< OUString > Driver::getSupportedServiceNames(void)
5359 + throw(::com::sun::star::uno::RuntimeException)
5361 + return DriverGetSupportedServiceNames();
5365 +void Driver::disposing()
5371 +Reference< XTablesSupplier > Driver::getDataDefinitionByConnection(
5372 + const Reference< XConnection >& connection )
5373 + throw (SQLException, RuntimeException)
5375 + return Reference< XTablesSupplier >( connection , UNO_QUERY );
5378 +Reference< XTablesSupplier > Driver::getDataDefinitionByURL(
5379 + const ::rtl::OUString& url, const Sequence< PropertyValue >& info )
5380 + throw (SQLException, RuntimeException)
5382 + return Reference< XTablesSupplier > ( connect( url, info ), UNO_QUERY );
5386 +Reference< XInterface > DriverCreateInstance( const Reference < XComponentContext > & ctx )
5388 + Reference< XInterface > ret = * new Driver( ctx );
5395 +class OOneInstanceComponentFactory :
5396 + public MutexHolder,
5397 + public WeakComponentImplHelper2< XSingleComponentFactory, XServiceInfo >
5400 + OOneInstanceComponentFactory(
5401 + const OUString & rImplementationName_,
5402 + cppu::ComponentFactoryFunc fptr,
5403 + const Sequence< OUString > & serviceNames,
5404 + const Reference< XComponentContext > & defaultContext) :
5405 + WeakComponentImplHelper2< XSingleComponentFactory, XServiceInfo >( this->m_mutex ),
5406 + m_implName( rImplementationName_ ),
5408 + m_serviceNames( serviceNames ),
5409 + m_defaultContext( defaultContext )
5413 + // XSingleComponentFactory
5414 + virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
5415 + Reference< XComponentContext > const & xContext )
5416 + throw (Exception, RuntimeException);
5417 + virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
5418 + Sequence< Any > const & rArguments,
5419 + Reference< XComponentContext > const & xContext )
5420 + throw (Exception, RuntimeException);
5423 + OUString SAL_CALL getImplementationName()
5424 + throw(::com::sun::star::uno::RuntimeException)
5426 + return m_implName;
5428 + sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
5429 + throw(::com::sun::star::uno::RuntimeException)
5431 + for( int i = 0 ; i < m_serviceNames.getLength() ; i ++ )
5432 + if( m_serviceNames[i] == ServiceName )
5436 + Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
5437 + throw(::com::sun::star::uno::RuntimeException)
5439 + return m_serviceNames;
5443 + virtual void SAL_CALL disposing();
5446 + cppu::ComponentFactoryFunc m_create;
5447 + Sequence< OUString > m_serviceNames;
5448 + OUString m_implName;
5449 + Reference< XInterface > m_theInstance;
5450 + Reference< XComponentContext > m_defaultContext;
5453 +Reference< XInterface > OOneInstanceComponentFactory::createInstanceWithArgumentsAndContext(
5454 + Sequence< Any > const &rArguments, const Reference< XComponentContext > & ctx )
5455 + throw( RuntimeException, Exception )
5457 + return createInstanceWithContext( ctx );
5460 +Reference< XInterface > OOneInstanceComponentFactory::createInstanceWithContext(
5461 + const Reference< XComponentContext > & ctx )
5462 + throw( RuntimeException, Exception )
5464 + if( ! m_theInstance.is() )
5466 + // work around the problem in sdbc
5467 + Reference< XComponentContext > useCtx = ctx;
5468 + if( ! useCtx.is() )
5469 + useCtx = m_defaultContext;
5470 + Reference< XInterface > theInstance = m_create( useCtx );
5471 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5472 + if( ! m_theInstance.is () )
5474 + m_theInstance = theInstance;
5477 + return m_theInstance;
5480 +void OOneInstanceComponentFactory::disposing()
5482 + Reference< XComponent > rComp;
5484 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5485 + rComp = Reference< XComponent >( m_theInstance, UNO_QUERY );
5486 + m_theInstance.clear();
5492 +// Reference< XSingleComponentFactory > createOneInstanceComponentFactory(
5493 +// cppu::ComponentFactoryFunc fptr,
5494 +// ::rtl::OUString const & rImplementationName,
5495 +// ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
5496 +// rtl_ModuleCount * pModCount = 0 )
5499 +// return new OOneInstanceComponentFactory( rImplementationName, fptr , rServiceNames);
5504 +static struct cppu::ImplementationEntry g_entries[] =
5507 + pq_sdbc_driver::DriverCreateInstance, pq_sdbc_driver::DriverGetImplementationName,
5508 + pq_sdbc_driver::DriverGetSupportedServiceNames, 0,
5511 + { 0, 0, 0, 0, 0, 0 }
5517 +//==================================================================================================
5518 +void SAL_CALL component_getImplementationEnvironment(
5519 + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
5521 + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
5523 +//==================================================================================================
5524 +sal_Bool SAL_CALL component_writeInfo(
5525 + void * pServiceManager, void * pRegistryKey )
5527 + return cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries );
5529 +//==================================================================================================
5530 +void * SAL_CALL component_getFactory(
5531 + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
5533 + // need to extract the defaultcontext, because the way, sdbc
5534 + // bypasses the servicemanager, does not allow to use the
5535 + // XSingleComponentFactory interface ...
5537 + Reference< XSingleComponentFactory > xFactory;
5538 + Reference< XInterface > xSmgr( (XInterface * ) pServiceManager );
5540 + for( sal_Int32 i = 0 ; g_entries[i].create ; i ++ )
5542 + OUString implName = g_entries[i].getImplementationName();
5543 + if( 0 == implName.compareToAscii( pImplName ) )
5545 + Reference< XComponentContext > defaultContext;
5546 + Reference< XPropertySet > propSet( xSmgr, UNO_QUERY );
5547 + if( propSet.is() )
5551 + propSet->getPropertyValue( ASCII_STR( "DefaultContext" ) ) >>= defaultContext;
5553 + catch( com::sun::star::uno::Exception &e )
5555 + // if there is no default context, ignore it
5558 + xFactory = new pq_sdbc_driver::OOneInstanceComponentFactory(
5560 + g_entries[i].create,
5561 + g_entries[i].getSupportedServiceNames(),
5566 + if( xFactory.is() )
5568 + xFactory->acquire();
5569 + pRet = xFactory.get();
5576 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
5577 +++ connectivity/source/drivers/postgresql/pq_driver.hxx 2004-05-09 21:47:14.000000000 +0200
5579 +/*************************************************************************
5581 + * $RCSfile: pq_driver.hxx,v $
5583 + * $Revision: 1.1.2.2 $
5585 + * last change: $Author: jbu $ $Date: 2004/05/09 19:47:14 $
5587 + * The Contents of this file are made available subject to the terms of
5588 + * either of the following licenses
5590 + * - GNU Lesser General Public License Version 2.1
5591 + * - Sun Industry Standards Source License Version 1.1
5593 + * Sun Microsystems Inc., October, 2000
5595 + * GNU Lesser General Public License Version 2.1
5596 + * =============================================
5597 + * Copyright 2000 by Sun Microsystems, Inc.
5598 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
5600 + * This library is free software; you can redistribute it and/or
5601 + * modify it under the terms of the GNU Lesser General Public
5602 + * License version 2.1, as published by the Free Software Foundation.
5604 + * This library is distributed in the hope that it will be useful,
5605 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5606 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5607 + * Lesser General Public License for more details.
5609 + * You should have received a copy of the GNU Lesser General Public
5610 + * License along with this library; if not, write to the Free Software
5611 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5612 + * MA 02111-1307 USA
5615 + * Sun Industry Standards Source License Version 1.1
5616 + * =================================================
5617 + * The contents of this file are subject to the Sun Industry Standards
5618 + * Source License Version 1.1 (the "License"); You may not use this file
5619 + * except in compliance with the License. You may obtain a copy of the
5620 + * License at http://www.openoffice.org/license.html.
5622 + * Software provided under this License is provided on an "AS IS" basis,
5623 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
5624 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
5625 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
5626 + * See the License for the specific provisions governing your rights and
5627 + * obligations concerning the Software.
5629 + * The Initial Developer of the Original Code is: Joerg Budischewski
5631 + * Copyright: 2000 by Sun Microsystems, Inc.
5633 + * All Rights Reserved.
5635 + * Contributor(s): Joerg Budischewski
5638 + ************************************************************************/
5639 +#ifndef _PG_DRIVER_HXX_
5640 +#define _PG_DRIVER_HXX_
5642 +#include <osl/mutex.hxx>
5644 +#include <cppuhelper/compbase2.hxx>
5645 +#include <cppuhelper/compbase3.hxx>
5647 +#include <com/sun/star/lang/XServiceInfo.hpp>
5649 +#include <com/sun/star/sdbc/XDriver.hpp>
5650 +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
5652 +#include <com/sun/star/uno/XComponentContext.hpp>
5654 +namespace pq_sdbc_driver
5657 +#define MY_STRINGIFY( x ) #x
5659 +#define PQ_SDBC_DRIVER_VERSION MY_STRINGIFY(PQ_SDBC_MAJOR) "." \
5660 + MY_STRINGIFY(PQ_SDBC_MINOR) "." \
5661 + MY_STRINGIFY(PQ_SDBC_MICRO)
5663 +#define POSTGRES_MAJOR 7
5664 +#define POSTGRES_MINOR 3
5665 +#define POSTGRES_MICRO 2
5666 +#define POSTGRESQL_VERSION MY_STRINGIFY(POSTGRESQL_MAJOR) "." \
5667 + MY_STRINGIFY(POSTGRESQL_MINOR) "." \
5668 + MY_STRINGIFY(POSTGRESQL_MICRO)
5671 +struct MutexHolder { osl::Mutex m_mutex; };
5672 +// use this to switch off sdbc support !
5673 +// typedef cppu::WeakComponentImplHelper2<
5674 +// com::sun::star::sdbc::XDriver,
5675 +// com::sun::star::lang::XServiceInfo
5677 +typedef cppu::WeakComponentImplHelper3<
5678 + com::sun::star::sdbc::XDriver,
5679 + com::sun::star::lang::XServiceInfo,
5680 + com::sun::star::sdbcx::XDataDefinitionSupplier > DriverBase ;
5681 +class Driver : public MutexHolder, public DriverBase
5683 + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_ctx;
5684 + com::sun::star::uno::Reference< com::sun::star::lang::XMultiComponentFactory > m_smgr;
5687 + Driver ( const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > & ctx )
5688 + : DriverBase( this->m_mutex ),
5690 + m_smgr( ctx->getServiceManager() )
5694 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect(
5695 + const ::rtl::OUString& url,
5696 + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info )
5697 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5699 + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url )
5700 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5702 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(
5703 + const ::rtl::OUString& url,
5704 + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info )
5705 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5707 + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw (::com::sun::star::uno::RuntimeException);
5708 + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw (::com::sun::star::uno::RuntimeException);
5710 +public: // XServiceInfo
5712 + virtual rtl::OUString SAL_CALL getImplementationName()
5713 + throw(::com::sun::star::uno::RuntimeException);
5714 + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
5715 + throw(::com::sun::star::uno::RuntimeException);
5717 + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
5718 + throw(::com::sun::star::uno::RuntimeException);
5720 +public: // XDataDefinitionSupplier
5721 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL
5722 + getDataDefinitionByConnection(
5723 + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection )
5724 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5725 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL
5726 + getDataDefinitionByURL(
5727 + const ::rtl::OUString& url,
5728 + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info )
5729 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
5732 + virtual void SAL_CALL disposing();
5740 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
5741 +++ connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx 2004-05-09 21:47:14.000000000 +0200
5743 +#include "pq_fakedupdateableresultset.hxx"
5744 +#include <cppuhelper/typeprovider.hxx>
5745 +#include <cppuhelper/queryinterface.hxx>
5747 +using osl::MutexGuard;
5749 +using rtl::OUString;
5751 +using com::sun::star::uno::Reference;
5752 +using com::sun::star::uno::makeAny;
5753 +using com::sun::star::uno::Sequence;
5754 +using com::sun::star::uno::UNO_QUERY;
5755 +using com::sun::star::uno::Any;
5756 +using com::sun::star::uno::Type;
5757 +using com::sun::star::uno::RuntimeException;
5759 +using com::sun::star::sdbc::SQLException;
5760 +using com::sun::star::sdbc::XResultSet;
5761 +using com::sun::star::sdbc::XResultSetUpdate;
5762 +using com::sun::star::sdbc::XRowUpdate;
5763 +using com::sun::star::sdbc::XRow;
5764 +using com::sun::star::sdbc::XStatement;
5766 +namespace pq_sdbc_driver
5769 +FakedUpdateableResultSet::FakedUpdateableResultSet(
5770 + const ::rtl::Reference< RefCountedMutex > & mutex,
5771 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
5772 + ConnectionSettings **pSettings,
5774 + const rtl::OUString &schema,
5775 + const rtl::OUString &table,
5776 + const rtl::OUString &aReason )
5777 + : ResultSet( mutex, owner, pSettings, result, schema, table ),
5778 + m_aReason( aReason )
5782 +com::sun::star::uno::Any FakedUpdateableResultSet::queryInterface(
5783 + const com::sun::star::uno::Type & reqType )
5784 + throw (com::sun::star::uno::RuntimeException)
5786 + Any ret = ResultSet::queryInterface( reqType );
5787 + if( ! ret.hasValue() )
5788 + ret = ::cppu::queryInterface(
5790 + static_cast< XResultSetUpdate * > ( this ),
5791 + static_cast< XRowUpdate * > ( this ) );
5796 +com::sun::star::uno::Sequence< com::sun::star::uno::Type > FakedUpdateableResultSet::getTypes()
5797 + throw( com::sun::star::uno::RuntimeException )
5799 + static cppu::OTypeCollection *pCollection;
5800 + if( ! pCollection )
5802 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5803 + if( !pCollection )
5805 + static cppu::OTypeCollection collection(
5806 + getCppuType( (Reference< XResultSetUpdate> *) 0 ),
5807 + getCppuType( (Reference< XRowUpdate> *) 0 ),
5808 + ResultSet::getTypes());
5809 + pCollection = &collection;
5812 + return pCollection->getTypes();
5816 +com::sun::star::uno::Sequence< sal_Int8> FakedUpdateableResultSet::getImplementationId()
5817 + throw( com::sun::star::uno::RuntimeException )
5819 + static cppu::OImplementationId *pId;
5822 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
5825 + static cppu::OImplementationId id(sal_False);
5829 + return pId->getImplementationId();
5832 +void FakedUpdateableResultSet::insertRow( ) throw (SQLException, RuntimeException)
5834 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5837 +void FakedUpdateableResultSet::updateRow( ) throw (SQLException, RuntimeException)
5839 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5842 +void FakedUpdateableResultSet::deleteRow( ) throw (SQLException, RuntimeException)
5844 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5847 +void FakedUpdateableResultSet::cancelRowUpdates( ) throw (SQLException, RuntimeException)
5849 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5852 +void FakedUpdateableResultSet::moveToInsertRow( ) throw (SQLException, RuntimeException)
5854 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5857 +void FakedUpdateableResultSet::moveToCurrentRow( ) throw (SQLException, RuntimeException)
5859 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5863 +void FakedUpdateableResultSet::updateNull( sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
5865 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5868 +void FakedUpdateableResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (SQLException, RuntimeException)
5870 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5873 +void FakedUpdateableResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (SQLException, RuntimeException)
5875 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5878 +void FakedUpdateableResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (SQLException, RuntimeException)
5880 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5883 +void FakedUpdateableResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (SQLException, RuntimeException)
5885 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5888 +void FakedUpdateableResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (SQLException, RuntimeException)
5890 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5893 +void FakedUpdateableResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw (SQLException, RuntimeException)
5895 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5898 +void FakedUpdateableResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw (SQLException, RuntimeException)
5900 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5903 +void FakedUpdateableResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw (SQLException, RuntimeException)
5905 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5908 +void FakedUpdateableResultSet::updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw (SQLException, RuntimeException)
5910 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5913 +void FakedUpdateableResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw (SQLException, RuntimeException)
5915 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5918 +void FakedUpdateableResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw (SQLException, RuntimeException)
5920 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5923 +void FakedUpdateableResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw (SQLException, RuntimeException)
5925 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5928 +void FakedUpdateableResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (SQLException, RuntimeException)
5930 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5933 +void FakedUpdateableResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (SQLException, RuntimeException)
5935 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5938 +void FakedUpdateableResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw (SQLException, RuntimeException)
5940 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5943 +void FakedUpdateableResultSet::updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw (SQLException, RuntimeException)
5945 + throw SQLException( m_aReason, *this, OUString(),1,Any() );
5949 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
5950 +++ connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx 2004-05-09 21:47:14.000000000 +0200
5952 +/*************************************************************************
5954 + * $RCSfile: pq_fakedupdateableresultset.hxx,v $
5956 + * $Revision: 1.1.2.1 $
5958 + * last change: $Author: jbu $ $Date: 2004/05/09 19:47:14 $
5960 + * The Contents of this file are made available subject to the terms of
5961 + * either of the following licenses
5963 + * - GNU Lesser General Public License Version 2.1
5964 + * - Sun Industry Standards Source License Version 1.1
5966 + * Sun Microsystems Inc., October, 2000
5968 + * GNU Lesser General Public License Version 2.1
5969 + * =============================================
5970 + * Copyright 2000 by Sun Microsystems, Inc.
5971 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
5973 + * This library is free software; you can redistribute it and/or
5974 + * modify it under the terms of the GNU Lesser General Public
5975 + * License version 2.1, as published by the Free Software Foundation.
5977 + * This library is distributed in the hope that it will be useful,
5978 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5979 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5980 + * Lesser General Public License for more details.
5982 + * You should have received a copy of the GNU Lesser General Public
5983 + * License along with this library; if not, write to the Free Software
5984 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5985 + * MA 02111-1307 USA
5988 + * Sun Industry Standards Source License Version 1.1
5989 + * =================================================
5990 + * The contents of this file are subject to the Sun Industry Standards
5991 + * Source License Version 1.1 (the "License"); You may not use this file
5992 + * except in compliance with the License. You may obtain a copy of the
5993 + * License at http://www.openoffice.org/license.html.
5995 + * Software provided under this License is provided on an "AS IS" basis,
5996 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
5997 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
5998 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
5999 + * See the License for the specific provisions governing your rights and
6000 + * obligations concerning the Software.
6002 + * The Initial Developer of the Original Code is: Joerg Budischewski
6004 + * Copyright: 2000 by Sun Microsystems, Inc.
6006 + * All Rights Reserved.
6008 + * Contributor(s): Joerg Budischewski
6011 + ************************************************************************/
6012 +#ifndef PG_UPDATEABLERESULTSET_HXX_
6013 +#define PG_UPDATEABLERESULTSET_HXX_
6015 +#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
6016 +#include <com/sun/star/sdbc/XRowUpdate.hpp>
6018 +#include "pq_resultset.hxx"
6020 +namespace pq_sdbc_driver
6022 +/** necessary to avoid crashes in OOo, when an updateable result set is requested,
6023 + but cannot be delivered.
6025 +class FakedUpdateableResultSet :
6027 + public com::sun::star::sdbc::XResultSetUpdate,
6028 + public com::sun::star::sdbc::XRowUpdate
6030 + ::rtl::OUString m_aReason;
6033 + FakedUpdateableResultSet(
6034 + const ::rtl::Reference< RefCountedMutex > & mutex,
6035 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
6036 + ConnectionSettings **pSettings,
6038 + const rtl::OUString &schema,
6039 + const rtl::OUString &table,
6040 + const rtl::OUString &aReason );
6042 +public: // XInterface
6043 + virtual void SAL_CALL acquire() throw() { ResultSet::acquire(); }
6044 + virtual void SAL_CALL release() throw() { ResultSet::release(); }
6045 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
6046 + const com::sun::star::uno::Type & reqType )
6047 + throw (com::sun::star::uno::RuntimeException);
6049 +public: // XTypeProvider
6050 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
6051 + throw( com::sun::star::uno::RuntimeException );
6052 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
6053 + throw( com::sun::star::uno::RuntimeException );
6055 +public: // XResultSetUpdate
6056 + virtual void SAL_CALL insertRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6057 + virtual void SAL_CALL updateRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6058 + virtual void SAL_CALL deleteRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6059 + virtual void SAL_CALL cancelRowUpdates( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6060 + virtual void SAL_CALL moveToInsertRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6061 + virtual void SAL_CALL moveToCurrentRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6063 +public: // XRowUpdate
6064 + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6065 + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6066 + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6067 + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6068 + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6069 + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6070 + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6071 + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6072 + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6073 + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6074 + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6075 + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6076 + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6077 + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6078 + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6079 + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6080 + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
6085 --- /dev/null 2008-11-25 09:24:02.506388553 +0100
6086 +++ connectivity/source/drivers/postgresql/pq_preparedstatement.cxx 2008-07-07 23:37:11.000000000 +0200
6088 +/*************************************************************************
6090 + * $RCSfile: pq_preparedstatement.cxx,v $
6092 + * $Revision: 1.1.2.10 $
6094 + * last change: $Author: jbu $ $Date: 2008/07/07 21:37:11 $
6096 + * The Contents of this file are made available subject to the terms of
6097 + * either of the following licenses
6099 + * - GNU Lesser General Public License Version 2.1
6100 + * - Sun Industry Standards Source License Version 1.1
6102 + * Sun Microsystems Inc., October, 2000
6104 + * GNU Lesser General Public License Version 2.1
6105 + * =============================================
6106 + * Copyright 2000 by Sun Microsystems, Inc.
6107 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
6109 + * This library is free software; you can redistribute it and/or
6110 + * modify it under the terms of the GNU Lesser General Public
6111 + * License version 2.1, as published by the Free Software Foundation.
6113 + * This library is distributed in the hope that it will be useful,
6114 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6115 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6116 + * Lesser General Public License for more details.
6118 + * You should have received a copy of the GNU Lesser General Public
6119 + * License along with this library; if not, write to the Free Software
6120 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6121 + * MA 02111-1307 USA
6124 + * Sun Industry Standards Source License Version 1.1
6125 + * =================================================
6126 + * The contents of this file are subject to the Sun Industry Standards
6127 + * Source License Version 1.1 (the "License"); You may not use this file
6128 + * except in compliance with the License. You may obtain a copy of the
6129 + * License at http://www.openoffice.org/license.html.
6131 + * Software provided under this License is provided on an "AS IS" basis,
6132 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
6133 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
6134 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
6135 + * See the License for the specific provisions governing your rights and
6136 + * obligations concerning the Software.
6138 + * The Initial Developer of the Original Code is: Joerg Budischewski
6140 + * Copyright: 2000 by Sun Microsystems, Inc.
6142 + * All Rights Reserved.
6144 + * Contributor(s): Joerg Budischewski
6147 + ************************************************************************/
6149 +#include "pq_preparedstatement.hxx"
6150 +#include "pq_resultset.hxx"
6151 +#include "pq_tools.hxx"
6152 +#include "pq_statics.hxx"
6153 +#include "pq_statement.hxx"
6155 +#include <rtl/strbuf.hxx>
6156 +#include <rtl/ustrbuf.hxx>
6159 +#include <cppuhelper/typeprovider.hxx>
6160 +#include <cppuhelper/queryinterface.hxx>
6162 +#include <com/sun/star/beans/PropertyAttribute.hpp>
6164 +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
6165 +#include <com/sun/star/sdbc/ResultSetType.hpp>
6168 +using osl::MutexGuard;
6170 +using rtl::OUString;
6171 +using rtl::OUStringToOString;
6172 +using rtl::OStringToOUString;
6173 +using rtl::OUStringBuffer;
6174 +using rtl::OStringBuffer;
6175 +using rtl::OString;
6177 +using com::sun::star::uno::Any;
6178 +using com::sun::star::uno::makeAny;
6179 +using com::sun::star::uno::Type;
6180 +using com::sun::star::uno::RuntimeException;
6181 +using com::sun::star::uno::Exception;
6182 +using com::sun::star::uno::Sequence;
6183 +using com::sun::star::uno::Reference;
6184 +using com::sun::star::uno::XInterface;
6185 +using com::sun::star::uno::UNO_QUERY;
6187 +using com::sun::star::lang::IllegalArgumentException;
6189 +using com::sun::star::sdbc::XWarningsSupplier;
6190 +using com::sun::star::sdbc::XCloseable;
6191 +using com::sun::star::sdbc::XPreparedStatement;
6192 +using com::sun::star::sdbc::XParameters;
6193 +using com::sun::star::sdbc::XResultSet;
6194 +using com::sun::star::sdbc::XRef;
6195 +using com::sun::star::sdbc::XBlob;
6196 +using com::sun::star::sdbc::XClob;
6197 +using com::sun::star::sdbc::XArray;
6198 +using com::sun::star::sdbc::XConnection;
6199 +using com::sun::star::sdbc::XGeneratedResultSet;
6200 +using com::sun::star::sdbc::SQLException;
6202 +using com::sun::star::beans::Property;
6203 +using com::sun::star::beans::XPropertySetInfo;
6204 +using com::sun::star::beans::XPropertySet;
6205 +using com::sun::star::beans::XMultiPropertySet;
6206 +using com::sun::star::beans::XFastPropertySet;
6208 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
6209 +namespace pq_sdbc_driver
6211 +static ::cppu::IPropertyArrayHelper & getPreparedStatementPropertyArrayHelper()
6213 + static ::cppu::IPropertyArrayHelper *pArrayHelper;
6214 + if( ! pArrayHelper )
6216 + MutexGuard guard( Mutex::getGlobalMutex() );
6217 + if( ! pArrayHelper )
6219 + static Property aTable[] =
6222 + OUString( RTL_CONSTASCII_USTRINGPARAM("CursorName") ), 0,
6223 + ::getCppuType( (OUString *)0) , 0 ),
6225 + OUString( RTL_CONSTASCII_USTRINGPARAM("EscapeProcessing") ), 1,
6226 + ::getBooleanCppuType() , 0 ),
6228 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchDirection") ), 2,
6229 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6231 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchSize") ), 3,
6232 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6234 + OUString( RTL_CONSTASCII_USTRINGPARAM("MaxFieldSize") ), 4,
6235 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6237 + OUString( RTL_CONSTASCII_USTRINGPARAM("MaxRows") ), 5,
6238 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6240 + OUString( RTL_CONSTASCII_USTRINGPARAM("QueryTimeOut") ), 6,
6241 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6243 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetConcurrency") ), 7,
6244 + ::getCppuType( (sal_Int32 *)0) , 0 ),
6246 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetType") ), 8,
6247 + ::getCppuType( (sal_Int32 *)0) , 0 )
6249 + OSL_ASSERT( sizeof(aTable)/ sizeof(Property) == PREPARED_STATEMENT_SIZE );
6250 + static ::cppu::OPropertyArrayHelper arrayHelper( aTable, PREPARED_STATEMENT_SIZE, sal_True );
6251 + pArrayHelper = &arrayHelper;
6254 + return *pArrayHelper;
6257 +static bool isOperator( char c )
6259 + static const char * operators = "<>=()!/&%.,;";
6261 + const char * w = operators;
6262 + for( ; *w && *w != c ; w ++);
6266 +static bool isNamedParameterStart( const rtl::OString & o , int index )
6268 + return o[index] == ':' && (
6269 + isWhitespace( o[index-1] ) || isOperator(o[index-1]) );
6272 +static bool isQuoted( const rtl::OString & str )
6274 + return str[0] == '"' || str[0] == '\'';
6277 +PreparedStatement::PreparedStatement(
6278 + const ::rtl::Reference< RefCountedMutex > & refMutex,
6279 + const Reference< XConnection > & conn,
6280 + struct ConnectionSettings *pSettings,
6281 + const ::rtl::OString & stmt )
6282 + : OComponentHelper( refMutex->mutex ),
6283 + OPropertySetHelper( OComponentHelper::rBHelper ),
6284 + m_refMutex( refMutex ),
6285 + m_connection( conn ),
6286 + m_pSettings( pSettings ),
6288 + m_lastOidInserted( InvalidOid )
6290 + m_props[PREPARED_STATEMENT_QUERY_TIME_OUT] = makeAny( (sal_Int32)0 );
6291 + m_props[PREPARED_STATEMENT_MAX_ROWS] = makeAny( (sal_Int32)0 );
6292 + m_props[PREPARED_STATEMENT_RESULT_SET_CONCURRENCY] = makeAny(
6293 + com::sun::star::sdbc::ResultSetConcurrency::READ_ONLY );
6294 + m_props[PREPARED_STATEMENT_RESULT_SET_TYPE] = makeAny(
6295 + com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
6297 + splitSQL( m_stmt, m_splittedStatement );
6299 + for( int i = 0, max = m_splittedStatement.size(); i < max ; i ++ )
6301 + const OString &str = m_splittedStatement[i];
6302 + // ignore quoted strings ....
6303 + if( ! isQuoted( str ) )
6305 + // the ':' cannot be the first or the last part of the
6307 + // the ? cannot be the first part of the token , so we start
6309 + for( int index = 1 ; index < str.getLength() ; index ++ )
6311 + if( str[index] == '?' ||
6312 + isNamedParameterStart( str , index )
6320 + m_vars = OStringVector ( elements );
6323 +PreparedStatement::~PreparedStatement()
6325 + POSTGRE_TRACE( "dtor PreparedStatement" );
6328 +void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex )
6330 + if( parameterIndex < 1 || parameterIndex > (sal_Int32) m_vars.size() )
6332 + OUStringBuffer buf( 128 );
6333 + buf.appendAscii( "pq_preparedstatement: parameter index out of range (expected 1 to " );
6334 + buf.append( (sal_Int32 ) m_vars.size() );
6335 + buf.appendAscii( ", got " );
6336 + buf.append( parameterIndex );
6337 + buf.appendAscii( ", statement '" );
6338 + buf.append( OStringToOUString( m_stmt, m_pSettings->encoding ) );
6339 + buf.appendAscii( "')" );
6340 + throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
6343 +void PreparedStatement::checkClosed() throw (SQLException, RuntimeException )
6345 + if( ! m_pSettings || ! m_pSettings->pConnection )
6346 + throw SQLException(
6347 + ASCII_STR("pq_driver: PreparedStatement or connection has already been closed !" ),
6348 + *this, OUString(),1,Any());
6351 +Any PreparedStatement::queryInterface( const Type & reqType ) throw (RuntimeException)
6355 + ret = OComponentHelper::queryInterface( reqType );
6356 + if( ! ret.hasValue() )
6357 + ret = ::cppu::queryInterface( reqType,
6358 + static_cast< XWarningsSupplier * > ( this ),
6359 + static_cast< XPreparedStatement * > ( this ),
6360 + static_cast< com::sun::star::sdbc::XResultSetMetaDataSupplier * > ( this ),
6361 + static_cast< XParameters * > ( this ),
6362 + static_cast< XCloseable * > ( this ),
6363 + static_cast< XGeneratedResultSet * > ( this ),
6364 + static_cast< XPropertySet * > ( this ),
6365 + static_cast< XMultiPropertySet * > ( this ),
6366 + static_cast< XFastPropertySet * > ( this ) );
6371 +Sequence< Type > PreparedStatement::getTypes() throw ( RuntimeException )
6373 + static cppu::OTypeCollection *pCollection;
6374 + if( ! pCollection )
6376 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
6377 + if( !pCollection )
6379 + static cppu::OTypeCollection collection(
6380 + getCppuType( (Reference< XWarningsSupplier> *) 0 ),
6381 + getCppuType( (Reference< XPreparedStatement> *) 0 ),
6382 + getCppuType( (Reference< com::sun::star::sdbc::XResultSetMetaDataSupplier> *) 0 ),
6383 + getCppuType( (Reference< XParameters> *) 0 ),
6384 + getCppuType( (Reference< XCloseable> *) 0 ),
6385 + getCppuType( (Reference< XGeneratedResultSet> *) 0 ),
6386 + getCppuType( (Reference< XPropertySet >*) 0 ),
6387 + getCppuType( (Reference< XFastPropertySet > *) 0 ),
6388 + getCppuType( (Reference< XMultiPropertySet > *) 0 ),
6389 + OComponentHelper::getTypes());
6390 + pCollection = &collection;
6393 + return pCollection->getTypes();
6396 +Sequence< sal_Int8> PreparedStatement::getImplementationId() throw ( RuntimeException )
6398 + static cppu::OImplementationId *pId;
6401 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
6404 + static cppu::OImplementationId id(sal_False);
6408 + return pId->getImplementationId();
6411 +void PreparedStatement::close( ) throw (SQLException, RuntimeException)
6413 + // let the connection die without acquired mutex !
6414 + Reference< XConnection > r;
6415 + Reference< XCloseable > resultSet;
6417 + MutexGuard guard( m_refMutex->mutex );
6420 + m_connection.clear();
6422 + resultSet = m_lastResultset;
6423 + m_lastResultset.clear();
6425 + if( resultSet.is() )
6427 + resultSet->close();
6431 +void PreparedStatement::raiseSQLException(
6432 + const char * errorMsg, const char *errorType )
6433 + throw( SQLException )
6435 + OUStringBuffer buf(128);
6436 + buf.appendAscii( "pq_driver: ");
6439 + buf.appendAscii( "[" );
6440 + buf.appendAscii( errorType );
6441 + buf.appendAscii( "]" );
6444 + rtl::OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) );
6445 + buf.appendAscii( " (caused by statement '" );
6446 + buf.appendAscii( m_executedStatement );
6447 + buf.appendAscii( "')" );
6448 + OUString error = buf.makeStringAndClear();
6449 + log( m_pSettings, LogLevel::ERROR, error );
6450 + throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
6453 +Reference< XResultSet > PreparedStatement::executeQuery( )
6454 + throw (SQLException, RuntimeException)
6456 + Reference< XCloseable > lastResultSet = m_lastResultset;
6457 + if( lastResultSet.is() )
6458 + lastResultSet->close();
6460 + if( ! execute( ) )
6462 + raiseSQLException( "not a query" );
6464 + return Reference< XResultSet > ( m_lastResultset, com::sun::star::uno::UNO_QUERY );
6467 +sal_Int32 PreparedStatement::executeUpdate( )
6468 + throw (SQLException, RuntimeException)
6472 + raiseSQLException( "not a command" );
6474 + return m_multipleResultUpdateCount;
6477 +sal_Bool PreparedStatement::execute( )
6478 + throw (SQLException, RuntimeException)
6480 + osl::MutexGuard guard( m_refMutex->mutex );
6482 + OStringBuffer buf( m_stmt.getLength() *2 );
6485 + for( int i = 0 ; i < m_splittedStatement.size() ; i ++ )
6487 + const OString &str = m_splittedStatement[i];
6488 +// printf( "Splitted %d %s\n" , i , str.getStr() );
6489 + if( isQuoted( str ) )
6491 + buf.append( str );
6495 + int start = 0,index;
6496 + for( index = 1 ; index < str.getLength() ; index ++ )
6498 + if( str[index] == '?' )
6500 + buf.append( str.getStr()+start, index - start );
6501 + buf.append( m_vars[vars] );
6507 + if ( isNamedParameterStart( str, index ) )
6509 + buf.append( str.getStr()+start, index -start );
6510 + buf.append( m_vars[vars] );
6512 + // skip to the end of the named parameter
6513 + for( ; index < str.getLength() &&
6514 + ! ( isWhitespace( str[index] ) || isOperator( str[index] ) ) ; index ++ );
6520 +// if( index +1 >= str.getLength() )
6522 + buf.append( str.getStr() + start, index -start );
6527 + m_executedStatement = buf.makeStringAndClear();
6529 + m_lastResultset.clear();
6530 + m_lastTableInserted = rtl::OUString();
6532 + struct CommandData data;
6533 + data.refMutex = m_refMutex;
6534 + data.ppSettings = &m_pSettings;
6535 + data.pLastOidInserted = &m_lastOidInserted;
6536 + data.pLastQuery = &m_lastQuery;
6537 + data.pMultipleResultUpdateCount = &m_multipleResultUpdateCount;
6538 + data.pMultipleResultAvailable = &m_multipleResultAvailable;
6539 + data.pLastTableInserted = &m_lastTableInserted;
6540 + data.pLastResultset = &m_lastResultset;
6541 + data.owner = *this;
6542 + data.tableSupplier = Reference< com::sun::star::sdbcx::XTablesSupplier >( m_connection, UNO_QUERY );
6543 + data.concurrency = extractIntProperty( this, getStatics().RESULT_SET_CONCURRENCY );
6545 + return executePostgresCommand( m_executedStatement , &data ); // see pq_statement.cxx
6548 +Reference< XConnection > PreparedStatement::getConnection( )
6549 + throw (SQLException, RuntimeException)
6551 + Reference< XConnection > ret;
6553 + MutexGuard guard( m_refMutex->mutex );
6555 + ret = m_connection;
6561 +void PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType )
6562 + throw (SQLException, RuntimeException)
6564 + MutexGuard guard( m_refMutex->mutex );
6566 + checkColumnIndex( parameterIndex );
6567 + m_vars[parameterIndex-1] = OString( "NULL" );
6570 +void PreparedStatement::setObjectNull(
6571 + sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName )
6572 + throw (SQLException, RuntimeException)
6574 + MutexGuard guard( m_refMutex->mutex );
6576 + checkColumnIndex( parameterIndex );
6577 + m_vars[parameterIndex-1] = OString( "NULL" );
6581 +void PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x )
6582 + throw (SQLException, RuntimeException)
6584 + MutexGuard guard(m_refMutex->mutex );
6586 + checkColumnIndex( parameterIndex );
6588 + m_vars[parameterIndex-1] = OString( "'t'" );
6590 + m_vars[parameterIndex-1] = OString( "'f'" );
6593 +void PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x )
6594 + throw (SQLException, RuntimeException)
6596 + setInt(parameterIndex,x);
6599 +void PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x )
6600 + throw (SQLException, RuntimeException)
6602 + setInt(parameterIndex, x );
6605 +void PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x )
6606 + throw (SQLException, RuntimeException)
6608 +// printf( "setString %d %d\n ", parameterIndex, x);
6609 + MutexGuard guard(m_refMutex->mutex );
6611 + checkColumnIndex( parameterIndex );
6612 + OStringBuffer buf( 20 );
6613 + buf.append( "'" );
6614 + buf.append( (sal_Int32) x );
6615 + buf.append( "'" );
6616 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6619 +void PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x )
6620 + throw (SQLException, RuntimeException)
6622 + MutexGuard guard(m_refMutex->mutex );
6624 + checkColumnIndex( parameterIndex );
6625 + OStringBuffer buf( 20 );
6626 + buf.append( "'" );
6627 + buf.append( (sal_Int64) x );
6628 + buf.append( "'" );
6629 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6632 +void PreparedStatement::setFloat( sal_Int32 parameterIndex, float x )
6633 + throw (SQLException, RuntimeException)
6635 + MutexGuard guard(m_refMutex->mutex );
6637 + checkColumnIndex( parameterIndex );
6638 + OStringBuffer buf( 20 );
6639 + buf.append( "'" );
6641 + buf.append( "'" );
6642 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6645 +void PreparedStatement::setDouble( sal_Int32 parameterIndex, double x )
6646 + throw (SQLException, RuntimeException)
6648 + MutexGuard guard(m_refMutex->mutex );
6650 + checkColumnIndex( parameterIndex );
6651 + OStringBuffer buf( 20 );
6652 + buf.append( "'" );
6654 + buf.append( "'" );
6655 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6658 +void PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x )
6659 + throw (SQLException, RuntimeException)
6661 +// printf( "setString %d %s\n ", parameterIndex,
6662 +// OUStringToOString( x , RTL_TEXTENCODING_ASCII_US ).getStr());
6663 + MutexGuard guard(m_refMutex->mutex );
6665 + checkColumnIndex( parameterIndex );
6666 + OStringBuffer buf( 20 );
6667 + buf.append( "'" );
6668 + OString y = OUStringToOString( x, m_pSettings->encoding );
6669 + buf.ensureCapacity( y.getLength() * 2 + 2 );
6670 + int len = PQescapeString( ((char*)buf.getStr())+1, y.getStr() , y.getLength() );
6671 + buf.setLength( 1 + len );
6672 + buf.append( "'" );
6673 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6676 +void PreparedStatement::setBytes(
6677 + sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x )
6678 + throw (SQLException, RuntimeException)
6680 + MutexGuard guard(m_refMutex->mutex );
6682 + checkColumnIndex( parameterIndex );
6683 + OStringBuffer buf( 20 );
6684 + buf.append( "'" );
6686 + unsigned char * escapedString =
6687 + PQescapeBytea( (unsigned char *)x.getConstArray(), x.getLength(), &len);
6688 + if( ! escapedString )
6690 + throw SQLException(
6691 + ASCII_STR("pq_preparedstatement.setBytes: Error during converting bytesequence to an SQL conform string" ),
6692 + *this, OUString(), 1, Any() );
6694 + buf.append( (const sal_Char *)escapedString, len -1 );
6695 + free( escapedString );
6696 + buf.append( "'" );
6697 + m_vars[parameterIndex-1] = buf.makeStringAndClear();
6701 +void PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x )
6702 + throw (SQLException, RuntimeException)
6704 + setString( parameterIndex, date2String( x ) );
6707 +void PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x )
6708 + throw (SQLException, RuntimeException)
6710 + setString( parameterIndex, time2String( x ) );
6713 +void PreparedStatement::setTimestamp(
6714 + sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x )
6715 + throw (SQLException, RuntimeException)
6717 + setString( parameterIndex, dateTime2String( x ) );
6720 +void PreparedStatement::setBinaryStream(
6721 + sal_Int32 parameterIndex,
6722 + const Reference< ::com::sun::star::io::XInputStream >& x,
6723 + sal_Int32 length )
6724 + throw (SQLException, RuntimeException)
6726 + throw SQLException(
6727 + ASCII_STR( "pq_preparedstatement: setBinaryStream not implemented" ),
6728 + *this, OUString(), 1, Any () );
6731 +void PreparedStatement::setCharacterStream(
6732 + sal_Int32 parameterIndex,
6733 + const Reference< ::com::sun::star::io::XInputStream >& x,
6734 + sal_Int32 length )
6735 + throw (SQLException, RuntimeException)
6737 + throw SQLException(
6738 + ASCII_STR( "pq_preparedstatement: setCharacterStream not implemented" ),
6739 + *this, OUString(), 1, Any () );
6742 +void PreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
6743 + throw (SQLException, RuntimeException)
6745 + if( ! implSetObject( this, parameterIndex, x ))
6747 + OUStringBuffer buf;
6748 + buf.append( ASCII_STR("pq_preparedstatement::setObject: can't convert value of type " ) );
6749 + buf.append( x.getValueTypeName() );
6750 + throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
6754 +void PreparedStatement::setObjectWithInfo(
6755 + sal_Int32 parameterIndex,
6757 + sal_Int32 targetSqlType,
6759 + throw (SQLException, RuntimeException)
6761 + if( com::sun::star::sdbc::DataType::DECIMAL == targetSqlType ||
6762 + com::sun::star::sdbc::DataType::NUMERIC == targetSqlType )
6765 + OUString myString;
6766 + if( x >>= myDouble )
6768 + myString = OUString::valueOf( myDouble );
6774 + if( myString.getLength() )
6776 +// printf( "setObjectWithInfo %s\n", OUStringToOString(myString,RTL_TEXTENCODING_ASCII_US).getStr());
6777 + setString( parameterIndex, myString );
6781 + OUStringBuffer buf;
6782 + buf.append( ASCII_STR("pq_preparedstatement::setObjectWithInfo: can't convert value of type " ) );
6783 + buf.append( x.getValueTypeName() );
6784 + buf.append( ASCII_STR(" to type DECIMAL or NUMERIC" ) );
6785 + throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
6790 + setObject( parameterIndex, x );
6795 +void PreparedStatement::setRef(
6796 + sal_Int32 parameterIndex,
6797 + const Reference< XRef >& x )
6798 + throw (SQLException, RuntimeException)
6800 + throw SQLException(
6801 + ASCII_STR( "pq_preparedstatement: setRef not implemented" ),
6802 + *this, OUString(), 1, Any () );
6806 +void PreparedStatement::setBlob(
6807 + sal_Int32 parameterIndex,
6808 + const Reference< XBlob >& x )
6809 + throw (SQLException, RuntimeException)
6811 + throw SQLException(
6812 + ASCII_STR( "pq_preparedstatement: setBlob not implemented" ),
6813 + *this, OUString(), 1, Any () );
6816 +void PreparedStatement::setClob(
6817 + sal_Int32 parameterIndex,
6818 + const Reference< XClob >& x )
6819 + throw (SQLException, RuntimeException)
6821 + throw SQLException(
6822 + ASCII_STR( "pq_preparedstatement: setClob not implemented" ),
6823 + *this, OUString(), 1, Any () );
6826 +void PreparedStatement::setArray(
6827 + sal_Int32 parameterIndex,
6828 + const Reference< XArray >& x )
6829 + throw (SQLException, RuntimeException)
6831 + setString( parameterIndex, array2String( x->getArray( 0 ) ) );
6833 +// throw SQLException(
6834 +// ASCII_STR( "pq_preparedstatement: setArray not implemented" ),
6835 +// *this, OUString(), 1, Any () );
6838 +void PreparedStatement::clearParameters( )
6839 + throw (SQLException, RuntimeException)
6841 + MutexGuard guard(m_refMutex->mutex );
6842 + m_vars = OStringVector ( m_vars.size() );
6845 +Any PreparedStatement::getWarnings( )
6846 + throw (SQLException,RuntimeException)
6851 +void PreparedStatement::clearWarnings( )
6852 + throw (SQLException, RuntimeException)
6856 +Reference< ::com::sun::star::sdbc::XResultSetMetaData > PreparedStatement::getMetaData()
6857 + throw (SQLException,RuntimeException)
6859 + Reference< com::sun::star::sdbc::XResultSetMetaData > ret;
6860 + Reference< com::sun::star::sdbc::XResultSetMetaDataSupplier > supplier( m_lastResultset, UNO_QUERY );
6861 + if( supplier.is() )
6862 + ret = supplier->getMetaData();
6866 +::cppu::IPropertyArrayHelper & PreparedStatement::getInfoHelper()
6868 + return getPreparedStatementPropertyArrayHelper();
6872 +sal_Bool PreparedStatement::convertFastPropertyValue(
6873 + Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue )
6874 + throw (IllegalArgumentException)
6877 + rOldValue = m_props[nHandle];
6880 + case PREPARED_STATEMENT_CURSOR_NAME:
6883 + bRet = ( rValue >>= val );
6884 + rConvertedValue = makeAny( val );
6887 + case PREPARED_STATEMENT_ESCAPE_PROCESSING:
6890 + bRet = ( rValue >>= val );
6891 + rConvertedValue = makeAny( val );
6894 + case PREPARED_STATEMENT_FETCH_DIRECTION:
6895 + case PREPARED_STATEMENT_FETCH_SIZE:
6896 + case PREPARED_STATEMENT_MAX_FIELD_SIZE:
6897 + case PREPARED_STATEMENT_MAX_ROWS:
6898 + case PREPARED_STATEMENT_QUERY_TIME_OUT:
6899 + case PREPARED_STATEMENT_RESULT_SET_CONCURRENCY:
6900 + case PREPARED_STATEMENT_RESULT_SET_TYPE:
6903 + bRet = ( rValue >>= val );
6904 + rConvertedValue = makeAny( val );
6909 + OUStringBuffer buf(128);
6910 + buf.appendAscii( "pq_statement: Invalid property handle (" );
6911 + buf.append( nHandle );
6912 + buf.appendAscii( ")" );
6913 + throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
6920 +void PreparedStatement::setFastPropertyValue_NoBroadcast(
6921 + sal_Int32 nHandle,const Any& rValue ) throw (Exception)
6923 + m_props[nHandle] = rValue;
6926 +void PreparedStatement::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
6928 + rValue = m_props[nHandle];
6931 +Reference < XPropertySetInfo > PreparedStatement::getPropertySetInfo()
6932 + throw(RuntimeException)
6934 + return OPropertySetHelper::createPropertySetInfo( getPreparedStatementPropertyArrayHelper() );
6937 +void PreparedStatement::disposing()
6943 +Reference< XResultSet > PreparedStatement::getResultSet( )
6944 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
6946 + return Reference< XResultSet > ( m_lastResultset, com::sun::star::uno::UNO_QUERY );
6948 +sal_Int32 PreparedStatement::getUpdateCount( )
6949 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
6951 + return m_multipleResultUpdateCount;
6953 +sal_Bool PreparedStatement::getMoreResults( )
6954 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
6959 +Reference< XResultSet > PreparedStatement::getGeneratedValues( )
6960 + throw (SQLException, RuntimeException)
6962 + osl::MutexGuard guard( m_refMutex->mutex );
6963 + return getGeneratedValuesFromLastInsert(
6964 + m_pSettings, m_connection, m_lastOidInserted, m_lastTableInserted, m_lastQuery );
6970 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
6971 +++ connectivity/source/drivers/postgresql/pq_preparedstatement.hxx 2006-01-22 16:14:29.000000000 +0100
6973 +/*************************************************************************
6975 + * $RCSfile: pq_preparedstatement.hxx,v $
6977 + * $Revision: 1.1.2.5 $
6979 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:29 $
6981 + * The Contents of this file are made available subject to the terms of
6982 + * either of the following licenses
6984 + * - GNU Lesser General Public License Version 2.1
6985 + * - Sun Industry Standards Source License Version 1.1
6987 + * Sun Microsystems Inc., October, 2000
6989 + * GNU Lesser General Public License Version 2.1
6990 + * =============================================
6991 + * Copyright 2000 by Sun Microsystems, Inc.
6992 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
6994 + * This library is free software; you can redistribute it and/or
6995 + * modify it under the terms of the GNU Lesser General Public
6996 + * License version 2.1, as published by the Free Software Foundation.
6998 + * This library is distributed in the hope that it will be useful,
6999 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7000 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7001 + * Lesser General Public License for more details.
7003 + * You should have received a copy of the GNU Lesser General Public
7004 + * License along with this library; if not, write to the Free Software
7005 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
7006 + * MA 02111-1307 USA
7009 + * Sun Industry Standards Source License Version 1.1
7010 + * =================================================
7011 + * The contents of this file are subject to the Sun Industry Standards
7012 + * Source License Version 1.1 (the "License"); You may not use this file
7013 + * except in compliance with the License. You may obtain a copy of the
7014 + * License at http://www.openoffice.org/license.html.
7016 + * Software provided under this License is provided on an "AS IS" basis,
7017 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
7018 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
7019 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
7020 + * See the License for the specific provisions governing your rights and
7021 + * obligations concerning the Software.
7023 + * The Initial Developer of the Original Code is: Joerg Budischewski
7025 + * Copyright: 2000 by Sun Microsystems, Inc.
7027 + * All Rights Reserved.
7029 + * Contributor(s): Joerg Budischewski
7032 + ************************************************************************/
7034 +#ifndef _PQ_PREPARED_STATEMENT_HXX_
7035 +#define _PQ_PREPARED_STATEMENT_HXX_
7038 +#include <libpq-fe.h>
7040 +#include <cppuhelper/propshlp.hxx>
7041 +#include <cppuhelper/component.hxx>
7043 +#include <com/sun/star/sdbc/XParameters.hpp>
7044 +#include <com/sun/star/sdbc/XMultipleResults.hpp>
7045 +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
7046 +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
7048 +#include "pq_connection.hxx"
7049 +namespace rtl { class OString; }
7050 +namespace pq_sdbc_driver
7053 +static const sal_Int32 PREPARED_STATEMENT_CURSOR_NAME = 0;
7054 +static const sal_Int32 PREPARED_STATEMENT_ESCAPE_PROCESSING = 1;
7055 +static const sal_Int32 PREPARED_STATEMENT_FETCH_DIRECTION = 2;
7056 +static const sal_Int32 PREPARED_STATEMENT_FETCH_SIZE = 3;
7057 +static const sal_Int32 PREPARED_STATEMENT_MAX_FIELD_SIZE = 4;
7058 +static const sal_Int32 PREPARED_STATEMENT_MAX_ROWS = 5;
7059 +static const sal_Int32 PREPARED_STATEMENT_QUERY_TIME_OUT = 6;
7060 +static const sal_Int32 PREPARED_STATEMENT_RESULT_SET_CONCURRENCY = 7;
7061 +static const sal_Int32 PREPARED_STATEMENT_RESULT_SET_TYPE = 8;
7063 +#define PREPARED_STATEMENT_SIZE 9
7066 +class PreparedStatement : public cppu::OComponentHelper,
7067 + public cppu::OPropertySetHelper,
7068 + public com::sun::star::sdbc::XPreparedStatement,
7069 + public com::sun::star::sdbc::XParameters,
7070 + public com::sun::star::sdbc::XCloseable,
7071 + public com::sun::star::sdbc::XWarningsSupplier,
7072 + public com::sun::star::sdbc::XMultipleResults,
7073 + public com::sun::star::sdbc::XGeneratedResultSet,
7074 + public com::sun::star::sdbc::XResultSetMetaDataSupplier
7077 + com::sun::star::uno::Any m_props[PREPARED_STATEMENT_SIZE];
7078 + com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
7079 + ConnectionSettings *m_pSettings;
7080 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
7081 + ::rtl::OString m_stmt;
7082 + ::rtl::OString m_executedStatement;
7083 + ::rtl::Reference< RefCountedMutex > m_refMutex;
7084 + OStringVector m_vars;
7085 + OStringVector m_splittedStatement;
7086 + sal_Bool m_multipleResultAvailable;
7087 + sal_Int32 m_multipleResultUpdateCount;
7088 + sal_Int32 m_lastOidInserted;
7089 + rtl::OUString m_lastTableInserted;
7090 + rtl::OString m_lastQuery;
7094 + * @param ppConnection The piece of memory, pConnection points to, is accessisble
7095 + * as long as a reference to paramenter con is held.
7097 + PreparedStatement( const rtl::Reference< RefCountedMutex > & refMutex,
7098 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
7099 + struct ConnectionSettings *pSettings,
7100 + const rtl::OString &stmt );
7102 + virtual ~PreparedStatement();
7103 +public: // XInterface
7104 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
7105 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
7106 + virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
7107 + throw (com::sun::star::uno::RuntimeException);
7109 +public: // XCloseable
7110 + virtual void SAL_CALL close( )
7111 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7113 +public: // XPreparedStatement
7114 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery()
7115 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7116 + virtual sal_Int32 SAL_CALL executeUpdate( )
7117 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7118 + virtual sal_Bool SAL_CALL execute( )
7119 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7120 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( )
7121 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7122 +public: // XParameters
7123 + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType )
7124 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7125 + virtual void SAL_CALL setObjectNull(
7126 + sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName )
7127 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7128 + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x )
7129 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7130 + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x )
7131 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7132 + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x )
7133 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7134 + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x )
7135 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7136 + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x )
7137 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7138 + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x )
7139 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7140 + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x )
7141 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7142 + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x )
7143 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7144 + virtual void SAL_CALL setBytes(
7145 + sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x )
7146 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7147 + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x )
7148 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7149 + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x )
7150 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7151 + virtual void SAL_CALL setTimestamp(
7152 + sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x )
7153 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7154 + virtual void SAL_CALL setBinaryStream(
7155 + sal_Int32 parameterIndex,
7156 + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,
7157 + sal_Int32 length )
7158 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7159 + virtual void SAL_CALL setCharacterStream(
7160 + sal_Int32 parameterIndex,
7161 + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,
7162 + sal_Int32 length )
7163 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7164 + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x )
7165 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7166 + virtual void SAL_CALL setObjectWithInfo(
7167 + sal_Int32 parameterIndex,
7168 + const ::com::sun::star::uno::Any& x,
7169 + sal_Int32 targetSqlType,
7171 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7172 + virtual void SAL_CALL setRef(
7173 + sal_Int32 parameterIndex,
7174 + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x )
7175 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7176 + virtual void SAL_CALL setBlob(
7177 + sal_Int32 parameterIndex,
7178 + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x )
7179 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7180 + virtual void SAL_CALL setClob(
7181 + sal_Int32 parameterIndex,
7182 + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x )
7183 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7184 + virtual void SAL_CALL setArray(
7185 + sal_Int32 parameterIndex,
7186 + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x )
7187 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7188 + virtual void SAL_CALL clearParameters( )
7189 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7191 +public: // XWarningsSupplier
7192 + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( )
7193 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7194 + virtual void SAL_CALL clearWarnings( )
7195 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7197 +public: // XTypeProvider, first implemented by OPropertySetHelper
7198 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
7199 + throw( com::sun::star::uno::RuntimeException );
7200 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
7201 + throw( com::sun::star::uno::RuntimeException );
7203 +public: // OPropertySetHelper
7204 + virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
7206 + virtual sal_Bool SAL_CALL convertFastPropertyValue(
7207 + ::com::sun::star::uno::Any & rConvertedValue,
7208 + ::com::sun::star::uno::Any & rOldValue,
7209 + sal_Int32 nHandle,
7210 + const ::com::sun::star::uno::Any& rValue )
7211 + throw (::com::sun::star::lang::IllegalArgumentException);
7213 + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
7214 + sal_Int32 nHandle,
7215 + const ::com::sun::star::uno::Any& rValue )
7216 + throw (::com::sun::star::uno::Exception);
7218 + virtual void SAL_CALL getFastPropertyValue(
7219 + ::com::sun::star::uno::Any& rValue,
7220 + sal_Int32 nHandle ) const;
7223 + ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
7224 + throw(com::sun::star::uno::RuntimeException);
7226 +public: // XGeneratedResultSet
7227 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
7228 + getGeneratedValues( )
7229 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7231 +public: // XMultipleResults
7232 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( )
7233 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7234 + virtual sal_Int32 SAL_CALL getUpdateCount( )
7235 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7236 + virtual sal_Bool SAL_CALL getMoreResults( )
7237 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7239 +public: // XResultSetMetaDataSupplier (is required by framework (see
7240 + // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
7241 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
7242 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7244 +public: // OComponentHelper
7245 + virtual void SAL_CALL disposing();
7248 + void checkColumnIndex( sal_Int32 parameterIndex );
7249 + void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
7250 + void raiseSQLException( const char * errorMsg, const char *errorType = 0 )
7251 + throw ( com::sun::star::sdbc::SQLException );
7252 +// PGresult *pgExecute( ::rtl::OString *pQuery );
7257 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
7258 +++ connectivity/source/drivers/postgresql/pq_resultset.cxx 2006-05-01 21:19:06.000000000 +0200
7260 +#include "pq_resultset.hxx"
7261 +#include "pq_resultsetmetadata.hxx"
7263 +#include <com/sun/star/sdbc/ResultSetType.hpp>
7264 +#include <com/sun/star/sdbc/DataType.hpp>
7266 +using rtl::OUString;
7267 +using rtl::OUStringToOString;
7269 +using osl::MutexGuard;
7271 +using com::sun::star::uno::RuntimeException;
7272 +using com::sun::star::uno::Any;
7273 +using com::sun::star::uno::makeAny;
7274 +using com::sun::star::uno::Reference;
7275 +using com::sun::star::uno::XInterface;
7277 +using com::sun::star::sdbc::SQLException;
7278 +using com::sun::star::sdbc::XResultSetMetaData;
7281 +namespace pq_sdbc_driver
7283 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
7285 +void ResultSet::checkClosed()
7286 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException )
7290 + throw SQLException( ASCII_STR( "pq_resultset: already closed" ),
7291 + *this, OUString(), 1, Any() );
7294 + if( ! m_ppSettings || ! *m_ppSettings || ! (*m_ppSettings)->pConnection )
7296 + throw SQLException( ASCII_STR( "pq_resultset: statement has been closed already" ),
7297 + *this, OUString(), 1, Any() );
7302 +ResultSet::ResultSet( const ::rtl::Reference< RefCountedMutex > & refMutex,
7303 + const Reference< XInterface > & owner,
7304 + ConnectionSettings **ppSettings,
7305 + PGresult * result,
7306 + const rtl::OUString &schema,
7307 + const rtl::OUString &table)
7309 + refMutex, owner, PQntuples( result ),
7310 + PQnfields( result ),(*ppSettings)->tc ),
7311 + m_ppSettings( ppSettings ),
7312 + m_result( result ),
7313 + m_schema( schema ),
7316 + sal_Bool b = sal_True;
7317 +// m_props[RESULTSET_IS_BOOKMARKABLE] = Any( &b, getBooleanCppuType() );
7318 + m_props[ BASERESULTSET_RESULT_SET_TYPE] = makeAny(
7319 + com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
7323 +Any ResultSet::getValue( sal_Int32 columnIndex )
7326 + if( PQgetisnull( m_result, m_row, columnIndex -1 ) )
7332 + m_wasNull = false;
7333 + ret <<= ::rtl::OUString(
7334 + PQgetvalue( m_result, m_row , columnIndex -1 ) ,
7335 + PQgetlength( m_result, m_row , columnIndex -1 ) ,
7336 + (*m_ppSettings)->encoding );
7342 +ResultSet::~ResultSet()
7345 +void ResultSet::close( ) throw (SQLException, RuntimeException)
7347 + Reference< XInterface > owner;
7349 + MutexGuard guard( m_refMutex->mutex );
7352 + PQclear(m_result );
7361 +Reference< XResultSetMetaData > ResultSet::getMetaData( ) throw (SQLException, RuntimeException)
7363 + MutexGuard guard( m_refMutex->mutex );
7365 + return new ResultSetMetaData(
7366 + m_refMutex, this, this, m_ppSettings, m_result, m_schema, m_table );
7369 +sal_Int32 ResultSet::findColumn( const ::rtl::OUString& columnName )
7370 + throw (SQLException, RuntimeException)
7372 + MutexGuard guard( m_refMutex->mutex );
7376 + OUStringToOString( columnName, (*m_ppSettings)->encoding ).getStr())
7380 +static bool isNumber( const char * data, sal_Int32 len )
7386 + for( int i = 0 ; i < len ; i ++ )
7388 + if( ( data[i] >= '0' && data[i] <= '9' ) ||
7389 + data[i] == '-' || data[i] == '+' || data[i] == '.' || data[i] == ',' )
7391 + if( data[i] == '-' && i != 0 && i != len-1 )
7393 + // no number, maybe a date
7408 +static bool isInteger( const char * data, sal_Int32 len )
7414 + for( int i = 0 ; i < len ; i ++ )
7416 + if( ( data[i] >= '0' && data[i] <= '9' ) ||
7417 + data[i] == '-' || data[i] == '+' )
7419 + if( data[i] == '-' && i != 0 && i != len-1 )
7421 + // no number, maybe a date
7436 +static bool isDate( const char * data, sal_Int32 len )
7439 + return 10 == len &&
7442 + isInteger( &(data[0]),4 ) &&
7443 + isInteger( &(data[5]),2) &&
7444 + isInteger( &(data[8]),2 );
7447 +static bool isTime( const char * data, sal_Int32 len )
7450 + return 8 == len &&
7453 + isInteger( &(data[0]),2 ) &&
7454 + isInteger( &(data[3]),2) &&
7455 + isInteger( &(data[6]),2 );
7459 +static bool isTimestamp( const char * data, sal_Int32 len )
7461 + return len == 19 && isDate( data, 10) && isTime( &(data[11]),8 );
7464 +sal_Int32 ResultSet::guessDataType( sal_Int32 column )
7466 + // we don't look into more than 100 rows ...
7467 + sal_Int32 ret = com::sun::star::sdbc::DataType::INTEGER;
7469 + int maxRows = ( m_rowCount > 100 ? 100 : m_rowCount );
7470 + for( int i = 0 ; i < maxRows ; i ++ )
7472 + if( ! PQgetisnull( m_result, i , column-1 ) )
7474 + const char * p = PQgetvalue( m_result, i , column -1 );
7475 + int len = PQgetlength( m_result, i , column -1 );
7477 + if( com::sun::star::sdbc::DataType::INTEGER == ret )
7479 + if( ! isInteger( p,len ) )
7480 + ret = com::sun::star::sdbc::DataType::NUMERIC;
7482 + if( com::sun::star::sdbc::DataType::NUMERIC == ret )
7484 + if( ! isNumber( p,len ) )
7486 + ret = com::sun::star::sdbc::DataType::DATE;
7489 + if( com::sun::star::sdbc::DataType::DATE == ret )
7491 + if( ! isDate( p,len ) )
7493 + ret = com::sun::star::sdbc::DataType::TIME;
7496 + if( com::sun::star::sdbc::DataType::TIME == ret )
7498 + if( ! isTime( p,len ) )
7500 + ret = com::sun::star::sdbc::DataType::TIMESTAMP;
7503 + if( com::sun::star::sdbc::DataType::TIMESTAMP == ret )
7505 + if( ! isTimestamp( p,len ) )
7507 + ret = com::sun::star::sdbc::DataType::LONGVARCHAR;
7517 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
7518 +++ connectivity/source/drivers/postgresql/pq_resultset.hxx 2006-05-01 21:19:06.000000000 +0200
7520 +/*************************************************************************
7522 + * $RCSfile: pq_resultset.hxx,v $
7524 + * $Revision: 1.1.2.3 $
7526 + * last change: $Author: jbu $ $Date: 2006/05/01 19:19:06 $
7528 + * The Contents of this file are made available subject to the terms of
7529 + * either of the following licenses
7531 + * - GNU Lesser General Public License Version 2.1
7532 + * - Sun Industry Standards Source License Version 1.1
7534 + * Sun Microsystems Inc., October, 2000
7536 + * GNU Lesser General Public License Version 2.1
7537 + * =============================================
7538 + * Copyright 2000 by Sun Microsystems, Inc.
7539 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
7541 + * This library is free software; you can redistribute it and/or
7542 + * modify it under the terms of the GNU Lesser General Public
7543 + * License version 2.1, as published by the Free Software Foundation.
7545 + * This library is distributed in the hope that it will be useful,
7546 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7547 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7548 + * Lesser General Public License for more details.
7550 + * You should have received a copy of the GNU Lesser General Public
7551 + * License along with this library; if not, write to the Free Software
7552 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
7553 + * MA 02111-1307 USA
7556 + * Sun Industry Standards Source License Version 1.1
7557 + * =================================================
7558 + * The contents of this file are subject to the Sun Industry Standards
7559 + * Source License Version 1.1 (the "License"); You may not use this file
7560 + * except in compliance with the License. You may obtain a copy of the
7561 + * License at http://www.openoffice.org/license.html.
7563 + * Software provided under this License is provided on an "AS IS" basis,
7564 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
7565 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
7566 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
7567 + * See the License for the specific provisions governing your rights and
7568 + * obligations concerning the Software.
7570 + * The Initial Developer of the Original Code is: Joerg Budischewski
7572 + * Copyright: 2000 by Sun Microsystems, Inc.
7574 + * All Rights Reserved.
7576 + * Contributor(s): Joerg Budischewski
7579 + ************************************************************************/
7580 +#ifndef _PG_RESULTSET_HXX_
7581 +#define _PG_RESULTSET_HXX_
7583 +#include <cppuhelper/propshlp.hxx>
7584 +#include <cppuhelper/component.hxx>
7586 +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
7587 +#include <com/sun/star/sdbc/XRow.hpp>
7588 +#include <com/sun/star/sdbc/XCloseable.hpp>
7589 +#include <com/sun/star/sdbc/XColumnLocate.hpp>
7590 +#include "pq_connection.hxx"
7591 +#include "pq_baseresultset.hxx"
7593 +namespace pq_sdbc_driver
7596 +class ResultSet : public BaseResultSet
7599 + PGresult *m_result;
7600 + ::rtl::OUString m_schema;
7601 + ::rtl::OUString m_table;
7602 + ConnectionSettings **m_ppSettings;
7605 + /** mutex should be locked before called
7607 + virtual void checkClosed()
7608 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
7610 + /** unchecked, acquire mutex before calling
7612 + virtual ::com::sun::star::uno::Any getValue( sal_Int32 columnIndex );
7616 + const ::rtl::Reference< RefCountedMutex > & mutex,
7617 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
7618 + ConnectionSettings **pSettings,
7620 + const rtl::OUString &schema,
7621 + const rtl::OUString &table );
7624 +public: // XCloseable
7625 + virtual void SAL_CALL close( )
7626 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7628 +public: // XResultSetMetaDataSupplier
7629 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
7630 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7632 +public: // XColumnLocate
7633 + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName )
7634 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
7637 + sal_Int32 guessDataType( sal_Int32 column );
7642 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
7643 +++ connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx 2006-05-27 13:32:13.000000000 +0200
7645 +/*************************************************************************
7647 + * $RCSfile: pq_resultsetmetadata.cxx,v $
7649 + * $Revision: 1.1.2.7 $
7651 + * last change: $Author: jbu $ $Date: 2006/05/27 11:32:13 $
7653 + * The Contents of this file are made available subject to the terms of
7654 + * either of the following licenses
7656 + * - GNU Lesser General Public License Version 2.1
7657 + * - Sun Industry Standards Source License Version 1.1
7659 + * Sun Microsystems Inc., October, 2000
7661 + * GNU Lesser General Public License Version 2.1
7662 + * =============================================
7663 + * Copyright 2000 by Sun Microsystems, Inc.
7664 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
7666 + * This library is free software; you can redistribute it and/or
7667 + * modify it under the terms of the GNU Lesser General Public
7668 + * License version 2.1, as published by the Free Software Foundation.
7670 + * This library is distributed in the hope that it will be useful,
7671 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7672 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7673 + * Lesser General Public License for more details.
7675 + * You should have received a copy of the GNU Lesser General Public
7676 + * License along with this library; if not, write to the Free Software
7677 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
7678 + * MA 02111-1307 USA
7681 + * Sun Industry Standards Source License Version 1.1
7682 + * =================================================
7683 + * The contents of this file are subject to the Sun Industry Standards
7684 + * Source License Version 1.1 (the "License"); You may not use this file
7685 + * except in compliance with the License. You may obtain a copy of the
7686 + * License at http://www.openoffice.org/license.html.
7688 + * Software provided under this License is provided on an "AS IS" basis,
7689 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
7690 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
7691 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
7692 + * See the License for the specific provisions governing your rights and
7693 + * obligations concerning the Software.
7695 + * The Initial Developer of the Original Code is: Joerg Budischewski
7697 + * Copyright: 2000 by Sun Microsystems, Inc.
7699 + * All Rights Reserved.
7701 + * Contributor(s): Joerg Budischewski
7704 + ************************************************************************/
7705 +#include <rtl/ustrbuf.hxx>
7707 +#include "pq_resultsetmetadata.hxx"
7708 +#include "pq_resultset.hxx"
7709 +#include "pq_tools.hxx"
7710 +#include "pq_statics.hxx"
7712 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
7713 +#include <com/sun/star/sdbc/ColumnValue.hpp>
7714 +#include <com/sun/star/sdbc/XRow.hpp>
7718 +using osl::MutexGuard;
7720 +using rtl::OUString;
7721 +using rtl::OUStringBuffer;
7722 +using rtl::OString;
7724 +using com::sun::star::uno::Any;
7725 +using com::sun::star::uno::RuntimeException;
7726 +using com::sun::star::uno::Exception;
7727 +using com::sun::star::uno::Reference;
7728 +using com::sun::star::uno::XInterface;
7729 +using com::sun::star::uno::UNO_QUERY;
7731 +using com::sun::star::lang::IllegalArgumentException;
7733 +using com::sun::star::sdbc::SQLException;
7734 +using com::sun::star::sdbc::XStatement;
7735 +using com::sun::star::sdbc::XRow;
7736 +using com::sun::star::sdbc::XResultSet;
7737 +// using com::sun::star::sdbc::XRow;
7738 +using com::sun::star::sdbc::XResultSet;
7739 +using com::sun::star::sdbcx::XColumnsSupplier;
7740 +using com::sun::star::sdbcx::XTablesSupplier;
7742 +using com::sun::star::beans::XPropertySet;
7743 +using com::sun::star::container::XNameAccess;
7746 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
7748 +namespace pq_sdbc_driver
7751 +// struct ColumnMetaData
7753 +// rtl::OUString tableName;
7754 +// rtl::OUString schemaTableName;
7755 +// rtl::OUString typeName;
7756 +// com::sun::star::sdbc::DataType type;
7757 +// sal_Int32 precision;
7758 +// sal_Int32 scale;
7759 +// sal_Bool isCurrency;
7760 +// sal_Bool isNullable;
7761 +// sal_Bool isAutoIncrement;
7762 +// sal_Bool isReadOnly;
7763 +// sal_Bool isSigned;
7766 +// is not exported by the postgres header
7767 +const static int PQ_VARHDRSZ = sizeof( sal_Int32 );
7769 +static void extractPrecisionAndScale( sal_Int32 atttypmod, sal_Int32 *precision, sal_Int32 *scale )
7771 + if( atttypmod < PQ_VARHDRSZ )
7778 + if( atttypmod & 0xffff0000 )
7780 + *precision = ( ( atttypmod - PQ_VARHDRSZ ) >> 16 ) & 0xffff;
7781 + *scale = (atttypmod - PQ_VARHDRSZ ) & 0xffff;
7785 + *precision = atttypmod - PQ_VARHDRSZ;
7791 +ResultSetMetaData::ResultSetMetaData(
7792 + const ::rtl::Reference< RefCountedMutex > & refMutex,
7793 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > & origin,
7794 + ResultSet * pResultSet,
7795 + ConnectionSettings **ppSettings,
7796 + PGresult *pResult,
7797 + const rtl::OUString &schemaName,
7798 + const rtl::OUString &tableName ) :
7799 + m_refMutex( refMutex ),
7800 + m_origin( origin ),
7801 + m_ppSettings( ppSettings ),
7802 + m_colCount( PQnfields( pResult ) ),
7803 + m_tableName( tableName ),
7804 + m_schemaName( schemaName ),
7805 + m_checkedForTable( false ),
7806 + m_checkedForTypes( false ),
7807 + m_colDesc( PQnfields( pResult ) ),
7808 + m_pResultSet( pResultSet )
7811 + // extract all needed information from the result object, so that we don't
7812 + // need it anymore after this call !
7813 + for( int col = 0; col < m_colCount ; col ++ )
7815 + sal_Int32 size = PQfsize( pResult, col );
7816 + size = -1 == size ? 25 : size;
7817 + m_colDesc[col].displaySize = size;
7819 + extractPrecisionAndScale(
7820 + PQfmod( pResult, col ),
7821 + & ( m_colDesc[col].precision ),
7822 + & ( m_colDesc[col].scale ) );
7823 + char *name = PQfname( pResult, col );
7824 + m_colDesc[col].name = OUString( name, strlen(name) , (*m_ppSettings)->encoding );
7825 + m_colDesc[col].typeOid = PQftype( pResult, col );
7826 + m_colDesc[col].type = com::sun::star::sdbc::DataType::LONGVARCHAR;
7830 +// typedef std::hash_map<
7833 +// std::hash< Oid >,
7834 +// std::equal_to< Oid >,
7835 +// Allocator < std::pair< Oid, rtl::OUString > > > PqTypeMap;
7838 +void ResultSetMetaData::checkForTypes()
7840 + if( ! m_checkedForTypes )
7842 + Reference< XStatement > stmt =
7843 + extractConnectionFromStatement( m_origin->getStatement() )->createStatement();
7844 + DisposeGuard guard( stmt );
7845 + OUStringBuffer buf(128);
7846 + buf.appendAscii( "SELECT oid, typname, typtype FROM pg_type WHERE ");
7847 + for( int i = 0 ; i < m_colCount ; i ++ )
7850 + buf.appendAscii( " OR " );
7851 + int oid = m_colDesc[i].typeOid;
7852 + buf.appendAscii( "oid=" );
7853 + buf.append( (sal_Int32) oid, 10 );
7855 + Reference< XResultSet > rs = stmt->executeQuery( buf.makeStringAndClear() );
7856 + Reference< XRow > xRow( rs, UNO_QUERY );
7857 + while( rs->next() )
7859 + sal_Int32 oid = xRow->getInt( 1 );
7860 + OUString typeName = xRow->getString( 2 );
7861 + OUString typType = xRow->getString( 3 );
7863 + sal_Int32 type = typeNameToDataType( typeName, typType );
7865 + for( int j = 0; j < m_colCount ; j ++ )
7867 + if( m_colDesc[j].typeOid == oid )
7869 + m_colDesc[j].typeName = typeName;
7870 + m_colDesc[j].type = type;
7874 + m_checkedForTypes = true;
7878 +void ResultSetMetaData::checkTable()
7880 + if( ! m_checkedForTable )
7882 + m_checkedForTable = true;
7883 + if( m_tableName.getLength() )
7886 + Reference< com::sun::star::container::XNameAccess > tables = (*m_ppSettings)->tables;
7887 + if( ! tables.is() )
7890 + Reference< XTablesSupplier > supplier =
7891 + Reference< XTablesSupplier > (
7892 + extractConnectionFromStatement( m_origin->getStatement() ), UNO_QUERY);
7893 + if( supplier.is() )
7894 + tables = supplier->getTables();
7898 + OUString name = getTableName( 1 );
7899 +// if( tables->hasByName( name ) )
7900 + tables->getByName( name ) >>= m_table;
7906 +sal_Int32 ResultSetMetaData::getIntColumnProperty( const rtl::OUString & name, int index, int def )
7908 + sal_Int32 ret = def; // give defensive answers, when data is not available
7911 + MutexGuard guard( m_refMutex->mutex );
7912 + checkColumnIndex( index );
7913 + Reference< XPropertySet > set = getColumnByIndex( index );
7917 + set->getPropertyValue( name ) >>= ret;
7920 + catch( com::sun::star::uno::Exception & e )
7926 +sal_Bool ResultSetMetaData::getBoolColumnProperty( const rtl::OUString & name, int index, sal_Bool def )
7928 + sal_Bool ret = def;
7931 + MutexGuard guard( m_refMutex->mutex );
7932 + checkColumnIndex( index );
7933 + Reference< XPropertySet > set = getColumnByIndex( index );
7936 + set->getPropertyValue( name ) >>= ret;
7939 + catch( com::sun::star::uno::Exception & e )
7946 +Reference< com::sun::star::beans::XPropertySet > ResultSetMetaData::getColumnByIndex( int index )
7948 + Reference< XPropertySet > ret;
7950 + if( m_table.is() )
7952 + OUString columnName = getColumnName( index );
7953 + Reference< XColumnsSupplier > supplier( m_table, UNO_QUERY );
7954 + if( supplier.is() )
7956 + Reference< XNameAccess > columns = supplier->getColumns();
7957 + if( columns.is() && columns->hasByName( columnName ) )
7959 + columns->getByName( columnName ) >>= ret;
7967 +sal_Int32 ResultSetMetaData::getColumnCount( )
7968 + throw (SQLException, RuntimeException)
7970 + return m_colCount;
7973 +sal_Bool ResultSetMetaData::isAutoIncrement( sal_Int32 column )
7974 + throw (SQLException, RuntimeException)
7977 + sal_Bool ret = getBoolColumnProperty( getStatics().IS_AUTO_INCREMENT, column, sal_False );
7981 +sal_Bool ResultSetMetaData::isCaseSensitive( sal_Int32 column )
7982 + throw (SQLException, RuntimeException)
7985 + return sal_True; // ??? hmm, numeric types or
7988 +sal_Bool ResultSetMetaData::isSearchable( sal_Int32 column ) throw (SQLException, RuntimeException)
7990 + return sal_True; // mmm, what types are not searchable ?
7993 +sal_Bool ResultSetMetaData::isCurrency( sal_Int32 column ) throw (SQLException, RuntimeException)
7995 + return getBoolColumnProperty( getStatics().IS_CURRENCY, column, sal_False );
7998 +sal_Int32 ResultSetMetaData::isNullable( sal_Int32 column )
7999 + throw (SQLException, RuntimeException)
8001 + return getIntColumnProperty(
8002 + getStatics().IS_NULLABLE, column, com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN );
8005 +sal_Bool ResultSetMetaData::isSigned( sal_Int32 column )
8006 + throw (SQLException, RuntimeException)
8008 + return sal_True; //
8011 +sal_Int32 ResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
8012 + throw (SQLException, RuntimeException)
8014 + MutexGuard guard( m_refMutex->mutex );
8016 + checkColumnIndex( column );
8017 + return m_colDesc[column-1].displaySize;
8020 +::rtl::OUString ResultSetMetaData::getColumnLabel( sal_Int32 column )
8021 + throw (SQLException, RuntimeException)
8023 + return getColumnName( column);
8026 +::rtl::OUString ResultSetMetaData::getColumnName( sal_Int32 column ) throw (SQLException, RuntimeException)
8028 + MutexGuard guard( m_refMutex->mutex );
8030 + checkColumnIndex( column );
8032 + return m_colDesc[column-1].name;
8035 +::rtl::OUString ResultSetMetaData::getSchemaName( sal_Int32 column ) throw (SQLException, RuntimeException)
8037 + return m_schemaName;
8042 +sal_Int32 ResultSetMetaData::getPrecision( sal_Int32 column )
8043 + throw (SQLException, RuntimeException)
8045 + MutexGuard guard( m_refMutex->mutex );
8047 + checkColumnIndex( column );
8048 + return m_colDesc[column-1].precision;
8051 +sal_Int32 ResultSetMetaData::getScale( sal_Int32 column )
8052 + throw (SQLException, RuntimeException)
8054 + MutexGuard guard( m_refMutex->mutex );
8056 + checkColumnIndex( column );
8057 + return m_colDesc[column-1].scale;
8060 +::rtl::OUString ResultSetMetaData::getTableName( sal_Int32 column )
8061 + throw (SQLException, RuntimeException)
8063 + rtl::OUString ret;
8064 + if( m_tableName.getLength() )
8066 + OUStringBuffer buf( 128 );
8067 + buf.append( m_schemaName );
8068 + buf.appendAscii( "." );
8069 + buf.append( m_tableName );
8070 + ret = buf.makeStringAndClear();
8075 +::rtl::OUString ResultSetMetaData::getCatalogName( sal_Int32 column )
8076 + throw (SQLException, RuntimeException)
8078 + // can do this through XConnection.getCatalog() !
8079 + return OUString();
8081 +sal_Int32 ResultSetMetaData::getColumnType( sal_Int32 column )
8082 + throw (SQLException, RuntimeException)
8084 + int ret = getIntColumnProperty( getStatics().TYPE, column, -100 );
8088 + if( com::sun::star::sdbc::DataType::LONGVARCHAR == m_colDesc[column-1].type && m_pResultSet )
8089 + m_colDesc[column-1].type = m_pResultSet->guessDataType( column );
8090 + ret = m_colDesc[column-1].type;
8095 +::rtl::OUString ResultSetMetaData::getColumnTypeName( sal_Int32 column )
8096 + throw (SQLException, RuntimeException)
8098 + ::rtl::OUString ret; // give defensive answers, when data is not available
8101 + MutexGuard guard( m_refMutex->mutex );
8102 + checkColumnIndex( column );
8103 + Reference< XPropertySet > set = getColumnByIndex( column );
8107 + set->getPropertyValue( getStatics().TYPE_NAME ) >>= ret;
8112 + ret = m_colDesc[column-1].typeName;
8115 + catch( com::sun::star::uno::Exception & e )
8122 +sal_Bool ResultSetMetaData::isReadOnly( sal_Int32 column )
8123 + throw (SQLException, RuntimeException)
8128 +sal_Bool ResultSetMetaData::isWritable( sal_Int32 column )
8129 + throw (SQLException, RuntimeException)
8131 + return ! isReadOnly( column ); // what's the sense if this method ?
8134 +sal_Bool ResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
8135 + throw (SQLException, RuntimeException)
8137 + return isWritable(column); // uhh, now it becomes really esoteric ....
8139 +::rtl::OUString ResultSetMetaData::getColumnServiceName( sal_Int32 column )
8140 + throw (SQLException, RuntimeException)
8142 + return OUString();
8145 +void ResultSetMetaData::checkClosed()
8146 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8151 +void ResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
8152 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8154 + if( columnIndex < 1 || columnIndex > m_colCount )
8156 + OUStringBuffer buf(128);
8158 + buf.appendAscii( "pq_resultsetmetadata: index out of range (expected 1 to " );
8159 + buf.append( m_colCount );
8160 + buf.appendAscii( ", got " );
8161 + buf.append( columnIndex );
8162 + throw SQLException(
8163 + buf.makeStringAndClear(), *this, OUString(), 1, Any() );
8168 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8169 +++ connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx 2006-05-01 21:19:07.000000000 +0200
8171 +/*************************************************************************
8173 + * $RCSfile: pq_resultsetmetadata.hxx,v $
8175 + * $Revision: 1.1.2.3 $
8177 + * last change: $Author: jbu $ $Date: 2006/05/01 19:19:07 $
8179 + * The Contents of this file are made available subject to the terms of
8180 + * either of the following licenses
8182 + * - GNU Lesser General Public License Version 2.1
8183 + * - Sun Industry Standards Source License Version 1.1
8185 + * Sun Microsystems Inc., October, 2000
8187 + * GNU Lesser General Public License Version 2.1
8188 + * =============================================
8189 + * Copyright 2000 by Sun Microsystems, Inc.
8190 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
8192 + * This library is free software; you can redistribute it and/or
8193 + * modify it under the terms of the GNU Lesser General Public
8194 + * License version 2.1, as published by the Free Software Foundation.
8196 + * This library is distributed in the hope that it will be useful,
8197 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8198 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8199 + * Lesser General Public License for more details.
8201 + * You should have received a copy of the GNU Lesser General Public
8202 + * License along with this library; if not, write to the Free Software
8203 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
8204 + * MA 02111-1307 USA
8207 + * Sun Industry Standards Source License Version 1.1
8208 + * =================================================
8209 + * The contents of this file are subject to the Sun Industry Standards
8210 + * Source License Version 1.1 (the "License"); You may not use this file
8211 + * except in compliance with the License. You may obtain a copy of the
8212 + * License at http://www.openoffice.org/license.html.
8214 + * Software provided under this License is provided on an "AS IS" basis,
8215 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
8216 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
8217 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
8218 + * See the License for the specific provisions governing your rights and
8219 + * obligations concerning the Software.
8221 + * The Initial Developer of the Original Code is: Joerg Budischewski
8223 + * Copyright: 2000 by Sun Microsystems, Inc.
8225 + * All Rights Reserved.
8227 + * Contributor(s): Joerg Budischewski
8230 + ************************************************************************/
8231 +#ifndef _PQ_RESULTSETMETADATA_HXX_
8232 +#define _PQ_RESULTSETMETADATA_HXX_
8235 +#include "pq_connection.hxx"
8237 +#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
8238 +#include <com/sun/star/beans/XPropertySet.hpp>
8240 +#include <cppuhelper/implbase1.hxx>
8242 +namespace pq_sdbc_driver
8247 + rtl::OUString name;
8248 + sal_Int32 precision;
8250 + sal_Int32 displaySize;
8252 + rtl::OUString typeName;
8258 +typedef std::vector< ColDesc, Allocator< ColDesc > > ColDescVector;
8261 +class ResultSetMetaData :
8262 + public ::cppu::WeakImplHelper1 < com::sun::star::sdbc::XResultSetMetaData >
8264 + ::rtl::Reference< RefCountedMutex > m_refMutex;
8265 + ConnectionSettings **m_ppSettings;
8266 + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_origin;
8267 + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_table;
8268 + ::rtl::OUString m_tableName;
8269 + ::rtl::OUString m_schemaName;
8270 + ColDescVector m_colDesc;
8271 + ResultSet *m_pResultSet;
8273 + bool m_checkedForTable;
8274 + bool m_checkedForTypes;
8276 + sal_Int32 m_colCount;
8278 + void checkClosed()
8279 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8280 + void checkColumnIndex( sal_Int32 columnIndex )
8281 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8282 + void checkTable();
8283 + void checkForTypes();
8284 + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getColumnByIndex( int index );
8286 + sal_Int32 getIntColumnProperty( const rtl::OUString & name, int index, int def );
8287 + sal_Bool getBoolColumnProperty( const rtl::OUString & name, int index, sal_Bool def );
8290 + ResultSetMetaData(
8291 + const ::rtl::Reference< RefCountedMutex > & reMutex,
8292 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > & origin,
8293 + ResultSet *pResultSet,
8294 + ConnectionSettings **pSettings,
8295 + PGresult *pResult,
8296 + const rtl::OUString &schemaName,
8297 + const rtl::OUString &tableName );
8301 + virtual sal_Int32 SAL_CALL getColumnCount( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8302 + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8303 + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8304 + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8305 + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8306 + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8307 + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8308 + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8309 + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8310 + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8311 + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8312 + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8313 + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8314 + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8315 + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8316 + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8317 + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8318 + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8319 + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8320 + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8321 + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8327 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8328 +++ connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx 2006-01-22 16:14:31.000000000 +0100
8330 +/*************************************************************************
8332 + * $RCSfile: pq_sequenceresultset.cxx,v $
8334 + * $Revision: 1.1.2.3 $
8336 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:31 $
8338 + * The Contents of this file are made available subject to the terms of
8339 + * either of the following licenses
8341 + * - GNU Lesser General Public License Version 2.1
8342 + * - Sun Industry Standards Source License Version 1.1
8344 + * Sun Microsystems Inc., October, 2000
8346 + * GNU Lesser General Public License Version 2.1
8347 + * =============================================
8348 + * Copyright 2000 by Sun Microsystems, Inc.
8349 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
8351 + * This library is free software; you can redistribute it and/or
8352 + * modify it under the terms of the GNU Lesser General Public
8353 + * License version 2.1, as published by the Free Software Foundation.
8355 + * This library is distributed in the hope that it will be useful,
8356 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8357 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8358 + * Lesser General Public License for more details.
8360 + * You should have received a copy of the GNU Lesser General Public
8361 + * License along with this library; if not, write to the Free Software
8362 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
8363 + * MA 02111-1307 USA
8366 + * Sun Industry Standards Source License Version 1.1
8367 + * =================================================
8368 + * The contents of this file are subject to the Sun Industry Standards
8369 + * Source License Version 1.1 (the "License"); You may not use this file
8370 + * except in compliance with the License. You may obtain a copy of the
8371 + * License at http://www.openoffice.org/license.html.
8373 + * Software provided under this License is provided on an "AS IS" basis,
8374 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
8375 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
8376 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
8377 + * See the License for the specific provisions governing your rights and
8378 + * obligations concerning the Software.
8380 + * The Initial Developer of the Original Code is: Joerg Budischewski
8382 + * Copyright: 2000 by Sun Microsystems, Inc.
8384 + * All Rights Reserved.
8386 + * Contributor(s): Joerg Budischewski
8389 + ************************************************************************/
8391 +#include "pq_sequenceresultset.hxx"
8392 +#include "pq_sequenceresultsetmetadata.hxx"
8395 +using rtl::OUString;
8397 +using com::sun::star::sdbc::XResultSetMetaData;
8399 +using com::sun::star::uno::Sequence;
8400 +using com::sun::star::uno::Reference;
8401 +using com::sun::star::uno::Any;
8403 +namespace pq_sdbc_driver
8405 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
8407 +void SequenceResultSet::checkClosed()
8408 + throw ( com::sun::star::sdbc::SQLException,
8409 + com::sun::star::uno::RuntimeException )
8411 + // we never close :o)
8415 +Any SequenceResultSet::getValue( sal_Int32 columnIndex )
8417 + m_wasNull = ! m_data[m_row][columnIndex -1 ].hasValue();
8418 + return m_data[m_row][columnIndex -1 ];
8421 +SequenceResultSet::SequenceResultSet(
8422 + const ::rtl::Reference< RefCountedMutex > & mutex,
8423 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
8424 + const Sequence< OUString > &colNames,
8425 + const Sequence< Sequence< Any > > &data,
8426 + const Reference< com::sun::star::script::XTypeConverter > & tc,
8427 + const ColumnMetaDataVector *pVec) :
8428 + BaseResultSet( mutex, owner, data.getLength(), colNames.getLength(),tc ),
8430 + m_columnNames( colNames )
8434 + m_meta = new SequenceResultSetMetaData( mutex, *pVec, m_columnNames.getLength() );
8438 +SequenceResultSet::~SequenceResultSet()
8443 +void SequenceResultSet::close( )
8444 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8449 +Reference< XResultSetMetaData > SAL_CALL SequenceResultSet::getMetaData( )
8450 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8452 + if( ! m_meta.is() )
8454 + // Oh no, not again
8455 + throw ::com::sun::star::sdbc::SQLException(
8456 + ASCII_STR( "pq_sequenceresultset: no meta supported " ), *this,
8457 + OUString(), 1, Any() );
8463 +sal_Int32 SAL_CALL SequenceResultSet::findColumn(
8464 + const ::rtl::OUString& columnName )
8465 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8467 + // no need to guard, as all members are readonly !
8468 + sal_Int32 ret = -1;
8469 + for( int i = 0 ;i < m_fieldCount ; i ++ )
8471 + if( columnName == m_columnNames[i] )
8480 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8481 +++ connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx 2006-01-22 16:14:32.000000000 +0100
8483 +/*************************************************************************
8485 + * $RCSfile: pq_sequenceresultset.hxx,v $
8487 + * $Revision: 1.1.2.3 $
8489 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:32 $
8491 + * The Contents of this file are made available subject to the terms of
8492 + * either of the following licenses
8494 + * - GNU Lesser General Public License Version 2.1
8495 + * - Sun Industry Standards Source License Version 1.1
8497 + * Sun Microsystems Inc., October, 2000
8499 + * GNU Lesser General Public License Version 2.1
8500 + * =============================================
8501 + * Copyright 2000 by Sun Microsystems, Inc.
8502 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
8504 + * This library is free software; you can redistribute it and/or
8505 + * modify it under the terms of the GNU Lesser General Public
8506 + * License version 2.1, as published by the Free Software Foundation.
8508 + * This library is distributed in the hope that it will be useful,
8509 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8510 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8511 + * Lesser General Public License for more details.
8513 + * You should have received a copy of the GNU Lesser General Public
8514 + * License along with this library; if not, write to the Free Software
8515 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
8516 + * MA 02111-1307 USA
8519 + * Sun Industry Standards Source License Version 1.1
8520 + * =================================================
8521 + * The contents of this file are subject to the Sun Industry Standards
8522 + * Source License Version 1.1 (the "License"); You may not use this file
8523 + * except in compliance with the License. You may obtain a copy of the
8524 + * License at http://www.openoffice.org/license.html.
8526 + * Software provided under this License is provided on an "AS IS" basis,
8527 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
8528 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
8529 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
8530 + * See the License for the specific provisions governing your rights and
8531 + * obligations concerning the Software.
8533 + * The Initial Developer of the Original Code is: Joerg Budischewski
8535 + * Copyright: 2000 by Sun Microsystems, Inc.
8537 + * All Rights Reserved.
8539 + * Contributor(s): Joerg Budischewski
8542 + ************************************************************************/
8543 +#ifndef _PG_SEQUENCERESULTSET_HXX_
8544 +#define _PG_SEQUENCERESULTSET_HXX_
8546 +#include <cppuhelper/propshlp.hxx>
8547 +#include <cppuhelper/component.hxx>
8549 +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
8550 +#include <com/sun/star/sdbc/XRow.hpp>
8551 +#include <com/sun/star/sdbc/XCloseable.hpp>
8552 +#include <com/sun/star/sdbc/XColumnLocate.hpp>
8553 +#include "pq_connection.hxx"
8554 +#include "pq_baseresultset.hxx"
8555 +#include "pq_statics.hxx"
8557 +namespace pq_sdbc_driver
8560 +// static const sal_Int32 RESULTSET_CURSOR_NAME = 0;
8561 +// static const sal_Int32 RESULTSET_ESCAPE_PROCESSING = 1;
8562 +// static const sal_Int32 RESULTSET_FETCH_DIRECTION = 2;
8563 +// static const sal_Int32 RESULTSET_FETCH_SIZE = 3;
8564 +// static const sal_Int32 RESULTSET_RESULT_SET_CONCURRENCY = 4;
8565 +// static const sal_Int32 RESULTSET_RESULT_SET_TYPE = 5;
8567 +//#define RESULTSET_SIZE 6
8568 +class ResultSetGuard;
8570 +class SequenceResultSet : public BaseResultSet
8573 + ::com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > m_data;
8575 + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_columnNames;
8576 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta;
8579 + /** mutex should be locked before called
8581 + virtual void checkClosed()
8582 + throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
8584 + /** unchecked, acquire mutex before calling
8586 + virtual ::com::sun::star::uno::Any getValue( sal_Int32 columnIndex );
8589 + SequenceResultSet(
8590 + const ::rtl::Reference< RefCountedMutex > & mutex,
8591 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
8592 + const com::sun::star::uno::Sequence< rtl::OUString > &colNames,
8593 + const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data,
8594 + const com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > &tc,
8595 + const ColumnMetaDataVector *pVec = 0);
8596 + ~SequenceResultSet();
8598 +public: // XCloseable
8599 + virtual void SAL_CALL close( )
8600 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8602 +public: // XResultSetMetaDataSupplier
8603 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
8604 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8606 +public: // XColumnLocate
8607 + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName )
8608 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8613 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8614 +++ connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx 2006-01-22 16:15:16.000000000 +0100
8616 +#include "pq_sequenceresultsetmetadata.hxx"
8618 +#include <rtl/ustrbuf.hxx>
8620 +using rtl::OUStringBuffer;
8621 +using rtl::OUString;
8622 +using com::sun::star::uno::Any;
8624 +using com::sun::star::uno::RuntimeException;
8626 +using com::sun::star::sdbc::SQLException;
8628 +namespace pq_sdbc_driver
8631 +SequenceResultSetMetaData::SequenceResultSetMetaData(
8632 + const ::rtl::Reference< RefCountedMutex > & refMutex,
8633 + const ColumnMetaDataVector &metaDataVector,
8635 + m_refMutex( refMutex ),
8636 + m_colCount( colCount ),
8637 + m_columnData( metaDataVector )
8643 +sal_Int32 SequenceResultSetMetaData::getColumnCount( )
8644 + throw (SQLException, RuntimeException)
8646 + return m_colCount;
8649 +sal_Bool SequenceResultSetMetaData::isAutoIncrement( sal_Int32 column )
8650 + throw (SQLException, RuntimeException)
8652 + checkColumnIndex( column );
8653 + return m_columnData[column-1].isAutoIncrement;
8656 +sal_Bool SequenceResultSetMetaData::isCaseSensitive( sal_Int32 column )
8657 + throw (SQLException, RuntimeException)
8660 + return sal_True; // ??? hmm, numeric types or
8663 +sal_Bool SequenceResultSetMetaData::isSearchable( sal_Int32 column ) throw (SQLException, RuntimeException)
8665 + return sal_True; // mmm, what types are not searchable ?
8668 +sal_Bool SequenceResultSetMetaData::isCurrency( sal_Int32 column ) throw (SQLException, RuntimeException)
8670 + checkColumnIndex( column );
8671 + return m_columnData[column-1].isCurrency;
8674 +sal_Int32 SequenceResultSetMetaData::isNullable( sal_Int32 column )
8675 + throw (SQLException, RuntimeException)
8677 + checkColumnIndex( column );
8678 + return m_columnData[column-1].isNullable;
8681 +sal_Bool SequenceResultSetMetaData::isSigned( sal_Int32 column )
8682 + throw (SQLException, RuntimeException)
8684 + return sal_True; //
8687 +sal_Int32 SequenceResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
8688 + throw (SQLException, RuntimeException)
8693 +::rtl::OUString SequenceResultSetMetaData::getColumnLabel( sal_Int32 column )
8694 + throw (SQLException, RuntimeException)
8696 + checkColumnIndex( column );
8697 + return m_columnData[column-1].columnName;
8700 +::rtl::OUString SequenceResultSetMetaData::getColumnName( sal_Int32 column ) throw (SQLException, RuntimeException)
8702 + checkColumnIndex( column );
8703 + return m_columnData[column-1].columnName;
8706 +::rtl::OUString SequenceResultSetMetaData::getSchemaName( sal_Int32 column ) throw (SQLException, RuntimeException)
8708 + checkColumnIndex( column );
8709 + return m_columnData[column-1].schemaTableName;
8714 +sal_Int32 SequenceResultSetMetaData::getPrecision( sal_Int32 column )
8715 + throw (SQLException, RuntimeException)
8717 + checkColumnIndex( column );
8718 + return m_columnData[column-1].precision;
8721 +sal_Int32 SequenceResultSetMetaData::getScale( sal_Int32 column )
8722 + throw (SQLException, RuntimeException)
8724 + checkColumnIndex( column );
8725 + return m_columnData[column-1].scale;
8728 +::rtl::OUString SequenceResultSetMetaData::getTableName( sal_Int32 column )
8729 + throw (SQLException, RuntimeException)
8731 + checkColumnIndex( column );
8732 + return m_columnData[column-1].tableName;
8735 +::rtl::OUString SequenceResultSetMetaData::getCatalogName( sal_Int32 column )
8736 + throw (SQLException, RuntimeException)
8738 + // can do this through XConnection.getCatalog() !
8739 + return OUString();
8741 +sal_Int32 SequenceResultSetMetaData::getColumnType( sal_Int32 column )
8742 + throw (SQLException, RuntimeException)
8744 + checkColumnIndex( column );
8745 + return m_columnData[column-1].type;
8748 +::rtl::OUString SequenceResultSetMetaData::getColumnTypeName( sal_Int32 column )
8749 + throw (SQLException, RuntimeException)
8751 + checkColumnIndex( column );
8752 + return m_columnData[column-1].typeName;
8756 +sal_Bool SequenceResultSetMetaData::isReadOnly( sal_Int32 column )
8757 + throw (SQLException, RuntimeException)
8762 +sal_Bool SequenceResultSetMetaData::isWritable( sal_Int32 column )
8763 + throw (SQLException, RuntimeException)
8765 + return ! isReadOnly( column ); // what's the sense if this method ?
8768 +sal_Bool SequenceResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
8769 + throw (SQLException, RuntimeException)
8771 + return isWritable(column); // uhh, now it becomes really esoteric ....
8773 +::rtl::OUString SequenceResultSetMetaData::getColumnServiceName( sal_Int32 column )
8774 + throw (SQLException, RuntimeException)
8776 + return OUString();
8780 +void SequenceResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
8781 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
8783 + if( columnIndex < 1 || columnIndex > m_colCount )
8785 + OUStringBuffer buf(128);
8787 + buf.appendAscii( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
8788 + buf.append( m_colCount );
8789 + buf.appendAscii( ", got " );
8790 + buf.append( columnIndex );
8791 + throw SQLException(
8792 + buf.makeStringAndClear(), *this, OUString(), 1, Any() );
8798 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8799 +++ connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.hxx 2006-01-22 16:15:18.000000000 +0100
8801 +#include <cppuhelper/implbase1.hxx>
8802 +#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
8804 +#include "pq_connection.hxx"
8805 +#include "pq_statics.hxx"
8807 +namespace pq_sdbc_driver
8809 + class SequenceResultSetMetaData :
8810 + public ::cppu::WeakImplHelper1 < com::sun::star::sdbc::XResultSetMetaData >
8812 + ::rtl::Reference< RefCountedMutex > m_refMutex;
8813 + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_origin;
8814 + ::rtl::OUString m_tableName;
8815 + ::rtl::OUString m_schemaName;
8816 + ColumnMetaDataVector m_columnData;
8817 + sal_Int32 m_colCount;
8819 + void checkColumnIndex( sal_Int32 columnIndex )
8820 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8823 + SequenceResultSetMetaData(
8824 + const ::rtl::Reference< RefCountedMutex > & reMutex,
8825 + const ColumnMetaDataVector &vec,
8830 + virtual sal_Int32 SAL_CALL getColumnCount( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8831 + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8832 + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8833 + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8834 + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8835 + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8836 + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8837 + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8838 + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8839 + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8840 + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8841 + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8842 + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8843 + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8844 + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8845 + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8846 + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8847 + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8848 + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8849 + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8850 + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
8854 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
8855 +++ connectivity/source/drivers/postgresql/pq_statement.cxx 2007-08-26 22:40:40.000000000 +0200
8857 +/*************************************************************************
8859 + * $RCSfile: pq_statement.cxx,v $
8861 + * $Revision: 1.1.2.7 $
8863 + * last change: $Author: jbu $ $Date: 2007/08/26 20:40:40 $
8865 + * The Contents of this file are made available subject to the terms of
8866 + * either of the following licenses
8868 + * - GNU Lesser General Public License Version 2.1
8869 + * - Sun Industry Standards Source License Version 1.1
8871 + * Sun Microsystems Inc., October, 2000
8873 + * GNU Lesser General Public License Version 2.1
8874 + * =============================================
8875 + * Copyright 2000 by Sun Microsystems, Inc.
8876 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
8878 + * This library is free software; you can redistribute it and/or
8879 + * modify it under the terms of the GNU Lesser General Public
8880 + * License version 2.1, as published by the Free Software Foundation.
8882 + * This library is distributed in the hope that it will be useful,
8883 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8884 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8885 + * Lesser General Public License for more details.
8887 + * You should have received a copy of the GNU Lesser General Public
8888 + * License along with this library; if not, write to the Free Software
8889 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
8890 + * MA 02111-1307 USA
8893 + * Sun Industry Standards Source License Version 1.1
8894 + * =================================================
8895 + * The contents of this file are subject to the Sun Industry Standards
8896 + * Source License Version 1.1 (the "License"); You may not use this file
8897 + * except in compliance with the License. You may obtain a copy of the
8898 + * License at http://www.openoffice.org/license.html.
8900 + * Software provided under this License is provided on an "AS IS" basis,
8901 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
8902 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
8903 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
8904 + * See the License for the specific provisions governing your rights and
8905 + * obligations concerning the Software.
8907 + * The Initial Developer of the Original Code is: Joerg Budischewski
8909 + * Copyright: 2000 by Sun Microsystems, Inc.
8911 + * All Rights Reserved.
8913 + * Contributor(s): Joerg Budischewski
8916 + ************************************************************************/
8917 +#include "pq_statement.hxx"
8918 +#include "pq_fakedupdateableresultset.hxx"
8919 +#include "pq_updateableresultset.hxx"
8920 +#include "pq_tools.hxx"
8921 +#include "pq_statics.hxx"
8923 +#include <osl/thread.h>
8924 +#include <osl/time.h>
8926 +#include <rtl/ustrbuf.hxx>
8927 +#include <rtl/strbuf.hxx>
8929 +#include <cppuhelper/typeprovider.hxx>
8930 +#include <cppuhelper/queryinterface.hxx>
8932 +#include <com/sun/star/beans/PropertyAttribute.hpp>
8934 +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
8935 +#include <com/sun/star/sdbc/ResultSetType.hpp>
8936 +#include <com/sun/star/sdbc/XParameters.hpp>
8938 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
8939 +#include <com/sun/star/sdbcx/KeyType.hpp>
8940 +#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
8942 +#include <com/sun/star/container/XIndexAccess.hpp>
8943 +#include <com/sun/star/container/XEnumerationAccess.hpp>
8947 +using osl::MutexGuard;
8949 +using rtl::OUString;
8950 +using rtl::OUStringBuffer;
8951 +using rtl::OUStringToOString;
8952 +using rtl::OStringToOUString;
8953 +using rtl::OString;
8955 +using com::sun::star::uno::Any;
8956 +using com::sun::star::uno::makeAny;
8957 +using com::sun::star::uno::Type;
8958 +using com::sun::star::uno::RuntimeException;
8959 +using com::sun::star::uno::Exception;
8960 +using com::sun::star::uno::Sequence;
8961 +using com::sun::star::uno::Reference;
8962 +using com::sun::star::uno::XInterface;
8963 +using com::sun::star::uno::UNO_QUERY;
8965 +using com::sun::star::lang::IllegalArgumentException;
8967 +using com::sun::star::sdbc::XWarningsSupplier;
8968 +using com::sun::star::sdbc::XCloseable;
8969 +using com::sun::star::sdbc::XStatement;
8970 +using com::sun::star::sdbc::XPreparedStatement;
8971 +using com::sun::star::sdbc::XParameters;
8972 +using com::sun::star::sdbc::XRow;
8973 +using com::sun::star::sdbc::XResultSet;
8974 +using com::sun::star::sdbc::XGeneratedResultSet;
8975 +using com::sun::star::sdbc::XConnection;
8976 +using com::sun::star::sdbc::SQLException;
8978 +using com::sun::star::sdbcx::XColumnsSupplier;
8979 +using com::sun::star::sdbcx::XTablesSupplier;
8980 +using com::sun::star::sdbcx::XKeysSupplier;
8982 +using com::sun::star::beans::Property;
8983 +using com::sun::star::beans::XPropertySetInfo;
8984 +using com::sun::star::beans::XPropertySet;
8985 +using com::sun::star::beans::XFastPropertySet;
8986 +using com::sun::star::beans::XMultiPropertySet;
8988 +using com::sun::star::container::XNameAccess;
8989 +using com::sun::star::container::XEnumerationAccess;
8990 +using com::sun::star::container::XEnumeration;
8991 +using com::sun::star::container::XIndexAccess;
8993 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
8994 +namespace pq_sdbc_driver
8996 +static ::cppu::IPropertyArrayHelper & getStatementPropertyArrayHelper()
8998 + static ::cppu::IPropertyArrayHelper *pArrayHelper;
8999 + if( ! pArrayHelper )
9001 + MutexGuard guard( Mutex::getGlobalMutex() );
9002 + if( ! pArrayHelper )
9004 + static Property aTable[] =
9007 + OUString( RTL_CONSTASCII_USTRINGPARAM("CursorName") ), 0,
9008 + ::getCppuType( (OUString *)0) , 0 ),
9010 + OUString( RTL_CONSTASCII_USTRINGPARAM("EscapeProcessing") ), 1,
9011 + ::getBooleanCppuType() , 0 ),
9013 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchDirection") ), 2,
9014 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9016 + OUString( RTL_CONSTASCII_USTRINGPARAM("FetchSize") ), 3,
9017 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9019 + OUString( RTL_CONSTASCII_USTRINGPARAM("MaxFieldSize") ), 4,
9020 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9022 + OUString( RTL_CONSTASCII_USTRINGPARAM("MaxRows") ), 5,
9023 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9025 + OUString( RTL_CONSTASCII_USTRINGPARAM("QueryTimeOut") ), 6,
9026 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9028 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetConcurrency") ), 7,
9029 + ::getCppuType( (sal_Int32 *)0) , 0 ),
9031 + OUString( RTL_CONSTASCII_USTRINGPARAM("ResultSetType") ), 8,
9032 + ::getCppuType( (sal_Int32 *)0) , 0 )
9034 + OSL_ASSERT( sizeof(aTable)/ sizeof(Property) == STATEMENT_SIZE );
9035 + static ::cppu::OPropertyArrayHelper arrayHelper( aTable, STATEMENT_SIZE, sal_True );
9036 + pArrayHelper = &arrayHelper;
9039 + return *pArrayHelper;
9042 +Statement::Statement( const ::rtl::Reference< RefCountedMutex > & refMutex,
9043 + const Reference< XConnection > & conn,
9044 + struct ConnectionSettings *pSettings )
9045 + : OComponentHelper( refMutex->mutex ),
9046 + OPropertySetHelper( OComponentHelper::rBHelper ),
9047 + m_refMutex( refMutex ),
9048 + m_connection( conn ),
9049 + m_pSettings( pSettings ),
9050 + m_lastOidInserted( InvalidOid )
9052 + m_props[STATEMENT_QUERY_TIME_OUT] = makeAny( (sal_Int32)0 );
9053 + m_props[STATEMENT_MAX_ROWS] = makeAny( (sal_Int32)0 );
9054 + m_props[STATEMENT_RESULT_SET_CONCURRENCY] = makeAny(
9055 + com::sun::star::sdbc::ResultSetConcurrency::READ_ONLY );
9056 + m_props[STATEMENT_RESULT_SET_TYPE] = makeAny(
9057 + com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
9060 +Statement::~Statement()
9062 + POSTGRE_TRACE( "dtor Statement" );
9065 +void Statement::checkClosed() throw (SQLException, RuntimeException )
9067 + if( ! m_pSettings || ! m_pSettings->pConnection )
9068 + throw SQLException(
9069 + ASCII_STR("pq_driver: Statement or connection has already been closed !" ),
9070 + *this, OUString(),1,Any());
9073 +Any Statement::queryInterface( const Type & reqType ) throw (RuntimeException)
9077 + ret = OComponentHelper::queryInterface( reqType );
9078 + if( ! ret.hasValue() )
9079 + ret = ::cppu::queryInterface( reqType,
9080 + static_cast< XWarningsSupplier * > ( this ),
9081 + static_cast< XStatement * > ( this ),
9082 + static_cast< com::sun::star::sdbc::XResultSetMetaDataSupplier * > ( this ),
9083 + static_cast< XCloseable * > ( this ),
9084 + static_cast< XPropertySet * > ( this ),
9085 + static_cast< XMultiPropertySet * > ( this ),
9086 + static_cast< XGeneratedResultSet * > ( this ),
9087 + static_cast< XFastPropertySet * > ( this ) );
9092 +Sequence< Type > Statement::getTypes() throw ( RuntimeException )
9094 + static cppu::OTypeCollection *pCollection;
9095 + if( ! pCollection )
9097 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
9098 + if( !pCollection )
9100 + static cppu::OTypeCollection collection(
9101 + getCppuType( (Reference< XWarningsSupplier> *) 0 ),
9102 + getCppuType( (Reference< XStatement> *) 0 ),
9103 + getCppuType( (Reference< com::sun::star::sdbc::XResultSetMetaDataSupplier> *) 0 ),
9104 + getCppuType( (Reference< XCloseable> *) 0 ),
9105 + getCppuType( (Reference< XPropertySet >*) 0 ),
9106 + getCppuType( (Reference< XFastPropertySet > *) 0 ),
9107 + getCppuType( (Reference< XMultiPropertySet > *) 0 ),
9108 + getCppuType( (Reference< XGeneratedResultSet > *) 0 ),
9109 + OComponentHelper::getTypes());
9110 + pCollection = &collection;
9113 + return pCollection->getTypes();
9116 +Sequence< sal_Int8> Statement::getImplementationId() throw ( RuntimeException )
9118 + static cppu::OImplementationId *pId;
9121 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
9124 + static cppu::OImplementationId id(sal_False);
9128 + return pId->getImplementationId();
9131 +void Statement::close( ) throw (SQLException, RuntimeException)
9133 + // let the connection die without acquired mutex !
9134 + Reference< XConnection > r;
9135 + Reference< XCloseable > resultSet;
9137 + MutexGuard guard( m_refMutex->mutex );
9140 + m_connection.clear();
9142 + resultSet = m_lastResultset;
9143 + m_lastResultset.clear();
9145 + if( resultSet.is() )
9147 + resultSet->close();
9148 + POSTGRE_TRACE( "statement closed" );
9153 +void Statement::raiseSQLException(
9154 + const OUString & sql, const char * errorMsg, const char *errorType )
9155 + throw( SQLException )
9157 + OUStringBuffer buf(128);
9158 + buf.appendAscii( "pq_driver: ");
9161 + buf.appendAscii( "[" );
9162 + buf.appendAscii( errorType );
9163 + buf.appendAscii( "]" );
9166 + rtl::OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) );
9167 + buf.appendAscii( " (caused by statement '" );
9168 + buf.append( sql );
9169 + buf.appendAscii( "')" );
9170 + OUString error = buf.makeStringAndClear();
9171 + log( m_pSettings, LogLevel::ERROR, error );
9172 + throw SQLException( error, *this, OUString(), 1, Any() );
9175 +Reference< XResultSet > Statement::executeQuery(const OUString& sql )
9176 + throw (SQLException, RuntimeException)
9178 + Reference< XCloseable > lastResultSetHolder = m_lastResultset;
9179 + if( lastResultSetHolder.is() )
9180 + lastResultSetHolder->close();
9182 + if( ! execute( sql ) )
9184 + raiseSQLException( sql, "not a query" );
9186 + return Reference< XResultSet > ( m_lastResultset, com::sun::star::uno::UNO_QUERY );
9189 +sal_Int32 Statement::executeUpdate( const OUString& sql )
9190 + throw (SQLException, RuntimeException)
9192 + if( execute( sql ) )
9194 + raiseSQLException( sql, "not a command" );
9196 + return m_multipleResultUpdateCount;
9200 +static void raiseSQLException(
9201 + ConnectionSettings *pSettings,
9202 + const Reference< XInterface> & owner,
9203 + const OString & sql,
9204 + const char * errorMsg,
9205 + const char *errorType = 0 )
9206 + throw( SQLException )
9208 + OUStringBuffer buf(128);
9209 + buf.appendAscii( "pq_driver: ");
9212 + buf.appendAscii( "[" );
9213 + buf.appendAscii( errorType );
9214 + buf.appendAscii( "]" );
9217 + rtl::OUString( errorMsg, strlen(errorMsg) , pSettings->encoding ) );
9218 + buf.appendAscii( " (caused by statement '" );
9219 + buf.append( rtl::OStringToOUString( sql, pSettings->encoding ) );
9220 + buf.appendAscii( "')" );
9221 + OUString error = buf.makeStringAndClear();
9222 + log( pSettings, LogLevel::ERROR, error );
9223 + throw SQLException( error, owner, OUString(), 1, Any() );
9227 +// returns the elements of the primary key of the given table
9228 +// static Sequence< Reference< com::sun::star::beans::XPropertySet > > lookupKeys(
9229 +static Sequence< ::rtl::OUString > lookupKeys(
9230 + const Reference< com::sun::star::container::XNameAccess > &tables,
9231 + const OUString & table,
9232 + OUString *pSchema,
9234 + ConnectionSettings *pSettings)
9236 + Sequence< ::rtl::OUString > ret;
9237 + Reference< XKeysSupplier > keySupplier;
9238 + Statics & st = getStatics();
9240 + if( tables->hasByName( table ) )
9241 + tables->getByName( table ) >>= keySupplier;
9242 + else if( -1 == table.indexOf( '.' ) )
9244 + // it wasn't a fully qualified name. Now need to skip through all tables.
9245 + Reference< XEnumerationAccess > enumerationAccess =
9246 + Reference< XEnumerationAccess > ( tables, UNO_QUERY );
9248 + Reference< com::sun::star::container::XEnumeration > enumeration =
9249 + enumerationAccess->createEnumeration();
9250 + while( enumeration->hasMoreElements() )
9252 + Reference< XPropertySet > set;
9253 + enumeration->nextElement() >>= set;
9255 +// ::rtl::OUString schema;
9257 + if( set->getPropertyValue( st.NAME ) >>= name )
9259 +// printf( "searching %s %s\n",
9260 +// OUStringToOString( schema, RTL_TEXTENCODING_ASCII_US ).getStr(),
9261 +// OUStringToOString( name, RTL_TEXTENCODING_ASCII_US ).getStr() );
9262 + if( name == table )
9265 + if( keySupplier.is() )
9267 + // is ambigous, as I don't know postgresql searchpath,
9268 + // I can't continue here, as I may write to a different table
9269 + keySupplier.clear();
9270 + if( isLog( pSettings, LogLevel::INFO ) )
9272 + rtl::OStringBuffer buf( 128 );
9273 + buf.append( "Can't offer updateable result set because table " );
9274 + buf.append( OUStringToOString(name, pSettings->encoding) );
9275 + buf.append( " is duplicated, add schema to resolve ambiguity" );
9276 + log( pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
9280 + keySupplier = Reference< XKeysSupplier > ( set, UNO_QUERY );
9287 + if( isLog( pSettings, LogLevel::INFO ) )
9289 + rtl::OStringBuffer buf( 128 );
9290 + buf.append( "Can't offer updateable result set ( table " );
9291 + buf.append( OUStringToOString(table, pSettings->encoding) );
9292 + buf.append( " is unknown)" );
9293 + log( pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
9297 + if( keySupplier.is() )
9299 + Reference< XPropertySet > set( keySupplier, UNO_QUERY );
9300 + set->getPropertyValue( getStatics().NAME ) >>= (*pTable);
9301 + set->getPropertyValue( getStatics().SCHEMA_NAME ) >>= (*pSchema );
9304 + Reference< XEnumerationAccess > keys ( keySupplier->getKeys(), UNO_QUERY );
9305 + Reference< XEnumeration > enumeration = keys->createEnumeration();
9306 + while( enumeration->hasMoreElements() )
9308 + enumeration->nextElement() >>= set;
9309 + sal_Int32 keyType;
9310 + if( (set->getPropertyValue( st.TYPE ) >>= keyType ) &&
9311 + keyType == com::sun::star::sdbcx::KeyType::PRIMARY )
9313 + Reference< XColumnsSupplier > columns( set, UNO_QUERY );
9314 + Reference< XIndexAccess > indexAccess =
9315 + Reference< XIndexAccess > ( columns->getColumns(), UNO_QUERY );
9317 + int length = indexAccess->getCount();
9318 + ret.realloc( length );
9319 +// printf( "primary key for Table %s is ",
9320 +// OUStringToOString( table, RTL_TEXTENCODING_ASCII_US ).getStr() );
9321 + for( int i = 0 ; i < length ; i ++ )
9323 + indexAccess->getByIndex( i ) >>= set;
9325 + set->getPropertyValue( st.NAME ) >>= name;
9327 +// printf( "%s," , OUStringToOString( name, RTL_TEXTENCODING_ASCII_US ).getStr() );
9332 + if( ! ret.getLength() )
9334 + if( isLog( pSettings, LogLevel::INFO ) )
9336 + rtl::OStringBuffer buf( 128 );
9337 + buf.append( "Can't offer updateable result set ( table " );
9338 + buf.append( OUStringToOString(table, pSettings->encoding) );
9339 + buf.append( " does not have a primary key)" );
9340 + log( pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
9347 +bool executePostgresCommand( const rtl::OString & cmd, struct CommandData *data )
9349 + ConnectionSettings *pSettings = *(data->ppSettings);
9351 + sal_Int32 duration = osl_getGlobalTimer();
9352 + PGresult *result = PQexec( pSettings->pConnection, cmd.getStr() );
9353 + duration = osl_getGlobalTimer() - duration;
9355 + raiseSQLException(
9356 + pSettings, data->owner, cmd, PQerrorMessage( pSettings->pConnection ) );
9358 + ExecStatusType state = PQresultStatus( result );
9359 + *(data->pLastOidInserted) = 0;
9360 + *(data->pLastTableInserted) = rtl::OUString();
9361 + *(data->pLastQuery) = cmd;
9363 + sal_Bool ret = sal_False;
9366 + case PGRES_COMMAND_OK:
9368 + *(data->pMultipleResultUpdateCount) = atoi( PQcmdTuples( result ) );
9369 + *(data->pMultipleResultAvailable) = sal_False;
9371 + // in case an oid value is available, we retrieve it
9372 + *(data->pLastOidInserted) = PQoidValue( result );
9374 + // in case it was a single insert, extract the name of the table,
9375 + // otherwise the table name is empty
9376 + *(data->pLastTableInserted) =
9377 + extractTableFromInsert( OStringToOUString( cmd, pSettings->encoding ) );
9378 + if( isLog( pSettings, LogLevel::SQL ) )
9380 + rtl::OStringBuffer buf( 128 );
9381 + buf.append( "executed command '" );
9382 + buf.append( cmd.getStr() );
9383 + buf.append( "' sucessfully (" );
9384 + buf.append( *( data->pMultipleResultUpdateCount ) );
9385 + buf.append( ")" );
9386 + buf.append( ", duration=" );
9387 + buf.append( duration );
9388 + buf.append( "ms" );
9389 + if( *(data->pLastOidInserted) )
9391 + buf.append( ", usedOid=" );
9392 + buf.append( *(data->pLastOidInserted) , 10 );
9393 + buf.append( ", diagnosedTable=" );
9395 + OUStringToOString( *data->pLastTableInserted, pSettings->encoding ) );
9397 + log( pSettings, LogLevel::SQL, buf.makeStringAndClear().getStr() );
9399 + PQclear( result );
9402 + case PGRES_TUPLES_OK: // success
9404 + // In case it is a single table, it has a primary key and all columns
9405 + // belonging to the primary key are in the result set, allow updateable result sets
9406 + // otherwise, don't
9407 + rtl::OUString table, schema;
9408 + Sequence< OUString > sourceTableKeys;
9409 + OStringVector vec;
9410 + tokenizeSQL( cmd, vec );
9411 + OUString sourceTable =
9412 + OStringToOUString(
9413 + extractSingleTableFromSelect( vec ), pSettings->encoding );
9415 + if( data->concurrency ==
9416 + com::sun::star::sdbc::ResultSetConcurrency::UPDATABLE )
9419 + if( sourceTable.getLength() )
9421 + sourceTableKeys = lookupKeys(
9422 + pSettings->tables.is() ?
9423 + pSettings->tables : data->tableSupplier->getTables() ,
9429 + // check, whether the columns are in the result set (required !)
9431 + for( i = 0 ; i < sourceTableKeys.getLength() ; i ++ )
9433 + if( -1 == PQfnumber(
9435 + OUStringToOString( sourceTableKeys[i] ,
9436 + pSettings->encoding ).getStr()) )
9442 + if( sourceTableKeys.getLength() && i == sourceTableKeys.getLength() )
9444 + *(data->pLastResultset) =
9445 + UpdateableResultSet::createFromPGResultSet(
9446 + data->refMutex, data->owner, data->ppSettings, result,
9447 + schema, table,sourceTableKeys );
9449 + else if( ! table.getLength() )
9451 + rtl::OStringBuffer buf( 128 );
9453 + RTL_CONSTASCII_STRINGPARAM(
9454 + "can't support updateable resultset, because a single table in the "
9455 + "WHERE part of the statement could not be identified (" ) );
9456 + buf.append( cmd );
9457 + buf.append( RTL_CONSTASCII_STRINGPARAM( "." ) );
9458 + aReason = buf.makeStringAndClear();
9460 + else if( sourceTableKeys.getLength() )
9462 + ::rtl::OStringBuffer buf( 128 );
9464 + RTL_CONSTASCII_STRINGPARAM(
9465 + "can't support updateable resultset for table " ) );
9466 + buf.append( rtl::OUStringToOString( schema, pSettings->encoding ) );
9467 + buf.append( RTL_CONSTASCII_STRINGPARAM( "." ) );
9468 + buf.append( rtl::OUStringToOString( table, pSettings->encoding ) );
9469 + buf.append( RTL_CONSTASCII_STRINGPARAM( ", because resultset does not contain a part of the primary key ( column " ) );
9470 + buf.append( rtl::OUStringToOString( sourceTableKeys[i], pSettings->encoding ) );
9471 + buf.append( RTL_CONSTASCII_STRINGPARAM( " is missing )") );
9472 + aReason = buf.makeStringAndClear();
9477 + ::rtl::OStringBuffer buf( 128 );
9479 + RTL_CONSTASCII_STRINGPARAM(
9480 + "can't support updateable resultset for table " ) );
9481 + buf.append( rtl::OUStringToOString( schema, pSettings->encoding ) );
9482 + buf.append( RTL_CONSTASCII_STRINGPARAM( "." ) );
9483 + buf.append( rtl::OUStringToOString( table, pSettings->encoding ) );
9484 + buf.append( RTL_CONSTASCII_STRINGPARAM( ", because resultset table does not have a primary key " ) );
9485 + aReason = buf.makeStringAndClear();
9490 + ::rtl::OStringBuffer buf( 128 );
9492 + RTL_CONSTASCII_STRINGPARAM(
9493 + "can't support updateable result for selects with multiple tables (" ) );
9494 + buf.append( cmd );
9495 + buf.append( RTL_CONSTASCII_STRINGPARAM( ")" ) );
9496 + log( pSettings, LogLevel::SQL, buf.makeStringAndClear().getStr() );
9498 + if( ! (*(data->pLastResultset)).is() )
9500 + if( isLog( pSettings, LogLevel::ERROR ) )
9502 + log( pSettings, LogLevel::ERROR, aReason.getStr());
9505 + // TODO: How to react here correctly ?
9506 + // remove this piece of code
9507 + *(data->pLastResultset) =
9508 + new FakedUpdateableResultSet(
9509 + data->refMutex, data->owner,
9510 + data->ppSettings,result, schema, table,
9511 + OStringToOUString( aReason, pSettings->encoding) );
9515 + else if( sourceTable.getLength() && -1 != sourceTable.indexOf( '.' ) )
9517 + splitConcatenatedIdentifier( sourceTable, &schema, &table );
9520 + sal_Int32 returnedRows = PQntuples( result );
9521 + if( ! data->pLastResultset->is() )
9522 + *(data->pLastResultset) =
9523 + Reference< XCloseable > (
9525 + data->refMutex, data->owner,
9526 + data->ppSettings,result, schema, table ) );
9527 + *(data->pMultipleResultAvailable) = sal_True;
9529 + if( isLog( pSettings, LogLevel::SQL ) )
9531 + rtl::OStringBuffer buf( 128 );
9532 + buf.append( RTL_CONSTASCII_STRINGPARAM("executed query '") );
9533 + buf.append( cmd );
9534 + buf.append( RTL_CONSTASCII_STRINGPARAM("' sucessfully") );
9535 + buf.append( RTL_CONSTASCII_STRINGPARAM(", duration=") );
9536 + buf.append( duration );
9537 + buf.append( RTL_CONSTASCII_STRINGPARAM("ms, returnedRows=") );
9538 + buf.append( returnedRows );
9539 + buf.append( RTL_CONSTASCII_STRINGPARAM("." ) );
9540 + log( pSettings, LogLevel::SQL, buf.makeStringAndClear().getStr() );
9544 + case PGRES_EMPTY_QUERY:
9545 + case PGRES_COPY_OUT:
9546 + case PGRES_COPY_IN:
9547 + case PGRES_BAD_RESPONSE:
9548 + case PGRES_NONFATAL_ERROR:
9549 + case PGRES_FATAL_ERROR:
9551 + raiseSQLException(
9552 + pSettings, data->owner, cmd, PQresultErrorMessage( result ) , PQresStatus( state ) );
9558 +static Sequence< OUString > getPrimaryKeyColumnNames(
9559 + const Reference< XConnection > & connection, const OUString &schemaName, const OUString &tableName )
9561 + Sequence< OUString > ret;
9563 + Int2StringMap mapIndex2Name;
9564 + fillAttnum2attnameMap( mapIndex2Name, connection, schemaName, tableName );
9566 + // retrieve the primary key ...
9567 + Reference< XPreparedStatement > stmt = connection->prepareStatement(
9569 + "SELECT conkey " // 7
9570 + "FROM pg_constraint INNER JOIN pg_class ON conrelid = pg_class.oid "
9571 + "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
9572 + "LEFT JOIN pg_class AS class2 ON confrelid = class2.oid "
9573 + "LEFT JOIN pg_namespace AS nmsp2 ON class2.relnamespace=nmsp2.oid "
9574 + "WHERE pg_class.relname = ? AND pg_namespace.nspname = ? AND pg_constraint.contype='p'" ) );
9575 + DisposeGuard guard( stmt );
9576 + Reference< XParameters > paras( stmt, UNO_QUERY );
9577 + paras->setString( 1 , tableName );
9578 + paras->setString( 2 , schemaName );
9579 + Reference< XResultSet > rs = stmt->executeQuery();
9580 + Reference< XRow > xRow( rs , UNO_QUERY );
9584 + ret = convertMappedIntArray2StringArray( mapIndex2Name, string2intarray(xRow->getString( 1 ) ) );
9589 +static void getAutoValues(
9590 + String2StringMap & result,
9591 + const Reference< XConnection > & connection,
9592 + const OUString &schemaName,
9593 + const OUString & tableName )
9595 + Reference< XPreparedStatement > stmt = connection->prepareStatement(
9596 + ASCII_STR("SELECT pg_attribute.attname, pg_attrdef.adsrc "
9597 + "FROM pg_class, pg_namespace, pg_attribute "
9598 + "LEFT JOIN pg_attrdef ON pg_attribute.attrelid = pg_attrdef.adrelid AND "
9599 + "pg_attribute.attnum = pg_attrdef.adnum "
9600 + "WHERE pg_attribute.attrelid = pg_class.oid AND "
9601 + "pg_class.relnamespace = pg_namespace.oid AND "
9602 + "pg_namespace.nspname = ? AND "
9603 + "pg_class.relname LIKE ? AND "
9604 + "pg_attrdef.adsrc != ''"
9606 + DisposeGuard guard( stmt );
9607 + Reference< XParameters > paras( stmt, UNO_QUERY );
9608 + paras->setString( 1 , schemaName );
9609 + paras->setString( 2 , tableName );
9610 + Reference< XResultSet > rs = stmt->executeQuery();
9611 + Reference< XRow > xRow( rs , UNO_QUERY );
9613 + while( rs->next() )
9615 + result[ OUStringToOString( xRow->getString( 1 ), RTL_TEXTENCODING_ASCII_US) ] =
9616 + OUStringToOString( xRow->getString(2), RTL_TEXTENCODING_ASCII_US );
9620 +Reference< XResultSet > getGeneratedValuesFromLastInsert(
9621 + ConnectionSettings *pConnectionSettings,
9622 + const Reference< XConnection > &connection,
9623 + sal_Int32 nLastOid,
9624 + const rtl::OUString & lastTableInserted,
9625 + const rtl::OString & lastQuery )
9627 + Reference< XResultSet > ret;
9629 + OUString schemaName, tableName;
9630 + splitConcatenatedIdentifier(
9631 + lastTableInserted, &schemaName, &tableName );
9633 + if( nLastOid && lastTableInserted.getLength() )
9635 + OUStringBuffer buf( 128 );
9636 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
9637 + if( schemaName.getLength() )
9638 + bufferQuoteQualifiedIdentifier(buf, schemaName,tableName );
9640 + bufferQuoteIdentifier( buf, lastTableInserted );
9641 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE oid = " ) );
9642 + buf.append( nLastOid , 10 );
9643 + query = buf.makeStringAndClear();
9645 + else if ( lastTableInserted.getLength() && lastQuery.getLength() )
9647 + // extract nameValue Pairs
9648 + String2StringMap namedValues;
9649 + extractNameValuePairsFromInsert( namedValues, lastQuery );
9652 +// rtl::OStringBuffer buf( 128);
9653 +// buf.append( "extracting name/value from '" );
9654 +// buf.append( lastQuery.getStr() );
9655 +// buf.append( "' to [" );
9656 +// for( String2StringMap::iterator ii = namedValues.begin() ; ii != namedValues.end() ; ++ii )
9658 +// buf.append( ii->first.getStr() );
9659 +// buf.append( "=" );
9660 +// buf.append( ii->second.getStr() );
9661 +// buf.append( "," );
9663 +// buf.append( "]\n" );
9664 +// printf( buf.makeStringAndClear() );
9666 + // TODO: make also unqualified tables names work here. Have a look at 2.8.3. The Schema Search Path
9667 + // in postgresql doc
9669 + Sequence< OUString > keyColumnNames = getPrimaryKeyColumnNames( connection, schemaName, tableName );
9670 + if( keyColumnNames.getLength() )
9672 + OUStringBuffer buf( 128 );
9673 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
9674 + bufferQuoteQualifiedIdentifier(buf, schemaName,tableName );
9675 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE " ) );
9676 + bool additionalCondition = false;
9677 + String2StringMap autoValues;
9678 + for( int i = 0 ; i < keyColumnNames.getLength() ; i ++ )
9681 + OString columnName = OUStringToOString( keyColumnNames[i], pConnectionSettings->encoding );
9682 + String2StringMap::iterator ii = namedValues.begin();
9683 + for( ; ii != namedValues.end() ; ++ii )
9685 + if( columnName.equalsIgnoreAsciiCase( ii->first ) )
9687 + value = OStringToOUString( ii->second , pConnectionSettings->encoding );
9692 + // check, if a column of the primary key was not inserted explicitly,
9693 + if( ii == namedValues.end() )
9696 + if( autoValues.begin() == autoValues.end() )
9698 + getAutoValues( autoValues, connection, schemaName, tableName );
9700 + // this could mean, that the column is a default or auto value, check this ...
9701 + String2StringMap::iterator ii = autoValues.begin();
9702 + for( ; ii != autoValues.end() ; ++ii )
9704 + if( columnName.equalsIgnoreAsciiCase( ii->first ) )
9706 + // it is indeed an auto value.
9707 + value = OStringToOUString(ii->second, RTL_TEXTENCODING_ASCII_US );
9708 + // check, whether it is a sequence
9710 + if( rtl_str_shortenedCompare_WithLength(
9711 + ii->second.getStr(), ii->second.getLength(),
9712 + RTL_CONSTASCII_STRINGPARAM( "nextval(" ), 8 ) == 0 )
9714 + // retrieve current sequence value:
9715 + OUStringBuffer myBuf(128 );
9716 + myBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT currval(" ) );
9717 + myBuf.appendAscii( &(ii->second.getStr()[8]));
9718 + value = querySingleValue( connection, myBuf.makeStringAndClear() );
9723 + if( ii == autoValues.end() )
9725 + // it even was no autovalue, no sense to continue as we can't query the
9727 + buf = OUStringBuffer();
9732 + if( additionalCondition )
9733 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AND " ) );
9734 + bufferQuoteIdentifier( buf, keyColumnNames[i] );
9735 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
9736 + buf.append( value );
9737 + additionalCondition = true;
9739 + query = buf.makeStringAndClear();
9743 + if( query.getLength() )
9745 + Reference< com::sun::star::sdbc::XStatement > stmt = connection->createStatement();
9746 + ret = stmt->executeQuery( query );
9753 +sal_Bool Statement::execute( const OUString& sql )
9754 + throw (SQLException, RuntimeException)
9756 + osl::MutexGuard guard( m_refMutex->mutex );
9758 + OString cmd = rtl::OUStringToOString( sql, m_pSettings->encoding );
9760 + m_lastResultset.clear();
9761 + m_lastTableInserted = rtl::OUString();
9763 + struct CommandData data;
9764 + data.refMutex = m_refMutex;
9765 + data.ppSettings = &m_pSettings;
9766 + data.pLastOidInserted = &m_lastOidInserted;
9767 + data.pLastQuery = &m_lastQuery;
9768 + data.pMultipleResultUpdateCount = &m_multipleResultUpdateCount;
9769 + data.pMultipleResultAvailable = &m_multipleResultAvailable;
9770 + data.pLastTableInserted = &m_lastTableInserted;
9771 + data.pLastResultset = &m_lastResultset;
9772 + data.owner = *this;
9773 + data.tableSupplier = Reference< com::sun::star::sdbcx::XTablesSupplier >( m_connection, UNO_QUERY );
9774 + data.concurrency =
9775 + extractIntProperty( this, getStatics().RESULT_SET_CONCURRENCY );
9776 + return executePostgresCommand( cmd , &data );
9779 +Reference< XConnection > Statement::getConnection( )
9780 + throw (SQLException, RuntimeException)
9782 + Reference< XConnection > ret;
9784 + MutexGuard guard( m_refMutex->mutex );
9786 + ret = m_connection;
9792 +Any Statement::getWarnings( )
9793 + throw (SQLException,RuntimeException)
9798 +void Statement::clearWarnings( )
9799 + throw (SQLException, RuntimeException)
9803 +Reference< ::com::sun::star::sdbc::XResultSetMetaData > Statement::getMetaData()
9804 + throw (SQLException,RuntimeException)
9806 + Reference< com::sun::star::sdbc::XResultSetMetaData > ret;
9807 + Reference< com::sun::star::sdbc::XResultSetMetaDataSupplier > supplier( m_lastResultset, UNO_QUERY );
9808 + if( supplier.is() )
9809 + ret = supplier->getMetaData();
9814 +::cppu::IPropertyArrayHelper & Statement::getInfoHelper()
9816 + return getStatementPropertyArrayHelper();
9820 +sal_Bool Statement::convertFastPropertyValue(
9821 + Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue )
9822 + throw (IllegalArgumentException)
9824 + rOldValue = m_props[nHandle];
9828 + case STATEMENT_CURSOR_NAME:
9831 + bRet = ( rValue >>= val );
9832 + rConvertedValue = makeAny( val );
9835 + case STATEMENT_ESCAPE_PROCESSING:
9838 + bRet = ( rValue >>= val );
9839 + rConvertedValue = makeAny( val );
9842 + case STATEMENT_FETCH_DIRECTION:
9843 + case STATEMENT_FETCH_SIZE:
9844 + case STATEMENT_MAX_FIELD_SIZE:
9845 + case STATEMENT_MAX_ROWS:
9846 + case STATEMENT_QUERY_TIME_OUT:
9847 + case STATEMENT_RESULT_SET_CONCURRENCY:
9848 + case STATEMENT_RESULT_SET_TYPE:
9851 + bRet = ( rValue >>= val );
9852 + rConvertedValue = makeAny( val );
9857 + OUStringBuffer buf(128);
9858 + buf.appendAscii( "pq_statement: Invalid property handle (" );
9859 + buf.append( nHandle );
9860 + buf.appendAscii( ")" );
9861 + throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
9868 +void Statement::setFastPropertyValue_NoBroadcast(
9869 + sal_Int32 nHandle,const Any& rValue ) throw (Exception)
9871 + m_props[nHandle] = rValue;
9874 +void Statement::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
9876 + rValue = m_props[nHandle];
9879 +Reference < XPropertySetInfo > Statement::getPropertySetInfo()
9880 + throw(RuntimeException)
9882 + return OPropertySetHelper::createPropertySetInfo( getStatementPropertyArrayHelper() );
9886 +Reference< XResultSet > Statement::getResultSet( )
9887 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
9889 + return Reference< XResultSet > ( m_lastResultset, com::sun::star::uno::UNO_QUERY );
9892 +sal_Int32 Statement::getUpdateCount( )
9893 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
9895 + return m_multipleResultUpdateCount;
9898 +sal_Bool Statement::getMoreResults( )
9899 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
9906 +void Statement::disposing()
9911 +Reference< XResultSet > Statement::getGeneratedValues( )
9912 + throw (SQLException, RuntimeException)
9914 + osl::MutexGuard guard( m_refMutex->mutex );
9915 + return getGeneratedValuesFromLastInsert(
9916 + m_pSettings, m_connection, m_lastOidInserted, m_lastTableInserted, m_lastQuery );
9921 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
9922 +++ connectivity/source/drivers/postgresql/pq_statement.hxx 2006-01-22 16:14:34.000000000 +0100
9924 +/*************************************************************************
9926 + * $RCSfile: pq_statement.hxx,v $
9928 + * $Revision: 1.1.2.3 $
9930 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:34 $
9932 + * The Contents of this file are made available subject to the terms of
9933 + * either of the following licenses
9935 + * - GNU Lesser General Public License Version 2.1
9936 + * - Sun Industry Standards Source License Version 1.1
9938 + * Sun Microsystems Inc., October, 2000
9940 + * GNU Lesser General Public License Version 2.1
9941 + * =============================================
9942 + * Copyright 2000 by Sun Microsystems, Inc.
9943 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
9945 + * This library is free software; you can redistribute it and/or
9946 + * modify it under the terms of the GNU Lesser General Public
9947 + * License version 2.1, as published by the Free Software Foundation.
9949 + * This library is distributed in the hope that it will be useful,
9950 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9951 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9952 + * Lesser General Public License for more details.
9954 + * You should have received a copy of the GNU Lesser General Public
9955 + * License along with this library; if not, write to the Free Software
9956 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
9957 + * MA 02111-1307 USA
9960 + * Sun Industry Standards Source License Version 1.1
9961 + * =================================================
9962 + * The contents of this file are subject to the Sun Industry Standards
9963 + * Source License Version 1.1 (the "License"); You may not use this file
9964 + * except in compliance with the License. You may obtain a copy of the
9965 + * License at http://www.openoffice.org/license.html.
9967 + * Software provided under this License is provided on an "AS IS" basis,
9968 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
9969 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
9970 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
9971 + * See the License for the specific provisions governing your rights and
9972 + * obligations concerning the Software.
9974 + * The Initial Developer of the Original Code is: Joerg Budischewski
9976 + * Copyright: 2000 by Sun Microsystems, Inc.
9978 + * All Rights Reserved.
9980 + * Contributor(s): Joerg Budischewski
9983 + ************************************************************************/
9984 +#ifndef _PQ_STATEMENT_HXX_
9985 +#define _PQ_STATEMENT_HXX_
9986 +#include <cppuhelper/propshlp.hxx>
9987 +#include <cppuhelper/component.hxx>
9989 +#include <libpq-fe.h>
9991 +#include "pq_connection.hxx"
9992 +#include <com/sun/star/sdbc/XMultipleResults.hpp>
9993 +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
9994 +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
9996 +namespace pq_sdbc_driver
9999 +static const sal_Int32 STATEMENT_CURSOR_NAME = 0;
10000 +static const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
10001 +static const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
10002 +static const sal_Int32 STATEMENT_FETCH_SIZE = 3;
10003 +static const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
10004 +static const sal_Int32 STATEMENT_MAX_ROWS = 5;
10005 +static const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
10006 +static const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY = 7;
10007 +static const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
10009 +#define STATEMENT_SIZE 9
10012 +class Statement : public cppu::OComponentHelper,
10013 + public cppu::OPropertySetHelper,
10014 + public com::sun::star::sdbc::XStatement,
10015 + public com::sun::star::sdbc::XCloseable,
10016 + public com::sun::star::sdbc::XWarningsSupplier,
10017 + public com::sun::star::sdbc::XMultipleResults,
10018 + public com::sun::star::sdbc::XGeneratedResultSet,
10019 + public com::sun::star::sdbc::XResultSetMetaDataSupplier
10022 + com::sun::star::uno::Any m_props[STATEMENT_SIZE];
10023 + com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
10024 + ConnectionSettings *m_pSettings;
10025 + com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
10026 + ::rtl::Reference< RefCountedMutex > m_refMutex;
10027 + sal_Bool m_multipleResultAvailable;
10028 + sal_Int32 m_multipleResultUpdateCount;
10029 + sal_Int32 m_lastOidInserted;
10030 + rtl::OUString m_lastTableInserted;
10031 + rtl::OString m_lastQuery;
10035 + * @param ppConnection The piece of memory, pConnection points to, is accessisble
10036 + * as long as a reference to paramenter con is held.
10038 + Statement( const rtl::Reference< RefCountedMutex > & refMutex,
10039 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
10040 + struct ConnectionSettings *pSettings );
10042 + virtual ~Statement();
10043 +public: // XInterface
10044 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
10045 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
10046 + virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
10047 + throw (com::sun::star::uno::RuntimeException);
10049 +public: // XCloseable
10050 + virtual void SAL_CALL close( )
10051 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10053 +public: // XStatement
10054 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
10055 + const ::rtl::OUString& sql )
10056 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10057 + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql )
10058 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10059 + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql )
10060 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10061 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( )
10062 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10064 +public: // XWarningsSupplier
10065 + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( )
10066 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10067 + virtual void SAL_CALL clearWarnings( )
10068 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10070 +public: // XTypeProvider, first implemented by OPropertySetHelper
10071 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
10072 + throw( com::sun::star::uno::RuntimeException );
10073 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
10074 + throw( com::sun::star::uno::RuntimeException );
10076 +public: // OPropertySetHelper
10077 + virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
10079 + virtual sal_Bool SAL_CALL convertFastPropertyValue(
10080 + ::com::sun::star::uno::Any & rConvertedValue,
10081 + ::com::sun::star::uno::Any & rOldValue,
10082 + sal_Int32 nHandle,
10083 + const ::com::sun::star::uno::Any& rValue )
10084 + throw (::com::sun::star::lang::IllegalArgumentException);
10086 + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
10087 + sal_Int32 nHandle,
10088 + const ::com::sun::star::uno::Any& rValue )
10089 + throw (::com::sun::star::uno::Exception);
10091 + virtual void SAL_CALL getFastPropertyValue(
10092 + ::com::sun::star::uno::Any& rValue,
10093 + sal_Int32 nHandle ) const;
10096 + ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
10097 + throw(com::sun::star::uno::RuntimeException);
10099 +public: // XGeneratedResultSet
10100 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
10101 + getGeneratedValues( )
10102 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10104 +public: // XMultipleResults
10105 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( )
10106 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10107 + virtual sal_Int32 SAL_CALL getUpdateCount( )
10108 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10109 + virtual sal_Bool SAL_CALL getMoreResults( )
10110 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10112 +public: // OComponentHelper
10113 + virtual void SAL_CALL disposing();
10115 +public: // XResultSetMetaDataSupplier (is required by framework (see
10116 + // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
10117 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
10118 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
10121 + void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
10122 + void raiseSQLException( const ::rtl::OUString & sql, const char * errorMsg, const char *errorType = 0 )
10123 + throw ( com::sun::star::sdbc::SQLException );
10127 +struct CommandData
10129 + ConnectionSettings **ppSettings;
10130 + sal_Int32 *pLastOidInserted;
10131 + sal_Int32 *pMultipleResultUpdateCount;
10132 + sal_Bool *pMultipleResultAvailable;
10133 + ::rtl::OUString *pLastTableInserted;
10134 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > *pLastResultset;
10135 + ::rtl::OString *pLastQuery;
10136 + ::rtl::Reference< RefCountedMutex > refMutex;
10137 + ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > owner;
10138 + ::com::sun::star::uno::Reference< com::sun::star::sdbcx::XTablesSupplier > tableSupplier;
10139 + sal_Int32 concurrency;
10142 +bool executePostgresCommand( const rtl::OString & cmd, struct CommandData *data );
10143 +com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
10144 + ConnectionSettings *pConnectionSettings,
10145 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
10146 + sal_Int32 nLastOid,
10147 + const rtl::OUString & lastTableInserted,
10148 + const rtl::OString & lastQuery );
10153 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
10154 +++ connectivity/source/drivers/postgresql/pq_statics.cxx 2007-02-15 21:04:48.000000000 +0100
10156 +/*************************************************************************
10158 + * $RCSfile: pq_statics.cxx,v $
10160 + * $Revision: 1.1.2.6 $
10162 + * last change: $Author: jbu $ $Date: 2007/02/15 20:04:48 $
10164 + * The Contents of this file are made available subject to the terms of
10165 + * either of the following licenses
10167 + * - GNU Lesser General Public License Version 2.1
10168 + * - Sun Industry Standards Source License Version 1.1
10170 + * Sun Microsystems Inc., October, 2000
10172 + * GNU Lesser General Public License Version 2.1
10173 + * =============================================
10174 + * Copyright 2000 by Sun Microsystems, Inc.
10175 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
10177 + * This library is free software; you can redistribute it and/or
10178 + * modify it under the terms of the GNU Lesser General Public
10179 + * License version 2.1, as published by the Free Software Foundation.
10181 + * This library is distributed in the hope that it will be useful,
10182 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10183 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10184 + * Lesser General Public License for more details.
10186 + * You should have received a copy of the GNU Lesser General Public
10187 + * License along with this library; if not, write to the Free Software
10188 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
10189 + * MA 02111-1307 USA
10192 + * Sun Industry Standards Source License Version 1.1
10193 + * =================================================
10194 + * The contents of this file are subject to the Sun Industry Standards
10195 + * Source License Version 1.1 (the "License"); You may not use this file
10196 + * except in compliance with the License. You may obtain a copy of the
10197 + * License at http://www.openoffice.org/license.html.
10199 + * Software provided under this License is provided on an "AS IS" basis,
10200 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
10201 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
10202 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
10203 + * See the License for the specific provisions governing your rights and
10204 + * obligations concerning the Software.
10206 + * The Initial Developer of the Original Code is: Joerg Budischewski
10208 + * Copyright: 2000 by Sun Microsystems, Inc.
10210 + * All Rights Reserved.
10212 + * Contributor(s): Joerg Budischewski
10215 + ************************************************************************/
10217 +#include "pq_statics.hxx"
10218 +#include "pq_updateableresultset.hxx"
10219 +#include <com/sun/star/sdbc/DataType.hpp>
10220 +#include <com/sun/star/beans/PropertyAttribute.hpp>
10222 +using rtl::OUString;
10223 +using com::sun::star::uno::Sequence;
10224 +using com::sun::star::uno::Any;
10225 +using com::sun::star::uno::Type;
10227 +using com::sun::star::beans::PropertyAttribute::READONLY;
10228 +using com::sun::star::beans::PropertyAttribute::BOUND;
10229 +using com::sun::star::beans::Property;
10231 +namespace pq_sdbc_driver
10234 +struct DefColumnMetaData
10236 + sal_Char * columnName;
10237 + sal_Char * tableName;
10238 + sal_Char * schemaTableName;
10239 + sal_Char * typeName;
10241 + sal_Int32 precision;
10243 + sal_Bool isCurrency;
10244 + sal_Bool isNullable;
10245 + sal_Bool isAutoIncrement;
10246 + sal_Bool isReadOnly;
10247 + sal_Bool isSigned;
10250 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
10251 +struct BaseTypeDef { const char * typeName; sal_Int32 value; };
10253 +static Sequence< OUString > createStringSequence( const char * name[] )
10256 + for( length = 0; name[length] ; length ++ );
10258 + Sequence< OUString > seq( length );
10259 + for( int i = 0; i < length; i ++ )
10261 + seq[i] = OUString( name[i] , strlen( name[i] ), RTL_TEXTENCODING_ASCII_US );
10266 +static Sequence< sal_Int8 > generateImplementationId()
10268 + Sequence< sal_Int8 > seq( 16 );
10269 + rtl_createUuid( (sal_uInt8*)seq.getArray(), 0 , sal_False );
10273 +struct PropertyDef
10275 + PropertyDef( const OUString &str, const Type &t )
10276 + : name( str ) , type( t ) {}
10277 + ::rtl::OUString name;
10278 + com::sun::star::uno::Type type;
10281 +struct PropertyDefEx : public PropertyDef
10283 + PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
10284 + : PropertyDef( str, t ) , attribute( a )
10286 + sal_Int32 attribute;
10289 +static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
10290 + PropertyDef *props, int count , sal_Int16 attr )
10292 + Sequence< Property > seq( count );
10293 + for( int i = 0 ; i < count ; i ++ )
10295 + seq[i] = Property( props[i].name, i, props[i].type, attr );
10297 + return new cppu::OPropertyArrayHelper( seq, sal_True );
10300 +static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
10301 + PropertyDefEx *props, int count )
10303 + Sequence< Property > seq( count );
10304 + for( int i = 0 ; i < count ; i ++ )
10306 + seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
10308 + return new cppu::OPropertyArrayHelper( seq, sal_True );
10311 +Statics & getStatics()
10313 + static Statics * p;
10316 + ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
10319 + static Statics statics ;
10320 + statics.SYSTEM_TABLE = ASCII_STR( "SYSTEM TABLE" );
10321 + statics.TABLE = ASCII_STR( "TABLE" );
10322 + statics.VIEW = ASCII_STR( "VIEW" );
10323 + statics.UNKNOWN = ASCII_STR( "UNKNOWN" );
10324 + statics.YES = ASCII_STR( "YES" );
10325 + statics.NO = ASCII_STR( "NO" );
10326 + statics.NO_NULLS = ASCII_STR( "NO_NULLS" );
10327 + statics.NULABLE = ASCII_STR( "NULABLE" );
10328 + statics.NULLABLE_UNKNOWN = ASCII_STR( "NULLABLE_UNKNOWN" );
10329 + statics.cPERCENT = ASCII_STR( "%" );
10331 + statics.TYPE = ASCII_STR( "Type" );
10332 + statics.TYPE_NAME = ASCII_STR( "TypeName" );
10333 + statics.NAME = ASCII_STR( "Name" );
10334 + statics.SCHEMA_NAME = ASCII_STR( "SchemaName" );
10335 + statics.CATALOG_NAME = ASCII_STR( "CatalogName" );
10336 + statics.DESCRIPTION = ASCII_STR( "Description" );
10337 + statics.PRIVILEGES = ASCII_STR( "Privileges" );
10339 + statics.DEFAULT_VALUE = ASCII_STR( "DefaultValue" );
10340 + statics.IS_AUTO_INCREMENT = ASCII_STR( "IsAutoIncrement" );
10341 + statics.IS_CURRENCY = ASCII_STR( "IsCurrency" );
10342 + statics.IS_NULLABLE = ASCII_STR( "IsNullable" );
10343 + statics.IS_ROW_VERSISON = ASCII_STR( "IsRowVersion" );
10344 + statics.PRECISION = ASCII_STR( "Precision" );
10345 + statics.SCALE = ASCII_STR( "Scale" );
10347 + statics.cPERCENT = ASCII_STR( "%" );
10348 + statics.BEGIN = ASCII_STR( "BEGIN" );
10349 + statics.COMMIT = ASCII_STR( "COMMIT" );
10350 + statics.ROLLBACK = ASCII_STR( "ROLLBACK" );
10352 + statics.KEY = ASCII_STR( "Key" );
10353 + statics.REFERENCED_TABLE = ASCII_STR( "ReferencedTable" );
10354 + statics.UPDATE_RULE = ASCII_STR( "UpdateRule" );
10355 + statics.DELETE_RULE = ASCII_STR( "DeleteRule" );
10356 + statics.PRIVATE_COLUMNS = ASCII_STR( "PrivateColumns" );
10357 + statics.PRIVATE_FOREIGN_COLUMNS = ASCII_STR( "PrivateForeignColumns" );
10359 + statics.KEY_COLUMN = ASCII_STR( "KeyColumn" );
10360 + statics.RELATED_COLUMN = ASCII_STR( "RelatedColumn" );
10361 + statics.PASSWORD = ASCII_STR( "Password" );
10362 + statics.USER = ASCII_STR( "User" );
10364 + statics.CURSOR_NAME = ASCII_STR( "CursorName" );
10365 + statics.ESCAPE_PROCESSING = ASCII_STR( "EscapeProcessing" );
10366 + statics.FETCH_DIRECTION = ASCII_STR( "FetchDirection" );
10367 + statics.FETCH_SIZE = ASCII_STR( "FetchSize" );
10368 + statics.IS_BOOKMARKABLE = ASCII_STR( "IsBookmarkable" );
10369 + statics.RESULT_SET_CONCURRENCY = ASCII_STR( "ResultSetConcurrency" );
10370 + statics.RESULT_SET_TYPE = ASCII_STR( "ResultSetType" );
10372 + statics.COMMAND = ASCII_STR( "Command" );
10373 + statics.CHECK_OPTION = ASCII_STR( "CheckOption" );
10375 + statics.TRUE = ASCII_STR( "t" );
10376 + statics.FALSE = ASCII_STR( "f" );
10377 + statics.IS_PRIMARY_KEY_INDEX = ASCII_STR( "IsPrimaryKeyIndex" );
10378 + statics.IS_CLUSTERED = ASCII_STR( "IsClustered" );
10379 + statics.IS_UNIQUE = ASCII_STR( "IsUnique" );
10380 + statics.IS_ASCENDING = ASCII_STR( "IsAscending" );
10381 + statics.PRIVATE_COLUMN_INDEXES = ASCII_STR( "PrivateColumnIndexes" );
10382 + statics.HELP_TEXT = ASCII_STR( "HelpText" );
10384 + statics.CATALOG = ASCII_STR( "Catalog" );
10386 + Type tString = getCppuType( (rtl::OUString *) 0 );
10387 + Type tInt = getCppuType( (sal_Int32 * ) 0 );
10388 + Type tBool = getBooleanCppuType();
10389 + Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< ::rtl::OUString > *) 0);
10391 + // Table props set
10392 + ImplementationStatics &ist = statics.refl.table;
10393 + ist.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Table" );
10394 + ist.serviceNames = Sequence< OUString > ( 1 );
10395 + ist.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Table" );
10396 + PropertyDef tableDef[] =
10398 + PropertyDef( statics.CATALOG_NAME , tString ),
10399 + PropertyDef( statics.DESCRIPTION , tString ),
10400 + PropertyDef( statics.NAME , tString ),
10401 + PropertyDef( statics.PRIVILEGES , tInt ),
10402 + PropertyDef( statics.SCHEMA_NAME , tString ),
10403 + PropertyDef( statics.TYPE , tString )
10405 + ist.pProps = createPropertyArrayHelper(
10406 + tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
10408 + statics.refl.tableDescriptor.implName =
10409 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.TableDescriptor" );
10410 + statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
10411 + statics.refl.tableDescriptor.serviceNames[0] =
10412 + ASCII_STR( "com.sun.star.sdbcx.TableDescriptor" );
10413 + PropertyDef tableDescDef[] =
10415 + PropertyDef( statics.CATALOG_NAME , tString ),
10416 + PropertyDef( statics.DESCRIPTION , tString ),
10417 + PropertyDef( statics.NAME , tString ),
10418 + PropertyDef( statics.PRIVILEGES , tInt ),
10419 + PropertyDef( statics.SCHEMA_NAME , tString )
10421 + statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
10422 + tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 );
10424 + // Column props set
10425 + statics.refl.column.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Column" );
10426 + statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
10427 + statics.refl.column.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Column" );
10428 + PropertyDefEx columnDef[] =
10430 + PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
10431 + PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
10432 + PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
10433 +// PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
10434 + PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
10435 + PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
10436 + PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
10437 + PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
10438 + PropertyDefEx( statics.NAME , tString,READONLY ),
10439 + PropertyDefEx( statics.PRECISION , tInt, READONLY ),
10440 + PropertyDefEx( statics.SCALE , tInt ,READONLY),
10441 + PropertyDefEx( statics.TYPE , tInt ,READONLY),
10442 + PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
10444 + statics.refl.column.pProps = createPropertyArrayHelper(
10445 + columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
10447 + statics.refl.columnDescriptor.implName =
10448 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.ColumnDescriptor" );
10449 + statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
10450 + statics.refl.columnDescriptor.serviceNames[0] =
10451 + ASCII_STR( "com.sun.star.sdbcx.ColumnDescriptor" );
10452 + PropertyDef columnDescDef[] =
10454 + PropertyDef( statics.CATALOG_NAME , tString ),
10455 + PropertyDef( statics.DEFAULT_VALUE, tString ),
10456 + PropertyDef( statics.DESCRIPTION , tString ),
10457 +// PropertyDef( statics.HELP_TEXT , tString ),
10458 + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
10459 + PropertyDef( statics.IS_CURRENCY, tBool ),
10460 + PropertyDef( statics.IS_NULLABLE, tInt ),
10461 + PropertyDef( statics.IS_ROW_VERSISON, tBool ),
10462 + PropertyDef( statics.NAME , tString ),
10463 + PropertyDef( statics.PRECISION , tInt ),
10464 + PropertyDef( statics.SCALE , tInt ),
10465 + PropertyDef( statics.TYPE , tInt ),
10466 + PropertyDef( statics.TYPE_NAME , tString )
10469 + statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
10470 + columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 );
10472 + // Key properties
10473 + statics.refl.key.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Key" );
10474 + statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
10475 + statics.refl.key.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Key" );
10476 + PropertyDef keyDef[] =
10478 + PropertyDef( statics.DELETE_RULE, tInt ),
10479 + PropertyDef( statics.NAME, tString ),
10480 + PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
10481 + PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
10482 + PropertyDef( statics.REFERENCED_TABLE, tString ),
10483 + PropertyDef( statics.TYPE, tInt ),
10484 + PropertyDef( statics.UPDATE_RULE, tInt )
10486 + statics.refl.key.pProps = createPropertyArrayHelper(
10487 + keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
10490 + // Key properties
10491 + statics.refl.keyDescriptor.implName =
10492 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyDescriptor" );
10493 + statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
10494 + statics.refl.keyDescriptor.serviceNames[0] =
10495 + ASCII_STR( "com.sun.star.sdbcx.KeyDescriptor" );
10496 + PropertyDef keyDescDef[] =
10498 + PropertyDef( statics.DELETE_RULE, tInt ),
10499 + PropertyDef( statics.NAME, tString ),
10500 + PropertyDef( statics.REFERENCED_TABLE, tString ),
10501 + PropertyDef( statics.TYPE, tInt ),
10502 + PropertyDef( statics.UPDATE_RULE, tInt )
10504 + statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
10505 + keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 );
10509 + // KeyColumn props set
10510 + statics.refl.keycolumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumn" );
10511 + statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
10512 + statics.refl.keycolumn.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.KeyColumn" );
10513 + PropertyDef keycolumnDef[] =
10515 + PropertyDef( statics.CATALOG_NAME , tString ),
10516 + PropertyDef( statics.DEFAULT_VALUE, tString ),
10517 + PropertyDef( statics.DESCRIPTION , tString ),
10518 + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
10519 + PropertyDef( statics.IS_CURRENCY, tBool ),
10520 + PropertyDef( statics.IS_NULLABLE, tInt ),
10521 + PropertyDef( statics.IS_ROW_VERSISON, tBool ),
10522 + PropertyDef( statics.NAME , tString ),
10523 + PropertyDef( statics.PRECISION , tInt ),
10524 + PropertyDef( statics.RELATED_COLUMN, tString ),
10525 + PropertyDef( statics.SCALE , tInt ),
10526 + PropertyDef( statics.TYPE , tInt ),
10527 + PropertyDef( statics.TYPE_NAME , tString )
10529 + statics.refl.keycolumn.pProps = createPropertyArrayHelper(
10530 + keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
10532 + // KeyColumn props set
10533 + statics.refl.keycolumnDescriptor.implName =
10534 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor" );
10535 + statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
10536 + statics.refl.keycolumnDescriptor.serviceNames[0] =
10537 + ASCII_STR( "com.sun.star.sdbcx.KeyColumnDescriptor" );
10538 + PropertyDef keycolumnDescDef[] =
10540 + PropertyDef( statics.NAME , tString ),
10541 + PropertyDef( statics.RELATED_COLUMN, tString )
10543 + statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
10544 + keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 );
10546 + // view props set
10547 + statics.refl.view.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.View");
10548 + statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
10549 + statics.refl.view.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.View" );
10550 + PropertyDef viewDef[] =
10552 + PropertyDef( statics.CATALOG_NAME , tString ),
10553 + PropertyDef( statics.CHECK_OPTION , tInt ),
10554 + PropertyDef( statics.COMMAND , tString ),
10555 + PropertyDef( statics.NAME , tString ),
10556 + PropertyDef( statics.SCHEMA_NAME , tString )
10558 + statics.refl.view.pProps = createPropertyArrayHelper(
10559 + viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
10561 + // view props set
10562 + statics.refl.viewDescriptor.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.ViewDescriptor");
10563 + statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
10564 + statics.refl.viewDescriptor.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.ViewDescriptor" );
10565 + statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
10566 + viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical
10567 + // user props set
10568 + statics.refl.user.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.User");
10569 + statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
10570 + statics.refl.user.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.User" );
10571 + PropertyDef userDefRO[] =
10573 + PropertyDef( statics.NAME , tString )
10575 + statics.refl.user.pProps = createPropertyArrayHelper(
10576 + userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
10578 + // user props set
10579 + statics.refl.userDescriptor.implName =
10580 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.UserDescriptor");
10581 + statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
10582 + statics.refl.userDescriptor.serviceNames[0] =
10583 + ASCII_STR( "com.sun.star.sdbcx.UserDescriptor" );
10584 + PropertyDef userDefWR[] =
10586 + PropertyDef( statics.NAME , tString ),
10587 + PropertyDef( statics.PASSWORD , tString )
10589 + statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
10590 + userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 );
10592 + // index props set
10593 + statics.refl.index.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Index");
10594 + statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
10595 + statics.refl.index.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Index" );
10596 + PropertyDef indexDef[] =
10598 + PropertyDef( statics.CATALOG , tString ),
10599 + PropertyDef( statics.IS_CLUSTERED, tBool ),
10600 + PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
10601 + PropertyDef( statics.IS_UNIQUE, tBool ),
10602 + PropertyDef( statics.NAME , tString ),
10603 + PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
10605 + statics.refl.index.pProps = createPropertyArrayHelper(
10606 + indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
10608 + // index props set
10609 + statics.refl.indexDescriptor.implName =
10610 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexDescriptor");
10611 + statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
10612 + statics.refl.indexDescriptor.serviceNames[0] =
10613 + ASCII_STR( "com.sun.star.sdbcx.IndexDescriptor" );
10614 + statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
10615 + indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 );
10617 + // indexColumn props set
10618 + statics.refl.indexColumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumn");
10619 + statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
10620 + statics.refl.indexColumn.serviceNames[0] = ASCII_STR("com.sun.star.sdbcx.IndexColumn");
10621 + PropertyDef indexColumnDef[] =
10623 + PropertyDef( statics.CATALOG_NAME , tString ),
10624 + PropertyDef( statics.DEFAULT_VALUE, tString ),
10625 + PropertyDef( statics.DESCRIPTION , tString ),
10626 + PropertyDef( statics.IS_ASCENDING, tBool ),
10627 + PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
10628 + PropertyDef( statics.IS_CURRENCY, tBool ),
10629 + PropertyDef( statics.IS_NULLABLE, tInt ),
10630 + PropertyDef( statics.IS_ROW_VERSISON, tBool ),
10631 + PropertyDef( statics.NAME , tString ),
10632 + PropertyDef( statics.PRECISION , tInt ),
10633 + PropertyDef( statics.SCALE , tInt ),
10634 + PropertyDef( statics.TYPE , tInt ),
10635 + PropertyDef( statics.TYPE_NAME , tString )
10637 + statics.refl.indexColumn.pProps = createPropertyArrayHelper(
10638 + indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
10640 + // indexColumn props set
10641 + statics.refl.indexColumnDescriptor.implName =
10642 + ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor");
10643 + statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
10644 + statics.refl.indexColumnDescriptor.serviceNames[0] =
10645 + ASCII_STR("com.sun.star.sdbcx.IndexColumnDescriptor");
10646 + PropertyDef indexColumnDescDef[] =
10648 + PropertyDef( statics.IS_ASCENDING, tBool ),
10649 + PropertyDef( statics.NAME , tString )
10651 + statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
10652 + indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 );
10655 + statics.refl.resultSet.implName = ASCII_STR( "org.openoffice.comp.pq.ResultSet");
10656 + statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
10657 + statics.refl.resultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
10658 + statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
10659 + PropertyDef resultSet[] =
10661 + PropertyDef( statics.CURSOR_NAME , tString ),
10662 + PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
10663 + PropertyDef( statics.FETCH_DIRECTION , tInt ),
10664 + PropertyDef( statics.FETCH_SIZE , tInt ),
10665 + PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
10666 + PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
10667 + PropertyDef( statics.RESULT_SET_TYPE , tInt )
10669 + statics.refl.resultSet.pProps = createPropertyArrayHelper(
10670 + resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
10672 + // updateableResultset
10673 + statics.refl.updateableResultSet.implName = ASCII_STR( "org.openoffice.comp.pq.UpdateableResultSet");
10674 + statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
10675 + statics.refl.updateableResultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
10676 + statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
10677 + statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
10678 + resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
10680 + // databasemetadata
10681 + statics.tablesRowNames = Sequence< OUString > ( 5 );
10682 + statics.tablesRowNames[TABLE_INDEX_CATALOG] = ASCII_STR( "TABLE_CAT" );
10683 + statics.tablesRowNames[TABLE_INDEX_SCHEMA] = ASCII_STR( "TABLE_SCHEM" );
10684 + statics.tablesRowNames[TABLE_INDEX_NAME] = ASCII_STR( "TABLE_NAME" );
10685 + statics.tablesRowNames[TABLE_INDEX_TYPE] = ASCII_STR( "TABLE_TYPE" );
10686 + statics.tablesRowNames[TABLE_INDEX_REMARKS] = ASCII_STR( "REMARKS" );
10688 + statics.primaryKeyNames = Sequence< OUString > ( 6 );
10689 + statics.primaryKeyNames[0] = ASCII_STR( "TABLE_CAT" );
10690 + statics.primaryKeyNames[1] = ASCII_STR( "TABLE_SCHEM" );
10691 + statics.primaryKeyNames[2] = ASCII_STR( "TABLE_NAME" );
10692 + statics.primaryKeyNames[3] = ASCII_STR( "COLUMN_NAME" );
10693 + statics.primaryKeyNames[4] = ASCII_STR( "KEY_SEQ" );
10694 + statics.primaryKeyNames[5] = ASCII_STR( "PK_NAME" );
10696 + statics.SELECT = ASCII_STR( "SELECT" );
10697 + statics.UPDATE = ASCII_STR( "UPDATE" );
10698 + statics.INSERT = ASCII_STR( "INSERT" );
10699 + statics.DELETE = ASCII_STR( "DELETE" );
10700 + statics.RULE = ASCII_STR( "RULE" );
10701 + statics.REFERENCES = ASCII_STR( "REFERENCES" );
10702 + statics.TRIGGER = ASCII_STR( "TRIGGER" );
10703 + statics.EXECUTE = ASCII_STR( "EXECUTE" );
10704 + statics.USAGE = ASCII_STR( "USAGE" );
10705 + statics.CREATE = ASCII_STR( "CREATE" );
10706 + statics.TEMPORARY = ASCII_STR( "TEMPORARY" );
10707 + statics.INDEX = ASCII_STR( "Index" );
10708 + statics.INDEX_COLUMN = ASCII_STR( "IndexColumn" );
10710 + statics.schemaNames = Sequence< OUString > ( 1 );
10711 + statics.schemaNames[0] = ASCII_STR( "TABLE_SCHEM" );
10713 + statics.tableTypeData = Sequence< Sequence< Any > >( 2 );
10715 + statics.tableTypeData[0] = Sequence< Any > ( 1 );
10716 + statics.tableTypeData[0][0] <<= statics.TABLE;
10718 +// statics.tableTypeData[2] = Sequence< Any > ( 1 );
10719 +// statics.tableTypeData[2][0] <<= statics.VIEW;
10721 + statics.tableTypeData[1] = Sequence< Any > ( 1 );
10722 + statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
10724 + statics.tableTypeNames = Sequence< OUString > ( 1 );
10725 + statics.tableTypeNames[0] = ASCII_STR( "TABLE_TYPE" );
10727 + static const char *tablePrivilegesNames[] =
10729 + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE",
10730 + "IS_GRANTABLE" , 0
10732 + statics.tablePrivilegesNames =
10733 + createStringSequence( tablePrivilegesNames );
10735 + static const char * columnNames[] =
10737 + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
10738 + "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
10739 + "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
10740 + "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
10741 + "ORDINAL_POSITION", "IS_NULLABLE", 0
10743 + statics.columnRowNames =
10744 + createStringSequence( columnNames );
10746 + static const char * typeinfoColumnNames[] =
10748 + "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
10749 + "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
10750 + "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
10751 + "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
10752 + "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
10753 + "NUM_PREC_RADIX", 0
10755 + statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames );
10757 + static const char * indexinfoColumnNames[] =
10759 + "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
10760 + "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
10761 + "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
10762 + "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0
10764 + statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames );
10766 + static const char * importedKeysColumnNames[] =
10781 + "DEFERRABILITY" ,
10784 + statics.importedKeysColumnNames =
10785 + createStringSequence( importedKeysColumnNames );
10787 + static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 };
10788 + statics.resultSetArrayColumnNames =
10789 + createStringSequence( resultSetArrayColumnNames );
10791 + BaseTypeDef baseTypeDefs[] =
10793 + { "bool" , com::sun::star::sdbc::DataType::BIT },
10794 + { "bytea", com::sun::star::sdbc::DataType::VARBINARY },
10795 + { "char" , com::sun::star::sdbc::DataType::CHAR },
10797 + { "int8" , com::sun::star::sdbc::DataType::BIGINT },
10798 + { "serial8" , com::sun::star::sdbc::DataType::BIGINT },
10801 + { "int2" , com::sun::star::sdbc::DataType::SMALLINT },
10803 + { "int4" , com::sun::star::sdbc::DataType::INTEGER },
10804 +// { "regproc" , com::sun::star::sdbc::DataType::INTEGER },
10805 +// { "oid" , com::sun::star::sdbc::DataType::INTEGER },
10806 +// { "xid" , com::sun::star::sdbc::DataType::INTEGER },
10807 +// { "cid" , com::sun::star::sdbc::DataType::INTEGER },
10808 +// { "serial", com::sun::star::sdbc::DataType::INTEGER },
10809 +// { "serial4", com::sun::star::sdbc::DataType::INTEGER },
10811 + { "text", com::sun::star::sdbc::DataType::VARCHAR },
10812 + { "bpchar", com::sun::star::sdbc::DataType::CHAR },
10813 + { "varchar", com::sun::star::sdbc::DataType::VARCHAR },
10815 + { "float4", com::sun::star::sdbc::DataType::REAL },
10816 + { "float8", com::sun::star::sdbc::DataType::DOUBLE },
10818 + { "numeric", com::sun::star::sdbc::DataType::NUMERIC },
10819 + { "decimal", com::sun::star::sdbc::DataType::DECIMAL },
10821 + { "date", com::sun::star::sdbc::DataType::DATE }, // switch to date later
10822 + { "time", com::sun::star::sdbc::DataType::TIME }, // switch to time later
10823 + { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP }, // switch to time later
10825 +// { "_bool" , com::sun::star::sdbc::DataType::ARRAY },
10826 +// { "_bytea", com::sun::star::sdbc::DataType::ARRAY },
10827 +// { "_char" , com::sun::star::sdbc::DataType::ARRAY },
10829 +// { "_int8" , com::sun::star::sdbc::DataType::ARRAY },
10830 +// { "_serial8" , com::sun::star::sdbc::DataType::ARRAY },
10833 +// { "_int2" , com::sun::star::sdbc::DataType::ARRAY },
10835 +// { "_int4" , com::sun::star::sdbc::DataType::ARRAY },
10836 +// { "_regproc" , com::sun::star::sdbc::DataType::ARRAY },
10837 +// { "_oid" , com::sun::star::sdbc::DataType::ARRAY },
10838 +// { "_xid" , com::sun::star::sdbc::DataType::ARRAY },
10839 +// { "_cid" , com::sun::star::sdbc::DataType::ARRAY },
10841 +// { "_text", com::sun::star::sdbc::DataType::ARRAY },
10842 +// { "_bpchar", com::sun::star::sdbc::DataType::ARRAY },
10843 +// { "_varchar", com::sun::star::sdbc::DataType::ARRAY },
10845 +// { "_float4", com::sun::star::sdbc::DataType::ARRAY },
10846 +// { "_float8", com::sun::star::sdbc::DataType::ARRAY },
10848 +// { "_numeric", com::sun::star::sdbc::DataType::ARRAY },
10849 +// { "_decimal", com::sun::star::sdbc::DataType::ARRAY },
10851 +// { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later
10852 +// { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later
10857 + for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
10859 + statics.baseTypeMap[
10860 + OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
10861 + baseTypeDefs[i].value;
10864 + DefColumnMetaData defTypeInfoMetaData[] =
10866 + { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 0
10867 + { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 1
10868 + { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 2
10869 + { "foo1", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 3
10870 + { "foo2", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 4
10871 + { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 5
10872 + { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 6
10873 + { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 7
10874 + { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0 }, // 8
10875 + { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 9
10876 + { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 10
10877 + { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 11
10878 + { "foo3", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 12
10879 + { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 13
10880 + { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 14
10881 + { "foo4", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 15
10882 + { "foo5", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 16
10883 + { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 17
10884 + {0,0,0,0,0,0,0,0,0,0,0}
10887 + for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
10889 + statics.typeInfoMetaData.push_back(
10891 + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
10892 + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
10893 + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
10894 + rtl::OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
10895 + defTypeInfoMetaData[i].type,
10896 + defTypeInfoMetaData[i].precision,
10897 + defTypeInfoMetaData[i].scale,
10898 + defTypeInfoMetaData[i].isCurrency,
10899 + defTypeInfoMetaData[i].isNullable,
10900 + defTypeInfoMetaData[i].isAutoIncrement,
10901 + defTypeInfoMetaData[i].isReadOnly,
10902 + defTypeInfoMetaData[i].isSigned ) );
10914 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
10915 +++ connectivity/source/drivers/postgresql/pq_statics.hxx 2006-01-22 16:14:36.000000000 +0100
10917 +/*************************************************************************
10919 + * $RCSfile: pq_statics.hxx,v $
10921 + * $Revision: 1.1.2.4 $
10923 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:36 $
10925 + * The Contents of this file are made available subject to the terms of
10926 + * either of the following licenses
10928 + * - GNU Lesser General Public License Version 2.1
10929 + * - Sun Industry Standards Source License Version 1.1
10931 + * Sun Microsystems Inc., October, 2000
10933 + * GNU Lesser General Public License Version 2.1
10934 + * =============================================
10935 + * Copyright 2000 by Sun Microsystems, Inc.
10936 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
10938 + * This library is free software; you can redistribute it and/or
10939 + * modify it under the terms of the GNU Lesser General Public
10940 + * License version 2.1, as published by the Free Software Foundation.
10942 + * This library is distributed in the hope that it will be useful,
10943 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10944 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10945 + * Lesser General Public License for more details.
10947 + * You should have received a copy of the GNU Lesser General Public
10948 + * License along with this library; if not, write to the Free Software
10949 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
10950 + * MA 02111-1307 USA
10953 + * Sun Industry Standards Source License Version 1.1
10954 + * =================================================
10955 + * The contents of this file are subject to the Sun Industry Standards
10956 + * Source License Version 1.1 (the "License"); You may not use this file
10957 + * except in compliance with the License. You may obtain a copy of the
10958 + * License at http://www.openoffice.org/license.html.
10960 + * Software provided under this License is provided on an "AS IS" basis,
10961 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
10962 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
10963 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
10964 + * See the License for the specific provisions governing your rights and
10965 + * obligations concerning the Software.
10967 + * The Initial Developer of the Original Code is: Joerg Budischewski
10969 + * Copyright: 2000 by Sun Microsystems, Inc.
10971 + * All Rights Reserved.
10973 + * Contributor(s): Joerg Budischewski
10976 + ************************************************************************/
10977 +#ifndef _PQ_STATICS_HXX_
10978 +#define _PQ_STATICS_HXX_
10980 +#include <hash_map>
10983 +#include <rtl/uuid.h>
10985 +#include <com/sun/star/uno/Any.hxx>
10986 +#include <com/sun/star/uno/Sequence.hxx>
10987 +#include <com/sun/star/sdbc/DataType.hpp>
10989 +#include <cppuhelper/propshlp.hxx>
10991 +#include "pq_allocator.hxx"
10993 +namespace pq_sdbc_driver
10996 +struct ColumnMetaData
10999 + const rtl::OUString &_columnName,
11000 + const rtl::OUString &_tableName,
11001 + const rtl::OUString &_schemaTableName,
11002 + const rtl::OUString &_typeName,
11004 + sal_Int32 _precision,
11005 + sal_Int32 _scale,
11006 + sal_Bool _isCurrency,
11007 + sal_Bool _isNullable,
11008 + sal_Bool _isAutoIncrement,
11009 + sal_Bool _isReadOnly,
11010 + sal_Bool _isSigned ) :
11011 + columnName( _columnName ),
11012 + tableName( _tableName ),
11013 + schemaTableName( _schemaTableName ),
11014 + typeName( _typeName ),
11016 + precision( _precision ),
11018 + isCurrency( _isCurrency ),
11019 + isNullable( _isNullable ),
11020 + isAutoIncrement( _isAutoIncrement ),
11021 + isReadOnly( _isReadOnly ),
11022 + isSigned( _isSigned )
11025 + rtl::OUString columnName;
11026 + rtl::OUString tableName;
11027 + rtl::OUString schemaTableName;
11028 + rtl::OUString typeName;
11030 + sal_Int32 precision;
11032 + sal_Bool isCurrency;
11033 + sal_Bool isNullable;
11034 + sal_Bool isAutoIncrement;
11035 + sal_Bool isReadOnly;
11036 + sal_Bool isSigned;
11039 +typedef std::vector< ColumnMetaData, Allocator< ColumnMetaData > > ColumnMetaDataVector;
11041 +struct TypeDetails
11043 + sal_Int32 dataType;
11044 + sal_Int32 minScale;
11045 + sal_Int32 maxScale; // in case nothing is given in getTypeInfo
11046 + sal_Bool isAutoIncrement;
11047 + sal_Bool isSearchable;
11050 +typedef ::std::hash_map
11054 + rtl::OUStringHash,
11055 + ::std::equal_to< rtl::OUString >,
11056 + Allocator< ::std::pair< const ::rtl::OUString , sal_Int32 > >
11061 +struct ImplementationStatics
11063 + ImplementationStatics() :
11064 + implementationId( 16 )
11066 + rtl_createUuid( (sal_uInt8*)implementationId.getArray(), 0 , sal_False );
11069 + rtl::OUString implName;
11070 + com::sun::star::uno::Sequence< ::rtl::OUString > serviceNames;
11071 + com::sun::star::uno::Sequence< sal_Int8 > implementationId;
11072 + cppu::IPropertyArrayHelper *pProps;
11073 + com::sun::star::uno::Sequence< com::sun::star::uno::Type > types;
11076 +struct ReflectionImplementations
11078 + struct ImplementationStatics table;
11079 + struct ImplementationStatics tableDescriptor;
11080 + struct ImplementationStatics column;
11081 + struct ImplementationStatics columnDescriptor;
11082 + struct ImplementationStatics key;
11083 + struct ImplementationStatics keyDescriptor;
11084 + struct ImplementationStatics keycolumn;
11085 + struct ImplementationStatics keycolumnDescriptor;
11086 + struct ImplementationStatics user;
11087 + struct ImplementationStatics userDescriptor;
11088 + struct ImplementationStatics view;
11089 + struct ImplementationStatics viewDescriptor;
11090 + struct ImplementationStatics index;
11091 + struct ImplementationStatics indexDescriptor;
11092 + struct ImplementationStatics indexColumn;
11093 + struct ImplementationStatics indexColumnDescriptor;
11095 + struct ImplementationStatics updateableResultSet;
11096 + struct ImplementationStatics resultSet;
11099 +static const sal_Int32 TABLE_INDEX_CATALOG = 0;
11100 +static const sal_Int32 TABLE_INDEX_SCHEMA = 1;
11101 +static const sal_Int32 TABLE_INDEX_NAME = 2;
11102 +static const sal_Int32 TABLE_INDEX_TYPE = 3;
11103 +static const sal_Int32 TABLE_INDEX_REMARKS = 4;
11107 + ::rtl::OUString SYSTEM_TABLE;
11108 + ::rtl::OUString TABLE;
11109 + ::rtl::OUString VIEW;
11110 + ::rtl::OUString UNKNOWN;
11111 + ::rtl::OUString YES;
11112 + ::rtl::OUString NO;
11113 + ::rtl::OUString NO_NULLS;
11114 + ::rtl::OUString NULABLE;
11115 + ::rtl::OUString NULLABLE_UNKNOWN;
11116 + ::rtl::OUString SELECT;
11117 + ::rtl::OUString UPDATE;
11118 + ::rtl::OUString INSERT;
11119 + ::rtl::OUString DELETE;
11120 + ::rtl::OUString RULE;
11121 + ::rtl::OUString REFERENCES;
11122 + ::rtl::OUString TRIGGER;
11123 + ::rtl::OUString EXECUTE;
11124 + ::rtl::OUString USAGE;
11125 + ::rtl::OUString CREATE;
11126 + ::rtl::OUString TEMPORARY;
11127 + ::rtl::OUString INDEX;
11128 + ::rtl::OUString INDEX_COLUMN;
11130 + ::rtl::OUString NAME;
11131 + ::rtl::OUString SCHEMA_NAME;
11132 + ::rtl::OUString CATALOG_NAME;
11133 + ::rtl::OUString DESCRIPTION;
11134 + ::rtl::OUString TYPE;
11135 + ::rtl::OUString TYPE_NAME;
11136 + ::rtl::OUString PRIVILEGES;
11138 + ::rtl::OUString DEFAULT_VALUE;
11139 + ::rtl::OUString IS_AUTO_INCREMENT;
11140 + ::rtl::OUString IS_CURRENCY;
11141 + ::rtl::OUString IS_NULLABLE;
11142 + ::rtl::OUString IS_ROW_VERSISON;
11143 + ::rtl::OUString PRECISION;
11144 + ::rtl::OUString SCALE;
11146 + ::rtl::OUString cPERCENT;
11148 + ::rtl::OUString BEGIN;
11149 + ::rtl::OUString ROLLBACK;
11150 + ::rtl::OUString COMMIT;
11152 + ::rtl::OUString KEY;
11153 + ::rtl::OUString REFERENCED_TABLE;
11154 + ::rtl::OUString UPDATE_RULE;
11155 + ::rtl::OUString DELETE_RULE;
11156 + ::rtl::OUString PRIVATE_COLUMNS;
11157 + ::rtl::OUString PRIVATE_FOREIGN_COLUMNS;
11159 + ::rtl::OUString KEY_COLUMN;
11160 + ::rtl::OUString RELATED_COLUMN;
11162 + ::rtl::OUString PASSWORD;
11163 + ::rtl::OUString USER;
11165 + ::rtl::OUString CURSOR_NAME;
11166 + ::rtl::OUString ESCAPE_PROCESSING;
11167 + ::rtl::OUString FETCH_DIRECTION;
11168 + ::rtl::OUString FETCH_SIZE;
11169 + ::rtl::OUString IS_BOOKMARKABLE;
11170 + ::rtl::OUString RESULT_SET_CONCURRENCY;
11171 + ::rtl::OUString RESULT_SET_TYPE;
11173 + ::rtl::OUString COMMAND;
11174 + ::rtl::OUString CHECK_OPTION;
11176 + ::rtl::OUString TRUE;
11177 + ::rtl::OUString FALSE;
11179 + ::rtl::OUString IS_PRIMARY_KEY_INDEX;
11180 + ::rtl::OUString IS_CLUSTERED;
11181 + ::rtl::OUString IS_UNIQUE;
11182 + ::rtl::OUString PRIVATE_COLUMN_INDEXES;
11183 + ::rtl::OUString HELP_TEXT;
11185 + ::rtl::OUString CATALOG;
11186 + ::rtl::OUString IS_ASCENDING;
11187 + ReflectionImplementations refl;
11189 + com::sun::star::uno::Sequence< ::rtl::OUString > tablesRowNames;
11190 + com::sun::star::uno::Sequence< ::rtl::OUString > columnRowNames;
11191 + com::sun::star::uno::Sequence< ::rtl::OUString > primaryKeyNames;
11192 + com::sun::star::uno::Sequence< ::rtl::OUString > tablePrivilegesNames;
11193 + com::sun::star::uno::Sequence< ::rtl::OUString > schemaNames;
11194 + com::sun::star::uno::Sequence< ::rtl::OUString > tableTypeNames;
11195 + com::sun::star::uno::Sequence< ::rtl::OUString > typeinfoColumnNames;
11196 + com::sun::star::uno::Sequence< ::rtl::OUString > indexinfoColumnNames;
11197 + com::sun::star::uno::Sequence< ::rtl::OUString > importedKeysColumnNames;
11198 + com::sun::star::uno::Sequence< ::rtl::OUString > resultSetArrayColumnNames;
11199 + com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > tableTypeData;
11201 + ColumnMetaDataVector typeInfoMetaData;
11202 + BaseTypeMap baseTypeMap;
11205 + Statics( const Statics & );
11206 + Statics & operator = ( const Statics & );
11209 +Statics & getStatics();
11213 --- /dev/null 2008-11-25 09:24:02.506388553 +0100
11214 +++ connectivity/source/drivers/postgresql/pq_tools.cxx 2008-07-07 23:43:17.000000000 +0200
11216 +#include <rtl/strbuf.hxx>
11217 +#include <rtl/ustrbuf.hxx>
11219 +#include <com/sun/star/beans/XPropertySet.hpp>
11220 +#include <com/sun/star/lang/XComponent.hpp>
11222 +#include <com/sun/star/sdbc/XRow.hpp>
11223 +#include <com/sun/star/sdbc/XParameters.hpp>
11224 +#include <com/sun/star/sdbc/DataType.hpp>
11225 +#include <com/sun/star/sdbc/KeyRule.hpp>
11226 +#include <com/sun/star/sdbcx/KeyType.hpp>
11227 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
11229 +#include "pq_xcontainer.hxx"
11230 +#include "pq_tools.hxx"
11231 +#include "pq_statics.hxx"
11233 +#include <libpq-fe.h>
11235 +using rtl::OUString;
11236 +using rtl::OUStringBuffer;
11238 +using com::sun::star::beans::XPropertySet;
11240 +using com::sun::star::lang::XComponent;
11242 +using com::sun::star::sdbc::SQLException;
11243 +using com::sun::star::sdbc::XStatement;
11244 +using com::sun::star::sdbc::XConnection;
11245 +using com::sun::star::sdbc::XPreparedStatement;
11246 +using com::sun::star::sdbc::XParameters;
11247 +using com::sun::star::sdbc::XResultSet;
11248 +using com::sun::star::sdbc::XRow;
11250 +using com::sun::star::sdbcx::XColumnsSupplier;
11252 +using com::sun::star::uno::UNO_QUERY;
11253 +using com::sun::star::uno::Reference;
11254 +using com::sun::star::uno::Sequence;
11255 +using com::sun::star::uno::XInterface;
11256 +using com::sun::star::uno::Any;
11257 +using com::sun::star::uno::makeAny;
11259 +using com::sun::star::container::XEnumeration;
11260 +using com::sun::star::container::XEnumerationAccess;
11262 +namespace pq_sdbc_driver
11264 +#define ASCII_STR(x) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
11266 +rtl::OUString date2String( const com::sun::star::util::Date & x )
11269 + sprintf( buffer, "%d-%02d-%02d", x.Year, x.Month, x.Day );
11270 + return OUString::createFromAscii( buffer );
11273 +com::sun::star::util::Date string2Date( const rtl::OUString &date )
11275 + // Format: Year-Month-Day
11276 + com::sun::star::util::Date ret;
11278 + ret.Year = (sal_Int32) rtl_ustr_toInt32( date.pData->buffer, 10 );
11280 + int index = date.indexOf( '-' );
11283 + ret.Month = (sal_Int32)rtl_ustr_toInt32( &(date.pData->buffer[ index+1]), 10 );
11284 + int start = index;
11285 + index = date.indexOf( '-', start+1 );
11288 + ret.Day = (sal_Int32)rtl_ustr_toInt32( &date.pData->buffer[index+1], 10 );
11294 +rtl::OUString time2String( const com::sun::star::util::Time & x )
11297 + sprintf( buffer, "%02d:%02d:%02d.%02d", x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
11298 + return OUString::createFromAscii( buffer );
11303 +com::sun::star::util::Time string2Time( const rtl::OUString & time )
11305 + com::sun::star::util::Time ret;
11307 + sal_Unicode temp[4];
11309 + temp[0] = time[0];
11310 + temp[1] = time[1];
11312 + ret.Hours = (sal_Int32)rtl_ustr_toInt32( temp , 10 );
11314 + temp[0] = time[3];
11315 + temp[1] = time[4];
11316 + ret.Minutes = (sal_Int32)rtl_ustr_toInt32( temp , 10 );
11318 + temp[0] = time[6];
11319 + temp[1] = time[7];
11320 + ret.Seconds = (sal_Int32)rtl_ustr_toInt32( temp , 10 );
11322 + if( time.getLength() >9 )
11324 + ret.HundredthSeconds = (sal_Int32)rtl_ustr_toInt32( &time[9] , 10 );
11332 +rtl::OUString dateTime2String( const com::sun::star::util::DateTime & x )
11334 + char buffer[128];
11335 + sprintf( buffer, "%d-%02d-%02d %02d:%02d:%02d.%02d",
11336 + x.Year, x.Month, x.Day,
11337 + x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
11338 + return OUString::createFromAscii( buffer );
11342 +com::sun::star::util::DateTime string2DateTime( const rtl::OUString & dateTime )
11344 + int space = dateTime.indexOf( ' ' );
11345 + com::sun::star::util::DateTime ret;
11349 + com::sun::star::util::Date date ( string2Date( OUString( dateTime.getStr(), space ) ) );
11350 + com::sun::star::util::Time time( string2Time( OUString( dateTime.getStr() + space +1 ) ) );
11351 + ret.Day = date.Day;
11352 + ret.Month = date.Month;
11353 + ret.Year = date.Year;
11355 + ret.Hours = time.Hours;
11356 + ret.Minutes = time.Minutes;
11357 + ret.Seconds = time.Seconds;
11358 + ret.HundredthSeconds = time.HundredthSeconds;
11363 +rtl::OUString concatQualified( const rtl::OUString & a, const rtl::OUString &b)
11365 + rtl::OUStringBuffer buf( a.getLength() + 2 + b.getLength() );
11367 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "." ) );
11369 + return buf.makeStringAndClear();
11372 +void bufferEscapeConstant( rtl::OUStringBuffer & buf, const rtl::OUString & value, sal_Int32 encoding )
11374 + rtl::OString y = rtl::OUStringToOString( value, encoding );
11375 + rtl::OStringBuffer strbuf( y.getLength() * 2 + 2 );
11376 + int len = PQescapeString( ((char*)strbuf.getStr()), y.getStr() , y.getLength() );
11377 + strbuf.setLength( len );
11378 + buf.append( rtl::OStringToOUString( strbuf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) );
11381 +void bufferQuoteConstant( rtl::OUStringBuffer & buf, const rtl::OUString & value, sal_Int32 encoding )
11383 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " '" ) );
11384 + bufferEscapeConstant( buf, value, encoding );
11385 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "' " ) );
11388 +void bufferQuoteQualifiedIdentifier(
11389 + rtl::OUStringBuffer & buf, const rtl::OUString &schema, const rtl::OUString &name)
11391 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" \"" ) );
11392 + buf.append(schema);
11393 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\".\"" ) );
11394 + buf.append( name );
11395 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\" " ) );
11398 +void bufferQuoteQualifiedIdentifier(
11399 + rtl::OUStringBuffer & buf,
11400 + const rtl::OUString &schema,
11401 + const rtl::OUString &name,
11402 + const rtl::OUString &col)
11404 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" \"" ) );
11405 + buf.append(schema);
11406 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\".\"" ) );
11407 + buf.append( name );
11408 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\".\"" ) );
11409 + buf.append( col );
11410 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\" " ) );
11414 +void bufferQuoteIdentifier( rtl::OUStringBuffer & buf, const rtl::OUString &toQuote )
11416 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " \"") );
11417 + buf.append( toQuote );
11418 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\" " ) );
11423 +rtl::OUString extractStringProperty(
11424 + const Reference< XPropertySet > & descriptor, const rtl::OUString &name )
11426 + rtl::OUString value;
11427 + descriptor->getPropertyValue( name ) >>= value;
11431 +sal_Bool extractBoolProperty(
11432 + const Reference< XPropertySet > & descriptor, const rtl::OUString &name )
11434 + sal_Bool value = sal_False;
11435 + descriptor->getPropertyValue( name ) >>= value;
11439 +sal_Int32 extractIntProperty(
11440 + const Reference< XPropertySet > & descriptor, const rtl::OUString &name )
11442 + sal_Int32 ret = 0;
11443 + descriptor->getPropertyValue( name ) >>= ret;
11447 +void disposeObject( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r )
11449 + Reference< XComponent > comp( r, UNO_QUERY );
11454 +void disposeNoThrow( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r )
11458 + disposeObject( r );
11460 + catch( SQLException & e )
11467 +void rollbackNoThrow( const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & r )
11471 + Reference< XStatement > stmt = r->createStatement();
11472 + stmt->executeUpdate( getStatics().ROLLBACK );
11475 + catch( SQLException & )
11481 +Reference< XConnection > extractConnectionFromStatement( const Reference< XInterface > & stmt )
11483 + Reference< XConnection > ret;
11485 + Reference< com::sun::star::sdbc::XStatement > owner( stmt, UNO_QUERY );
11487 + ret = owner->getConnection();
11490 + Reference< com::sun::star::sdbc::XPreparedStatement > myowner( stmt, UNO_QUERY );
11491 + if( myowner.is() )
11492 + ret = myowner->getConnection();
11494 + throw SQLException(
11495 + ASCII_STR( "PQSDBC: Couldn't retrieve connection from statement" ),
11496 + Reference< XInterface > () , rtl::OUString(), 0 , com::sun::star::uno::Any() );
11503 +DisposeGuard::DisposeGuard( const Reference< XInterface > & r )
11507 +DisposeGuard::~DisposeGuard()
11509 + disposeNoThrow( d );
11512 +TransactionGuard::TransactionGuard( const Reference< XStatement > &stmt )
11513 + : m_stmt( stmt ),
11514 + m_commited( sal_False )
11516 + m_stmt->executeUpdate( getStatics().BEGIN );
11519 +void TransactionGuard::commit()
11521 + m_stmt->executeUpdate( getStatics().COMMIT );
11522 + m_commited = sal_True;
11525 +void TransactionGuard::executeUpdate( const rtl::OUString & sql )
11527 + m_stmt->executeUpdate( sql );
11530 +TransactionGuard::~TransactionGuard()
11534 + if( ! m_commited )
11535 + m_stmt->executeUpdate( getStatics().ROLLBACK );
11537 + catch( com::sun::star::uno::Exception & e )
11539 + // ignore, we are within a dtor
11542 + disposeNoThrow( m_stmt );
11546 +bool isWhitespace( sal_Unicode c )
11548 + return ' ' == c || 9 == c || 10 == c || 13 == c;
11551 +::rtl::OUString extractTableFromInsert( const rtl::OUString & sql )
11553 + rtl::OUString ret;
11555 + for( ; i < sql.getLength() && isWhitespace(sql[i]) ; i++ );
11557 + if( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
11558 + &sql[i], sql.getLength() - i, "insert" , 6 ) )
11561 + for( ; i < sql.getLength() && isWhitespace(sql[i]) ; i++ );
11562 + if( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
11563 + &sql[i], sql.getLength() - i, "into" , 4 ) )
11566 + for( ; i < sql.getLength() && isWhitespace(sql[i]) ; i++ );
11568 + bool quote = (sql[i] == '"');
11569 + for( i++ ; i < sql.getLength() ; i ++ )
11571 + if( quote && sql[i] == '"' )
11573 + for( i++ ; i < sql.getLength() && isWhitespace(sql[i]) ; i++ );
11574 + if( '.' == sql[i] )
11576 + for( i++ ; i < sql.getLength() && isWhitespace(sql[i]) ; i++ );
11577 + if( '"' == sql[i] )
11579 + // the second part of the table name does not use quotes
11586 + // end quoted name, ok
11592 + if( isWhitespace( sql[i] ) )
11594 + // found the end of an unquoted name
11599 + ret = rtl::OUString( &sql[start], i - start ).trim();
11600 +// printf( "pq_statement: parsed table name %s from insert\n" ,
11601 +// OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US).getStr() );
11608 +static bool isOperator( char c )
11638 +void splitSQL( const rtl::OString & sql, OStringVector &vec )
11640 + int length = sql.getLength();
11643 + bool singleQuote = false;
11644 + bool doubleQuote = false;
11646 + for( ; i < length ; i ++ )
11649 + if( doubleQuote )
11653 + vec.push_back( rtl::OString( &sql[start], i-start+1 ) );
11655 + doubleQuote = false;
11658 + else if( singleQuote )
11660 + if( '\'' == c && '\'' == sql[i+1] )
11662 + // two subsequent single quotes within a quoted string
11663 + // mean a single quote within the string
11666 + else if( '\'' == c )
11668 + vec.push_back( rtl::OString( &sql[start], i - start +1 ) );
11669 + start = i + 1; // leave single quotes !
11670 + singleQuote = false;
11677 + vec.push_back( rtl::OString( &sql[start], i - start ) );
11678 + doubleQuote = true;
11681 + else if( '\'' == c )
11683 + vec.push_back( rtl::OString( &sql[start], i - start ) );
11684 + singleQuote = true;
11690 + vec.push_back( rtl::OString( &sql[start] , i - start ) );
11692 +// for( i = 0 ; i < vec.size() ; i ++ )
11693 +// printf( "%s!" , vec[i].getStr() );
11694 +// printf( "\n" );
11698 +void tokenizeSQL( const rtl::OString & sql, OStringVector &vec )
11700 + int length = sql.getLength();
11703 + bool singleQuote = false;
11704 + bool doubleQuote = false;
11706 + for( ; i < length ; i ++ )
11709 + if( doubleQuote )
11713 + vec.push_back( rtl::OString( &sql[start], i-start ) );
11715 + doubleQuote = false;
11718 + else if( singleQuote )
11722 + vec.push_back( rtl::OString( &sql[start], i - start +1 ) );
11723 + start = i + 1; // leave single quotes !
11724 + singleQuote = false;
11731 + doubleQuote = true;
11732 + start = i +1; // skip double quotes !
11734 + else if( '\'' == c )
11736 + singleQuote = true;
11737 + start = i; // leave single quotes
11739 + else if( isWhitespace( c ) )
11742 + start ++; // skip additional whitespace
11745 + vec.push_back( rtl::OString( &sql[start], i - start ) );
11749 + else if( ',' == c || isOperator( c ) || '(' == c || ')' == c )
11752 + vec.push_back( rtl::OString( &sql[start], i - start ) );
11753 + vec.push_back( rtl::OString( &sql[i], 1 ) );
11756 + else if( '.' == c )
11758 + if( ( i > start && sql[start] >= '0' && sql[start] <= '9' ) ||
11759 + ( i == start && i > 1 && isWhitespace( sql[i-1] ) ) )
11761 + // ignore, is a literal
11766 + vec.push_back( rtl::OString( &sql[start], i - start ) );
11767 + vec.push_back( rtl::OString( RTL_CONSTASCII_STRINGPARAM( "." ) ) );
11774 + vec.push_back( rtl::OString( &sql[start] , i - start ) );
11776 +// for( i = 0 ; i < vec.size() ; i ++ )
11777 +// printf( "%s!" , vec[i].getStr() );
11778 +// printf( "\n" );
11782 +void splitConcatenatedIdentifier( const rtl::OUString & source, rtl::OUString *first, rtl::OUString *second)
11784 + OStringVector vec;
11785 + tokenizeSQL( rtl::OUStringToOString( source, RTL_TEXTENCODING_UTF8 ), vec );
11786 + if( vec.size() == 3 )
11788 + *first = rtl::OStringToOUString( vec[0] , RTL_TEXTENCODING_UTF8 );
11789 + *second = rtl::OStringToOUString( vec[2], RTL_TEXTENCODING_UTF8 );
11793 +typedef std::vector< sal_Int32 , Allocator< sal_Int32 > > IntVector;
11796 +rtl::OUString array2String( const com::sun::star::uno::Sequence< Any > &seq )
11798 + OUStringBuffer buf(128);
11799 + int len = seq.getLength();
11800 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "{" ) );
11801 + for( int i = 0 ; i < len ; i ++ )
11803 + OUString element;
11804 + seq[i] >>= element;
11807 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(",") );
11808 + int strLength = element.getLength();
11809 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\"") );
11810 + for( int j = 0 ; j < strLength ; j ++ )
11812 + sal_Unicode c = element[j];
11813 + if( c == '\\' || c == '"' || c == '{' || c == '}' )
11815 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\\" ) );
11819 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\"" ) );
11821 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "}" ) );
11822 + return buf.makeStringAndClear();
11828 + com::sun::star::uno::Any,
11829 + Allocator< com::sun::star::uno::Any >
11832 +com::sun::star::uno::Sequence< Any > parseArray( const rtl::OUString & str ) throw( SQLException )
11834 + com::sun::star::uno::Sequence< Any > ret;
11836 + int len = str.getLength();
11837 + bool doubleQuote = false;
11838 + int brackets = 0;
11841 + OUStringBuffer current;
11842 + AnyVector elements;
11843 + bool doubleQuotedValue = false;
11846 + sal_Unicode c = str[i];
11847 + sal_Unicode cnext = str[i+1];
11848 + if( doubleQuote )
11853 + current.append( cnext );
11855 + else if( '"' == c )
11857 + doubleQuote = false;
11858 + doubleQuotedValue = true; // signal, that there was an empty element
11862 + current.append( c );
11865 + else if ( '{' == c )
11869 + else if( '}' == c )
11872 + if( brackets < 0 )
11875 + OUStringBuffer buf;
11876 + buf.appendAscii( "error during array parsing, didn't expect a } at position " );
11877 + buf.append( (sal_Int32) i );
11878 + buf.appendAscii( " ('" );
11879 + buf.append( str );
11880 + buf.appendAscii( "')" );
11881 + throw SQLException(
11882 + buf.makeStringAndClear(),
11883 + Reference< XInterface > (), rtl::OUString(), 1, Any() );
11885 + if( brackets == 0 )
11887 + if( current.getLength() > 0 || doubleQuotedValue )
11888 + elements.push_back( makeAny( current.makeStringAndClear() ) );
11892 + current.append( c );
11895 + else if( '"' == c )
11897 +// if( current.getLength() != 0 )
11899 +// OUStringBuffer buf;
11900 +// buf.appendAscii( "error during array parsing, didn't expect a \" at position " );
11901 +// buf.append( i );
11902 +// buf.append( " ('" );
11903 +// buf.append( str );
11904 +// buf.append( "')" );
11905 +// throw SDBCException(
11906 +// buf.makeStringAndClear(),
11907 +// Reference< XInterface > (), 1, Any() );
11911 + doubleQuote = true;
11914 + else if( ',' == c && brackets == 1)
11916 + doubleQuotedValue = false;
11917 + elements.push_back( makeAny( current.makeStringAndClear() ) );
11919 + else if( isWhitespace( c ) )
11921 + // ignore whitespace without quotes
11925 + current.append( c );
11929 + ret = Sequence< Any > ( &elements[0] , elements.size() );
11933 +com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const ::rtl::OUString & str )
11935 + sal_Int32 start = 0;
11937 +// printf( ">%s<\n" , OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
11938 + for( sal_Int32 i = str.indexOf( ' ' ) ; i != -1 ; i = str.indexOf( ' ', start) )
11940 + vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str.pData->buffer[start], 10 ) );
11941 +// printf( "found %d\n" , rtl_ustr_toInt32( &str.pData->buffer[start], 10 ));
11944 + vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str.pData->buffer[start], 10 ) );
11945 +// printf( "found %d\n" , rtl_ustr_toInt32( &str.pData->buffer[start], 10 ));
11946 + return Sequence< sal_Int32 > ( &vec[0], vec.size() );
11949 +void fillAttnum2attnameMap(
11950 + Int2StringMap &map,
11951 + const Reference< com::sun::star::sdbc::XConnection > &conn,
11952 + const rtl::OUString &schema,
11953 + const rtl::OUString &table )
11955 + Reference< XPreparedStatement > prep = conn->prepareStatement(
11956 + ASCII_STR( "SELECT attname,attnum "
11957 + "FROM pg_attribute "
11958 + "INNER JOIN pg_class ON attrelid = pg_class.oid "
11959 + "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
11960 + "WHERE relname=? AND nspname=?" ) );
11962 + Reference< XParameters > paras( prep, UNO_QUERY );
11963 + paras->setString( 1 , table );
11964 + paras->setString( 2 , schema );
11965 + Reference< XResultSet > rs = prep->executeQuery();
11967 + Reference< XRow > xRow( rs , UNO_QUERY );
11968 + while( rs->next() )
11970 + map[ xRow->getInt(2) ] = xRow->getString(1);
11974 +::rtl::OString extractSingleTableFromSelect( const OStringVector &vec )
11976 + rtl::OString ret;
11979 + if( 0 == rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
11980 + vec[0].pData->buffer, vec[0].pData->length, "select" , 6 , 6 ) )
11982 + for( token = 1; token < vec.size() ; token ++ )
11984 + if( 0 == rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
11985 + vec[token].getStr(), vec[token].getLength(), "from" , 4 , 4 ) )
11993 + if( token < vec.size() && 0 == rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
11994 + vec[token].pData->buffer, vec[token].pData->length, "only " , 4 , 4 ) )
11999 + if( token < vec.size() && rtl_str_compare_WithLength(
12000 + vec[token].getStr(), vec[token].getLength(),
12001 + RTL_CONSTASCII_STRINGPARAM("(") ) )
12003 + // it is a table or a function name
12004 + rtl::OStringBuffer buf(128);
12005 + if( '"' == vec[token][0] )
12006 + buf.append( &(vec[token][1]) , vec[token].getLength() -2 );
12008 + buf.append( vec[token] );
12011 + if( token < vec.size() )
12013 + if( rtl_str_compare_WithLength(
12014 + vec[token].getStr(), vec[token].getLength(),
12015 + RTL_CONSTASCII_STRINGPARAM( "." ) ) == 0 )
12017 + buf.append( vec[token] );
12019 + if( token < vec.size() )
12021 + if( '"' == vec[token][0] )
12022 + buf.append( &(vec[token][1]) , vec[token].getLength() -2 );
12024 + buf.append( vec[token] );
12030 + ret = buf.makeStringAndClear();
12031 + // now got my table candidate
12033 + if( token < vec.size() && rtl_str_compare_WithLength(
12034 + vec[token].getStr(), vec[token].getLength(),
12035 + RTL_CONSTASCII_STRINGPARAM( "(" ) ) == 0 )
12037 + // whoops, it is a function
12038 + ret = rtl::OString();
12042 + if( token < vec.size() )
12044 + if( 0 == rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
12045 + vec[token].pData->buffer, vec[token].pData->length, "as" , 2, 2 ) )
12047 + token += 2; // skip alias
12051 + if( token < vec.size() )
12053 + if( rtl_str_compare_WithLength(
12054 + vec[token].getStr(), vec[token].getLength(),
12055 + RTL_CONSTASCII_STRINGPARAM( "," ) ) == 0 )
12057 + // whoops, multiple tables are used
12058 + ret = rtl::OString();
12062 + static const char * forbiddenKeywords[] =
12063 + { "join", "natural", "outer", "inner", "left", "right", "full" , 0 };
12064 + for( int i = 0 ; forbiddenKeywords[i] ; i ++ )
12066 + if( 0 == rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
12067 + vec[token].pData->buffer, vec[token].pData->length,
12068 + forbiddenKeywords[i], strlen(forbiddenKeywords[i]),
12069 + strlen(forbiddenKeywords[i]) ) )
12071 + // whoops, it is a join
12072 + ret = rtl::OString();
12084 +com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const ::rtl::OUString & str )
12086 + com::sun::star::uno::Sequence< sal_Int32 > ret;
12087 + if( str.getLength() > 1 && '{' == str[0] )
12089 + std::vector< sal_Int32, Allocator< sal_Int32 > > vec;
12090 + sal_Int32 start = 0;
12094 + vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str[start], 10 ) );
12095 + start = str.indexOf( ',' , start );
12096 + } while( start != -1 );
12097 + ret = com::sun::star::uno::Sequence< sal_Int32 > ( &vec[0] , vec.size() );
12103 +Sequence< rtl::OUString > convertMappedIntArray2StringArray(
12104 + const Int2StringMap &map, const Sequence< sal_Int32 > &intArray )
12106 + Sequence< ::rtl::OUString > ret( intArray.getLength() );
12107 + for( int i = 0; i < intArray.getLength() ; i ++ )
12109 + Int2StringMap::const_iterator ii = map.find( intArray[i] );
12110 + if( ii != map.end() )
12111 + ret[i] = ii->second;
12117 +::rtl::OUString sqltype2string( const Reference< XPropertySet > & desc )
12119 + OUStringBuffer typeName;
12120 + typeName.append( extractStringProperty( desc, getStatics().TYPE_NAME ) );
12121 + sal_Int32 precision = extractIntProperty( desc, getStatics().PRECISION );
12125 + switch( extractIntProperty( desc, getStatics().TYPE ) )
12127 + case com::sun::star::sdbc::DataType::VARBINARY:
12128 + case com::sun::star::sdbc::DataType::VARCHAR:
12129 + case com::sun::star::sdbc::DataType::CHAR:
12131 + typeName.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(" ) );
12132 + typeName.append( precision );
12133 + typeName.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
12136 + case com::sun::star::sdbc::DataType::DECIMAL:
12137 + case com::sun::star::sdbc::DataType::NUMERIC:
12139 + typeName.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(" ) );
12140 + typeName.append( precision );
12141 + typeName.appendAscii( RTL_CONSTASCII_STRINGPARAM( "," ) );
12142 + typeName.append( extractIntProperty( desc, getStatics().SCALE ) );
12143 + typeName.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
12150 + return typeName.makeStringAndClear();
12156 +static void keyType2String( OUStringBuffer & buf, sal_Int32 keyType )
12158 + if( com::sun::star::sdbc::KeyRule::CASCADE == keyType )
12160 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CASCADE " ) );
12162 + else if( com::sun::star::sdbc::KeyRule::RESTRICT == keyType )
12164 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "RESTRICT " ) );
12166 + else if( com::sun::star::sdbc::KeyRule::SET_DEFAULT == keyType )
12168 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET DEFAULT " ) );
12170 + else if( com::sun::star::sdbc::KeyRule::SET_NULL == keyType )
12172 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET NULL " ) );
12174 + else //if( com::sun::star::sdbc::KeyRule::NO_ACTION == keyType )
12176 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "NO ACTION " ) );
12180 +void bufferKey2TableConstraint(
12181 + OUStringBuffer &buf, const Reference< XPropertySet > &key )
12183 + Statics &st = getStatics();
12184 + sal_Int32 type = extractIntProperty( key, st.TYPE );
12185 + OUString referencedTable = extractStringProperty( key, st.REFERENCED_TABLE );
12186 + sal_Int32 updateRule = extractIntProperty( key, st.UPDATE_RULE );
12187 + sal_Int32 deleteRule = extractIntProperty( key, st.DELETE_RULE );
12188 + bool foreign = false;
12189 + if( type == com::sun::star::sdbcx::KeyType::UNIQUE )
12191 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "UNIQUE( " ) );
12193 + else if( type == com::sun::star::sdbcx::KeyType::PRIMARY )
12195 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "PRIMARY KEY( " ) );
12197 + else if( type == com::sun::star::sdbcx::KeyType::FOREIGN )
12200 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "FOREIGN KEY( " ) );
12203 + Reference< XColumnsSupplier > columns( key, UNO_QUERY );
12204 + if( columns.is() )
12206 + Reference< XEnumerationAccess > colEnumAccess( columns->getColumns(), UNO_QUERY );
12207 + if( colEnumAccess.is() )
12209 + Reference< XEnumeration > colEnum = colEnumAccess->createEnumeration();
12210 + bool first = true;
12211 + while(colEnum.is() && colEnum->hasMoreElements() )
12219 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
12221 + Reference< XPropertySet > keyColumn( colEnum->nextElement(), UNO_QUERY );
12222 + bufferQuoteIdentifier(buf, extractStringProperty( keyColumn, st.NAME ) );
12226 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ") " ));
12230 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "REFERENCES " ) );
12232 + OUString tableName;
12233 + splitConcatenatedIdentifier( referencedTable, &schema, &tableName );
12234 + bufferQuoteQualifiedIdentifier(buf , schema, tableName);
12235 + if(columns.is() )
12237 + Reference< XEnumerationAccess > colEnumAccess( columns->getColumns(), UNO_QUERY);
12238 + if( colEnumAccess.is() )
12240 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
12241 + Reference< XEnumeration > colEnum(colEnumAccess->createEnumeration());
12242 + bool first = true;
12243 + while(colEnum.is() && colEnum->hasMoreElements() )
12251 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
12253 + Reference< XPropertySet > keyColumn( colEnum->nextElement(), UNO_QUERY );
12254 + bufferQuoteIdentifier(
12255 + buf, extractStringProperty( keyColumn, st.RELATED_COLUMN ) );
12257 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ") " ) );
12261 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ON DELETE " ) );
12262 + keyType2String( buf, deleteRule );
12263 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ON UPDATE " ) );
12264 + keyType2String( buf, updateRule );
12269 +static bool equalsIgnoreCase( const rtl::OString & str, const char *str2, int length2 )
12271 + return 0 == rtl_str_compareIgnoreAsciiCase_WithLength(
12272 + str.pData->buffer, str.pData->length, str2, length2 );
12275 +void extractNameValuePairsFromInsert( String2StringMap & map, const rtl::OString & lastQuery )
12277 + OStringVector vec;
12278 + tokenizeSQL( lastQuery, vec );
12280 + int nSize = vec.size();
12281 +// printf( "1 %d\n", nSize );
12283 + equalsIgnoreCase( vec[0] , RTL_CONSTASCII_STRINGPARAM( "insert" ) ) &&
12284 + equalsIgnoreCase( vec[1] , RTL_CONSTASCII_STRINGPARAM( "into" ) ) )
12288 +// printf( "1a\n" );
12289 + // extract table name
12290 + rtl::OString tableName;
12291 + if( equalsIgnoreCase( vec[n+1], RTL_CONSTASCII_STRINGPARAM( "." ) ) )
12293 + tableName = vec[n];
12294 + tableName += vec[n+1];
12295 + tableName += vec[n+2];
12300 + tableName = vec[n];
12303 + OStringVector names;
12305 + if( equalsIgnoreCase( vec[n], RTL_CONSTASCII_STRINGPARAM( "(" ) ) )
12307 +// printf( "2\n" );
12310 + while( nSize > n && ! equalsIgnoreCase(vec[n] , RTL_CONSTASCII_STRINGPARAM( ")" ) ) )
12312 + names.push_back( vec[n] );
12313 + if( nSize > n+1 && equalsIgnoreCase( vec[n+1] , RTL_CONSTASCII_STRINGPARAM( "," ) ) )
12321 + // now read the values
12322 + if( nSize > n +1 && equalsIgnoreCase( vec[n], RTL_CONSTASCII_STRINGPARAM("VALUES") ) &&
12323 + equalsIgnoreCase(vec[n+1], RTL_CONSTASCII_STRINGPARAM( "(" ) ) )
12326 +// printf( "3\n" );
12327 + for ( int i = 0 ; i < names.size() && nSize > n ; i ++ )
12329 + map[names[i]] = vec[n];
12330 + if( nSize > n+1 && equalsIgnoreCase( vec[n+1] , RTL_CONSTASCII_STRINGPARAM(",") ) )
12341 +rtl::OUString querySingleValue(
12342 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
12343 + const rtl::OUString &query )
12346 + Reference< XStatement > stmt = connection->createStatement();
12347 + DisposeGuard guard( stmt );
12348 + Reference< XResultSet > rs = stmt->executeQuery( query );
12349 + Reference< XRow > xRow( rs, UNO_QUERY );
12351 + ret = xRow->getString( 1 );
12356 +// copied from connectivity/source/dbtools, can't use the function directly
12357 +bool implSetObject( const Reference< XParameters >& _rxParameters,
12358 + const sal_Int32 _nColumnIndex, const Any& _rValue)
12360 + sal_Bool bSuccessfullyReRouted = sal_True;
12361 + switch (_rValue.getValueTypeClass())
12363 + case typelib_TypeClass_HYPER:
12365 + sal_Int64 nValue = 0;
12366 + _rxParameters->setLong( _nColumnIndex, nValue );
12370 + case typelib_TypeClass_VOID:
12371 + _rxParameters->setNull(_nColumnIndex,com::sun::star::sdbc::DataType::VARCHAR);
12374 + case typelib_TypeClass_STRING:
12375 + _rxParameters->setString(_nColumnIndex, *(rtl::OUString*)_rValue.getValue());
12378 + case typelib_TypeClass_BOOLEAN:
12379 + _rxParameters->setBoolean(_nColumnIndex, *(sal_Bool *)_rValue.getValue());
12382 + case typelib_TypeClass_BYTE:
12383 + _rxParameters->setByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
12386 + case typelib_TypeClass_UNSIGNED_SHORT:
12387 + case typelib_TypeClass_SHORT:
12388 + _rxParameters->setShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
12391 + case typelib_TypeClass_CHAR:
12392 + _rxParameters->setString(_nColumnIndex, ::rtl::OUString((sal_Unicode *)_rValue.getValue(),1));
12395 + case typelib_TypeClass_UNSIGNED_LONG:
12396 + case typelib_TypeClass_LONG:
12397 + _rxParameters->setInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
12400 + case typelib_TypeClass_FLOAT:
12401 + _rxParameters->setFloat(_nColumnIndex, *(float*)_rValue.getValue());
12404 + case typelib_TypeClass_DOUBLE:
12405 + _rxParameters->setDouble(_nColumnIndex, *(double*)_rValue.getValue());
12408 + case typelib_TypeClass_SEQUENCE:
12409 + if (_rValue.getValueType() == ::getCppuType((const Sequence< sal_Int8 > *)0))
12411 + _rxParameters->setBytes(_nColumnIndex, *(Sequence<sal_Int8>*)_rValue.getValue());
12414 + bSuccessfullyReRouted = sal_False;
12416 + case typelib_TypeClass_STRUCT:
12417 + if (_rValue.getValueType() == ::getCppuType((const com::sun::star::util::DateTime*)0))
12418 + _rxParameters->setTimestamp(_nColumnIndex, *(com::sun::star::util::DateTime*)_rValue.getValue());
12419 + else if (_rValue.getValueType() == ::getCppuType((const com::sun::star::util::Date*)0))
12420 + _rxParameters->setDate(_nColumnIndex, *(com::sun::star::util::Date*)_rValue.getValue());
12421 + else if (_rValue.getValueType() == ::getCppuType((const com::sun::star::util::Time*)0))
12422 + _rxParameters->setTime(_nColumnIndex, *(com::sun::star::util::Time*)_rValue.getValue());
12424 + bSuccessfullyReRouted = sal_False;
12427 + case typelib_TypeClass_INTERFACE:
12429 + Reference< com::sun::star::io::XInputStream > xStream;
12430 + if (_rValue >>= xStream)
12432 + _rValue >>= xStream;
12433 + _rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
12439 + bSuccessfullyReRouted = sal_False;
12443 + return bSuccessfullyReRouted;
12448 --- /dev/null 2008-11-25 09:24:02.506388553 +0100
12449 +++ connectivity/source/drivers/postgresql/pq_tools.hxx 2008-07-07 23:37:11.000000000 +0200
12451 +/*************************************************************************
12453 + * $RCSfile: pq_tools.hxx,v $
12455 + * $Revision: 1.1.2.7 $
12457 + * last change: $Author: jbu $ $Date: 2008/07/07 21:37:11 $
12459 + * The Contents of this file are made available subject to the terms of
12460 + * either of the following licenses
12462 + * - GNU Lesser General Public License Version 2.1
12463 + * - Sun Industry Standards Source License Version 1.1
12465 + * Sun Microsystems Inc., October, 2000
12467 + * GNU Lesser General Public License Version 2.1
12468 + * =============================================
12469 + * Copyright 2000 by Sun Microsystems, Inc.
12470 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
12472 + * This library is free software; you can redistribute it and/or
12473 + * modify it under the terms of the GNU Lesser General Public
12474 + * License version 2.1, as published by the Free Software Foundation.
12476 + * This library is distributed in the hope that it will be useful,
12477 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12478 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12479 + * Lesser General Public License for more details.
12481 + * You should have received a copy of the GNU Lesser General Public
12482 + * License along with this library; if not, write to the Free Software
12483 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
12484 + * MA 02111-1307 USA
12487 + * Sun Industry Standards Source License Version 1.1
12488 + * =================================================
12489 + * The contents of this file are subject to the Sun Industry Standards
12490 + * Source License Version 1.1 (the "License"); You may not use this file
12491 + * except in compliance with the License. You may obtain a copy of the
12492 + * License at http://www.openoffice.org/license.html.
12494 + * Software provided under this License is provided on an "AS IS" basis,
12495 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
12496 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
12497 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
12498 + * See the License for the specific provisions governing your rights and
12499 + * obligations concerning the Software.
12501 + * The Initial Developer of the Original Code is: Joerg Budischewski
12503 + * Copyright: 2000 by Sun Microsystems, Inc.
12505 + * All Rights Reserved.
12507 + * Contributor(s): Joerg Budischewski
12510 + ************************************************************************/
12512 +#ifndef _PQ_TOOLS_
12513 +#define _PQ_TOOLS_
12515 +#include <com/sun/star/beans/XPropertySet.hpp>
12516 +#include <com/sun/star/sdbc/XParameters.hpp>
12517 +#include <com/sun/star/util/Date.hpp>
12518 +#include <com/sun/star/util/Time.hpp>
12519 +#include <com/sun/star/util/DateTime.hpp>
12521 +#include <rtl/ustrbuf.hxx>
12522 +#include <rtl/string.hxx>
12524 +#include <pq_connection.hxx>
12525 +namespace pq_sdbc_driver
12527 +bool isWhitespace( sal_Unicode c );
12529 +rtl::OUString date2String( const com::sun::star::util::Date & date );
12530 +com::sun::star::util::Date string2Date( const rtl::OUString & str );
12532 +rtl::OUString time2String( const com::sun::star::util::Time & time );
12533 +com::sun::star::util::Time string2Time( const rtl::OUString & str );
12535 +rtl::OUString dateTime2String( const com::sun::star::util::DateTime & dateTime );
12536 +com::sun::star::util::DateTime string2DateTime( const rtl::OUString & dateTime );
12538 +rtl::OUString concatQualified( const rtl::OUString & a, const rtl::OUString &b);
12540 +void bufferQuoteConstant( rtl::OUStringBuffer & buf, const rtl::OUString & str, sal_Int32 encoding );
12542 +void bufferEscapeConstant( rtl::OUStringBuffer & buf, const rtl::OUString & str, sal_Int32 encoding );
12544 +::rtl::OUString sqltype2string(
12545 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & column );
12548 +void bufferQuoteQualifiedIdentifier(
12549 + rtl::OUStringBuffer & buf, const rtl::OUString &schema, const rtl::OUString &name);
12551 +void bufferQuoteQualifiedIdentifier(
12552 + rtl::OUStringBuffer & buf,
12553 + const rtl::OUString &schema,
12554 + const rtl::OUString &name,
12555 + const rtl::OUString &col);
12557 +void bufferQuoteIdentifier( rtl::OUStringBuffer & buf, const rtl::OUString &toQuote );
12558 +void bufferKey2TableConstraint(
12559 + rtl::OUStringBuffer &buf,
12560 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > &key );
12562 +rtl::OUString extractStringProperty(
12563 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
12564 + const rtl::OUString &name );
12566 +sal_Int32 extractIntProperty(
12567 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
12568 + const rtl::OUString &name );
12570 +sal_Bool extractBoolProperty(
12571 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & descriptor,
12572 + const rtl::OUString &name );
12574 +void disposeNoThrow( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
12575 +void disposeObject( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
12577 +void rollbackNoThrow( const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & r );
12579 +::rtl::OUString extractTableFromInsert( const rtl::OUString & sql );
12580 +::rtl::OString extractSingleTableFromSelect( const OStringVector &vec );
12582 +void tokenizeSQL( const rtl::OString & sql, OStringVector &vec );
12583 +void splitSQL( const rtl::OString & sql, OStringVector &vec );
12584 +com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const ::rtl::OUString & str );
12585 +com::sun::star::uno::Sequence< com::sun::star::uno::Any > parseArray( const ::rtl::OUString & str )
12586 + throw( com::sun::star::sdbc::SQLException );
12588 +rtl::OUString array2String( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > &seq );
12590 +com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > extractConnectionFromStatement(
12591 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & stmt );
12593 +void splitConcatenatedIdentifier( const rtl::OUString & source, rtl::OUString *first, rtl::OUString *second);
12596 +void fillAttnum2attnameMap(
12597 + Int2StringMap &map,
12598 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &conn,
12599 + const rtl::OUString &schema,
12600 + const rtl::OUString &table );
12602 +com::sun::star::uno::Sequence< sal_Int32 > string2intarray( const ::rtl::OUString & str );
12604 +com::sun::star::uno::Sequence< rtl::OUString > convertMappedIntArray2StringArray(
12605 + const Int2StringMap &map, const com::sun::star::uno::Sequence< sal_Int32> &source );
12607 +typedef std::hash_map
12611 + ::rtl::OStringHash,
12612 + ::std::equal_to< rtl::OString >,
12613 + Allocator< ::std::pair< rtl::OString, ::rtl::OString > >
12614 +> String2StringMap;
12616 +rtl::OUString querySingleValue(
12617 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
12618 + const rtl::OUString &query );
12620 +void extractNameValuePairsFromInsert( String2StringMap & map, const rtl::OString & lastQuery );
12621 +sal_Int32 typeNameToDataType( const rtl::OUString &typeName, const rtl::OUString &typtype );
12623 +// copied from connectivity/source/dbtools, can't use the function directly
12624 +bool implSetObject( const com::sun::star::uno::Reference< com::sun::star::sdbc::XParameters >& _rxParameters,
12625 + const sal_Int32 _nColumnIndex, const com::sun::star::uno::Any& _rValue);
12627 +class DisposeGuard
12629 + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > d;
12631 + DisposeGuard(const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & r );
12636 +class TransactionGuard
12638 + com::sun::star::uno::Reference< com::sun::star::sdbc::XStatement > m_stmt;
12639 + sal_Bool m_commited;
12641 + /// takes over ownership of given statemet
12642 + TransactionGuard( const com::sun::star::uno::Reference< com::sun::star::sdbc::XStatement > &stmt );
12643 + ~TransactionGuard( );
12646 + void executeUpdate( const rtl::OUString & sql );
12652 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
12653 +++ connectivity/source/drivers/postgresql/pq_updateableresultset.cxx 2006-05-01 21:19:07.000000000 +0200
12655 +#include <rtl/ustrbuf.hxx>
12656 +#include <rtl/strbuf.hxx>
12658 +#include <cppuhelper/queryinterface.hxx>
12659 +#include <cppuhelper/typeprovider.hxx>
12661 +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
12662 +// #include <com/sun/star/sdbcx/XRowLocate.hpp>
12664 +#include "pq_updateableresultset.hxx"
12665 +#include "pq_resultsetmetadata.hxx"
12666 +#include "pq_tools.hxx"
12667 +#include "pq_statics.hxx"
12669 +using osl::MutexGuard;
12671 +using rtl::OUString;
12672 +using rtl::OUStringBuffer;
12673 +using rtl::OStringBuffer;
12674 +using rtl::OString;
12676 +using com::sun::star::uno::Reference;
12677 +using com::sun::star::uno::makeAny;
12678 +using com::sun::star::uno::Sequence;
12679 +using com::sun::star::uno::UNO_QUERY;
12680 +using com::sun::star::uno::Any;
12681 +using com::sun::star::uno::Type;
12682 +using com::sun::star::uno::RuntimeException;
12684 +using com::sun::star::sdbc::XGeneratedResultSet;
12685 +using com::sun::star::sdbc::XResultSetMetaDataSupplier;
12686 +using com::sun::star::sdbc::SQLException;
12687 +using com::sun::star::sdbc::XResultSet;
12688 +using com::sun::star::sdbc::XCloseable;
12689 +using com::sun::star::sdbc::XColumnLocate;
12690 +using com::sun::star::sdbc::XResultSetUpdate;
12691 +using com::sun::star::sdbc::XRowUpdate;
12692 +using com::sun::star::sdbc::XRow;
12693 +using com::sun::star::sdbc::XStatement;
12695 +using com::sun::star::beans::XFastPropertySet;
12696 +using com::sun::star::beans::XPropertySet;
12697 +using com::sun::star::beans::XMultiPropertySet;
12699 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
12701 +namespace pq_sdbc_driver
12705 +com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > UpdateableResultSet::createFromPGResultSet(
12706 + const ::rtl::Reference< RefCountedMutex > & mutex,
12707 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
12708 + ConnectionSettings **ppSettings,
12709 + PGresult *result,
12710 + const rtl::OUString &schema,
12711 + const rtl::OUString &table,
12712 + const com::sun::star::uno::Sequence< ::rtl::OUString > &primaryKey )
12714 + ConnectionSettings *pSettings = *ppSettings;
12715 + sal_Int32 columnCount = PQnfields( result );
12716 + sal_Int32 rowCount = PQntuples( result );
12717 + Sequence< OUString > columnNames( columnCount );
12718 + for( int i = 0 ; i < columnCount ; i ++ )
12720 + char * name = PQfname( result, i );
12721 + columnNames[i] = rtl::OUString( name, strlen(name), pSettings->encoding );
12723 + Sequence< Sequence< Any > > data( rowCount );
12725 + // copy all the data into unicode strings (also binaries, as we yet
12726 + // don't know, what a binary is and what not!)
12727 + for( int row = 0 ; row < rowCount ; row ++ )
12729 + Sequence< Any > aRow( columnCount );
12730 + for( int col = 0 ; col < columnCount ; col ++ )
12732 + if( ! PQgetisnull( result, row, col ) )
12734 + char * val = PQgetvalue( result, row, col );
12736 + aRow[col] = makeAny(
12737 + rtl::OUString( val, strlen( val ) , (*ppSettings)->encoding ) );
12740 + data[row] = aRow;
12743 + UpdateableResultSet *pRS = new UpdateableResultSet(
12744 + mutex, owner, columnNames, data, ppSettings, schema, table , primaryKey );
12746 + Reference <XCloseable > ret = pRS; // give it an refcount
12748 + pRS->m_meta = new ResultSetMetaData( mutex, pRS,0, ppSettings, result, schema, table );
12750 + PQclear( result ); // we don't need it anymore
12755 +static void bufferQuoteAnyConstant( rtl::OUStringBuffer & buf, const Any &val )
12757 + if( val.hasValue() )
12761 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "'" ) );
12762 + buf.append( str );
12763 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "'" ) );
12766 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "NULL" ) );
12770 +com::sun::star::uno::Any UpdateableResultSet::queryInterface(
12771 + const com::sun::star::uno::Type & reqType )
12772 + throw (com::sun::star::uno::RuntimeException)
12774 + Any ret = SequenceResultSet::queryInterface( reqType );
12775 + if( ! ret.hasValue() )
12776 + ret = ::cppu::queryInterface(
12778 + static_cast< XResultSetUpdate * > ( this ),
12779 + static_cast< XRowUpdate * > ( this ) );
12784 +com::sun::star::uno::Sequence< com::sun::star::uno::Type > UpdateableResultSet::getTypes()
12785 + throw( com::sun::star::uno::RuntimeException )
12787 + static cppu::OTypeCollection *pCollection;
12788 + if( ! pCollection )
12790 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
12791 + if( !pCollection )
12793 + static cppu::OTypeCollection collection(
12794 + getCppuType( (Reference< XResultSetUpdate> *) 0 ),
12795 + getCppuType( (Reference< XRowUpdate> *) 0 ),
12796 + SequenceResultSet::getTypes());
12797 + pCollection = &collection;
12800 + return pCollection->getTypes();
12804 +com::sun::star::uno::Sequence< sal_Int8> UpdateableResultSet::getImplementationId()
12805 + throw( com::sun::star::uno::RuntimeException )
12807 + static cppu::OImplementationId *pId;
12810 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
12813 + static cppu::OImplementationId id(sal_False);
12817 + return pId->getImplementationId();
12820 +OUString UpdateableResultSet::buildWhereClause()
12823 + if( m_primaryKey.getLength() )
12825 + OUStringBuffer buf( 128 );
12826 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE " ) );
12827 + for( int i = 0 ; i < m_primaryKey.getLength() ; i ++ )
12830 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AND " ) );
12831 + sal_Int32 index = findColumn( m_primaryKey[i] );
12832 + bufferQuoteIdentifier( buf, m_primaryKey[i] );
12833 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
12834 + bufferQuoteConstant( buf, getString( index ), (*m_ppSettings)->encoding );
12836 + ret = buf.makeStringAndClear();
12842 +void UpdateableResultSet::insertRow( ) throw (SQLException, RuntimeException)
12844 + MutexGuard guard( m_refMutex->mutex );
12845 + if( isLog( *m_ppSettings, LogLevel::INFO ) )
12847 + log( *m_ppSettings, LogLevel::INFO,"UpdateableResultSet::insertRow got called" );
12849 + if( ! m_insertRow )
12850 + throw SQLException(
12851 + ASCII_STR("pq_resultset.insertRow: moveToInsertRow has not been called !" ),
12852 + *this, OUString(), 1, Any() );
12854 + OUStringBuffer buf( 128 );
12855 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "INSERT INTO " ) );
12856 + bufferQuoteQualifiedIdentifier( buf, m_schema, m_table );
12857 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ( " ) );
12861 + for( i = 0 ; i < m_updateableField.size() ; i++ )
12863 + if( m_updateableField[i].isTouched )
12865 + if( columns > 0 )
12866 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
12868 + bufferQuoteIdentifier( buf, m_columnNames[i]);
12871 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ) VALUES ( " ) );
12874 + for( i = 0 ; i < m_updateableField.size() ; i ++ )
12876 + if( m_updateableField[i].isTouched )
12878 + if( columns > 0 )
12879 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " , " ) );
12881 + bufferQuoteAnyConstant( buf, m_updateableField[i].value );
12884 +// m_updateableField[i].value >>= val;
12885 +// buf.append( val );
12886 +// rtl::OStringToOUString(val, (*m_ppSettings)->encoding ) );
12890 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) );
12892 + Reference< XStatement > stmt =
12893 + extractConnectionFromStatement(m_owner)->createStatement();
12894 + DisposeGuard dispGuard( stmt );
12895 + stmt->executeUpdate( buf.makeStringAndClear() );
12897 + // reflect the changes !
12899 + m_data.realloc( m_rowCount );
12900 + m_data[m_rowCount-1] = Sequence< Any > ( m_fieldCount );
12901 + Reference< XGeneratedResultSet > result( stmt, UNO_QUERY );
12902 + if( result.is() )
12904 + Reference< XResultSet > rs = result->getGeneratedValues();
12905 + if( rs.is() && rs->next() )
12907 + Reference< XColumnLocate > columnLocate( rs, UNO_QUERY );
12908 + Reference< XRow> xRow ( rs, UNO_QUERY );
12909 + for( i = 0 ; i < m_fieldCount ; i++ )
12911 + int field = columnLocate->findColumn( m_columnNames[i] );
12914 + m_data[m_rowCount-1][i] <<= xRow->getString( field );
12915 +// printf( "adding %s %s\n" ,
12916 +// OUStringToOString( m_columnNames[i], RTL_TEXTENCODING_ASCII_US).getStr(),
12917 +// OUStringToOString( xRow->getString( field ), RTL_TEXTENCODING_ASCII_US).getStr() );
12924 + // do the best we can ( DEFAULT and AUTO increment values fail ! )
12925 + for( int i = 0 ; i < m_fieldCount ; i ++ )
12927 + if( m_updateableField[i].isTouched )
12928 + m_data[m_rowCount-1][i] = m_updateableField[i].value;
12934 + m_updateableField = UpdateableFieldVector();
12937 +void UpdateableResultSet::updateRow( ) throw (SQLException, RuntimeException)
12939 + MutexGuard guard( m_refMutex->mutex );
12940 + if( isLog( *m_ppSettings, LogLevel::INFO ) )
12942 + log( *m_ppSettings, LogLevel::INFO,"UpdateableResultSet::updateRow got called" );
12944 + if( m_insertRow )
12945 + throw SQLException(
12946 + ASCII_STR("pq_resultset.updateRow: moveToCurrentRow has not been called !" ),
12947 + *this, OUString(), 1, Any() );
12949 + OUStringBuffer buf( 128 );
12950 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "UPDATE " ) );
12951 + bufferQuoteQualifiedIdentifier( buf, m_schema, m_table );
12952 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET " ) );
12954 + int columns = 0,i;
12955 + for( i = 0; i < m_updateableField.size() ; i ++ )
12957 + if( m_updateableField[i].isTouched )
12959 + if( columns > 0 )
12960 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
12963 + buf.append( m_columnNames[i] );
12964 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" = " ) );
12965 + bufferQuoteAnyConstant( buf, m_updateableField[i].value );
12967 +// m_updateableField[i].value >>= val;
12968 +// bufferQuoteConstant( buf, val ):
12969 +// buf.append( val );
12972 + buf.append( buildWhereClause() );
12974 + Reference< XStatement > stmt = extractConnectionFromStatement(m_owner)->createStatement();
12975 + DisposeGuard dispGuard( stmt );
12976 + stmt->executeUpdate( buf.makeStringAndClear() );
12978 + // reflect the changes !
12979 + for( i = 0 ; i < m_fieldCount ; i ++ )
12981 + if( m_updateableField[i].isTouched )
12982 + m_data[m_row][i] = m_updateableField[i].value;
12984 + m_updateableField = UpdateableFieldVector();
12987 +void UpdateableResultSet::deleteRow( ) throw (SQLException, RuntimeException)
12989 + if( isLog( *m_ppSettings, LogLevel::INFO ) )
12991 + log( *m_ppSettings, LogLevel::INFO,"UpdateableResultSet::deleteRow got called" );
12993 + if( m_insertRow )
12994 + throw SQLException(
12995 + ASCII_STR("pq_resultset.deleteRow: deleteRow cannot be called when on insert row !" ),
12996 + *this, OUString(), 1, Any() );
12998 + if( m_row < 0 || m_row >= m_rowCount )
13000 + OUStringBuffer buf( 128 );
13001 + buf.appendAscii( "deleteRow cannot be called on invalid row (" );
13002 + buf.append( m_row );
13003 + buf.appendAscii( ")" );
13004 + throw SQLException( buf.makeStringAndClear() , *this, OUString(), 0, Any() );
13007 + Reference< XStatement > stmt = extractConnectionFromStatement(m_owner)->createStatement();
13008 + DisposeGuard dispGuard( stmt );
13009 + OUStringBuffer buf( 128 );
13010 + buf.appendAscii( "DELETE FROM " );
13011 + bufferQuoteQualifiedIdentifier( buf, m_schema, m_table );
13012 + buf.appendAscii( " " );
13013 + buf.append( buildWhereClause() );
13015 + stmt->executeUpdate( buf.makeStringAndClear() );
13017 + // reflect the changes !
13018 + for( int i = m_row + 1; i < m_row ; i ++ )
13020 + m_data[i-1] = m_data[i];
13023 + m_data.realloc( m_rowCount );
13026 +void UpdateableResultSet::cancelRowUpdates( ) throw (SQLException, RuntimeException)
13028 + MutexGuard guard( m_refMutex->mutex );
13029 + m_updateableField = UpdateableFieldVector();
13032 +void UpdateableResultSet::moveToInsertRow( ) throw (SQLException, RuntimeException)
13034 + m_insertRow = true;
13037 +void UpdateableResultSet::moveToCurrentRow( ) throw (SQLException, RuntimeException)
13039 + m_insertRow = false;
13042 +void UpdateableResultSet::checkUpdate( sal_Int32 columnIndex)
13044 + checkColumnIndex( columnIndex );
13045 + if( m_updateableField.empty() )
13046 + m_updateableField = UpdateableFieldVector( m_fieldCount );
13047 + m_updateableField[columnIndex-1].isTouched = true;
13050 +void UpdateableResultSet::updateNull( sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
13052 + MutexGuard guard( m_refMutex->mutex );
13054 + checkUpdate( columnIndex );
13055 + m_updateableField[columnIndex-1].value = Any();
13058 +void UpdateableResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (SQLException, RuntimeException)
13060 + MutexGuard guard( m_refMutex->mutex );
13062 + checkUpdate( columnIndex );
13064 + Statics &st = getStatics();
13066 + m_updateableField[columnIndex-1].value <<= ( x ? st.TRUE : st.FALSE );
13070 +void UpdateableResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (SQLException, RuntimeException)
13072 + updateInt(columnIndex,x);
13075 +void UpdateableResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (SQLException, RuntimeException)
13077 + updateInt( columnIndex, x );
13080 +void UpdateableResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (SQLException, RuntimeException)
13082 + updateLong( columnIndex, x );
13083 +// MutexGuard guard( m_refMutex->mutex );
13085 +// checkUpdate( columnIndex );
13087 +// m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
13091 +void UpdateableResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (SQLException, RuntimeException)
13093 + MutexGuard guard( m_refMutex->mutex );
13095 + checkUpdate( columnIndex );
13097 +// OStringBuffer buf( 20 );
13098 +// buf.append( "'" );
13099 +// buf.append( (sal_Int64) x );
13100 +// buf.append( "'" );
13101 + m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
13104 +void UpdateableResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw (SQLException, RuntimeException)
13107 + MutexGuard guard( m_refMutex->mutex );
13109 + checkUpdate( columnIndex );
13111 + m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
13114 +void UpdateableResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw (SQLException, RuntimeException)
13116 + MutexGuard guard( m_refMutex->mutex );
13118 + checkUpdate( columnIndex );
13120 + m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
13123 +void UpdateableResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw (SQLException, RuntimeException)
13125 + MutexGuard guard( m_refMutex->mutex );
13127 + checkUpdate( columnIndex );
13129 + m_updateableField[columnIndex-1].value <<= x;
13132 +void UpdateableResultSet::updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw (SQLException, RuntimeException)
13134 + MutexGuard guard( m_refMutex->mutex );
13136 + checkUpdate( columnIndex );
13139 + unsigned char * escapedString =
13140 + PQescapeBytea( (unsigned char *)x.getConstArray(), x.getLength(), &len);
13141 + if( ! escapedString )
13143 + throw SQLException(
13144 + ASCII_STR("pq_preparedstatement.setBytes: Error during converting bytesequence to an SQL conform string" ),
13145 + *this, OUString(), 1, Any() );
13147 +// buf.append( (const sal_Char *)escapedString, len -1 );
13149 + m_updateableField[columnIndex-1].value <<=
13150 + OUString( (sal_Char*) escapedString, len, RTL_TEXTENCODING_ASCII_US );
13151 + free( escapedString );
13154 +void UpdateableResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw (SQLException, RuntimeException)
13156 + updateString( columnIndex, date2String( x ) );
13159 +void UpdateableResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw (SQLException, RuntimeException)
13161 + updateString( columnIndex, time2String( x ) );
13164 +void UpdateableResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw (SQLException, RuntimeException)
13166 + updateString( columnIndex, dateTime2String( x ) );
13169 +void UpdateableResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (SQLException, RuntimeException)
13173 +void UpdateableResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (SQLException, RuntimeException)
13177 +void UpdateableResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw (SQLException, RuntimeException)
13181 +void UpdateableResultSet::updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw (SQLException, RuntimeException)
13186 +::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > UpdateableResultSet::getMetaData( )
13187 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
13192 +Sequence< Type > UpdateableResultSet::getStaticTypes( bool updateable )
13193 + throw( com::sun::star::uno::RuntimeException )
13197 + cppu::OTypeCollection collection(
13198 + getCppuType( (Reference< XResultSetUpdate> *) 0 ),
13199 + getCppuType( (Reference< XRowUpdate> *) 0 ),
13200 +// getCppuType( (Reference< com::sun::star::sdbcx::XRowLocate > *) 0 ),
13201 + getStaticTypes( false /* updateable */ ) );
13202 + return collection.getTypes();
13206 + cppu::OTypeCollection collection(
13207 + getCppuType( (Reference< XResultSet> *) 0 ),
13208 + getCppuType( (Reference< XResultSetMetaDataSupplier> *) 0 ),
13209 + getCppuType( (Reference< XRow> *) 0 ),
13210 + getCppuType( (Reference< XColumnLocate> *) 0 ),
13211 + getCppuType( (Reference< XCloseable> *) 0 ),
13212 + getCppuType( (Reference< XPropertySet >*) 0 ),
13213 + getCppuType( (Reference< XFastPropertySet > *) 0 ),
13214 + getCppuType( (Reference< XMultiPropertySet > *) 0 ),
13215 + getCppuType( (const Reference< com::sun::star::lang::XComponent > *)0 ), // OComponentHelper
13216 + getCppuType( (const Reference< com::sun::star::lang::XTypeProvider > *)0 ),
13217 + getCppuType( (const Reference< com::sun::star::uno::XAggregation > *)0 ),
13218 + getCppuType( (const Reference< com::sun::star::uno::XWeak > *)0 ) );
13219 + return collection.getTypes();
13224 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
13225 +++ connectivity/source/drivers/postgresql/pq_updateableresultset.hxx 2007-08-26 22:40:40.000000000 +0200
13227 +#include "pq_sequenceresultset.hxx"
13228 +#include "pq_resultsetmetadata.hxx"
13230 +#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
13231 +#include <com/sun/star/sdbc/XRowUpdate.hpp>
13233 +namespace pq_sdbc_driver
13236 +struct UpdateableField
13238 + UpdateableField( )
13239 + : isTouched(false)
13241 + com::sun::star::uno::Any value;
13245 +typedef ::std::vector< UpdateableField , Allocator< UpdateableField > > UpdateableFieldVector;
13247 +class UpdateableResultSet :
13248 + public SequenceResultSet,
13249 + public com::sun::star::sdbc::XResultSetUpdate,
13250 + public com::sun::star::sdbc::XRowUpdate
13252 + ConnectionSettings **m_ppSettings;
13253 + rtl::OUString m_schema;
13254 + rtl::OUString m_table;
13255 + com::sun::star::uno::Sequence< rtl::OUString > m_primaryKey;
13256 + UpdateableFieldVector m_updateableField;
13257 + com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta;
13258 + bool m_insertRow;
13261 + UpdateableResultSet(
13262 + const ::rtl::Reference< RefCountedMutex > & mutex,
13263 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
13264 + const com::sun::star::uno::Sequence< rtl::OUString > &colNames,
13265 + const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data,
13266 + ConnectionSettings **ppSettings,
13267 + const rtl::OUString &schema,
13268 + const rtl::OUString &table,
13269 + const com::sun::star::uno::Sequence< ::rtl::OUString > &primaryKey)
13270 + : SequenceResultSet( mutex, owner, colNames, data, (*ppSettings)->tc ),
13271 + m_insertRow( false ),
13272 + m_primaryKey( primaryKey ),
13273 + m_table( table ),
13274 + m_schema( schema ),
13275 + m_ppSettings( ppSettings )
13279 + rtl::OUString buildWhereClause();
13280 + void checkUpdate( sal_Int32 column );
13283 + static com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > createFromPGResultSet(
13284 + const ::rtl::Reference< RefCountedMutex > & mutex,
13285 + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
13286 + ConnectionSettings **ppSettings,
13287 + PGresult *result,
13288 + const rtl::OUString &schema,
13289 + const rtl::OUString &table,
13290 + const com::sun::star::uno::Sequence< ::rtl::OUString > &primaryKey );
13292 +public: // XInterface
13293 + virtual void SAL_CALL acquire() throw() { SequenceResultSet::acquire(); }
13294 + virtual void SAL_CALL release() throw() { SequenceResultSet::release(); }
13295 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
13296 + const com::sun::star::uno::Type & reqType )
13297 + throw (com::sun::star::uno::RuntimeException);
13299 +public: // XTypeProvider
13300 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
13301 + throw( com::sun::star::uno::RuntimeException );
13302 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
13303 + throw( com::sun::star::uno::RuntimeException );
13305 +public: // XResultSetUpdate
13306 + virtual void SAL_CALL insertRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13307 + virtual void SAL_CALL updateRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13308 + virtual void SAL_CALL deleteRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13309 + virtual void SAL_CALL cancelRowUpdates( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13310 + virtual void SAL_CALL moveToInsertRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13311 + virtual void SAL_CALL moveToCurrentRow( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13313 +public: // XRowUpdate
13314 + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13315 + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13316 + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13317 + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13318 + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13319 + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13320 + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13321 + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13322 + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13323 + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13324 + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13325 + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13326 + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13327 + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13328 + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13329 + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13330 + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13332 +public: // XResultSetMetaDataSupplier
13333 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
13334 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
13337 + static com::sun::star::uno::Sequence< com::sun::star::uno::Type > getStaticTypes( bool updateable )
13338 + throw( com::sun::star::uno::RuntimeException );
13345 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
13346 +++ connectivity/source/drivers/postgresql/pq_xbase.cxx 2004-06-10 17:26:59.000000000 +0200
13348 +/*************************************************************************
13350 + * $RCSfile: pq_xbase.cxx,v $
13352 + * $Revision: 1.1.2.2 $
13354 + * last change: $Author: jbu $ $Date: 2004/06/10 15:26:59 $
13356 + * The Contents of this file are made available subject to the terms of
13357 + * either of the following licenses
13359 + * - GNU Lesser General Public License Version 2.1
13360 + * - Sun Industry Standards Source License Version 1.1
13362 + * Sun Microsystems Inc., October, 2000
13364 + * GNU Lesser General Public License Version 2.1
13365 + * =============================================
13366 + * Copyright 2000 by Sun Microsystems, Inc.
13367 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
13369 + * This library is free software; you can redistribute it and/or
13370 + * modify it under the terms of the GNU Lesser General Public
13371 + * License version 2.1, as published by the Free Software Foundation.
13373 + * This library is distributed in the hope that it will be useful,
13374 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13375 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13376 + * Lesser General Public License for more details.
13378 + * You should have received a copy of the GNU Lesser General Public
13379 + * License along with this library; if not, write to the Free Software
13380 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
13381 + * MA 02111-1307 USA
13384 + * Sun Industry Standards Source License Version 1.1
13385 + * =================================================
13386 + * The contents of this file are subject to the Sun Industry Standards
13387 + * Source License Version 1.1 (the "License"); You may not use this file
13388 + * except in compliance with the License. You may obtain a copy of the
13389 + * License at http://www.openoffice.org/license.html.
13391 + * Software provided under this License is provided on an "AS IS" basis,
13392 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
13393 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
13394 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
13395 + * See the License for the specific provisions governing your rights and
13396 + * obligations concerning the Software.
13398 + * The Initial Developer of the Original Code is: Joerg Budischewski
13400 + * Copyright: 2000 by Sun Microsystems, Inc.
13402 + * All Rights Reserved.
13404 + * Contributor(s): Joerg Budischewski
13407 + ************************************************************************/
13409 +#include <rtl/ustrbuf.hxx>
13410 +#include <cppuhelper/typeprovider.hxx>
13412 +#include "pq_tools.hxx"
13413 +#include "pq_xbase.hxx"
13415 +using osl::MutexGuard;
13417 +using com::sun::star::uno::Any;
13418 +using com::sun::star::uno::Sequence;
13419 +using com::sun::star::uno::Reference;
13420 +using com::sun::star::uno::RuntimeException;
13422 +using com::sun::star::beans::Property;
13423 +using com::sun::star::beans::XPropertySetInfo;
13424 +using com::sun::star::beans::XMultiPropertySet;
13425 +using com::sun::star::beans::XFastPropertySet;
13426 +using com::sun::star::beans::XPropertySet;
13428 +namespace pq_sdbc_driver
13431 +ReflectionBase::ReflectionBase(
13432 + const ::rtl::OUString &implName,
13433 + const ::com::sun::star::uno::Sequence< rtl::OUString > &supportedServices,
13434 + const ::rtl::Reference< RefCountedMutex > refMutex,
13435 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &conn,
13436 + ConnectionSettings *pSettings,
13437 + cppu::IPropertyArrayHelper & props /* must survive this object !*/ )
13438 + : OComponentHelper( refMutex->mutex ),
13439 + OPropertySetHelper( OComponentHelper::rBHelper ),
13440 + m_implName( implName ),
13441 + m_supportedServices( supportedServices ),
13442 + m_refMutex( refMutex ),
13444 + m_pSettings( pSettings ),
13445 + m_propsDesc( props ),
13446 + m_values( props.getProperties().getLength() )
13449 +cppu::IPropertyArrayHelper & ReflectionBase::getInfoHelper()
13451 + return m_propsDesc;
13454 +sal_Bool ReflectionBase::convertFastPropertyValue(
13455 + ::com::sun::star::uno::Any & rConvertedValue,
13456 + ::com::sun::star::uno::Any & rOldValue,
13457 + sal_Int32 nHandle,
13458 + const ::com::sun::star::uno::Any& rValue )
13459 + throw (::com::sun::star::lang::IllegalArgumentException)
13462 + rOldValue = m_values[nHandle];
13463 + rConvertedValue = rValue; // TODO !!! implement correct conversion !
13464 + m_values[nHandle] = rValue;
13468 +void ReflectionBase::setPropertyValue_NoBroadcast_public(
13469 + const rtl::OUString & name, const com::sun::star::uno::Any & value )
13471 + sal_Int32 nHandle = m_propsDesc.getHandleByName( name );
13472 + if( -1 == nHandle )
13474 + rtl::OUStringBuffer buf(128);
13475 + buf.appendAscii( "Unkown property '" );
13476 + buf.append( name );
13477 + buf.appendAscii( "' in " );
13478 + buf.append( m_implName );
13479 + throw com::sun::star::uno::RuntimeException( buf.makeStringAndClear() , *this );
13481 + setFastPropertyValue_NoBroadcast( nHandle , value );
13484 +void ReflectionBase::setFastPropertyValue_NoBroadcast(
13485 + sal_Int32 nHandle,
13486 + const ::com::sun::star::uno::Any& rValue )
13487 + throw (::com::sun::star::uno::Exception)
13489 +// rtl::OUString s;
13491 +// printf( "setting value (handle %d):%s\n" ,
13492 +// nHandle, rtl::OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
13493 + m_values[nHandle] = rValue;
13496 +void ReflectionBase::getFastPropertyValue(
13497 + ::com::sun::star::uno::Any& rValue,
13498 + sal_Int32 nHandle ) const
13500 + rValue = m_values[nHandle];
13501 +// rtl::OUString s;
13503 +// printf( "getting value (handle %d):%s\n" ,
13504 +// nHandle, rtl::OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
13508 +Reference < ::com::sun::star::beans::XPropertySetInfo > ReflectionBase::getPropertySetInfo()
13509 + throw(com::sun::star::uno::RuntimeException)
13511 + return OPropertySetHelper::createPropertySetInfo( m_propsDesc );
13514 +rtl::OUString ReflectionBase::getImplementationName()
13515 + throw(::com::sun::star::uno::RuntimeException)
13517 + return m_implName;
13520 +sal_Bool ReflectionBase::supportsService(const rtl::OUString& ServiceName)
13521 + throw(::com::sun::star::uno::RuntimeException)
13523 + for( int i = 0 ; i < m_supportedServices.getLength() ; i ++ )
13524 + if( m_supportedServices[i] == ServiceName )
13526 + return sal_False;
13529 +Sequence< rtl::OUString > ReflectionBase::getSupportedServiceNames(void)
13530 + throw(::com::sun::star::uno::RuntimeException)
13532 + return m_supportedServices;
13536 +Sequence< com::sun::star::uno::Type > ReflectionBase::getTypes()
13537 + throw( com::sun::star::uno::RuntimeException )
13539 + osl::MutexGuard guard( m_refMutex->mutex );
13540 + static cppu::OTypeCollection collection(
13541 + getCppuType( (Reference< XPropertySet >*) 0 ),
13542 + getCppuType( (Reference< XFastPropertySet > *) 0 ),
13543 + getCppuType( (Reference< XMultiPropertySet > *) 0 ),
13544 + getCppuType( (Reference< com::sun::star::lang::XServiceInfo > *) 0 ),
13545 + getCppuType( (Reference< com::sun::star::sdbcx::XDataDescriptorFactory > *) 0 ),
13546 + getCppuType( (Reference< com::sun::star::container::XNamed > *) 0 ),
13547 + OComponentHelper::getTypes());
13548 + return collection.getTypes();
13552 +com::sun::star::uno::Any ReflectionBase::queryInterface(
13553 + const com::sun::star::uno::Type & reqType )
13554 + throw (com::sun::star::uno::RuntimeException)
13557 + ret = OComponentHelper::queryInterface( reqType );
13558 + if( ! ret.hasValue() )
13559 + ret = ::cppu::queryInterface(
13561 + static_cast< com::sun::star::beans::XPropertySet * > ( this ),
13562 + static_cast< com::sun::star::beans::XMultiPropertySet * > ( this ),
13563 + static_cast< com::sun::star::lang::XServiceInfo * > ( this ),
13564 + static_cast< com::sun::star::beans::XFastPropertySet * > ( this ) ,
13565 + static_cast< com::sun::star::sdbcx::XDataDescriptorFactory * > ( this ),
13566 + static_cast< com::sun::star::container::XNamed * > ( this ) );
13571 +Sequence< sal_Int8> ReflectionBase::getImplementationId() throw( RuntimeException )
13573 + static cppu::OImplementationId *pId;
13576 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
13579 + static cppu::OImplementationId id(sal_False);
13583 + return pId->getImplementationId();
13586 +void ReflectionBase::copyValuesFrom( const Reference< XPropertySet > & set )
13588 + Reference< XPropertySetInfo > info = set->getPropertySetInfo();
13591 + Reference< XPropertySetInfo > myPropInfo = getPropertySetInfo();
13593 + Sequence< Property > props = info->getProperties();
13594 + for( int i = 0 ; i < props.getLength() ; i ++ )
13596 + if( myPropInfo->hasPropertyByName( props[i].Name ) )
13597 + setPropertyValue_NoBroadcast_public(
13598 + props[i].Name, set->getPropertyValue( props[i].Name ) );
13603 +::rtl::OUString ReflectionBase::getName( ) throw (::com::sun::star::uno::RuntimeException)
13605 + Statics & st = getStatics();
13606 + if( getInfoHelper().hasPropertyByName( st.SCHEMA_NAME ) )
13607 + return concatQualified(
13608 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
13609 + extractStringProperty( this, getStatics().NAME ) );
13611 + return extractStringProperty( this, getStatics().NAME );
13615 +void ReflectionBase::setName( const ::rtl::OUString& aName )
13616 + throw (::com::sun::star::uno::RuntimeException)
13618 + throw RuntimeException(
13620 + RTL_CONSTASCII_USTRINGPARAM( "pq_sdbc::ReflectionBase::setName not implemented" ) ),
13622 + //setPropertyValue( getStatics().NAME , makeAny( aName ) );
13627 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
13628 +++ connectivity/source/drivers/postgresql/pq_xbase.hxx 2004-06-10 17:26:59.000000000 +0200
13630 +/*************************************************************************
13632 + * $RCSfile: pq_xbase.hxx,v $
13634 + * $Revision: 1.1.2.2 $
13636 + * last change: $Author: jbu $ $Date: 2004/06/10 15:26:59 $
13638 + * The Contents of this file are made available subject to the terms of
13639 + * either of the following licenses
13641 + * - GNU Lesser General Public License Version 2.1
13642 + * - Sun Industry Standards Source License Version 1.1
13644 + * Sun Microsystems Inc., October, 2000
13646 + * GNU Lesser General Public License Version 2.1
13647 + * =============================================
13648 + * Copyright 2000 by Sun Microsystems, Inc.
13649 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
13651 + * This library is free software; you can redistribute it and/or
13652 + * modify it under the terms of the GNU Lesser General Public
13653 + * License version 2.1, as published by the Free Software Foundation.
13655 + * This library is distributed in the hope that it will be useful,
13656 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13657 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13658 + * Lesser General Public License for more details.
13660 + * You should have received a copy of the GNU Lesser General Public
13661 + * License along with this library; if not, write to the Free Software
13662 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
13663 + * MA 02111-1307 USA
13666 + * Sun Industry Standards Source License Version 1.1
13667 + * =================================================
13668 + * The contents of this file are subject to the Sun Industry Standards
13669 + * Source License Version 1.1 (the "License"); You may not use this file
13670 + * except in compliance with the License. You may obtain a copy of the
13671 + * License at http://www.openoffice.org/license.html.
13673 + * Software provided under this License is provided on an "AS IS" basis,
13674 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
13675 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
13676 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
13677 + * See the License for the specific provisions governing your rights and
13678 + * obligations concerning the Software.
13680 + * The Initial Developer of the Original Code is: Joerg Budischewski
13682 + * Copyright: 2000 by Sun Microsystems, Inc.
13684 + * All Rights Reserved.
13686 + * Contributor(s): Joerg Budischewski
13689 + ************************************************************************/
13691 +#ifndef _PQ_REFL_BASE_HXX_
13692 +#define _PQ_REFL_BASE_HXX_
13693 +#include <cppuhelper/propshlp.hxx>
13694 +#include <cppuhelper/component.hxx>
13696 +#include <com/sun/star/lang/XServiceInfo.hpp>
13697 +#include <com/sun/star/container/XNamed.hpp>
13699 +#include "pq_xcontainer.hxx"
13701 +namespace pq_sdbc_driver
13704 +class ReflectionBase :
13705 + public cppu::OComponentHelper,
13706 + public cppu::OPropertySetHelper,
13707 + public com::sun::star::lang::XServiceInfo,
13708 + public com::sun::star::sdbcx::XDataDescriptorFactory,
13709 + public com::sun::star::container::XNamed
13712 + const rtl::OUString m_implName;
13713 + const ::com::sun::star::uno::Sequence< rtl::OUString > m_supportedServices;
13714 + ::rtl::Reference< RefCountedMutex > m_refMutex;
13715 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_conn;
13716 + ConnectionSettings *m_pSettings;
13717 + cppu::IPropertyArrayHelper & m_propsDesc;
13718 + com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values;
13721 + const ::rtl::OUString &implName,
13722 + const ::com::sun::star::uno::Sequence< rtl::OUString > &supportedServices,
13723 + const ::rtl::Reference< RefCountedMutex > refMutex,
13724 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &conn,
13725 + ConnectionSettings *pSettings,
13726 + cppu::IPropertyArrayHelper & props /* must survive this object !*/ );
13729 + void copyValuesFrom( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > &set );
13731 +public: // for initialization purposes only, not exported via an interface !
13732 + void setPropertyValue_NoBroadcast_public(
13733 + const rtl::OUString & name, const com::sun::star::uno::Any & value );
13735 +public: //XInterface
13736 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
13737 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
13738 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
13739 + const com::sun::star::uno::Type & reqType )
13740 + throw (com::sun::star::uno::RuntimeException);
13742 +public: // OPropertySetHelper
13743 + virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
13745 + virtual sal_Bool SAL_CALL convertFastPropertyValue(
13746 + ::com::sun::star::uno::Any & rConvertedValue,
13747 + ::com::sun::star::uno::Any & rOldValue,
13748 + sal_Int32 nHandle,
13749 + const ::com::sun::star::uno::Any& rValue )
13750 + throw (::com::sun::star::lang::IllegalArgumentException);
13752 + virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
13753 + sal_Int32 nHandle,
13754 + const ::com::sun::star::uno::Any& rValue )
13755 + throw (::com::sun::star::uno::Exception);
13757 + virtual void SAL_CALL getFastPropertyValue(
13758 + ::com::sun::star::uno::Any& rValue,
13759 + sal_Int32 nHandle ) const;
13762 + ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
13763 + throw(com::sun::star::uno::RuntimeException);
13765 +public: // XServiceInfo
13766 + virtual rtl::OUString SAL_CALL getImplementationName()
13767 + throw(::com::sun::star::uno::RuntimeException);
13768 + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
13769 + throw(::com::sun::star::uno::RuntimeException);
13770 + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
13771 + throw(::com::sun::star::uno::RuntimeException);
13773 +public: // XTypeProvider, first implemented by OPropertySetHelper
13774 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
13775 + throw( com::sun::star::uno::RuntimeException );
13776 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
13777 + throw( com::sun::star::uno::RuntimeException );
13779 +public: // XDataDescriptorFactory
13780 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
13781 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException) = 0;
13784 + virtual ::rtl::OUString SAL_CALL getName( ) throw (::com::sun::star::uno::RuntimeException);
13785 + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
13791 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
13792 +++ connectivity/source/drivers/postgresql/pq_xcolumn.cxx 2004-06-10 17:26:59.000000000 +0200
13794 +/*************************************************************************
13796 + * $RCSfile: pq_xcolumn.cxx,v $
13798 + * $Revision: 1.1.2.2 $
13800 + * last change: $Author: jbu $ $Date: 2004/06/10 15:26:59 $
13802 + * The Contents of this file are made available subject to the terms of
13803 + * either of the following licenses
13805 + * - GNU Lesser General Public License Version 2.1
13806 + * - Sun Industry Standards Source License Version 1.1
13808 + * Sun Microsystems Inc., October, 2000
13810 + * GNU Lesser General Public License Version 2.1
13811 + * =============================================
13812 + * Copyright 2000 by Sun Microsystems, Inc.
13813 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
13815 + * This library is free software; you can redistribute it and/or
13816 + * modify it under the terms of the GNU Lesser General Public
13817 + * License version 2.1, as published by the Free Software Foundation.
13819 + * This library is distributed in the hope that it will be useful,
13820 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13821 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13822 + * Lesser General Public License for more details.
13824 + * You should have received a copy of the GNU Lesser General Public
13825 + * License along with this library; if not, write to the Free Software
13826 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
13827 + * MA 02111-1307 USA
13830 + * Sun Industry Standards Source License Version 1.1
13831 + * =================================================
13832 + * The contents of this file are subject to the Sun Industry Standards
13833 + * Source License Version 1.1 (the "License"); You may not use this file
13834 + * except in compliance with the License. You may obtain a copy of the
13835 + * License at http://www.openoffice.org/license.html.
13837 + * Software provided under this License is provided on an "AS IS" basis,
13838 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
13839 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
13840 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
13841 + * See the License for the specific provisions governing your rights and
13842 + * obligations concerning the Software.
13844 + * The Initial Developer of the Original Code is: Joerg Budischewski
13846 + * Copyright: 2000 by Sun Microsystems, Inc.
13848 + * All Rights Reserved.
13850 + * Contributor(s): Joerg Budischewski
13853 + ************************************************************************/
13855 +#include <cppuhelper/typeprovider.hxx>
13857 +#include "pq_xcolumn.hxx"
13859 +using com::sun::star::uno::Any;
13860 +using com::sun::star::uno::Reference;
13861 +using com::sun::star::uno::RuntimeException;
13862 +using com::sun::star::uno::Type;
13863 +using com::sun::star::uno::Sequence;
13865 +using com::sun::star::beans::XPropertySet;
13867 +namespace pq_sdbc_driver
13869 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
13871 +Column::Column( const ::rtl::Reference< RefCountedMutex > & refMutex,
13872 + const Reference< com::sun::star::sdbc::XConnection > & connection,
13873 + ConnectionSettings *pSettings)
13874 + : ReflectionBase(
13875 + getStatics().refl.column.implName,
13876 + getStatics().refl.column.serviceNames,
13880 + * getStatics().refl.column.pProps )
13883 +Reference< XPropertySet > Column::createDataDescriptor( ) throw (RuntimeException)
13885 + ColumnDescriptor * pColumn = new ColumnDescriptor(
13886 + m_refMutex, m_conn, m_pSettings );
13887 + pColumn->copyValuesFrom( this );
13888 + return Reference< XPropertySet > ( pColumn );
13891 +ColumnDescriptor::ColumnDescriptor(
13892 + const ::rtl::Reference< RefCountedMutex > & refMutex,
13893 + const Reference< com::sun::star::sdbc::XConnection > & connection,
13894 + ConnectionSettings *pSettings)
13895 + : ReflectionBase(
13896 + getStatics().refl.columnDescriptor.implName,
13897 + getStatics().refl.columnDescriptor.serviceNames,
13901 + *getStatics().refl.columnDescriptor.pProps )
13904 +Reference< XPropertySet > ColumnDescriptor::createDataDescriptor( ) throw (RuntimeException)
13906 + ColumnDescriptor * pColumn = new ColumnDescriptor(
13907 + m_refMutex, m_conn, m_pSettings );
13908 + pColumn->copyValuesFrom( this );
13910 + return Reference< XPropertySet > ( pColumn );
13918 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
13919 +++ connectivity/source/drivers/postgresql/pq_xcolumn.hxx 2004-06-10 17:26:59.000000000 +0200
13921 +/*************************************************************************
13923 + * $RCSfile: pq_xcolumn.hxx,v $
13925 + * $Revision: 1.1.2.2 $
13927 + * last change: $Author: jbu $ $Date: 2004/06/10 15:26:59 $
13929 + * The Contents of this file are made available subject to the terms of
13930 + * either of the following licenses
13932 + * - GNU Lesser General Public License Version 2.1
13933 + * - Sun Industry Standards Source License Version 1.1
13935 + * Sun Microsystems Inc., October, 2000
13937 + * GNU Lesser General Public License Version 2.1
13938 + * =============================================
13939 + * Copyright 2000 by Sun Microsystems, Inc.
13940 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
13942 + * This library is free software; you can redistribute it and/or
13943 + * modify it under the terms of the GNU Lesser General Public
13944 + * License version 2.1, as published by the Free Software Foundation.
13946 + * This library is distributed in the hope that it will be useful,
13947 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13948 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13949 + * Lesser General Public License for more details.
13951 + * You should have received a copy of the GNU Lesser General Public
13952 + * License along with this library; if not, write to the Free Software
13953 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
13954 + * MA 02111-1307 USA
13957 + * Sun Industry Standards Source License Version 1.1
13958 + * =================================================
13959 + * The contents of this file are subject to the Sun Industry Standards
13960 + * Source License Version 1.1 (the "License"); You may not use this file
13961 + * except in compliance with the License. You may obtain a copy of the
13962 + * License at http://www.openoffice.org/license.html.
13964 + * Software provided under this License is provided on an "AS IS" basis,
13965 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
13966 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
13967 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
13968 + * See the License for the specific provisions governing your rights and
13969 + * obligations concerning the Software.
13971 + * The Initial Developer of the Original Code is: Joerg Budischewski
13973 + * Copyright: 2000 by Sun Microsystems, Inc.
13975 + * All Rights Reserved.
13977 + * Contributor(s): Joerg Budischewski
13980 + ************************************************************************/
13982 +#ifndef _PQ_COLUMN_HXX_
13983 +#define _PQ_COLUMN_HXX_
13985 +#include <cppuhelper/component.hxx>
13986 +#include <cppuhelper/propshlp.hxx>
13988 +#include <com/sun/star/lang/XServiceInfo.hpp>
13989 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
13991 +#include "pq_connection.hxx"
13992 +#include "pq_xbase.hxx"
13994 +namespace pq_sdbc_driver
13997 +class Column : public ReflectionBase
14000 + Column( const ::rtl::Reference< RefCountedMutex > & refMutex,
14001 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
14002 + ConnectionSettings *pSettings);
14004 +public: // XDataDescriptorFactory
14005 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
14006 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
14010 +class ColumnDescriptor : public ReflectionBase
14013 + ColumnDescriptor(
14014 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14015 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
14016 + ConnectionSettings *pSettings );
14018 +public: // XDataDescriptorFactory
14019 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
14020 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
14029 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
14030 +++ connectivity/source/drivers/postgresql/pq_xcolumns.cxx 2004-08-29 10:33:30.000000000 +0200
14032 +/*************************************************************************
14034 + * $RCSfile: pq_xcolumns.cxx,v $
14036 + * $Revision: 1.1.2.3 $
14038 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:30 $
14040 + * The Contents of this file are made available subject to the terms of
14041 + * either of the following licenses
14043 + * - GNU Lesser General Public License Version 2.1
14044 + * - Sun Industry Standards Source License Version 1.1
14046 + * Sun Microsystems Inc., October, 2000
14048 + * GNU Lesser General Public License Version 2.1
14049 + * =============================================
14050 + * Copyright 2000 by Sun Microsystems, Inc.
14051 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
14053 + * This library is free software; you can redistribute it and/or
14054 + * modify it under the terms of the GNU Lesser General Public
14055 + * License version 2.1, as published by the Free Software Foundation.
14057 + * This library is distributed in the hope that it will be useful,
14058 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14059 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14060 + * Lesser General Public License for more details.
14062 + * You should have received a copy of the GNU Lesser General Public
14063 + * License along with this library; if not, write to the Free Software
14064 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
14065 + * MA 02111-1307 USA
14068 + * Sun Industry Standards Source License Version 1.1
14069 + * =================================================
14070 + * The contents of this file are subject to the Sun Industry Standards
14071 + * Source License Version 1.1 (the "License"); You may not use this file
14072 + * except in compliance with the License. You may obtain a copy of the
14073 + * License at http://www.openoffice.org/license.html.
14075 + * Software provided under this License is provided on an "AS IS" basis,
14076 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
14077 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
14078 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
14079 + * See the License for the specific provisions governing your rights and
14080 + * obligations concerning the Software.
14082 + * The Initial Developer of the Original Code is: Joerg Budischewski
14084 + * Copyright: 2000 by Sun Microsystems, Inc.
14086 + * All Rights Reserved.
14088 + * Contributor(s): Joerg Budischewski
14091 + ************************************************************************/
14095 +#include <rtl/ustrbuf.hxx>
14096 +#include <rtl/strbuf.hxx>
14098 +#include <com/sun/star/sdbc/XRow.hpp>
14099 +#include <com/sun/star/sdbc/XParameters.hpp>
14100 +#include <com/sun/star/sdbc/DataType.hpp>
14101 +#include <com/sun/star/sdbc/ColumnValue.hpp>
14103 +#include <cppuhelper/implbase1.hxx>
14105 +#include "pq_xcolumns.hxx"
14106 +#include "pq_xcolumn.hxx"
14107 +#include "pq_statics.hxx"
14108 +#include "pq_tools.hxx"
14110 +using osl::MutexGuard;
14112 +using rtl::OUString;
14113 +using rtl::OUStringBuffer;
14114 +using rtl::OUStringToOString;
14116 +using com::sun::star::beans::XPropertySet;
14117 +using com::sun::star::beans::XPropertyChangeListener;
14118 +using com::sun::star::beans::PropertyChangeEvent;
14120 +using com::sun::star::uno::Any;
14121 +using com::sun::star::uno::makeAny;
14122 +using com::sun::star::uno::UNO_QUERY;
14123 +using com::sun::star::uno::Type;
14124 +using com::sun::star::uno::XInterface;
14125 +using com::sun::star::uno::Reference;
14126 +using com::sun::star::uno::Sequence;
14127 +using com::sun::star::uno::RuntimeException;
14129 +using com::sun::star::container::NoSuchElementException;
14130 +using com::sun::star::lang::WrappedTargetException;
14132 +using com::sun::star::sdbc::XRow;
14133 +using com::sun::star::sdbc::XCloseable;
14134 +using com::sun::star::sdbc::XStatement;
14135 +using com::sun::star::sdbc::XResultSet;
14136 +using com::sun::star::sdbc::XParameters;
14137 +using com::sun::star::sdbc::XPreparedStatement;
14138 +using com::sun::star::sdbc::XDatabaseMetaData;
14139 +using com::sun::star::sdbc::SQLException;
14141 +namespace pq_sdbc_driver
14143 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
14145 +static Any isCurrency( const rtl::OUString & typeName )
14147 + sal_Bool b = typeName.equalsIgnoreAsciiCaseAscii( "money" );
14148 + return Any( &b, getBooleanCppuType() );
14151 +// static sal_Bool isAutoIncrement8( const rtl::OUString & typeName )
14153 +// return typeName.equalsIgnoreAsciiCaseAscii( "serial8" ) ||
14154 +// typeName.equalsIgnoreAsciiCaseAscii( "bigserial" );
14157 +static Any isAutoIncrement( const rtl::OUString & defaultValue )
14159 + sal_Bool ret = sal_False;
14161 + ret = defaultValue.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "nextval(" ) );
14162 +// printf( "%s %d\n",
14163 +// OUStringToOString(defaultValue, RTL_TEXTENCODING_ASCII_US).getStr(),
14166 +// static const char * const serials[] =
14168 +// "serial", "serial4", "serial8", "bigserial", 0
14170 +// s sal_Bool b = sal_False;
14171 +// for( int i = 0; !b && serials[i] ; i ++ )
14173 +// b = b || typeName.equalsIgnoreAsciiCaseAscii( serials[i] );
14175 + return Any ( &ret, getBooleanCppuType() );
14179 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14180 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14181 + ConnectionSettings *pSettings,
14182 + const rtl::OUString &schemaName,
14183 + const rtl::OUString &tableName)
14184 + : Container( refMutex, origin, pSettings, ASCII_STR( "COLUMN" ) ),
14185 + m_schemaName( schemaName ),
14186 + m_tableName( tableName )
14189 +Columns::~Columns()
14192 +rtl::OUString columnMetaData2SDBCX(
14193 + ReflectionBase *pBase, const com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > &xRow )
14195 + Statics & st = getStatics();
14197 + // 1. TABLE_CAT string => table catalog (may be NULL)
14198 + // => not supported
14199 + // 2. TABLE_SCHEM string => table schema (may be NULL)
14200 + // => pg_namespace.nspname
14201 + // 3. TABLE_NAME string => table name
14202 + // => pg_class.relname
14203 + // 4. COLUMN_NAME string => column name
14204 + // => pg_attribure.attname
14205 + // 5. DATA_TYPE short => SQL type from java.sql.Types
14206 + // => pg_type.typname => sdbc.DataType
14207 + // 6. TYPE_NAME string => Data source dependent type name, for a UDT the
14208 + // type name is fully qualified
14209 + // => pg_type.typname
14210 + // 7. COLUMN_SIZE long => column size. For char or date types this is
14211 + // the maximum number of characters, for numeric
14212 + // or decimal types this is precision.
14213 + // => pg_type.typlen ( TODO: What is about variable size ? )
14214 + // 8. BUFFER_LENGTH is not used.
14216 + // 9. DECIMAL_DIGITS long => the number of fractional digits
14217 + // => don't know ! TODO !
14218 + // 10. NUM_PREC_RADIX long => Radix (typically either 10 or 2)
14220 + // 11. NULLABLE long => is NULL allowed?
14221 + // NO_NULLS - might not allow NULL values
14222 + // NULABLE - definitely allows NULL values
14223 + // NULLABLE_UNKNOWN - nullability unknown
14224 + // => pg_attribute.attnotnull
14225 + // 12. REMARKS string => comment describing column (may be NULL )
14226 + // => Don't know, there does not seem to exist something like
14227 + // that in postgres
14228 + // 13. COLUMN_DEF string => default value (may be NULL)
14229 + // => pg_type.typdefault
14230 + // 14. SQL_DATA_TYPE long => unused
14232 + // 15. SQL_DATETIME_SUB long => unused
14234 + // 16. CHAR_OCTET_LENGTH long => for char types the maximum number of
14235 + // bytes in the column
14236 + // => pg_type.typlen
14237 + // 17. ORDINAL_POSITION int => index of column in table (starting at 1)
14238 + // pg_attribute.attnum
14239 + // 18. IS_NULLABLE string => "NO" means column definitely does not allow
14240 + // NULL values; "YES" means the column might
14241 + // allow NULL values. An empty string means
14243 + // => pg_attribute.attnotnull
14245 + static const int COLUMN_NAME = 4;
14246 + static const int DATA_TYPE = 5;
14247 + static const int TYPE_NAME = 6;
14248 + static const int COLUMN_SIZE = 7;
14249 + static const int DECIMAL_DIGITS = 9;
14250 + static const int IS_NULLABLE = 11;
14251 + static const int DESCRIPTION = 12;
14252 + static const int DEFAULT_VALUE = 13;
14254 + OUString name = xRow->getString( COLUMN_NAME );
14255 + OUString typeName = xRow->getString( TYPE_NAME );
14257 + pBase->setPropertyValue_NoBroadcast_public(
14258 + st.NAME, makeAny( name ) );
14260 + pBase->setPropertyValue_NoBroadcast_public(
14261 + st.TYPE, makeAny( xRow->getInt( DATA_TYPE ) ) );
14263 + pBase->setPropertyValue_NoBroadcast_public(
14264 + st.TYPE_NAME, makeAny( typeName ) );
14266 + pBase->setPropertyValue_NoBroadcast_public(
14267 + st.PRECISION, makeAny( xRow->getInt( COLUMN_SIZE ) ) );
14269 + pBase->setPropertyValue_NoBroadcast_public(
14270 + st.SCALE, makeAny( xRow->getInt( DECIMAL_DIGITS ) ) );
14272 + pBase->setPropertyValue_NoBroadcast_public(
14273 + st.IS_NULLABLE, makeAny( xRow->getInt( IS_NULLABLE ) ) );
14275 + pBase->setPropertyValue_NoBroadcast_public(
14276 + st.DEFAULT_VALUE, makeAny( xRow->getString( DEFAULT_VALUE ) ) );
14278 +// pBase->setPropertyValue_NoBroadcast_public(
14279 +// st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
14281 +// if( pBase->getPropertySetInfo()->hasPropertyByName( st.HELP_TEXT ) )
14282 +// pBase->setPropertyValue_NoBroadcast_public(
14283 +// st.HELP_TEXT, makeAny( xRow->getString( DESCRIPTION ) ) );
14284 +// else // for key columns, etc. ...
14285 + pBase->setPropertyValue_NoBroadcast_public(
14286 + st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
14289 + // maybe a better criterium than the type name can be found in future
14290 + pBase->setPropertyValue_NoBroadcast_public(
14291 + st.IS_AUTO_INCREMENT, isAutoIncrement(xRow->getString( DEFAULT_VALUE )) );
14293 + pBase->setPropertyValue_NoBroadcast_public(
14294 + st.IS_CURRENCY, isCurrency( typeName));
14299 +// class CommentChanger : public cppu::WeakImplHelper1< XPropertyChangeListener >
14301 +// ::rtl::Reference< RefCountedMutex > m_refMutex;
14302 +// ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
14303 +// ConnectionSettings *m_pSettings;
14304 +// rtl::OUString m_schema;
14305 +// rtl::OUString m_table;
14306 +// rtl::OUString m_column;
14309 +// CommentChanger(
14310 +// const ::rtl::Reference< RefCountedMutex > & refMutex,
14311 +// const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
14312 +// ConnectionSettings *pSettings,
14313 +// const rtl::OUString & schema,
14314 +// const rtl::OUString & table,
14315 +// const rtl::OUString & column ) :
14316 +// m_refMutex( refMutex ),
14317 +// m_connection( connection ),
14318 +// m_pSettings( pSettings ),
14319 +// m_schema ( schema ),
14320 +// m_table ( table ),
14321 +// m_column ( column )
14326 +// virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
14328 +// osl::MutexGuard guard( m_refMutex->mutex );
14329 +// m_connection.clear();
14332 +// virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
14334 +// osl::MutexGuard guard( m_refMutex->mutex );
14335 +// OUStringBuffer buf( 128 );
14336 +// OUString comment;
14337 +// evt.NewValue >>= comment;
14338 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
14339 +// bufferQuoteQualifiedIdentifier( buf, m_schema, m_table , m_column );
14340 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
14341 +// bufferQuoteConstant( buf, comment,m_pSettings->encoding);
14343 +// printf( "changing comment of column %s to %s\n",
14344 +// OUStringToOString( m_column, RTL_TEXTENCODING_ASCII_US ).getStr(),
14345 +// OUStringToOString( comment, RTL_TEXTENCODING_ASCII_US ).getStr() );
14347 +// m_connection->createStatement()->executeUpdate( buf.makeStringAndClear() );
14351 +void Columns::refresh()
14352 + throw (::com::sun::star::uno::RuntimeException)
14356 + if( isLog( m_pSettings, LogLevel::INFO ) )
14358 + rtl::OStringBuffer buf;
14359 + buf.append( "sdbcx.Columns get refreshed for table " );
14360 + buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) );
14361 + buf.append( "." );
14362 + buf.append( OUStringToOString( m_tableName, m_pSettings->encoding ) );
14363 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
14365 + osl::MutexGuard guard( m_refMutex->mutex );
14367 + Statics &st = getStatics();
14368 + Reference< XDatabaseMetaData > meta = m_origin->getMetaData();
14370 + Reference< XResultSet > rs =
14371 + meta->getColumns( Any(), m_schemaName, m_tableName, st.cPERCENT );
14373 + DisposeGuard disposeIt( rs );
14374 + Reference< XRow > xRow( rs , UNO_QUERY );
14376 + String2IntMap map;
14378 + std::vector< Any, Allocator< Any> > vec;
14379 + sal_Int32 columnIndex = 0;
14380 + while( rs->next() )
14382 + Column * pColumn =
14383 + new Column( m_refMutex, m_origin, m_pSettings );
14384 + Reference< com::sun::star::beans::XPropertySet > prop = pColumn;
14386 + OUString name = columnMetaData2SDBCX( pColumn, xRow );
14387 +// pColumn->addPropertyChangeListener(
14389 +// new CommentChanger(
14397 + vec.push_back( makeAny( prop ) );
14398 + map[ name ] = columnIndex;
14401 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
14402 + m_name2index.swap( map );
14404 + catch ( com::sun::star::sdbc::SQLException & e )
14406 + throw RuntimeException( e.Message , e.Context );
14408 + fire( RefreshedBroadcaster( *this ) );
14412 +void alterColumnByDescriptor(
14413 + const OUString & schemaName,
14414 + const OUString & tableName,
14415 + rtl_TextEncoding encoding,
14416 + const Reference< XStatement > &stmt,
14417 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & past,
14418 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & future)
14420 + Statics & st = getStatics();
14422 +// if( past->getPropertyValue( st.TABLE_NAME ) != future->getPropertyValue( st.TABLE_NAME ) ||
14423 +// past->getPropertyValue( st.SCHEMA_NAME ) != future->getPropertyValue( st.SCHEMA_NAME ))
14425 +// OUStringBuffer buf(128);
14426 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Can't move column " ) );
14427 +// buf.append( extractStringProperty( past, st.COLUMN_NAME ) );
14428 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " from table " ) );
14429 +// buf.append( extractStringProperty( past, st.TABLE_NAME ) );
14430 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " to table " ) );
14431 +// buf.append( extractStringProperty( past, st.TABLE_NAME ) );
14432 +// throw SQLException( buf.makeStringAndClear(), Reference< XInterface > () );
14435 +// OUString tableName = extractStringProperty( past, st.TABLE_NAME );
14436 +// OUString schemaName = extractStringProperty( past, st.SCHEMA_NAME );
14437 + OUString pastColumnName = extractStringProperty( past, st.NAME );
14438 + OUString futureColumnName = extractStringProperty( future, st.NAME );
14439 + OUString pastTypeName = sqltype2string( past );
14440 + OUString futureTypeName = sqltype2string( future );
14442 + TransactionGuard transaction( stmt );
14444 + OUStringBuffer buf( 128 );
14445 + if( ! pastColumnName.getLength())
14447 + // create a new column
14448 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
14449 + bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
14450 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ADD COLUMN" ) );
14451 + bufferQuoteIdentifier( buf, futureColumnName );
14452 + buf.append( futureTypeName );
14453 + transaction.executeUpdate( buf.makeStringAndClear() );
14457 + if( pastTypeName != futureTypeName )
14459 + throw RuntimeException(
14460 + ASCII_STR( "Can't modify column types, drop the column and create a new one" ),
14461 + Reference< XInterface > () );
14464 + if( pastColumnName != futureColumnName )
14466 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
14467 + bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
14468 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "RENAME COLUMN" ) );
14469 + bufferQuoteIdentifier( buf, pastColumnName );
14470 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TO" ) );
14471 + bufferQuoteIdentifier( buf, futureColumnName );
14472 + transaction.executeUpdate( buf.makeStringAndClear() );
14476 + OUString futureDefaultValue = extractStringProperty( future, st.DEFAULT_VALUE );
14477 + OUString pastDefaultValue = extractStringProperty( past, st.DEFAULT_VALUE );
14478 + if( futureDefaultValue != pastDefaultValue )
14480 + buf = OUStringBuffer( 128 );
14481 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
14482 + bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
14483 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
14484 + bufferQuoteIdentifier( buf, futureColumnName );
14485 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET DEFAULT " ) );
14486 + // default value is not quoted, caller needs to quote himself (otherwise
14487 + // how to pass e.g. nextval('something' ) ????
14488 + buf.append( futureDefaultValue );
14489 +// bufferQuoteConstant( buf, defaultValue, encoding );
14490 + transaction.executeUpdate( buf.makeStringAndClear() );
14493 + sal_Int32 futureNullable = extractIntProperty( future, st.IS_NULLABLE );
14494 + sal_Int32 pastNullable = extractIntProperty( past, st.IS_NULLABLE );
14495 + if( futureNullable != pastNullable )
14497 + buf = OUStringBuffer( 128 );
14498 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
14499 + bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
14500 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
14501 + bufferQuoteIdentifier( buf, futureColumnName );
14502 + if( futureNullable == com::sun::star::sdbc::ColumnValue::NO_NULLS )
14504 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET" ) );
14508 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP" ) );
14510 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL" ) );
14511 + transaction.executeUpdate( buf.makeStringAndClear() );
14514 +// OUString futureComment = extractStringProperty( future, st.HELP_TEXT );
14515 +// OUString pastComment = extractStringProperty( past, st.HELP_TEXT );
14516 +// printf( "past Comment %s, futureComment %s\n",
14517 +// OUStringToOString( pastComment, RTL_TEXTENCODING_ASCII_US ).getStr(),
14518 +// OUStringToOString( futureComment, RTL_TEXTENCODING_ASCII_US ).getStr() );
14519 + OUString futureComment = extractStringProperty( future, st.DESCRIPTION );
14520 + OUString pastComment = extractStringProperty( past, st.DESCRIPTION );
14522 + if( futureComment != pastComment )
14524 + buf = OUStringBuffer( 128 );
14525 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
14526 + bufferQuoteQualifiedIdentifier( buf, schemaName, tableName , futureColumnName );
14527 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
14528 + bufferQuoteConstant( buf, futureComment,encoding);
14529 + transaction.executeUpdate( buf.makeStringAndClear() );
14531 + transaction.commit();
14534 +void Columns::appendByDescriptor(
14535 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& future )
14536 + throw (::com::sun::star::sdbc::SQLException,
14537 + ::com::sun::star::container::ElementExistException,
14538 + ::com::sun::star::uno::RuntimeException)
14540 + osl::MutexGuard guard( m_refMutex->mutex );
14541 + Statics & st = getStatics();
14542 + Reference< XPropertySet > past = createDataDescriptor();
14543 + past->setPropertyValue( st.IS_NULLABLE, makeAny( com::sun::star::sdbc::ColumnValue::NULLABLE ) );
14544 + alterColumnByDescriptor(
14545 + m_schemaName, m_tableName, m_pSettings->encoding, m_origin->createStatement() , past, future );
14550 +// void Columns::dropByName( const ::rtl::OUString& elementName )
14551 +// throw (::com::sun::star::sdbc::SQLException,
14552 +// ::com::sun::star::container::NoSuchElementException,
14553 +// ::com::sun::star::uno::RuntimeException)
14555 +// String2IntMap::const_iterator ii = m_name2index.find( elementName );
14556 +// if( ii == m_name2index.end() )
14558 +// OUStringBuffer buf( 128 );
14559 +// buf.appendAscii( "Column " );
14560 +// buf.append( elementName );
14561 +// buf.appendAscii( " is unknown in table " );
14562 +// buf.append( m_schemaName );
14563 +// buf.appendAscii( "." );
14564 +// buf.append( m_tableName );
14565 +// buf.appendAscii( ", so it can't be dropped" );
14566 +// throw com::sun::star::container::NoSuchElementException(
14567 +// buf.makeStringAndClear(), *this );
14569 +// dropByIndex( ii->second );
14572 +void Columns::dropByIndex( sal_Int32 index )
14573 + throw (::com::sun::star::sdbc::SQLException,
14574 + ::com::sun::star::lang::IndexOutOfBoundsException,
14575 + ::com::sun::star::uno::RuntimeException)
14577 + osl::MutexGuard guard( m_refMutex->mutex );
14578 + if( index < 0 || index >= m_values.getLength() )
14580 + OUStringBuffer buf( 128 );
14581 + buf.appendAscii( "COLUMNS: Index out of range (allowed 0 to " );
14582 + buf.append((sal_Int32)(m_values.getLength() -1) );
14583 + buf.appendAscii( ", got " );
14584 + buf.append( index );
14585 + buf.appendAscii( ")" );
14586 + throw com::sun::star::lang::IndexOutOfBoundsException(
14587 + buf.makeStringAndClear(), *this );
14590 + Reference< XPropertySet > set;
14591 + m_values[index] >>= set;
14592 + Statics &st = getStatics();
14594 + set->getPropertyValue( st.NAME ) >>= name;
14596 + OUStringBuffer update( 128 );
14597 + update.appendAscii( "ALTER TABLE ONLY");
14598 + bufferQuoteQualifiedIdentifier( update, m_schemaName, m_tableName );
14599 + update.appendAscii( "DROP COLUMN" );
14600 + bufferQuoteIdentifier( update, name );
14601 + Reference< XStatement > stmt = m_origin->createStatement( );
14602 + DisposeGuard disposeIt( stmt );
14603 + stmt->executeUpdate( update.makeStringAndClear() );
14605 + Container::dropByIndex( index );
14609 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Columns::createDataDescriptor()
14610 + throw (::com::sun::star::uno::RuntimeException)
14612 + return new ColumnDescriptor( m_refMutex, m_origin, m_pSettings );
14615 +Reference< com::sun::star::container::XNameAccess > Columns::create(
14616 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14617 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14618 + ConnectionSettings *pSettings,
14619 + const rtl::OUString &schemaName,
14620 + const rtl::OUString &tableName,
14621 + Columns **ppColumns)
14623 + *ppColumns = new Columns(
14624 + refMutex, origin, pSettings, schemaName, tableName );
14625 + Reference< com::sun::star::container::XNameAccess > ret = *ppColumns;
14626 + (*ppColumns)->refresh();
14632 +//_____________________________________________________________________________________
14633 +ColumnDescriptors::ColumnDescriptors(
14634 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14635 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14636 + ConnectionSettings *pSettings )
14637 + : Container( refMutex, origin, pSettings, ASCII_STR( "COLUMN-DESCRIPTOR" ) )
14641 +Reference< ::com::sun::star::beans::XPropertySet > ColumnDescriptors::createDataDescriptor()
14642 + throw (::com::sun::star::uno::RuntimeException)
14644 + return new ColumnDescriptor( m_refMutex, m_origin, m_pSettings );
14649 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
14650 +++ connectivity/source/drivers/postgresql/pq_xcolumns.hxx 2004-06-10 17:27:00.000000000 +0200
14652 +/*************************************************************************
14654 + * $RCSfile: pq_xcolumns.hxx,v $
14656 + * $Revision: 1.1.2.2 $
14658 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:00 $
14660 + * The Contents of this file are made available subject to the terms of
14661 + * either of the following licenses
14663 + * - GNU Lesser General Public License Version 2.1
14664 + * - Sun Industry Standards Source License Version 1.1
14666 + * Sun Microsystems Inc., October, 2000
14668 + * GNU Lesser General Public License Version 2.1
14669 + * =============================================
14670 + * Copyright 2000 by Sun Microsystems, Inc.
14671 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
14673 + * This library is free software; you can redistribute it and/or
14674 + * modify it under the terms of the GNU Lesser General Public
14675 + * License version 2.1, as published by the Free Software Foundation.
14677 + * This library is distributed in the hope that it will be useful,
14678 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14679 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14680 + * Lesser General Public License for more details.
14682 + * You should have received a copy of the GNU Lesser General Public
14683 + * License along with this library; if not, write to the Free Software
14684 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
14685 + * MA 02111-1307 USA
14688 + * Sun Industry Standards Source License Version 1.1
14689 + * =================================================
14690 + * The contents of this file are subject to the Sun Industry Standards
14691 + * Source License Version 1.1 (the "License"); You may not use this file
14692 + * except in compliance with the License. You may obtain a copy of the
14693 + * License at http://www.openoffice.org/license.html.
14695 + * Software provided under this License is provided on an "AS IS" basis,
14696 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
14697 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
14698 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
14699 + * See the License for the specific provisions governing your rights and
14700 + * obligations concerning the Software.
14702 + * The Initial Developer of the Original Code is: Joerg Budischewski
14704 + * Copyright: 2000 by Sun Microsystems, Inc.
14706 + * All Rights Reserved.
14708 + * Contributor(s): Joerg Budischewski
14711 + ************************************************************************/
14713 +#ifndef _PQ_COLUMNS_HXX_
14714 +#define _PQ_COLUMNS_HXX_
14716 +#include "pq_xcontainer.hxx"
14717 +#include "pq_xbase.hxx"
14719 +namespace pq_sdbc_driver
14722 +void alterColumnByDescriptor(
14723 + const rtl::OUString & schemaName,
14724 + const rtl::OUString & tableName,
14725 + rtl_TextEncoding encoding,
14726 + const com::sun::star::uno::Reference< com::sun::star::sdbc::XStatement > &stmt,
14727 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & past,
14728 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & future);
14730 +rtl::OUString columnMetaData2SDBCX(
14731 + ReflectionBase *pBase, const com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > &xRow );
14733 +class Columns : public Container
14735 + rtl::OUString m_schemaName;
14736 + rtl::OUString m_tableName;
14738 +public: // instances Columns 'exception safe'
14739 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
14740 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14741 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14742 + ConnectionSettings *pSettings,
14743 + const rtl::OUString &schemaName,
14744 + const rtl::OUString &tableName,
14745 + Columns **pColumns);
14749 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14750 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14751 + ConnectionSettings *pSettings,
14752 + const rtl::OUString &schemaName,
14753 + const rtl::OUString &tableName);
14756 + virtual ~Columns();
14758 +public: // XAppend
14759 + virtual void SAL_CALL appendByDescriptor(
14760 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
14761 + throw (::com::sun::star::sdbc::SQLException,
14762 + ::com::sun::star::container::ElementExistException,
14763 + ::com::sun::star::uno::RuntimeException);
14765 +// public: // XDrop
14766 +// virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
14767 +// throw (::com::sun::star::sdbc::SQLException,
14768 +// ::com::sun::star::container::NoSuchElementException,
14769 +// ::com::sun::star::uno::RuntimeException);
14770 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
14771 + throw (::com::sun::star::sdbc::SQLException,
14772 + ::com::sun::star::lang::IndexOutOfBoundsException,
14773 + ::com::sun::star::uno::RuntimeException);
14775 +public: // XRefreshable
14776 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
14778 +public: // XDataDescriptorFactory
14779 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
14780 + throw (::com::sun::star::uno::RuntimeException);
14784 +class ColumnDescriptors : public Container
14787 + ColumnDescriptors(
14788 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14789 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14790 + ConnectionSettings *pSettings );
14792 +public: // XDataDescriptorFactory
14793 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
14794 + throw (::com::sun::star::uno::RuntimeException);
14799 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
14800 +++ connectivity/source/drivers/postgresql/pq_xcontainer.cxx 2007-01-07 14:50:38.000000000 +0100
14802 +/*************************************************************************
14804 + * $RCSfile: pq_xcontainer.cxx,v $
14806 + * $Revision: 1.1.2.5 $
14808 + * last change: $Author: jbu $ $Date: 2007/01/07 13:50:38 $
14810 + * The Contents of this file are made available subject to the terms of
14811 + * either of the following licenses
14813 + * - GNU Lesser General Public License Version 2.1
14814 + * - Sun Industry Standards Source License Version 1.1
14816 + * Sun Microsystems Inc., October, 2000
14818 + * GNU Lesser General Public License Version 2.1
14819 + * =============================================
14820 + * Copyright 2000 by Sun Microsystems, Inc.
14821 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
14823 + * This library is free software; you can redistribute it and/or
14824 + * modify it under the terms of the GNU Lesser General Public
14825 + * License version 2.1, as published by the Free Software Foundation.
14827 + * This library is distributed in the hope that it will be useful,
14828 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14829 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14830 + * Lesser General Public License for more details.
14832 + * You should have received a copy of the GNU Lesser General Public
14833 + * License along with this library; if not, write to the Free Software
14834 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
14835 + * MA 02111-1307 USA
14838 + * Sun Industry Standards Source License Version 1.1
14839 + * =================================================
14840 + * The contents of this file are subject to the Sun Industry Standards
14841 + * Source License Version 1.1 (the "License"); You may not use this file
14842 + * except in compliance with the License. You may obtain a copy of the
14843 + * License at http://www.openoffice.org/license.html.
14845 + * Software provided under this License is provided on an "AS IS" basis,
14846 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
14847 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
14848 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
14849 + * See the License for the specific provisions governing your rights and
14850 + * obligations concerning the Software.
14852 + * The Initial Developer of the Original Code is: Joerg Budischewski
14854 + * Copyright: 2000 by Sun Microsystems, Inc.
14856 + * All Rights Reserved.
14858 + * Contributor(s): Joerg Budischewski
14861 + ************************************************************************/
14863 +#include <rtl/ustrbuf.hxx>
14865 +#include <com/sun/star/sdbc/XRow.hpp>
14866 +#include <com/sun/star/sdbc/XParameters.hpp>
14869 +#include <cppuhelper/implbase1.hxx>
14871 +#include "pq_xcontainer.hxx"
14872 +#include "pq_statics.hxx"
14873 +#include "pq_tools.hxx"
14875 +using osl::MutexGuard;
14877 +using rtl::OUString;
14878 +using rtl::OUStringBuffer;
14879 +using rtl::OUStringToOString;
14881 +using com::sun::star::beans::XPropertySet;
14883 +using com::sun::star::uno::Any;
14884 +using com::sun::star::uno::makeAny;
14885 +using com::sun::star::uno::UNO_QUERY;
14886 +using com::sun::star::uno::Type;
14887 +using com::sun::star::uno::XInterface;
14888 +using com::sun::star::uno::Reference;
14889 +using com::sun::star::uno::Sequence;
14890 +using com::sun::star::uno::RuntimeException;
14892 +using com::sun::star::container::NoSuchElementException;
14893 +using com::sun::star::container::XEnumeration;
14894 +using com::sun::star::container::XContainerListener;
14895 +using com::sun::star::container::ContainerEvent;
14896 +using com::sun::star::lang::IndexOutOfBoundsException;
14897 +using com::sun::star::lang::XEventListener;
14899 +using com::sun::star::lang::WrappedTargetException;
14901 +using com::sun::star::sdbc::XRow;
14902 +using com::sun::star::sdbc::XCloseable;
14903 +using com::sun::star::sdbc::XStatement;
14904 +using com::sun::star::sdbc::XResultSet;
14905 +using com::sun::star::sdbc::XParameters;
14906 +using com::sun::star::sdbc::XPreparedStatement;
14907 +using com::sun::star::sdbcx::XDataDescriptorFactory;
14909 +namespace pq_sdbc_driver
14911 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
14914 +class ReplacedBroadcaster : public EventBroadcastHelper
14916 + ContainerEvent m_event;
14918 + ReplacedBroadcaster(
14919 + const Reference< XInterface > & source,
14920 + const rtl::OUString & name,
14921 + const Any & newElement,
14922 + const rtl::OUString & oldElement ) :
14923 + m_event( source, makeAny( name ), newElement, makeAny(oldElement) )
14926 + virtual void fire( XEventListener * listener ) const
14928 + ((XContainerListener*)listener)->elementReplaced( m_event );
14930 + virtual Type getType() const
14932 + return getCppuType( (Reference< XContainerListener > *)0 );
14936 +class InsertedBroadcaster : public EventBroadcastHelper
14939 + ContainerEvent m_event;
14940 + InsertedBroadcaster(
14941 + const Reference< XInterface > & source,
14942 + const rtl::OUString & name,
14943 + const Any & newElement ) :
14944 + m_event( source, makeAny( name ), newElement, Any() )
14947 + virtual void fire( XEventListener * listener ) const
14949 + ((XContainerListener*)listener)->elementInserted( m_event );
14952 + virtual Type getType() const
14954 + return getCppuType( (Reference< XContainerListener > *)0 );
14958 +class RemovedBroadcaster : public EventBroadcastHelper
14961 + ContainerEvent m_event;
14962 + RemovedBroadcaster(
14963 + const Reference< XInterface > & source,
14964 + const rtl::OUString & name) :
14965 + m_event( source, makeAny( name ), Any(), Any() )
14968 + virtual void fire( XEventListener * listener ) const
14970 + ((XContainerListener*)listener)->elementRemoved( m_event );
14973 + virtual Type getType() const
14975 + return getCppuType( (Reference< XContainerListener > *)0 );
14979 +Container::Container(
14980 + const ::rtl::Reference< RefCountedMutex > & refMutex,
14981 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
14982 + ConnectionSettings *pSettings,
14983 + const ::rtl::OUString &type)
14984 + : ContainerBase( refMutex->mutex ),
14985 + m_refMutex( refMutex ),
14986 + m_pSettings( pSettings ),
14987 + m_origin( origin ),
14992 +Any Container::getByName( const ::rtl::OUString& aName )
14993 + throw (NoSuchElementException,WrappedTargetException,RuntimeException)
14995 + String2IntMap::const_iterator ii = m_name2index.find( aName );
14996 + if( ii == m_name2index.end() )
14998 + OUStringBuffer buf(128);
14999 + buf.appendAscii( "Element " );
15000 + buf.append( aName );
15001 + buf.appendAscii( " unknown in " );
15002 + buf.append( m_type );
15003 + buf.appendAscii( "-Container" );
15004 + throw NoSuchElementException( buf.makeStringAndClear() , *this );
15006 + OSL_ASSERT( ii->second >= 0 && ii->second < m_values.getLength() );
15007 + return m_values[ ii->second ];
15010 +Sequence< OUString > Container::getElementNames( )
15011 + throw (::com::sun::star::uno::RuntimeException)
15013 + Sequence< OUString > ret( m_values.getLength() );
15014 + for( String2IntMap::const_iterator ii = m_name2index.begin();
15015 + ii != m_name2index.end() ;
15018 + // give element names in index order !
15019 + ret[ii->second] = ii->first;
15020 +// ret[i] = ii->first;
15025 +sal_Bool Container::hasByName( const ::rtl::OUString& aName )
15026 + throw (::com::sun::star::uno::RuntimeException)
15028 + return m_name2index.find( aName ) != m_name2index.end();
15031 +Type Container::getElementType( )
15032 + throw (::com::sun::star::uno::RuntimeException)
15037 +sal_Bool Container::hasElements( )
15038 + throw (::com::sun::star::uno::RuntimeException)
15040 + return ! m_name2index.empty();
15043 +Any Container::getByIndex( sal_Int32 Index )
15044 + throw (::com::sun::star::lang::IndexOutOfBoundsException,
15045 + ::com::sun::star::lang::WrappedTargetException,
15046 + ::com::sun::star::uno::RuntimeException)
15048 + if( Index < 0 || Index >= m_values.getLength() )
15050 + OUStringBuffer buf(128);
15051 + buf.appendAscii( "Index " );
15052 + buf.append( Index );
15053 + buf.appendAscii(" out of range for " );
15054 + buf.append( m_type );
15055 + buf.appendAscii("-Container, expected 0 <= x <= " );
15056 + buf.append( (sal_Int32 ) (m_values.getLength() -1));
15057 + throw IndexOutOfBoundsException( buf.makeStringAndClear(), *this );
15059 + return m_values[Index];
15062 +sal_Int32 Container::getCount()
15063 + throw (::com::sun::star::uno::RuntimeException)
15065 + return m_values.getLength();
15069 +class ContainerEnumeration : public ::cppu::WeakImplHelper1< XEnumeration >
15071 + com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_vec;
15072 + sal_Int32 m_index;
15074 + ContainerEnumeration( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > &vec )
15081 + virtual sal_Bool SAL_CALL hasMoreElements( )
15082 + throw (::com::sun::star::uno::RuntimeException);
15083 + virtual ::com::sun::star::uno::Any SAL_CALL nextElement( )
15084 + throw (::com::sun::star::container::NoSuchElementException,
15085 + ::com::sun::star::lang::WrappedTargetException,
15086 + ::com::sun::star::uno::RuntimeException);
15090 +sal_Bool ContainerEnumeration::hasMoreElements()
15091 + throw (::com::sun::star::uno::RuntimeException)
15093 + return m_vec.getLength() > m_index +1;
15096 +com::sun::star::uno::Any ContainerEnumeration::nextElement()
15097 + throw (::com::sun::star::container::NoSuchElementException,
15098 + ::com::sun::star::lang::WrappedTargetException,
15099 + ::com::sun::star::uno::RuntimeException)
15101 + if( ! hasMoreElements() )
15103 + throw NoSuchElementException(
15104 + ASCII_STR( "NoSuchElementException during enumeration" ), *this );
15107 + return m_vec[m_index];
15110 +Reference< XEnumeration > Container::createEnumeration( )
15111 + throw (::com::sun::star::uno::RuntimeException)
15113 + return new ContainerEnumeration( m_values );
15116 +void Container::addRefreshListener(
15117 + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
15118 + throw (::com::sun::star::uno::RuntimeException)
15120 + rBHelper.addListener( getCppuType(&l) , l );
15123 +void Container::removeRefreshListener(
15124 + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
15125 + throw (::com::sun::star::uno::RuntimeException)
15127 + rBHelper.removeListener( getCppuType(&l) , l );
15130 +void Container::disposing()
15132 + m_origin.clear();
15135 +void Container::rename( const rtl::OUString &oldName, const rtl::OUString &newName )
15139 + osl::MutexGuard guard ( m_refMutex->mutex );
15140 + String2IntMap::iterator ii = m_name2index.find( oldName );
15141 + if( ii != m_name2index.end() )
15143 + sal_Int32 nIndex = ii->second;
15144 + newValue = m_values[nIndex];
15145 + m_name2index.erase( ii );
15146 + m_name2index[ newName ] = nIndex;
15147 + newValue = m_values[nIndex];
15150 + fire( ReplacedBroadcaster( *this, newName, newValue, oldName ) );
15151 + fire( RefreshedBroadcaster( *this ) );
15154 +void Container::dropByName( const ::rtl::OUString& elementName )
15155 + throw (::com::sun::star::sdbc::SQLException,
15156 + ::com::sun::star::container::NoSuchElementException,
15157 + ::com::sun::star::uno::RuntimeException)
15159 + osl::MutexGuard guard( m_refMutex->mutex );
15160 + String2IntMap::const_iterator ii = m_name2index.find( elementName );
15161 + if( ii == m_name2index.end() )
15163 + OUStringBuffer buf( 128 );
15164 + buf.appendAscii( "Column " );
15165 + buf.append( elementName );
15166 + buf.appendAscii( " is unknown in " );
15167 + buf.append( m_type );
15168 +// buf.appendAscii( " " );
15169 +// buf.append( m_schemaName );
15170 +// buf.appendAscii( "." );
15171 +// buf.append( m_tableName );
15172 + buf.appendAscii( " container, so it can't be dropped" );
15173 + throw com::sun::star::container::NoSuchElementException(
15174 + buf.makeStringAndClear(), *this );
15176 + dropByIndex( ii->second );
15179 +void Container::dropByIndex( sal_Int32 index )
15180 + throw (::com::sun::star::sdbc::SQLException,
15181 + ::com::sun::star::lang::IndexOutOfBoundsException,
15182 + ::com::sun::star::uno::RuntimeException)
15184 + osl::MutexGuard guard( m_refMutex->mutex );
15185 + if( index < 0 || index >= m_values.getLength() )
15187 + OUStringBuffer buf( 128 );
15188 + buf.appendAscii( "Index out of range (allowed 0 to " );
15189 + buf.append((sal_Int32)(m_values.getLength() -1) );
15190 + buf.appendAscii( ", got " );
15191 + buf.append( index );
15192 + buf.appendAscii( ") in " );
15193 + buf.append( m_type );
15194 + throw com::sun::star::lang::IndexOutOfBoundsException(
15195 + buf.makeStringAndClear(), *this );
15199 + for( String2IntMap::iterator ii = m_name2index.begin() ;
15200 + ii != m_name2index.end() ;
15203 + if( ii->second == index )
15205 + name = ii->first;
15206 + m_name2index.erase( ii );
15211 + Any oldElement = m_values[index];
15212 + for( int i = index +1 ; i < m_values.getLength() ; i ++ )
15214 + m_values[i-1] = m_values[i];
15216 + // I know, this is expensive, but don't want to maintain another map ...
15217 + for( String2IntMap::iterator ii = m_name2index.begin() ;
15218 + ii != m_name2index.end() ;
15221 + if( ii->second == i )
15223 + ii->second = i-1;
15228 + m_values.realloc( m_values.getLength() - 1 );
15230 + fire( RemovedBroadcaster( *this, name ) );
15233 +void Container::append(
15234 + const rtl::OUString & name,
15235 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
15236 + throw ( ::com::sun::star::container::ElementExistException )
15239 + osl::MutexGuard guard( m_refMutex->mutex );
15241 + if( hasByName( name ) )
15243 + OUStringBuffer buf( 128 );
15244 + buf.appendAscii( "a ");
15245 + buf.append( m_type );
15246 + buf.appendAscii( " with name " );
15247 + buf.append( name );
15248 + buf.appendAscii( " already exists in this container" );
15249 + throw com::sun::star::container::ElementExistException(
15250 + buf.makeStringAndClear() , *this );
15253 + int index = m_values.getLength();
15254 + m_values.realloc( m_values.getLength() + 1 );
15255 + m_values[index] = makeAny( descriptor );
15256 + m_name2index[name] = index;
15258 + fire( InsertedBroadcaster( *this, name, makeAny( descriptor ) ) );
15261 +void Container::appendByDescriptor(
15262 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor)
15263 + throw (::com::sun::star::sdbc::SQLException,
15264 + ::com::sun::star::container::ElementExistException,
15265 + ::com::sun::star::uno::RuntimeException)
15267 + append( extractStringProperty( descriptor, getStatics().NAME ), descriptor );
15271 +void Container::addContainerListener(
15272 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l )
15273 + throw (::com::sun::star::uno::RuntimeException)
15275 + rBHelper.addListener( getCppuType(&l) , l );
15278 +void Container::removeContainerListener(
15279 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& l )
15280 + throw (::com::sun::star::uno::RuntimeException)
15282 + rBHelper.removeListener( getCppuType(&l) , l );
15286 +void Container::fire( const EventBroadcastHelper &helper )
15288 + Reference< ::com::sun::star::util::XRefreshListener > l;
15289 + cppu::OInterfaceContainerHelper *container = rBHelper.getContainer( helper.getType() );
15292 + cppu::OInterfaceIteratorHelper iterator( * container );
15293 + while( iterator.hasMoreElements() )
15297 + helper.fire( (XEventListener * ) iterator.next() );
15299 + catch ( com::sun::star::uno::RuntimeException & e )
15301 + OSL_ENSURE( 0, "exception catched" );
15302 + // loose coupling, a runtime exception shall not break anything
15303 + // TODO: log away as warning !
15305 + catch( com::sun::star::uno::Exception & e )
15307 + OSL_ENSURE( 0, "exception from listener flying through" );
15316 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
15317 +++ connectivity/source/drivers/postgresql/pq_xcontainer.hxx 2007-01-07 14:50:38.000000000 +0100
15319 +/*************************************************************************
15321 + * $RCSfile: pq_xcontainer.hxx,v $
15323 + * $Revision: 1.1.2.4 $
15325 + * last change: $Author: jbu $ $Date: 2007/01/07 13:50:38 $
15327 + * The Contents of this file are made available subject to the terms of
15328 + * either of the following licenses
15330 + * - GNU Lesser General Public License Version 2.1
15331 + * - Sun Industry Standards Source License Version 1.1
15333 + * Sun Microsystems Inc., October, 2000
15335 + * GNU Lesser General Public License Version 2.1
15336 + * =============================================
15337 + * Copyright 2000 by Sun Microsystems, Inc.
15338 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
15340 + * This library is free software; you can redistribute it and/or
15341 + * modify it under the terms of the GNU Lesser General Public
15342 + * License version 2.1, as published by the Free Software Foundation.
15344 + * This library is distributed in the hope that it will be useful,
15345 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15346 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15347 + * Lesser General Public License for more details.
15349 + * You should have received a copy of the GNU Lesser General Public
15350 + * License along with this library; if not, write to the Free Software
15351 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15352 + * MA 02111-1307 USA
15355 + * Sun Industry Standards Source License Version 1.1
15356 + * =================================================
15357 + * The contents of this file are subject to the Sun Industry Standards
15358 + * Source License Version 1.1 (the "License"); You may not use this file
15359 + * except in compliance with the License. You may obtain a copy of the
15360 + * License at http://www.openoffice.org/license.html.
15362 + * Software provided under this License is provided on an "AS IS" basis,
15363 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
15364 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
15365 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
15366 + * See the License for the specific provisions governing your rights and
15367 + * obligations concerning the Software.
15369 + * The Initial Developer of the Original Code is: Joerg Budischewski
15371 + * Copyright: 2000 by Sun Microsystems, Inc.
15373 + * All Rights Reserved.
15375 + * Contributor(s): Joerg Budischewski
15378 + ************************************************************************/
15380 +#ifndef _PQ_CONTAINER_HXX_
15381 +#define _PQ_CONTAINER_HXX_
15382 +#include <hash_map>
15385 +#include <com/sun/star/container/XNameAccess.hpp>
15386 +#include <com/sun/star/container/XIndexAccess.hpp>
15387 +#include <com/sun/star/container/XEnumerationAccess.hpp>
15388 +#include <com/sun/star/container/XContainer.hpp>
15390 +#include <com/sun/star/sdbcx/XAppend.hpp>
15391 +#include <com/sun/star/sdbcx/XDrop.hpp>
15392 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
15394 +#include <com/sun/star/util/XRefreshable.hpp>
15396 +#include <cppuhelper/compbase8.hxx>
15398 +#include "pq_connection.hxx"
15399 +#include "pq_statics.hxx"
15401 +namespace pq_sdbc_driver
15404 +class EventBroadcastHelper
15407 + virtual void fire(com::sun::star::lang::XEventListener * listener) const = 0;
15408 + virtual com::sun::star::uno::Type getType() const = 0;
15409 + virtual ~EventBroadcastHelper(){};
15412 +class RefreshedBroadcaster : public EventBroadcastHelper
15414 + com::sun::star::lang::EventObject m_event;
15416 + RefreshedBroadcaster(const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & source ) :
15417 + m_event( source )
15420 + virtual void fire( com::sun::star::lang::XEventListener * listener ) const
15422 + ((com::sun::star::util::XRefreshListener*)listener)->refreshed( m_event );
15425 + virtual com::sun::star::uno::Type getType() const
15427 + return getCppuType(
15428 + (com::sun::star::uno::Reference< com::sun::star::util::XRefreshListener > *)0 );
15432 +typedef ::std::hash_map
15436 + rtl::OUStringHash,
15437 + ::std::equal_to< rtl::OUString >,
15438 + Allocator< ::std::pair< const ::rtl::OUString , sal_Int32 > >
15441 +typedef ::cppu::WeakComponentImplHelper8
15443 + com::sun::star::container::XNameAccess,
15444 + com::sun::star::container::XIndexAccess,
15445 + com::sun::star::container::XEnumerationAccess,
15446 + com::sun::star::sdbcx::XAppend,
15447 + com::sun::star::sdbcx::XDrop,
15448 + com::sun::star::util::XRefreshable,
15449 + com::sun::star::sdbcx::XDataDescriptorFactory,
15450 + com::sun::star::container::XContainer
15453 +class /* abstract */ Container : public ContainerBase
15456 + ::rtl::Reference< RefCountedMutex > m_refMutex;
15457 + ConnectionSettings *m_pSettings;
15458 + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_origin;
15459 + String2IntMap m_name2index; // maps the element name to an index
15460 + ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values; // contains the real values
15461 + ::rtl::OUString m_type;
15465 + const ::rtl::Reference< RefCountedMutex > & refMutex,
15466 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
15467 + ConnectionSettings *pSettings,
15468 + const ::rtl::OUString & type // for exception messages
15471 +public: // XIndexAccess
15472 + virtual sal_Int32 SAL_CALL getCount( )
15473 + throw (::com::sun::star::uno::RuntimeException);
15474 + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
15475 + throw (::com::sun::star::lang::IndexOutOfBoundsException,
15476 + ::com::sun::star::lang::WrappedTargetException,
15477 + ::com::sun::star::uno::RuntimeException);
15479 +public: // XEnumerationAccess
15480 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
15481 + SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException);
15483 +public: // XNameAccess
15484 + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
15485 + throw (::com::sun::star::container::NoSuchElementException,
15486 + ::com::sun::star::lang::WrappedTargetException,
15487 + ::com::sun::star::uno::RuntimeException);
15488 + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
15489 + throw (::com::sun::star::uno::RuntimeException);
15490 + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
15491 + throw (::com::sun::star::uno::RuntimeException);
15493 + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
15494 + throw (::com::sun::star::uno::RuntimeException);
15495 + virtual sal_Bool SAL_CALL hasElements( )
15496 + throw (::com::sun::star::uno::RuntimeException);
15499 +public: // XAppend
15500 + // Must be overriden in Non-Descriptors. May be overriden in descriptors, when
15501 + // PropertySet.NAME != container name
15502 + virtual void SAL_CALL appendByDescriptor(
15503 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
15504 + throw (::com::sun::star::sdbc::SQLException,
15505 + ::com::sun::star::container::ElementExistException,
15506 + ::com::sun::star::uno::RuntimeException);
15508 + // helper method !
15510 + const rtl::OUString & str,
15511 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
15512 + throw ( ::com::sun::star::container::ElementExistException );
15516 + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
15517 + throw (::com::sun::star::sdbc::SQLException,
15518 + ::com::sun::star::container::NoSuchElementException,
15519 + ::com::sun::star::uno::RuntimeException);
15520 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
15521 + throw (::com::sun::star::sdbc::SQLException,
15522 + ::com::sun::star::lang::IndexOutOfBoundsException,
15523 + ::com::sun::star::uno::RuntimeException);
15525 +public: // XDataDescriptorFactory
15526 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
15527 + throw (::com::sun::star::uno::RuntimeException) = 0;
15529 +public: // XRefreshable
15530 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException) {}
15531 + virtual void SAL_CALL addRefreshListener(
15532 + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
15533 + throw (::com::sun::star::uno::RuntimeException);
15534 + virtual void SAL_CALL removeRefreshListener(
15535 + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l )
15536 + throw (::com::sun::star::uno::RuntimeException);
15540 + virtual void SAL_CALL addContainerListener(
15541 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
15542 + throw (::com::sun::star::uno::RuntimeException);
15543 + virtual void SAL_CALL removeContainerListener(
15544 + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
15545 + throw (::com::sun::star::uno::RuntimeException);
15548 + virtual void SAL_CALL disposing();
15551 + void rename( const rtl::OUString & oldName, const rtl::OUString &newName );
15554 + void fire( const EventBroadcastHelper & helper );
15559 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
15560 +++ connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx 2004-06-10 17:27:03.000000000 +0200
15562 +/*************************************************************************
15564 + * $RCSfile: pq_xindexcolumn.cxx,v $
15566 + * $Revision: 1.1.2.1 $
15568 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:03 $
15570 + * The Contents of this file are made available subject to the terms of
15571 + * either of the following licenses
15573 + * - GNU Lesser General Public License Version 2.1
15574 + * - Sun Industry Standards Source License Version 1.1
15576 + * Sun Microsystems Inc., October, 2000
15578 + * GNU Lesser General Public License Version 2.1
15579 + * =============================================
15580 + * Copyright 2000 by Sun Microsystems, Inc.
15581 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
15583 + * This library is free software; you can redistribute it and/or
15584 + * modify it under the terms of the GNU Lesser General Public
15585 + * License version 2.1, as published by the Free Software Foundation.
15587 + * This library is distributed in the hope that it will be useful,
15588 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15589 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15590 + * Lesser General Public License for more details.
15592 + * You should have received a copy of the GNU Lesser General Public
15593 + * License along with this library; if not, write to the Free Software
15594 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15595 + * MA 02111-1307 USA
15598 + * Sun Industry Standards Source License Version 1.1
15599 + * =================================================
15600 + * The contents of this file are subject to the Sun Industry Standards
15601 + * Source License Version 1.1 (the "License"); You may not use this file
15602 + * except in compliance with the License. You may obtain a copy of the
15603 + * License at http://www.openoffice.org/license.html.
15605 + * Software provided under this License is provided on an "AS IS" basis,
15606 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
15607 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
15608 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
15609 + * See the License for the specific provisions governing your rights and
15610 + * obligations concerning the Software.
15612 + * The Initial Developer of the Original Code is: Joerg Budischewski
15614 + * Copyright: 2000 by Sun Microsystems, Inc.
15616 + * All Rights Reserved.
15618 + * Contributor(s): Joerg Budischewski
15621 + ************************************************************************/
15623 +#include <cppuhelper/typeprovider.hxx>
15625 +#include "pq_xindexcolumn.hxx"
15627 +using com::sun::star::uno::Any;
15628 +using com::sun::star::uno::Reference;
15629 +using com::sun::star::uno::RuntimeException;
15630 +using com::sun::star::uno::Type;
15631 +using com::sun::star::uno::Sequence;
15633 +using com::sun::star::beans::XPropertySet;
15635 +namespace pq_sdbc_driver
15637 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
15639 +IndexColumn::IndexColumn( const ::rtl::Reference< RefCountedMutex > & refMutex,
15640 + const Reference< com::sun::star::sdbc::XConnection > & connection,
15641 + ConnectionSettings *pSettings )
15642 + : ReflectionBase(
15643 + getStatics().refl.indexColumn.implName,
15644 + getStatics().refl.indexColumn.serviceNames,
15648 + * getStatics().refl.indexColumn.pProps )
15651 +Reference< XPropertySet > IndexColumn::createDataDescriptor( ) throw (RuntimeException)
15653 + IndexColumnDescriptor * pIndexColumn = new IndexColumnDescriptor(
15654 + m_refMutex, m_conn, m_pSettings );
15655 + pIndexColumn->copyValuesFrom( this );
15657 + return Reference< XPropertySet > ( pIndexColumn );
15661 +IndexColumnDescriptor::IndexColumnDescriptor(
15662 + const ::rtl::Reference< RefCountedMutex > & refMutex,
15663 + const Reference< com::sun::star::sdbc::XConnection > & connection,
15664 + ConnectionSettings *pSettings )
15665 + : ReflectionBase(
15666 + getStatics().refl.indexColumnDescriptor.implName,
15667 + getStatics().refl.indexColumnDescriptor.serviceNames,
15671 + * getStatics().refl.indexColumnDescriptor.pProps )
15674 +Reference< XPropertySet > IndexColumnDescriptor::createDataDescriptor( ) throw (RuntimeException)
15676 + IndexColumnDescriptor * pIndexColumn = new IndexColumnDescriptor(
15677 + m_refMutex, m_conn, m_pSettings );
15678 + pIndexColumn->copyValuesFrom( this );
15680 + return Reference< XPropertySet > ( pIndexColumn );
15684 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
15685 +++ connectivity/source/drivers/postgresql/pq_xindexcolumn.hxx 2004-06-10 17:27:04.000000000 +0200
15687 +/*************************************************************************
15689 + * $RCSfile: pq_xindexcolumn.hxx,v $
15691 + * $Revision: 1.1.2.1 $
15693 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:04 $
15695 + * The Contents of this file are made available subject to the terms of
15696 + * either of the following licenses
15698 + * - GNU Lesser General Public License Version 2.1
15699 + * - Sun Industry Standards Source License Version 1.1
15701 + * Sun Microsystems Inc., October, 2000
15703 + * GNU Lesser General Public License Version 2.1
15704 + * =============================================
15705 + * Copyright 2000 by Sun Microsystems, Inc.
15706 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
15708 + * This library is free software; you can redistribute it and/or
15709 + * modify it under the terms of the GNU Lesser General Public
15710 + * License version 2.1, as published by the Free Software Foundation.
15712 + * This library is distributed in the hope that it will be useful,
15713 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15714 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15715 + * Lesser General Public License for more details.
15717 + * You should have received a copy of the GNU Lesser General Public
15718 + * License along with this library; if not, write to the Free Software
15719 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15720 + * MA 02111-1307 USA
15723 + * Sun Industry Standards Source License Version 1.1
15724 + * =================================================
15725 + * The contents of this file are subject to the Sun Industry Standards
15726 + * Source License Version 1.1 (the "License"); You may not use this file
15727 + * except in compliance with the License. You may obtain a copy of the
15728 + * License at http://www.openoffice.org/license.html.
15730 + * Software provided under this License is provided on an "AS IS" basis,
15731 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
15732 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
15733 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
15734 + * See the License for the specific provisions governing your rights and
15735 + * obligations concerning the Software.
15737 + * The Initial Developer of the Original Code is: Joerg Budischewski
15739 + * Copyright: 2000 by Sun Microsystems, Inc.
15741 + * All Rights Reserved.
15743 + * Contributor(s): Joerg Budischewski
15746 + ************************************************************************/
15748 +#ifndef HEADER_PQ_INDEXCOLUMN_HXX
15749 +#define HEADER_PQ_INDEXCOLUMN_HXX
15751 +#include <cppuhelper/component.hxx>
15752 +#include <cppuhelper/propshlp.hxx>
15754 +#include <com/sun/star/lang/XServiceInfo.hpp>
15755 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
15757 +#include "pq_connection.hxx"
15758 +#include "pq_xbase.hxx"
15760 +namespace pq_sdbc_driver
15763 +class IndexColumn : public ReflectionBase
15767 + const ::rtl::Reference< RefCountedMutex > & refMutex,
15768 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
15769 + ConnectionSettings *pSettings);
15771 +public: // XDataDescriptorFactory
15772 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
15773 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
15777 +class IndexColumnDescriptor : public ReflectionBase
15780 + IndexColumnDescriptor(
15781 + const ::rtl::Reference< RefCountedMutex > & refMutex,
15782 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
15783 + ConnectionSettings *pSettings);
15785 +public: // XDataDescriptorFactory
15786 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
15787 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
15796 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
15797 +++ connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx 2004-08-29 10:33:31.000000000 +0200
15799 +/*************************************************************************
15801 + * $RCSfile: pq_xindexcolumns.cxx,v $
15803 + * $Revision: 1.1.2.2 $
15805 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:31 $
15807 + * The Contents of this file are made available subject to the terms of
15808 + * either of the following licenses
15810 + * - GNU Lesser General Public License Version 2.1
15811 + * - Sun Industry Standards Source License Version 1.1
15813 + * Sun Microsystems Inc., October, 2000
15815 + * GNU Lesser General Public License Version 2.1
15816 + * =============================================
15817 + * Copyright 2000 by Sun Microsystems, Inc.
15818 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
15820 + * This library is free software; you can redistribute it and/or
15821 + * modify it under the terms of the GNU Lesser General Public
15822 + * License version 2.1, as published by the Free Software Foundation.
15824 + * This library is distributed in the hope that it will be useful,
15825 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15826 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15827 + * Lesser General Public License for more details.
15829 + * You should have received a copy of the GNU Lesser General Public
15830 + * License along with this library; if not, write to the Free Software
15831 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15832 + * MA 02111-1307 USA
15835 + * Sun Industry Standards Source License Version 1.1
15836 + * =================================================
15837 + * The contents of this file are subject to the Sun Industry Standards
15838 + * Source License Version 1.1 (the "License"); You may not use this file
15839 + * except in compliance with the License. You may obtain a copy of the
15840 + * License at http://www.openoffice.org/license.html.
15842 + * Software provided under this License is provided on an "AS IS" basis,
15843 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
15844 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
15845 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
15846 + * See the License for the specific provisions governing your rights and
15847 + * obligations concerning the Software.
15849 + * The Initial Developer of the Original Code is: Joerg Budischewski
15851 + * Copyright: 2000 by Sun Microsystems, Inc.
15853 + * All Rights Reserved.
15855 + * Contributor(s): Joerg Budischewski
15858 + ************************************************************************/
15862 +#include <rtl/ustrbuf.hxx>
15863 +#include <rtl/strbuf.hxx>
15865 +#include <com/sun/star/sdbc/XRow.hpp>
15866 +#include <com/sun/star/sdbc/XParameters.hpp>
15867 +#include <com/sun/star/sdbc/DataType.hpp>
15868 +#include <com/sun/star/sdbc/ColumnValue.hpp>
15870 +#include "pq_xcolumns.hxx"
15871 +#include "pq_xindexcolumns.hxx"
15872 +#include "pq_xindexcolumn.hxx"
15873 +#include "pq_statics.hxx"
15874 +#include "pq_tools.hxx"
15876 +using osl::MutexGuard;
15878 +using rtl::OUString;
15879 +using rtl::OUStringBuffer;
15880 +using rtl::OUStringToOString;
15882 +using com::sun::star::beans::XPropertySet;
15884 +using com::sun::star::uno::Any;
15885 +using com::sun::star::uno::makeAny;
15886 +using com::sun::star::uno::UNO_QUERY;
15887 +using com::sun::star::uno::Type;
15888 +using com::sun::star::uno::XInterface;
15889 +using com::sun::star::uno::Reference;
15890 +using com::sun::star::uno::Sequence;
15891 +using com::sun::star::uno::RuntimeException;
15893 +using com::sun::star::container::NoSuchElementException;
15894 +using com::sun::star::lang::WrappedTargetException;
15896 +using com::sun::star::sdbc::XRow;
15897 +using com::sun::star::sdbc::XCloseable;
15898 +using com::sun::star::sdbc::XStatement;
15899 +using com::sun::star::sdbc::XResultSet;
15900 +using com::sun::star::sdbc::XParameters;
15901 +using com::sun::star::sdbc::XPreparedStatement;
15902 +using com::sun::star::sdbc::XDatabaseMetaData;
15903 +using com::sun::star::sdbc::SQLException;
15905 +namespace pq_sdbc_driver
15907 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
15909 +IndexColumns::IndexColumns(
15910 + const ::rtl::Reference< RefCountedMutex > & refMutex,
15911 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
15912 + ConnectionSettings *pSettings,
15913 + const rtl::OUString &schemaName,
15914 + const rtl::OUString &tableName,
15915 + const rtl::OUString &indexName,
15916 + const com::sun::star::uno::Sequence< rtl::OUString > &columns )
15917 + : Container( refMutex, origin, pSettings, ASCII_STR( "INDEX_COLUMN" ) ),
15918 + m_schemaName( schemaName ),
15919 + m_tableName( tableName ),
15920 + m_columns( columns ),
15921 + m_indexName( indexName )
15924 +IndexColumns::~IndexColumns()
15927 +static sal_Int32 findInSequence( const Sequence< rtl::OUString > & seq , const rtl::OUString &str)
15930 + for( index = 0 ; index < seq.getLength() ; index ++ )
15932 + if( str == seq[index] )
15938 +void IndexColumns::refresh()
15939 + throw (::com::sun::star::uno::RuntimeException)
15943 + if( isLog( m_pSettings, LogLevel::INFO ) )
15945 + rtl::OStringBuffer buf;
15946 + buf.append( "sdbcx.IndexColumns get refreshed for index " );
15947 + buf.append( OUStringToOString( m_indexName, m_pSettings->encoding ) );
15948 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
15951 + osl::MutexGuard guard( m_refMutex->mutex );
15953 + Statics &st = getStatics();
15954 + Reference< XDatabaseMetaData > meta = m_origin->getMetaData();
15956 + Reference< XResultSet > rs =
15957 + meta->getColumns( Any(), m_schemaName, m_tableName, st.cPERCENT );
15959 + DisposeGuard disposeIt( rs );
15960 + Reference< XRow > xRow( rs , UNO_QUERY );
15961 + m_values = Sequence< Any >( m_columns.getLength() );
15963 + while( rs->next() )
15965 + OUString columnName = xRow->getString( 4 );
15967 + sal_Int32 index = findInSequence( m_columns, columnName );
15968 + if( index >= m_columns.getLength() )
15971 + IndexColumn * pIndexColumn =
15972 + new IndexColumn( m_refMutex, m_origin, m_pSettings );
15973 + Reference< com::sun::star::beans::XPropertySet > prop = pIndexColumn;
15975 + columnMetaData2SDBCX( pIndexColumn, xRow );
15976 + pIndexColumn->setPropertyValue_NoBroadcast_public(
15977 + st.IS_ASCENDING , makeAny( (sal_Bool ) sal_False ) );
15979 + m_values[ index ] = makeAny( prop );
15980 + m_name2index[ columnName ] = index;
15983 + catch ( com::sun::star::sdbc::SQLException & e )
15985 + throw RuntimeException( e.Message , e.Context );
15988 + fire( RefreshedBroadcaster( *this ) );
15992 +void IndexColumns::appendByDescriptor(
15993 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& future )
15994 + throw (::com::sun::star::sdbc::SQLException,
15995 + ::com::sun::star::container::ElementExistException,
15996 + ::com::sun::star::uno::RuntimeException)
15998 + OUString name = extractStringProperty( future, getStatics().NAME );
15999 + throw com::sun::star::sdbc::SQLException(
16000 + ASCII_STR( "SDBC-POSTGRESQL: IndexesColumns.appendByDescriptor not yet implemented" ),
16001 + *this, OUString(), 1, Any() );
16002 +// osl::MutexGuard guard( m_refMutex->mutex );
16003 +// Statics & st = getStatics();
16004 +// Reference< XPropertySet > past = createDataDescriptor();
16005 +// past->setPropertyValue( st.IS_NULLABLE, makeAny( com::sun::star::sdbc::ColumnValue::NULLABLE ) );
16006 +// alterColumnByDescriptor(
16007 +// m_schemaName, m_tableName, m_pSettings->encoding, m_origin->createStatement() , past, future );
16011 +void IndexColumns::dropByName( const ::rtl::OUString& elementName )
16012 + throw (::com::sun::star::sdbc::SQLException,
16013 + ::com::sun::star::container::NoSuchElementException,
16014 + ::com::sun::star::uno::RuntimeException)
16016 + throw com::sun::star::sdbc::SQLException(
16017 + ASCII_STR( "SDBC-POSTGRESQL: IndexesColumns.dropByName not yet implemented" ),
16018 + *this, OUString(), 1, Any() );
16019 +// String2IntMap::const_iterator ii = m_name2index.find( elementName );
16020 +// if( ii == m_name2index.end() )
16022 +// OUStringBuffer buf( 128 );
16023 +// buf.appendAscii( "Column " );
16024 +// buf.append( elementName );
16025 +// buf.appendAscii( " is unknown in table " );
16026 +// buf.append( m_schemaName );
16027 +// buf.appendAscii( "." );
16028 +// buf.append( m_tableName );
16029 +// buf.appendAscii( ", so it can't be dropped" );
16030 +// throw com::sun::star::container::NoSuchElementException(
16031 +// buf.makeStringAndClear(), *this );
16033 +// dropByIndex( ii->second );
16036 +void IndexColumns::dropByIndex( sal_Int32 index )
16037 + throw (::com::sun::star::sdbc::SQLException,
16038 + ::com::sun::star::lang::IndexOutOfBoundsException,
16039 + ::com::sun::star::uno::RuntimeException)
16041 + throw com::sun::star::sdbc::SQLException(
16042 + ASCII_STR( "SDBC-POSTGRESQL: IndexesColumns.dropByIndex not yet implemented" ),
16043 + *this, OUString(), 1, Any() );
16044 +// osl::MutexGuard guard( m_refMutex->mutex );
16045 +// if( index < 0 || index >= m_values.getLength() )
16047 +// OUStringBuffer buf( 128 );
16048 +// buf.appendAscii( "COLUMNS: Index out of range (allowed 0 to " );
16049 +// buf.append((sal_Int32)(m_values.getLength() -1) );
16050 +// buf.appendAscii( ", got " );
16051 +// buf.append( index );
16052 +// buf.appendAscii( ")" );
16053 +// throw com::sun::star::lang::IndexOutOfBoundsException(
16054 +// buf.makeStringAndClear(), *this );
16057 +// Reference< XPropertySet > set;
16058 +// m_values[index] >>= set;
16059 +// Statics &st = getStatics();
16061 +// set->getPropertyValue( st.NAME ) >>= name;
16063 +// OUStringBuffer update( 128 );
16064 +// update.appendAscii( "ALTER TABLE ONLY");
16065 +// bufferQuoteQualifiedIdentifier( update, m_schemaName, m_tableName );
16066 +// update.appendAscii( "DROP COLUMN" );
16067 +// bufferQuoteIdentifier( update, name );
16068 +// Reference< XStatement > stmt = m_origin->createStatement( );
16069 +// DisposeGuard disposeIt( stmt );
16070 +// stmt->executeUpdate( update.makeStringAndClear() );
16075 +Reference< ::com::sun::star::beans::XPropertySet > IndexColumns::createDataDescriptor()
16076 + throw (::com::sun::star::uno::RuntimeException)
16078 + return new IndexColumnDescriptor( m_refMutex, m_origin, m_pSettings );
16081 +Reference< com::sun::star::container::XNameAccess > IndexColumns::create(
16082 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16083 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16084 + ConnectionSettings *pSettings,
16085 + const rtl::OUString &schemaName,
16086 + const rtl::OUString &tableName,
16087 + const rtl::OUString &indexName,
16088 + const Sequence< rtl::OUString > &columns )
16090 + IndexColumns *pIndexColumns = new IndexColumns(
16091 + refMutex, origin, pSettings, schemaName, tableName, indexName, columns );
16092 + Reference< com::sun::star::container::XNameAccess > ret = pIndexColumns;
16093 + pIndexColumns->refresh();
16098 +//_________________________________________________________________________________________
16099 +IndexColumnDescriptors::IndexColumnDescriptors(
16100 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16101 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16102 + ConnectionSettings *pSettings)
16103 + : Container( refMutex, origin, pSettings, getStatics().INDEX_COLUMN )
16106 +Reference< com::sun::star::container::XNameAccess > IndexColumnDescriptors::create(
16107 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16108 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16109 + ConnectionSettings *pSettings)
16111 + return new IndexColumnDescriptors( refMutex, origin, pSettings );
16114 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > IndexColumnDescriptors::createDataDescriptor()
16115 + throw (::com::sun::star::uno::RuntimeException)
16117 + return new IndexColumnDescriptor( m_refMutex, m_origin, m_pSettings );
16121 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
16122 +++ connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx 2004-06-10 17:27:05.000000000 +0200
16124 +/*************************************************************************
16126 + * $RCSfile: pq_xindexcolumns.hxx,v $
16128 + * $Revision: 1.1.2.1 $
16130 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:05 $
16132 + * The Contents of this file are made available subject to the terms of
16133 + * either of the following licenses
16135 + * - GNU Lesser General Public License Version 2.1
16136 + * - Sun Industry Standards Source License Version 1.1
16138 + * Sun Microsystems Inc., October, 2000
16140 + * GNU Lesser General Public License Version 2.1
16141 + * =============================================
16142 + * Copyright 2000 by Sun Microsystems, Inc.
16143 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
16145 + * This library is free software; you can redistribute it and/or
16146 + * modify it under the terms of the GNU Lesser General Public
16147 + * License version 2.1, as published by the Free Software Foundation.
16149 + * This library is distributed in the hope that it will be useful,
16150 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16151 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16152 + * Lesser General Public License for more details.
16154 + * You should have received a copy of the GNU Lesser General Public
16155 + * License along with this library; if not, write to the Free Software
16156 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16157 + * MA 02111-1307 USA
16160 + * Sun Industry Standards Source License Version 1.1
16161 + * =================================================
16162 + * The contents of this file are subject to the Sun Industry Standards
16163 + * Source License Version 1.1 (the "License"); You may not use this file
16164 + * except in compliance with the License. You may obtain a copy of the
16165 + * License at http://www.openoffice.org/license.html.
16167 + * Software provided under this License is provided on an "AS IS" basis,
16168 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
16169 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
16170 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
16171 + * See the License for the specific provisions governing your rights and
16172 + * obligations concerning the Software.
16174 + * The Initial Developer of the Original Code is: Joerg Budischewski
16176 + * Copyright: 2000 by Sun Microsystems, Inc.
16178 + * All Rights Reserved.
16180 + * Contributor(s): Joerg Budischewski
16183 + ************************************************************************/
16185 +#ifndef HEADER_PQ_INDEXCOLUMNS_HXX
16186 +#define HEADER_PQ_INDEXCOLUMNS_HXX
16188 +#include "pq_xcontainer.hxx"
16190 +namespace pq_sdbc_driver
16193 +class IndexColumns : public Container
16195 + rtl::OUString m_schemaName;
16196 + rtl::OUString m_tableName;
16197 + rtl::OUString m_indexName;
16198 + com::sun::star::uno::Sequence< rtl::OUString > m_columns;
16200 +public: // instances IndexColumns 'exception safe'
16201 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
16202 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16203 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16204 + ConnectionSettings *pSettings,
16205 + const rtl::OUString &schemaName,
16206 + const rtl::OUString &tableName,
16207 + const rtl::OUString &indexName,
16208 + const com::sun::star::uno::Sequence< ::rtl::OUString > &columns );
16212 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16213 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16214 + ConnectionSettings *pSettings,
16215 + const rtl::OUString &schemaName,
16216 + const rtl::OUString &tableName,
16217 + const rtl::OUString &indexName,
16218 + const com::sun::star::uno::Sequence< ::rtl::OUString > &columns );
16220 + virtual ~IndexColumns();
16222 +public: // XAppend
16223 + virtual void SAL_CALL appendByDescriptor(
16224 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
16225 + throw (::com::sun::star::sdbc::SQLException,
16226 + ::com::sun::star::container::ElementExistException,
16227 + ::com::sun::star::uno::RuntimeException);
16230 + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
16231 + throw (::com::sun::star::sdbc::SQLException,
16232 + ::com::sun::star::container::NoSuchElementException,
16233 + ::com::sun::star::uno::RuntimeException);
16234 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
16235 + throw (::com::sun::star::sdbc::SQLException,
16236 + ::com::sun::star::lang::IndexOutOfBoundsException,
16237 + ::com::sun::star::uno::RuntimeException);
16239 +public: // XRefreshable
16240 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
16242 +public: // XDataDescriptorFactory
16243 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
16244 + throw (::com::sun::star::uno::RuntimeException);
16248 +class IndexColumnDescriptors : public Container
16251 +public: // instances IndexColumns 'exception safe'
16252 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
16253 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16254 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16255 + ConnectionSettings *pSettings );
16258 + IndexColumnDescriptors(
16259 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16260 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16261 + ConnectionSettings *pSettings);
16263 +public: // XDataDescriptorFactory
16264 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
16265 + throw (::com::sun::star::uno::RuntimeException);
16270 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
16271 +++ connectivity/source/drivers/postgresql/pq_xindex.cxx 2004-06-10 17:27:01.000000000 +0200
16273 +/*************************************************************************
16275 + * $RCSfile: pq_xindex.cxx,v $
16277 + * $Revision: 1.1.2.1 $
16279 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:01 $
16281 + * The Contents of this file are made available subject to the terms of
16282 + * either of the following licenses
16284 + * - GNU Lesser General Public License Version 2.1
16285 + * - Sun Industry Standards Source License Version 1.1
16287 + * Sun Microsystems Inc., October, 2000
16289 + * GNU Lesser General Public License Version 2.1
16290 + * =============================================
16291 + * Copyright 2000 by Sun Microsystems, Inc.
16292 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
16294 + * This library is free software; you can redistribute it and/or
16295 + * modify it under the terms of the GNU Lesser General Public
16296 + * License version 2.1, as published by the Free Software Foundation.
16298 + * This library is distributed in the hope that it will be useful,
16299 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16300 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16301 + * Lesser General Public License for more details.
16303 + * You should have received a copy of the GNU Lesser General Public
16304 + * License along with this library; if not, write to the Free Software
16305 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16306 + * MA 02111-1307 USA
16309 + * Sun Industry Standards Source License Version 1.1
16310 + * =================================================
16311 + * The contents of this file are subject to the Sun Industry Standards
16312 + * Source License Version 1.1 (the "License"); You may not use this file
16313 + * except in compliance with the License. You may obtain a copy of the
16314 + * License at http://www.openoffice.org/license.html.
16316 + * Software provided under this License is provided on an "AS IS" basis,
16317 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
16318 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
16319 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
16320 + * See the License for the specific provisions governing your rights and
16321 + * obligations concerning the Software.
16323 + * The Initial Developer of the Original Code is: Joerg Budischewski
16325 + * Copyright: 2000 by Sun Microsystems, Inc.
16327 + * All Rights Reserved.
16329 + * Contributor(s): Joerg Budischewski
16332 + ************************************************************************/
16334 +#include <rtl/ustrbuf.hxx>
16336 +#include <cppuhelper/typeprovider.hxx>
16337 +#include <cppuhelper/queryinterface.hxx>
16339 +#include <com/sun/star/beans/PropertyAttribute.hpp>
16341 +#include <com/sun/star/sdbc/XRow.hpp>
16342 +#include <com/sun/star/sdbc/XParameters.hpp>
16344 +#include "pq_xindex.hxx"
16345 +#include "pq_xindexcolumns.hxx"
16346 +#include "pq_tools.hxx"
16347 +#include "pq_statics.hxx"
16349 +using osl::MutexGuard;
16352 +using rtl::OUString;
16353 +using rtl::OUStringBuffer;
16355 +using com::sun::star::container::XNameAccess;
16356 +using com::sun::star::container::XIndexAccess;
16357 +using com::sun::star::container::ElementExistException;
16358 +using com::sun::star::container::NoSuchElementException;
16360 +using com::sun::star::uno::Reference;
16361 +using com::sun::star::uno::Exception;
16362 +using com::sun::star::uno::UNO_QUERY;
16363 +using com::sun::star::uno::XInterface;
16364 +using com::sun::star::uno::Sequence;
16365 +using com::sun::star::uno::Any;
16366 +using com::sun::star::uno::makeAny;
16367 +using com::sun::star::uno::Type;
16368 +using com::sun::star::uno::RuntimeException;
16370 +using com::sun::star::lang::IllegalArgumentException;
16371 +using com::sun::star::lang::IndexOutOfBoundsException;
16373 +using com::sun::star::beans::XPropertySetInfo;
16374 +using com::sun::star::beans::XFastPropertySet;
16375 +using com::sun::star::beans::XMultiPropertySet;
16376 +using com::sun::star::beans::XPropertySet;
16377 +using com::sun::star::beans::Property;
16379 +using com::sun::star::sdbc::XResultSet;
16380 +using com::sun::star::sdbc::XPreparedStatement;
16381 +using com::sun::star::sdbc::XStatement;
16382 +using com::sun::star::sdbc::XParameters;
16383 +using com::sun::star::sdbc::XRow;
16384 +using com::sun::star::sdbc::SQLException;
16386 +namespace pq_sdbc_driver
16388 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
16390 +Index::Index( const ::rtl::Reference< RefCountedMutex > & refMutex,
16391 + const Reference< com::sun::star::sdbc::XConnection > & connection,
16392 + ConnectionSettings *pSettings,
16393 + const rtl::OUString & schemaName,
16394 + const rtl::OUString & tableName )
16395 + : ReflectionBase(
16396 + getStatics().refl.index.implName,
16397 + getStatics().refl.index.serviceNames,
16401 + * getStatics().refl.index.pProps ),
16402 + m_schemaName( schemaName ),
16403 + m_tableName( tableName )
16406 +Reference< XPropertySet > Index::createDataDescriptor( ) throw (RuntimeException)
16408 + IndexDescriptor * pIndex = new IndexDescriptor(
16409 + m_refMutex, m_conn, m_pSettings );
16410 + pIndex->copyValuesFrom( this );
16412 + return Reference< XPropertySet > ( pIndex );
16415 +Reference< XNameAccess > Index::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
16417 + if( ! m_indexColumns.is() )
16419 + Sequence< OUString > columnNames;
16420 + getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
16421 + OUString indexName = extractStringProperty( this, getStatics().NAME );
16422 + m_indexColumns = IndexColumns::create(
16423 + m_refMutex, m_conn, m_pSettings, m_schemaName,
16424 + m_tableName, indexName, columnNames );
16426 + return m_indexColumns;
16429 +Sequence<Type > Index::getTypes() throw( RuntimeException )
16431 + static cppu::OTypeCollection *pCollection;
16432 + if( ! pCollection )
16434 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
16435 + if( !pCollection )
16437 + static cppu::OTypeCollection collection(
16438 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
16439 + ReflectionBase::getTypes());
16440 + pCollection = &collection;
16443 + return pCollection->getTypes();
16446 +Sequence< sal_Int8> Index::getImplementationId() throw( RuntimeException )
16448 + return getStatics().refl.index.implementationId;
16451 +Any Index::queryInterface( const Type & reqType ) throw (RuntimeException)
16455 + ret = ReflectionBase::queryInterface( reqType );
16456 + if( ! ret.hasValue() )
16457 + ret = ::cppu::queryInterface(
16459 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
16464 +//___________________________________________________________________________________
16465 +IndexDescriptor::IndexDescriptor(
16466 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16467 + const Reference< com::sun::star::sdbc::XConnection > & connection,
16468 + ConnectionSettings *pSettings )
16469 + : ReflectionBase(
16470 + getStatics().refl.indexDescriptor.implName,
16471 + getStatics().refl.indexDescriptor.serviceNames,
16475 + * getStatics().refl.indexDescriptor.pProps )
16478 +Reference< XPropertySet > IndexDescriptor::createDataDescriptor( ) throw (RuntimeException)
16480 + IndexDescriptor * pIndex = new IndexDescriptor(
16481 + m_refMutex, m_conn, m_pSettings );
16482 + pIndex->copyValuesFrom( this );
16483 + return Reference< XPropertySet > ( pIndex );
16486 +Reference< XNameAccess > IndexDescriptor::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
16488 + if( ! m_indexColumns.is() )
16490 + m_indexColumns = IndexColumnDescriptors::create(
16491 + m_refMutex, m_conn, m_pSettings );
16492 +// Sequence< OUString > columnNames;
16493 +// getPropertyValue( getStatics().PRIVATE_COLUMN_INDEXES ) >>= columnNames;
16494 +// OUString indexName = extractStringProperty( this, getStatics().NAME );
16495 +// m_indexColumns = IndexColumns::create(
16496 +// m_refMutex, m_conn, m_pSettings, m_schemaName,
16497 +// m_tableName, indexName, columnNames );
16499 + return m_indexColumns;
16502 +Sequence<Type > IndexDescriptor::getTypes() throw( RuntimeException )
16504 + static cppu::OTypeCollection *pCollection;
16505 + if( ! pCollection )
16507 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
16508 + if( !pCollection )
16510 + static cppu::OTypeCollection collection(
16511 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
16512 + ReflectionBase::getTypes());
16513 + pCollection = &collection;
16516 + return pCollection->getTypes();
16519 +Sequence< sal_Int8> IndexDescriptor::getImplementationId() throw( RuntimeException )
16521 + return getStatics().refl.indexDescriptor.implementationId;
16524 +Any IndexDescriptor::queryInterface( const Type & reqType ) throw (RuntimeException)
16528 + ret = ReflectionBase::queryInterface( reqType );
16529 + if( ! ret.hasValue() )
16530 + ret = ::cppu::queryInterface(
16532 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
16540 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
16541 +++ connectivity/source/drivers/postgresql/pq_xindexes.cxx 2004-08-29 10:33:31.000000000 +0200
16543 +/*************************************************************************
16545 + * $RCSfile: pq_xindexes.cxx,v $
16547 + * $Revision: 1.1.2.2 $
16549 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:31 $
16551 + * The Contents of this file are made available subject to the terms of
16552 + * either of the following licenses
16554 + * - GNU Lesser General Public License Version 2.1
16555 + * - Sun Industry Standards Source License Version 1.1
16557 + * Sun Microsystems Inc., October, 2000
16559 + * GNU Lesser General Public License Version 2.1
16560 + * =============================================
16561 + * Copyright 2000 by Sun Microsystems, Inc.
16562 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
16564 + * This library is free software; you can redistribute it and/or
16565 + * modify it under the terms of the GNU Lesser General Public
16566 + * License version 2.1, as published by the Free Software Foundation.
16568 + * This library is distributed in the hope that it will be useful,
16569 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16570 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16571 + * Lesser General Public License for more details.
16573 + * You should have received a copy of the GNU Lesser General Public
16574 + * License along with this library; if not, write to the Free Software
16575 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16576 + * MA 02111-1307 USA
16579 + * Sun Industry Standards Source License Version 1.1
16580 + * =================================================
16581 + * The contents of this file are subject to the Sun Industry Standards
16582 + * Source License Version 1.1 (the "License"); You may not use this file
16583 + * except in compliance with the License. You may obtain a copy of the
16584 + * License at http://www.openoffice.org/license.html.
16586 + * Software provided under this License is provided on an "AS IS" basis,
16587 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
16588 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
16589 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
16590 + * See the License for the specific provisions governing your rights and
16591 + * obligations concerning the Software.
16593 + * The Initial Developer of the Original Code is: Joerg Budischewski
16595 + * Copyright: 2000 by Sun Microsystems, Inc.
16597 + * All Rights Reserved.
16599 + * Contributor(s): Joerg Budischewski
16602 + ************************************************************************/
16605 +#include <hash_map>
16607 +#include <rtl/ustrbuf.hxx>
16608 +#include <rtl/strbuf.hxx>
16610 +#include <com/sun/star/sdbc/XRow.hpp>
16611 +#include <com/sun/star/sdbc/XParameters.hpp>
16612 +#include <com/sun/star/sdbc/KeyRule.hpp>
16613 +#include <com/sun/star/sdbcx/KeyType.hpp>
16615 +#include "pq_xindexes.hxx"
16616 +#include "pq_xindex.hxx"
16617 +#include "pq_statics.hxx"
16618 +#include "pq_tools.hxx"
16620 +using osl::MutexGuard;
16622 +using rtl::OUString;
16623 +using rtl::OUStringBuffer;
16624 +using rtl::OUStringToOString;
16626 +using com::sun::star::beans::XPropertySet;
16628 +using com::sun::star::uno::Any;
16629 +using com::sun::star::uno::makeAny;
16630 +using com::sun::star::uno::UNO_QUERY;
16631 +using com::sun::star::uno::Type;
16632 +using com::sun::star::uno::XInterface;
16633 +using com::sun::star::uno::Reference;
16634 +using com::sun::star::uno::Sequence;
16635 +using com::sun::star::uno::RuntimeException;
16637 +using com::sun::star::container::NoSuchElementException;
16638 +using com::sun::star::container::XEnumerationAccess;
16639 +using com::sun::star::container::XEnumeration;
16641 +using com::sun::star::lang::WrappedTargetException;
16643 +using com::sun::star::sdbcx::XColumnsSupplier;
16645 +using com::sun::star::sdbc::XRow;
16646 +using com::sun::star::sdbc::XCloseable;
16647 +using com::sun::star::sdbc::XStatement;
16648 +using com::sun::star::sdbc::XResultSet;
16649 +using com::sun::star::sdbc::XParameters;
16650 +using com::sun::star::sdbc::XPreparedStatement;
16651 +using com::sun::star::sdbc::XDatabaseMetaData;
16653 +namespace pq_sdbc_driver
16655 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
16658 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16659 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16660 + ConnectionSettings *pSettings,
16661 + const rtl::OUString &schemaName,
16662 + const rtl::OUString &tableName)
16663 + : Container( refMutex, origin, pSettings, getStatics().KEY ),
16664 + m_schemaName( schemaName ),
16665 + m_tableName( tableName )
16669 +Indexes::~Indexes()
16672 +void Indexes::refresh()
16673 + throw (::com::sun::star::uno::RuntimeException)
16677 + if( isLog( m_pSettings, LogLevel::INFO ) )
16679 + rtl::OStringBuffer buf;
16680 + buf.append( "sdbcx.Indexes get refreshed for table " );
16681 + buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) );
16682 + buf.append( "." );
16683 + buf.append( OUStringToOString( m_tableName,m_pSettings->encoding ) );
16684 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
16687 + osl::MutexGuard guard( m_refMutex->mutex );
16688 + Statics & st = getStatics();
16690 + Int2StringMap column2NameMap;
16691 + fillAttnum2attnameMap( column2NameMap, m_origin, m_schemaName, m_tableName );
16693 + // see XDatabaseMetaData::getIndexInfo()
16694 + Reference< XPreparedStatement > stmt = m_origin->prepareStatement(
16696 + "SELECT nspname, " // 1
16697 + "pg_class.relname, " // 2
16698 + "class2.relname, " // 3
16699 + "indisclustered, " // 4
16700 + "indisunique, " // 5
16701 + "indisprimary, " // 6
16703 + "FROM pg_index INNER JOIN pg_class ON indrelid = pg_class.oid "
16704 + "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
16705 + "INNER JOIN pg_class as class2 ON pg_index.indexrelid = class2.oid "
16706 + "WHERE nspname = ? AND pg_class.relname = ?" ) );
16708 + Reference< XParameters > params( stmt, UNO_QUERY);
16709 + params->setString( 1, m_schemaName );
16710 + params->setString( 2, m_tableName );
16711 + Reference< XResultSet > rs = stmt->executeQuery();
16713 + Reference< XRow > row( rs, UNO_QUERY );
16714 + String2IntMap map;
16715 + std::vector< Any, Allocator< Any> > vec;
16716 + sal_Int32 index = 0;
16717 + while( rs->next() )
16719 + static const sal_Int32 C_SCHEMA = 1;
16720 + static const sal_Int32 C_TABLENAME = 2;
16721 + static const sal_Int32 C_INDEXNAME = 3;
16722 + static const sal_Int32 C_IS_CLUSTERED = 4;
16723 + static const sal_Int32 C_IS_UNIQUE = 5;
16724 + static const sal_Int32 C_IS_PRIMARY = 6;
16725 + static const sal_Int32 C_COLUMNS = 7;
16726 + OUString currentIndexName = row->getString( C_INDEXNAME );
16728 + new Index( m_refMutex, m_origin, m_pSettings,
16729 + m_schemaName, m_tableName );
16731 + sal_Bool isUnique = row->getBoolean( C_IS_UNIQUE );
16732 + sal_Bool isPrimary = row->getBoolean( C_IS_PRIMARY );
16733 + sal_Bool isClusterd = row->getBoolean( C_IS_CLUSTERED );
16734 + Reference< com::sun::star::beans::XPropertySet > prop = pIndex;
16735 + pIndex->setPropertyValue_NoBroadcast_public(
16736 + st.IS_UNIQUE, Any( &isUnique, getBooleanCppuType() ) );
16737 + pIndex->setPropertyValue_NoBroadcast_public(
16738 + st.IS_PRIMARY_KEY_INDEX, Any( &isPrimary, getBooleanCppuType() ) );
16739 + pIndex->setPropertyValue_NoBroadcast_public(
16740 + st.IS_CLUSTERED, Any( &isClusterd, getBooleanCppuType() ) );
16741 + pIndex->setPropertyValue_NoBroadcast_public(
16742 + st.NAME, makeAny( currentIndexName ) );
16744 + Sequence< sal_Int32 > seq = parseIntArray( row->getString( C_COLUMNS ) );
16745 + Sequence< OUString > columnNames(seq.getLength());
16746 + for( int columns = 0 ; columns < seq.getLength() ; columns ++ )
16748 + columnNames[columns] = column2NameMap[ seq[columns] ];
16751 + pIndex->setPropertyValue_NoBroadcast_public(
16752 + st.PRIVATE_COLUMN_INDEXES, makeAny( columnNames ));
16754 + vec.push_back( makeAny( prop ) );
16755 + map[ currentIndexName ] = index;
16758 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
16759 + m_name2index.swap( map );
16761 + catch ( com::sun::star::sdbc::SQLException & e )
16763 + throw RuntimeException( e.Message , e.Context );
16766 + fire( RefreshedBroadcaster( *this ) );
16770 +void Indexes::appendByDescriptor(
16771 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
16772 + throw (::com::sun::star::sdbc::SQLException,
16773 + ::com::sun::star::container::ElementExistException,
16774 + ::com::sun::star::uno::RuntimeException)
16776 + Statics & st = getStatics();
16777 + OUString name = extractStringProperty( descriptor, st.NAME );
16779 + sal_Bool isUnique = extractBoolProperty( descriptor, st.IS_UNIQUE );
16781 + OUStringBuffer buf( 128 );
16783 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE " ) );
16785 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "UNIQUE " ) );
16786 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "INDEX " ) );
16787 + bufferQuoteIdentifier( buf, name );
16788 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ON " ) );
16789 + bufferQuoteQualifiedIdentifier( buf, m_schemaName, m_tableName );
16791 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ( " ) );
16793 + Reference< XColumnsSupplier > columns( descriptor, UNO_QUERY );
16794 + if( columns.is() )
16796 + Reference< XEnumerationAccess > access( columns->getColumns(), UNO_QUERY );
16797 + if( access.is() )
16799 + Reference< XEnumeration > xEnum( access->createEnumeration() );
16800 + bool first = true;
16801 + while( xEnum.is() && xEnum->hasMoreElements() )
16803 + Reference< XPropertySet > column( xEnum->nextElement(), UNO_QUERY );
16810 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
16812 + buf.append( extractStringProperty( column, st.NAME ) );
16816 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ) " ) );
16818 + m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
16822 +void Indexes::dropByIndex( sal_Int32 index )
16823 + throw (::com::sun::star::sdbc::SQLException,
16824 + ::com::sun::star::lang::IndexOutOfBoundsException,
16825 + ::com::sun::star::uno::RuntimeException)
16829 + osl::MutexGuard guard( m_refMutex->mutex );
16830 + if( index < 0 || index >= m_values.getLength() )
16832 + OUStringBuffer buf( 128 );
16833 + buf.appendAscii( "Indexes: Index out of range (allowed 0 to " );
16834 + buf.append( (sal_Int32) (m_values.getLength() -1) );
16835 + buf.appendAscii( ", got " );
16836 + buf.append( index );
16837 + buf.appendAscii( ")" );
16838 + throw com::sun::star::lang::IndexOutOfBoundsException(
16839 + buf.makeStringAndClear(), *this );
16842 + Reference< XPropertySet > set;
16843 + m_values[index] >>= set;
16844 + Statics &st = getStatics();
16846 + OUStringBuffer buf( 128 );
16847 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP INDEX " ) );
16848 + bufferQuoteIdentifier( buf, extractStringProperty( set, st.NAME ) );
16849 + m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
16851 + Container::dropByIndex( index );
16855 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Indexes::createDataDescriptor()
16856 + throw (::com::sun::star::uno::RuntimeException)
16858 + return new IndexDescriptor( m_refMutex, m_origin, m_pSettings );
16861 +Reference< com::sun::star::container::XNameAccess > Indexes::create(
16862 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16863 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16864 + ConnectionSettings *pSettings,
16865 + const rtl::OUString & schemaName,
16866 + const rtl::OUString & tableName)
16868 + Indexes *pIndexes = new Indexes( refMutex, origin, pSettings, schemaName, tableName );
16869 + Reference< com::sun::star::container::XNameAccess > ret = pIndexes;
16870 + pIndexes->refresh();
16875 +//_________________________________________________________________________________________
16876 +IndexDescriptors::IndexDescriptors(
16877 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16878 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16879 + ConnectionSettings *pSettings)
16880 + : Container( refMutex, origin, pSettings, getStatics().INDEX )
16883 +Reference< com::sun::star::container::XNameAccess > IndexDescriptors::create(
16884 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16885 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16886 + ConnectionSettings *pSettings)
16888 + return new IndexDescriptors( refMutex, origin, pSettings );
16891 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > IndexDescriptors::createDataDescriptor()
16892 + throw (::com::sun::star::uno::RuntimeException)
16894 + return new IndexDescriptor( m_refMutex, m_origin, m_pSettings );
16901 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
16902 +++ connectivity/source/drivers/postgresql/pq_xindexes.hxx 2004-06-10 17:27:07.000000000 +0200
16904 +/*************************************************************************
16906 + * $RCSfile: pq_xindexes.hxx,v $
16908 + * $Revision: 1.1.2.1 $
16910 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:07 $
16912 + * The Contents of this file are made available subject to the terms of
16913 + * either of the following licenses
16915 + * - GNU Lesser General Public License Version 2.1
16916 + * - Sun Industry Standards Source License Version 1.1
16918 + * Sun Microsystems Inc., October, 2000
16920 + * GNU Lesser General Public License Version 2.1
16921 + * =============================================
16922 + * Copyright 2000 by Sun Microsystems, Inc.
16923 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
16925 + * This library is free software; you can redistribute it and/or
16926 + * modify it under the terms of the GNU Lesser General Public
16927 + * License version 2.1, as published by the Free Software Foundation.
16929 + * This library is distributed in the hope that it will be useful,
16930 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16931 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16932 + * Lesser General Public License for more details.
16934 + * You should have received a copy of the GNU Lesser General Public
16935 + * License along with this library; if not, write to the Free Software
16936 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16937 + * MA 02111-1307 USA
16940 + * Sun Industry Standards Source License Version 1.1
16941 + * =================================================
16942 + * The contents of this file are subject to the Sun Industry Standards
16943 + * Source License Version 1.1 (the "License"); You may not use this file
16944 + * except in compliance with the License. You may obtain a copy of the
16945 + * License at http://www.openoffice.org/license.html.
16947 + * Software provided under this License is provided on an "AS IS" basis,
16948 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
16949 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
16950 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
16951 + * See the License for the specific provisions governing your rights and
16952 + * obligations concerning the Software.
16954 + * The Initial Developer of the Original Code is: Joerg Budischewski
16956 + * Copyright: 2000 by Sun Microsystems, Inc.
16958 + * All Rights Reserved.
16960 + * Contributor(s): Joerg Budischewski
16963 + ************************************************************************/
16965 +#ifndef HEADER_PQ_INDEXES_HXX_
16966 +#define HEADER_PQ_INDEXES_HXX_
16968 +#include "pq_xcontainer.hxx"
16970 +namespace pq_sdbc_driver
16972 +class Indexes : public Container
16974 + rtl::OUString m_schemaName;
16975 + rtl::OUString m_tableName;
16977 +public: // instances Columns 'exception safe'
16978 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
16979 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16980 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16981 + ConnectionSettings *pSettings,
16982 + const rtl::OUString &schemaName,
16983 + const rtl::OUString &tableName);
16987 + const ::rtl::Reference< RefCountedMutex > & refMutex,
16988 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
16989 + ConnectionSettings *pSettings,
16990 + const rtl::OUString &schemaName,
16991 + const rtl::OUString &tableName);
16993 + virtual ~Indexes();
16995 +public: // XAppend
16996 + virtual void SAL_CALL appendByDescriptor(
16997 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
16998 + throw (::com::sun::star::sdbc::SQLException,
16999 + ::com::sun::star::container::ElementExistException,
17000 + ::com::sun::star::uno::RuntimeException);
17003 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
17004 + throw (::com::sun::star::sdbc::SQLException,
17005 + ::com::sun::star::lang::IndexOutOfBoundsException,
17006 + ::com::sun::star::uno::RuntimeException);
17008 +public: // XRefreshable
17009 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
17011 +public: // XDataDescriptorFactory
17012 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
17013 + throw (::com::sun::star::uno::RuntimeException);
17017 +class IndexDescriptors : public Container
17019 +public: // instances IndexDescriptors 'exception safe'
17020 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
17021 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17022 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17023 + ConnectionSettings *pSettings );
17026 + IndexDescriptors(
17027 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17028 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17029 + ConnectionSettings *pSettings );
17031 +public: // XDataDescriptorFactory
17032 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
17033 + throw (::com::sun::star::uno::RuntimeException);
17039 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17040 +++ connectivity/source/drivers/postgresql/pq_xindex.hxx 2004-06-10 17:27:02.000000000 +0200
17042 +/*************************************************************************
17044 + * $RCSfile: pq_xindex.hxx,v $
17046 + * $Revision: 1.1.2.1 $
17048 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:02 $
17050 + * The Contents of this file are made available subject to the terms of
17051 + * either of the following licenses
17053 + * - GNU Lesser General Public License Version 2.1
17054 + * - Sun Industry Standards Source License Version 1.1
17056 + * Sun Microsystems Inc., October, 2000
17058 + * GNU Lesser General Public License Version 2.1
17059 + * =============================================
17060 + * Copyright 2000 by Sun Microsystems, Inc.
17061 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
17063 + * This library is free software; you can redistribute it and/or
17064 + * modify it under the terms of the GNU Lesser General Public
17065 + * License version 2.1, as published by the Free Software Foundation.
17067 + * This library is distributed in the hope that it will be useful,
17068 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17069 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17070 + * Lesser General Public License for more details.
17072 + * You should have received a copy of the GNU Lesser General Public
17073 + * License along with this library; if not, write to the Free Software
17074 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17075 + * MA 02111-1307 USA
17078 + * Sun Industry Standards Source License Version 1.1
17079 + * =================================================
17080 + * The contents of this file are subject to the Sun Industry Standards
17081 + * Source License Version 1.1 (the "License"); You may not use this file
17082 + * except in compliance with the License. You may obtain a copy of the
17083 + * License at http://www.openoffice.org/license.html.
17085 + * Software provided under this License is provided on an "AS IS" basis,
17086 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
17087 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
17088 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
17089 + * See the License for the specific provisions governing your rights and
17090 + * obligations concerning the Software.
17092 + * The Initial Developer of the Original Code is: Joerg Budischewski
17094 + * Copyright: 2000 by Sun Microsystems, Inc.
17096 + * All Rights Reserved.
17098 + * Contributor(s): Joerg Budischewski
17101 + ************************************************************************/
17103 +#ifndef HEADER_PQ_XINDEX_HXX
17104 +#define HEADER_PQ_XINDEX_HXX
17106 +#include <cppuhelper/component.hxx>
17107 +#include <cppuhelper/propshlp.hxx>
17109 +#include <com/sun/star/lang/XServiceInfo.hpp>
17110 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
17111 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
17113 +#include "pq_connection.hxx"
17114 +#include "pq_xbase.hxx"
17116 +namespace pq_sdbc_driver
17119 +class Index : public ReflectionBase,
17120 + public com::sun::star::sdbcx::XColumnsSupplier
17122 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XDatabaseMetaData > m_meta;
17123 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_indexColumns;
17125 + rtl::OUString m_schemaName;
17126 + rtl::OUString m_tableName;
17129 + Index( const ::rtl::Reference< RefCountedMutex > & refMutex,
17130 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
17131 + ConnectionSettings *pSettings,
17132 + const rtl::OUString &schemaName,
17133 + const rtl::OUString &tableName);
17135 +public: // XInterface
17136 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
17137 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
17138 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
17139 + const com::sun::star::uno::Type & reqType )
17140 + throw (com::sun::star::uno::RuntimeException);
17142 +public: // XColumnsSupplier
17143 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
17144 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
17146 +public: // XTypeProvider, first implemented by OPropertySetHelper
17147 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
17148 + throw( com::sun::star::uno::RuntimeException );
17149 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
17150 + throw( com::sun::star::uno::RuntimeException );
17152 +public: // XDataDescriptorFactory
17153 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
17154 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
17159 +class IndexDescriptor : public ReflectionBase,
17160 + public com::sun::star::sdbcx::XColumnsSupplier
17162 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_indexColumns;
17166 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17167 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
17168 + ConnectionSettings *pSettings);
17170 +public: // XInterface
17171 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
17172 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
17173 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
17174 + const com::sun::star::uno::Type & reqType )
17175 + throw (com::sun::star::uno::RuntimeException);
17177 +public: // XColumnsSupplier
17178 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
17179 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
17181 +public: // XTypeProvider, first implemented by OPropertySetHelper
17182 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
17183 + throw( com::sun::star::uno::RuntimeException );
17184 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
17185 + throw( com::sun::star::uno::RuntimeException );
17187 +public: // XDataDescriptorFactory
17188 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
17189 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
17198 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17199 +++ connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx 2004-06-10 17:27:08.000000000 +0200
17201 +/*************************************************************************
17203 + * $RCSfile: pq_xkeycolumn.cxx,v $
17205 + * $Revision: 1.1.2.2 $
17207 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:08 $
17209 + * The Contents of this file are made available subject to the terms of
17210 + * either of the following licenses
17212 + * - GNU Lesser General Public License Version 2.1
17213 + * - Sun Industry Standards Source License Version 1.1
17215 + * Sun Microsystems Inc., October, 2000
17217 + * GNU Lesser General Public License Version 2.1
17218 + * =============================================
17219 + * Copyright 2000 by Sun Microsystems, Inc.
17220 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
17222 + * This library is free software; you can redistribute it and/or
17223 + * modify it under the terms of the GNU Lesser General Public
17224 + * License version 2.1, as published by the Free Software Foundation.
17226 + * This library is distributed in the hope that it will be useful,
17227 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17228 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17229 + * Lesser General Public License for more details.
17231 + * You should have received a copy of the GNU Lesser General Public
17232 + * License along with this library; if not, write to the Free Software
17233 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17234 + * MA 02111-1307 USA
17237 + * Sun Industry Standards Source License Version 1.1
17238 + * =================================================
17239 + * The contents of this file are subject to the Sun Industry Standards
17240 + * Source License Version 1.1 (the "License"); You may not use this file
17241 + * except in compliance with the License. You may obtain a copy of the
17242 + * License at http://www.openoffice.org/license.html.
17244 + * Software provided under this License is provided on an "AS IS" basis,
17245 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
17246 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
17247 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
17248 + * See the License for the specific provisions governing your rights and
17249 + * obligations concerning the Software.
17251 + * The Initial Developer of the Original Code is: Joerg Budischewski
17253 + * Copyright: 2000 by Sun Microsystems, Inc.
17255 + * All Rights Reserved.
17257 + * Contributor(s): Joerg Budischewski
17260 + ************************************************************************/
17262 +#include <cppuhelper/typeprovider.hxx>
17264 +#include "pq_xkeycolumn.hxx"
17266 +using com::sun::star::uno::Any;
17267 +using com::sun::star::uno::Reference;
17268 +using com::sun::star::uno::RuntimeException;
17269 +using com::sun::star::uno::Type;
17270 +using com::sun::star::uno::Sequence;
17272 +using com::sun::star::beans::XPropertySet;
17274 +namespace pq_sdbc_driver
17276 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
17278 +KeyColumn::KeyColumn( const ::rtl::Reference< RefCountedMutex > & refMutex,
17279 + const Reference< com::sun::star::sdbc::XConnection > & connection,
17280 + ConnectionSettings *pSettings)
17281 + : ReflectionBase(
17282 + getStatics().refl.keycolumn.implName,
17283 + getStatics().refl.keycolumn.serviceNames,
17287 + * getStatics().refl.keycolumn.pProps )
17290 +Reference< XPropertySet > KeyColumn::createDataDescriptor( ) throw (RuntimeException)
17292 + KeyColumnDescriptor * pKeyColumn = new KeyColumnDescriptor(
17293 + m_refMutex, m_conn, m_pSettings );
17294 + pKeyColumn->copyValuesFrom( this );
17296 + return Reference< XPropertySet > ( pKeyColumn );
17299 +KeyColumnDescriptor::KeyColumnDescriptor(
17300 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17301 + const Reference< com::sun::star::sdbc::XConnection > & connection,
17302 + ConnectionSettings *pSettings)
17303 + : ReflectionBase(
17304 + getStatics().refl.keycolumnDescriptor.implName,
17305 + getStatics().refl.keycolumnDescriptor.serviceNames,
17309 + * getStatics().refl.keycolumnDescriptor.pProps )
17312 +Reference< XPropertySet > KeyColumnDescriptor::createDataDescriptor( ) throw (RuntimeException)
17314 + KeyColumnDescriptor * pKeyColumn = new KeyColumnDescriptor(
17315 + m_refMutex, m_conn, m_pSettings );
17316 + pKeyColumn->copyValuesFrom( this );
17318 + return Reference< XPropertySet > ( pKeyColumn );
17322 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17323 +++ connectivity/source/drivers/postgresql/pq_xkeycolumn.hxx 2004-06-10 17:27:09.000000000 +0200
17325 +/*************************************************************************
17327 + * $RCSfile: pq_xkeycolumn.hxx,v $
17329 + * $Revision: 1.1.2.2 $
17331 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:09 $
17333 + * The Contents of this file are made available subject to the terms of
17334 + * either of the following licenses
17336 + * - GNU Lesser General Public License Version 2.1
17337 + * - Sun Industry Standards Source License Version 1.1
17339 + * Sun Microsystems Inc., October, 2000
17341 + * GNU Lesser General Public License Version 2.1
17342 + * =============================================
17343 + * Copyright 2000 by Sun Microsystems, Inc.
17344 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
17346 + * This library is free software; you can redistribute it and/or
17347 + * modify it under the terms of the GNU Lesser General Public
17348 + * License version 2.1, as published by the Free Software Foundation.
17350 + * This library is distributed in the hope that it will be useful,
17351 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17352 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17353 + * Lesser General Public License for more details.
17355 + * You should have received a copy of the GNU Lesser General Public
17356 + * License along with this library; if not, write to the Free Software
17357 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17358 + * MA 02111-1307 USA
17361 + * Sun Industry Standards Source License Version 1.1
17362 + * =================================================
17363 + * The contents of this file are subject to the Sun Industry Standards
17364 + * Source License Version 1.1 (the "License"); You may not use this file
17365 + * except in compliance with the License. You may obtain a copy of the
17366 + * License at http://www.openoffice.org/license.html.
17368 + * Software provided under this License is provided on an "AS IS" basis,
17369 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
17370 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
17371 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
17372 + * See the License for the specific provisions governing your rights and
17373 + * obligations concerning the Software.
17375 + * The Initial Developer of the Original Code is: Joerg Budischewski
17377 + * Copyright: 2000 by Sun Microsystems, Inc.
17379 + * All Rights Reserved.
17381 + * Contributor(s): Joerg Budischewski
17384 + ************************************************************************/
17386 +#ifndef HEADER_PQ_KEYCOLUMN_HXX
17387 +#define HEADER_PQ_KEYCOLUMN_HXX
17389 +#include <cppuhelper/component.hxx>
17390 +#include <cppuhelper/propshlp.hxx>
17392 +#include <com/sun/star/lang/XServiceInfo.hpp>
17393 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
17395 +#include "pq_connection.hxx"
17396 +#include "pq_xbase.hxx"
17398 +namespace pq_sdbc_driver
17401 +class KeyColumn : public ReflectionBase
17404 + KeyColumn( const ::rtl::Reference< RefCountedMutex > & refMutex,
17405 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
17406 + ConnectionSettings *pSettings);
17408 +public: // XDataDescriptorFactory
17409 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
17410 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
17414 +class KeyColumnDescriptor : public ReflectionBase
17417 + KeyColumnDescriptor(
17418 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17419 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
17420 + ConnectionSettings *pSettings);
17422 +public: // XDataDescriptorFactory
17423 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
17424 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
17433 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17434 +++ connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx 2004-08-29 10:33:31.000000000 +0200
17436 +/*************************************************************************
17438 + * $RCSfile: pq_xkeycolumns.cxx,v $
17440 + * $Revision: 1.1.2.3 $
17442 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:31 $
17444 + * The Contents of this file are made available subject to the terms of
17445 + * either of the following licenses
17447 + * - GNU Lesser General Public License Version 2.1
17448 + * - Sun Industry Standards Source License Version 1.1
17450 + * Sun Microsystems Inc., October, 2000
17452 + * GNU Lesser General Public License Version 2.1
17453 + * =============================================
17454 + * Copyright 2000 by Sun Microsystems, Inc.
17455 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
17457 + * This library is free software; you can redistribute it and/or
17458 + * modify it under the terms of the GNU Lesser General Public
17459 + * License version 2.1, as published by the Free Software Foundation.
17461 + * This library is distributed in the hope that it will be useful,
17462 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17463 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17464 + * Lesser General Public License for more details.
17466 + * You should have received a copy of the GNU Lesser General Public
17467 + * License along with this library; if not, write to the Free Software
17468 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17469 + * MA 02111-1307 USA
17472 + * Sun Industry Standards Source License Version 1.1
17473 + * =================================================
17474 + * The contents of this file are subject to the Sun Industry Standards
17475 + * Source License Version 1.1 (the "License"); You may not use this file
17476 + * except in compliance with the License. You may obtain a copy of the
17477 + * License at http://www.openoffice.org/license.html.
17479 + * Software provided under this License is provided on an "AS IS" basis,
17480 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
17481 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
17482 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
17483 + * See the License for the specific provisions governing your rights and
17484 + * obligations concerning the Software.
17486 + * The Initial Developer of the Original Code is: Joerg Budischewski
17488 + * Copyright: 2000 by Sun Microsystems, Inc.
17490 + * All Rights Reserved.
17492 + * Contributor(s): Joerg Budischewski
17495 + ************************************************************************/
17499 +#include <rtl/ustrbuf.hxx>
17500 +#include <rtl/strbuf.hxx>
17502 +#include <com/sun/star/sdbc/XRow.hpp>
17503 +#include <com/sun/star/sdbc/XParameters.hpp>
17504 +#include <com/sun/star/sdbc/DataType.hpp>
17505 +#include <com/sun/star/sdbc/ColumnValue.hpp>
17507 +#include "pq_xcolumns.hxx"
17508 +#include "pq_xkeycolumns.hxx"
17509 +#include "pq_xkeycolumn.hxx"
17510 +#include "pq_statics.hxx"
17511 +#include "pq_tools.hxx"
17513 +using osl::MutexGuard;
17515 +using rtl::OUString;
17516 +using rtl::OUStringBuffer;
17517 +using rtl::OUStringToOString;
17519 +using com::sun::star::beans::XPropertySet;
17521 +using com::sun::star::uno::Any;
17522 +using com::sun::star::uno::makeAny;
17523 +using com::sun::star::uno::UNO_QUERY;
17524 +using com::sun::star::uno::Type;
17525 +using com::sun::star::uno::XInterface;
17526 +using com::sun::star::uno::Reference;
17527 +using com::sun::star::uno::Sequence;
17528 +using com::sun::star::uno::RuntimeException;
17530 +using com::sun::star::container::NoSuchElementException;
17531 +using com::sun::star::lang::WrappedTargetException;
17533 +using com::sun::star::sdbc::XRow;
17534 +using com::sun::star::sdbc::XCloseable;
17535 +using com::sun::star::sdbc::XStatement;
17536 +using com::sun::star::sdbc::XResultSet;
17537 +using com::sun::star::sdbc::XParameters;
17538 +using com::sun::star::sdbc::XPreparedStatement;
17539 +using com::sun::star::sdbc::XDatabaseMetaData;
17540 +using com::sun::star::sdbc::SQLException;
17542 +namespace pq_sdbc_driver
17544 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
17546 +KeyColumns::KeyColumns(
17547 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17548 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17549 + ConnectionSettings *pSettings,
17550 + const rtl::OUString &schemaName,
17551 + const rtl::OUString &tableName,
17552 + const Sequence< rtl::OUString > &columnNames,
17553 + const Sequence< rtl::OUString > &foreignColumnNames )
17554 + : Container( refMutex, origin, pSettings, ASCII_STR( "KEY_COLUMN" ) ),
17555 + m_schemaName( schemaName ),
17556 + m_tableName( tableName ),
17557 + m_columnNames( columnNames ),
17558 + m_foreignColumnNames( foreignColumnNames )
17561 +KeyColumns::~KeyColumns()
17565 +void KeyColumns::refresh()
17566 + throw (::com::sun::star::uno::RuntimeException)
17570 + if( isLog( m_pSettings, LogLevel::INFO ) )
17572 + rtl::OStringBuffer buf;
17573 + buf.append( "sdbcx.KeyColumns get refreshed for table " );
17574 + buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) );
17575 + buf.append( "." );
17576 + buf.append( OUStringToOString( m_tableName, m_pSettings->encoding ) );
17577 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
17580 + osl::MutexGuard guard( m_refMutex->mutex );
17582 + Statics &st = getStatics();
17583 + Reference< XDatabaseMetaData > meta = m_origin->getMetaData();
17585 + Reference< XResultSet > rs =
17586 + meta->getColumns( Any(), m_schemaName, m_tableName, st.cPERCENT );
17588 + DisposeGuard disposeIt( rs );
17589 + Reference< XRow > xRow( rs , UNO_QUERY );
17591 + String2IntMap map;
17593 + std::vector< Any, Allocator< Any> > vec;
17594 + sal_Int32 columnIndex = 0;
17595 + while( rs->next() )
17597 + OUString columnName = xRow->getString( 4 );
17600 + for( keyindex = 0 ; keyindex < m_columnNames.getLength() ; keyindex ++ )
17602 + if( columnName == m_columnNames[keyindex] )
17605 + if( m_columnNames.getLength() == keyindex )
17608 + KeyColumn * pKeyColumn =
17609 + new KeyColumn( m_refMutex, m_origin, m_pSettings );
17610 + Reference< com::sun::star::beans::XPropertySet > prop = pKeyColumn;
17612 + OUString name = columnMetaData2SDBCX( pKeyColumn, xRow );
17613 + if( keyindex < m_foreignColumnNames.getLength() )
17615 + pKeyColumn->setPropertyValue_NoBroadcast_public(
17616 + st.RELATED_COLUMN, makeAny( m_foreignColumnNames[keyindex]) );
17619 + vec.push_back( makeAny( prop ) );
17620 + map[ name ] = columnIndex;
17623 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
17624 + m_name2index.swap( map );
17626 + catch ( com::sun::star::sdbc::SQLException & e )
17628 + throw RuntimeException( e.Message , e.Context );
17631 + fire( RefreshedBroadcaster( *this ) );
17635 +// void alterColumnByDescriptor(
17636 +// const OUString & schemaName,
17637 +// const OUString & tableName,
17638 +// rtl_TextEncoding encoding,
17639 +// const Reference< XStatement > &stmt,
17640 +// const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & past,
17641 +// const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & future)
17643 +// Statics & st = getStatics();
17645 +// // if( past->getPropertyValue( st.TABLE_NAME ) != future->getPropertyValue( st.TABLE_NAME ) ||
17646 +// // past->getPropertyValue( st.SCHEMA_NAME ) != future->getPropertyValue( st.SCHEMA_NAME ))
17648 +// // OUStringBuffer buf(128);
17649 +// // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Can't move column " ) );
17650 +// // buf.append( extractStringProperty( past, st.COLUMN_NAME ) );
17651 +// // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " from table " ) );
17652 +// // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
17653 +// // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " to table " ) );
17654 +// // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
17655 +// // throw SQLException( buf.makeStringAndClear(), Reference< XInterface > () );
17658 +// // OUString tableName = extractStringProperty( past, st.TABLE_NAME );
17659 +// // OUString schemaName = extractStringProperty( past, st.SCHEMA_NAME );
17660 +// OUString pastColumnName = extractStringProperty( past, st.NAME );
17661 +// OUString futureColumnName = extractStringProperty( future, st.NAME );
17662 +// OUString pastTypeName = sqltype2string( past );
17663 +// OUString futureTypeName = sqltype2string( future );
17665 +// TransactionGuard transaction( stmt );
17667 +// OUStringBuffer buf( 128 );
17668 +// if( ! pastColumnName.getLength())
17670 +// // create a new column
17671 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
17672 +// bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
17673 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ADD COLUMN" ) );
17674 +// bufferQuoteIdentifier( buf, futureColumnName );
17675 +// buf.append( futureTypeName );
17676 +// transaction.executeUpdate( buf.makeStringAndClear() );
17680 +// if( pastTypeName != futureTypeName )
17682 +// throw RuntimeException(
17683 +// ASCII_STR( "Can't modify column types, drop the column and create a new one" ),
17684 +// Reference< XInterface > () );
17687 +// if( pastColumnName != futureColumnName )
17689 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
17690 +// bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
17691 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "RENAME COLUMN" ) );
17692 +// bufferQuoteIdentifier( buf, pastColumnName );
17693 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TO" ) );
17694 +// bufferQuoteIdentifier( buf, futureColumnName );
17695 +// transaction.executeUpdate( buf.makeStringAndClear() );
17699 +// OUString futureDefaultValue = extractStringProperty( future, st.DEFAULT_VALUE );
17700 +// OUString pastDefaultValue = extractStringProperty( past, st.DEFAULT_VALUE );
17701 +// if( futureDefaultValue != pastDefaultValue )
17703 +// buf = OUStringBuffer( 128 );
17704 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
17705 +// bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
17706 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
17707 +// bufferQuoteIdentifier( buf, futureColumnName );
17708 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET DEFAULT " ) );
17709 +// // default value is not quoted, caller needs to quote himself (otherwise
17710 +// // how to pass e.g. nextval('something' ) ????
17711 +// buf.append( futureDefaultValue );
17712 +// // bufferQuoteConstant( buf, defaultValue, encoding );
17713 +// transaction.executeUpdate( buf.makeStringAndClear() );
17716 +// sal_Int32 futureNullable = extractIntProperty( future, st.IS_NULLABLE );
17717 +// sal_Int32 pastNullable = extractIntProperty( past, st.IS_NULLABLE );
17718 +// if( futureNullable != pastNullable )
17720 +// buf = OUStringBuffer( 128 );
17721 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
17722 +// bufferQuoteQualifiedIdentifier( buf, schemaName, tableName );
17723 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
17724 +// bufferQuoteIdentifier( buf, futureColumnName );
17725 +// if( futureNullable == com::sun::star::sdbc::ColumnValue::NO_NULLS )
17727 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET" ) );
17731 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP" ) );
17733 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL" ) );
17734 +// transaction.executeUpdate( buf.makeStringAndClear() );
17737 +// OUString futureComment = extractStringProperty( future, st.DESCRIPTION );
17738 +// OUString pastComment = extractStringProperty( past, st.DESCRIPTION );
17739 +// if( futureComment != pastComment )
17741 +// buf = OUStringBuffer( 128 );
17742 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
17743 +// bufferQuoteQualifiedIdentifier( buf, schemaName, tableName , futureColumnName );
17744 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
17745 +// bufferQuoteConstant( buf, futureComment,encoding);
17746 +// transaction.executeUpdate( buf.makeStringAndClear() );
17748 +// transaction.commit();
17751 +void KeyColumns::appendByDescriptor(
17752 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& future )
17753 + throw (::com::sun::star::sdbc::SQLException,
17754 + ::com::sun::star::container::ElementExistException,
17755 + ::com::sun::star::uno::RuntimeException)
17757 + throw com::sun::star::sdbc::SQLException(
17758 + ASCII_STR( "KeyColumns::appendByDescriptor not implemented yet" ),
17759 + *this, OUString(), 1, Any() );
17761 +// osl::MutexGuard guard( m_refMutex->mutex );
17762 +// Statics & st = getStatics();
17763 +// Reference< XPropertySet > past = createDataDescriptor();
17764 +// past->setPropertyValue( st.IS_NULLABLE, makeAny( com::sun::star::sdbc::ColumnValue::NULLABLE ) );
17765 +// alterColumnByDescriptor(
17766 +// m_schemaName, m_tableName, m_pSettings->encoding, m_origin->createStatement() , past, future );
17771 +void KeyColumns::dropByIndex( sal_Int32 index )
17772 + throw (::com::sun::star::sdbc::SQLException,
17773 + ::com::sun::star::lang::IndexOutOfBoundsException,
17774 + ::com::sun::star::uno::RuntimeException)
17776 + throw com::sun::star::sdbc::SQLException(
17777 + ASCII_STR( "KeyColumns::dropByIndex not implemented yet" ),
17778 + *this, OUString(), 1, Any() );
17779 +// osl::MutexGuard guard( m_refMutex->mutex );
17780 +// if( index < 0 || index >= m_values.getLength() )
17782 +// OUStringBuffer buf( 128 );
17783 +// buf.appendAscii( "COLUMNS: Index out of range (allowed 0 to " );
17784 +// buf.append((sal_Int32)(m_values.getLength() -1) );
17785 +// buf.appendAscii( ", got " );
17786 +// buf.append( index );
17787 +// buf.appendAscii( ")" );
17788 +// throw com::sun::star::lang::IndexOutOfBoundsException(
17789 +// buf.makeStringAndClear(), *this );
17792 +// Reference< XPropertySet > set;
17793 +// m_values[index] >>= set;
17794 +// Statics &st = getStatics();
17796 +// set->getPropertyValue( st.NAME ) >>= name;
17798 +// OUStringBuffer update( 128 );
17799 +// update.appendAscii( "ALTER TABLE ONLY");
17800 +// bufferQuoteQualifiedIdentifier( update, m_schemaName, m_tableName );
17801 +// update.appendAscii( "DROP COLUMN" );
17802 +// bufferQuoteIdentifier( update, name );
17803 +// Reference< XStatement > stmt = m_origin->createStatement( );
17804 +// DisposeGuard disposeIt( stmt );
17805 +// stmt->executeUpdate( update.makeStringAndClear() );
17810 +Reference< ::com::sun::star::beans::XPropertySet > KeyColumns::createDataDescriptor()
17811 + throw (::com::sun::star::uno::RuntimeException)
17813 + return new KeyColumnDescriptor( m_refMutex, m_origin, m_pSettings );
17816 +Reference< com::sun::star::container::XNameAccess > KeyColumns::create(
17817 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17818 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17819 + ConnectionSettings *pSettings,
17820 + const rtl::OUString &schemaName,
17821 + const rtl::OUString &tableName,
17822 + const Sequence< rtl::OUString > &columnNames ,
17823 + const Sequence< rtl::OUString > &foreignColumnNames )
17825 + KeyColumns *pKeyColumns = new KeyColumns(
17826 + refMutex, origin, pSettings, schemaName, tableName, columnNames, foreignColumnNames );
17827 + Reference< com::sun::star::container::XNameAccess > ret = pKeyColumns;
17828 + pKeyColumns->refresh();
17833 +//_______________________________________________________________________________________
17834 +KeyColumnDescriptors::KeyColumnDescriptors(
17835 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17836 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17837 + ConnectionSettings *pSettings )
17838 + : Container( refMutex, origin, pSettings, ASCII_STR( "KEY_COLUMN" ) )
17841 +Reference< ::com::sun::star::beans::XPropertySet > KeyColumnDescriptors::createDataDescriptor()
17842 + throw (::com::sun::star::uno::RuntimeException)
17844 + return new KeyColumnDescriptor( m_refMutex, m_origin, m_pSettings );
17847 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17848 +++ connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx 2004-06-10 17:27:09.000000000 +0200
17850 +/*************************************************************************
17852 + * $RCSfile: pq_xkeycolumns.hxx,v $
17854 + * $Revision: 1.1.2.2 $
17856 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:09 $
17858 + * The Contents of this file are made available subject to the terms of
17859 + * either of the following licenses
17861 + * - GNU Lesser General Public License Version 2.1
17862 + * - Sun Industry Standards Source License Version 1.1
17864 + * Sun Microsystems Inc., October, 2000
17866 + * GNU Lesser General Public License Version 2.1
17867 + * =============================================
17868 + * Copyright 2000 by Sun Microsystems, Inc.
17869 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
17871 + * This library is free software; you can redistribute it and/or
17872 + * modify it under the terms of the GNU Lesser General Public
17873 + * License version 2.1, as published by the Free Software Foundation.
17875 + * This library is distributed in the hope that it will be useful,
17876 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17877 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17878 + * Lesser General Public License for more details.
17880 + * You should have received a copy of the GNU Lesser General Public
17881 + * License along with this library; if not, write to the Free Software
17882 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17883 + * MA 02111-1307 USA
17886 + * Sun Industry Standards Source License Version 1.1
17887 + * =================================================
17888 + * The contents of this file are subject to the Sun Industry Standards
17889 + * Source License Version 1.1 (the "License"); You may not use this file
17890 + * except in compliance with the License. You may obtain a copy of the
17891 + * License at http://www.openoffice.org/license.html.
17893 + * Software provided under this License is provided on an "AS IS" basis,
17894 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
17895 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
17896 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
17897 + * See the License for the specific provisions governing your rights and
17898 + * obligations concerning the Software.
17900 + * The Initial Developer of the Original Code is: Joerg Budischewski
17902 + * Copyright: 2000 by Sun Microsystems, Inc.
17904 + * All Rights Reserved.
17906 + * Contributor(s): Joerg Budischewski
17909 + ************************************************************************/
17911 +#ifndef HEADER_PQ_KEYCOLUMNS_HXX
17912 +#define HEADER_PQ_KEYCOLUMNS_HXX
17914 +#include "pq_xcontainer.hxx"
17916 +namespace pq_sdbc_driver
17919 +class KeyColumns : public Container
17921 + rtl::OUString m_schemaName;
17922 + rtl::OUString m_tableName;
17923 + com::sun::star::uno::Sequence< rtl::OUString > m_columnNames;
17924 + com::sun::star::uno::Sequence< rtl::OUString > m_foreignColumnNames;
17926 +public: // instances KeyColumns 'exception safe'
17927 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
17928 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17929 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17930 + ConnectionSettings *pSettings,
17931 + const rtl::OUString &schemaName,
17932 + const rtl::OUString &tableName,
17933 + const com::sun::star::uno::Sequence< rtl::OUString > &keyColumns,
17934 + const com::sun::star::uno::Sequence< rtl::OUString > &foreignColumnNames );
17938 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17939 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17940 + ConnectionSettings *pSettings,
17941 + const rtl::OUString &schemaName,
17942 + const rtl::OUString &tableName,
17943 + const com::sun::star::uno::Sequence< rtl::OUString > &keyColumns,
17944 + const com::sun::star::uno::Sequence< rtl::OUString > &foreignColumnNames);
17946 + virtual ~KeyColumns();
17948 +public: // XAppend
17949 + virtual void SAL_CALL appendByDescriptor(
17950 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
17951 + throw (::com::sun::star::sdbc::SQLException,
17952 + ::com::sun::star::container::ElementExistException,
17953 + ::com::sun::star::uno::RuntimeException);
17956 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
17957 + throw (::com::sun::star::sdbc::SQLException,
17958 + ::com::sun::star::lang::IndexOutOfBoundsException,
17959 + ::com::sun::star::uno::RuntimeException);
17961 +public: // XRefreshable
17962 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
17964 +public: // XDataDescriptorFactory
17965 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
17966 + throw (::com::sun::star::uno::RuntimeException);
17970 +class KeyColumnDescriptors : public Container
17973 + KeyColumnDescriptors(
17974 + const ::rtl::Reference< RefCountedMutex > & refMutex,
17975 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
17976 + ConnectionSettings *pSettings);
17978 +public: // XDataDescriptorFactory
17979 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
17980 + throw (::com::sun::star::uno::RuntimeException);
17984 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
17985 +++ connectivity/source/drivers/postgresql/pq_xkey.cxx 2004-06-10 17:27:07.000000000 +0200
17987 +/*************************************************************************
17989 + * $RCSfile: pq_xkey.cxx,v $
17991 + * $Revision: 1.1.2.2 $
17993 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:07 $
17995 + * The Contents of this file are made available subject to the terms of
17996 + * either of the following licenses
17998 + * - GNU Lesser General Public License Version 2.1
17999 + * - Sun Industry Standards Source License Version 1.1
18001 + * Sun Microsystems Inc., October, 2000
18003 + * GNU Lesser General Public License Version 2.1
18004 + * =============================================
18005 + * Copyright 2000 by Sun Microsystems, Inc.
18006 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
18008 + * This library is free software; you can redistribute it and/or
18009 + * modify it under the terms of the GNU Lesser General Public
18010 + * License version 2.1, as published by the Free Software Foundation.
18012 + * This library is distributed in the hope that it will be useful,
18013 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
18014 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18015 + * Lesser General Public License for more details.
18017 + * You should have received a copy of the GNU Lesser General Public
18018 + * License along with this library; if not, write to the Free Software
18019 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18020 + * MA 02111-1307 USA
18023 + * Sun Industry Standards Source License Version 1.1
18024 + * =================================================
18025 + * The contents of this file are subject to the Sun Industry Standards
18026 + * Source License Version 1.1 (the "License"); You may not use this file
18027 + * except in compliance with the License. You may obtain a copy of the
18028 + * License at http://www.openoffice.org/license.html.
18030 + * Software provided under this License is provided on an "AS IS" basis,
18031 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18032 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
18033 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
18034 + * See the License for the specific provisions governing your rights and
18035 + * obligations concerning the Software.
18037 + * The Initial Developer of the Original Code is: Joerg Budischewski
18039 + * Copyright: 2000 by Sun Microsystems, Inc.
18041 + * All Rights Reserved.
18043 + * Contributor(s): Joerg Budischewski
18046 + ************************************************************************/
18048 +#include <rtl/ustrbuf.hxx>
18050 +#include <cppuhelper/typeprovider.hxx>
18051 +#include <cppuhelper/queryinterface.hxx>
18053 +#include <com/sun/star/beans/PropertyAttribute.hpp>
18055 +#include <com/sun/star/sdbc/XRow.hpp>
18056 +#include <com/sun/star/sdbc/XParameters.hpp>
18058 +#include "pq_xkey.hxx"
18059 +#include "pq_xkeycolumns.hxx"
18060 +#include "pq_tools.hxx"
18061 +#include "pq_statics.hxx"
18063 +using osl::MutexGuard;
18066 +using rtl::OUString;
18067 +using rtl::OUStringBuffer;
18069 +using com::sun::star::container::XNameAccess;
18070 +using com::sun::star::container::XIndexAccess;
18071 +using com::sun::star::container::ElementExistException;
18072 +using com::sun::star::container::NoSuchElementException;
18074 +using com::sun::star::uno::Reference;
18075 +using com::sun::star::uno::Exception;
18076 +using com::sun::star::uno::UNO_QUERY;
18077 +using com::sun::star::uno::XInterface;
18078 +using com::sun::star::uno::Sequence;
18079 +using com::sun::star::uno::Any;
18080 +using com::sun::star::uno::makeAny;
18081 +using com::sun::star::uno::Type;
18082 +using com::sun::star::uno::RuntimeException;
18084 +using com::sun::star::lang::IllegalArgumentException;
18085 +using com::sun::star::lang::IndexOutOfBoundsException;
18087 +using com::sun::star::beans::XPropertySetInfo;
18088 +using com::sun::star::beans::XFastPropertySet;
18089 +using com::sun::star::beans::XMultiPropertySet;
18090 +using com::sun::star::beans::XPropertySet;
18091 +using com::sun::star::beans::Property;
18093 +using com::sun::star::sdbc::XResultSet;
18094 +using com::sun::star::sdbc::XPreparedStatement;
18095 +using com::sun::star::sdbc::XStatement;
18096 +using com::sun::star::sdbc::XParameters;
18097 +using com::sun::star::sdbc::XRow;
18098 +using com::sun::star::sdbc::SQLException;
18100 +namespace pq_sdbc_driver
18102 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
18104 +Key::Key( const ::rtl::Reference< RefCountedMutex > & refMutex,
18105 + const Reference< com::sun::star::sdbc::XConnection > & connection,
18106 + ConnectionSettings *pSettings,
18107 + const rtl::OUString & schemaName,
18108 + const rtl::OUString & tableName )
18109 + : ReflectionBase(
18110 + getStatics().refl.key.implName,
18111 + getStatics().refl.key.serviceNames,
18115 + * getStatics().refl.key.pProps ),
18116 + m_schemaName( schemaName ),
18117 + m_tableName( tableName )
18120 +Reference< XPropertySet > Key::createDataDescriptor( ) throw (RuntimeException)
18122 + KeyDescriptor * pKeyDescriptor = new KeyDescriptor(
18123 + m_refMutex, m_conn, m_pSettings );
18124 + pKeyDescriptor->copyValuesFrom( this );
18126 + return Reference< XPropertySet > ( pKeyDescriptor );
18129 +Reference< XNameAccess > Key::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
18131 + // TODO: cash columns object !
18132 + if( !m_keyColumns.is() )
18134 + Sequence< OUString > columnNames, foreignColumnNames;
18135 + getPropertyValue( getStatics().PRIVATE_COLUMNS ) >>= columnNames;
18136 + getPropertyValue( getStatics().PRIVATE_FOREIGN_COLUMNS ) >>= foreignColumnNames;
18138 + m_keyColumns = KeyColumns::create(
18139 + m_refMutex, m_conn, m_pSettings, m_schemaName,
18140 + m_tableName, columnNames, foreignColumnNames );
18142 + return m_keyColumns;
18145 +Sequence<Type > Key::getTypes() throw( RuntimeException )
18147 + static cppu::OTypeCollection *pCollection;
18148 + if( ! pCollection )
18150 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
18151 + if( !pCollection )
18153 + static cppu::OTypeCollection collection(
18154 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
18155 + ReflectionBase::getTypes());
18156 + pCollection = &collection;
18159 + return pCollection->getTypes();
18162 +Sequence< sal_Int8> Key::getImplementationId() throw( RuntimeException )
18164 + return getStatics().refl.key.implementationId;
18167 +Any Key::queryInterface( const Type & reqType ) throw (RuntimeException)
18171 + ret = ReflectionBase::queryInterface( reqType );
18172 + if( ! ret.hasValue() )
18173 + ret = ::cppu::queryInterface(
18175 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
18180 +//_____________________________________________________________________________
18181 +KeyDescriptor::KeyDescriptor( const ::rtl::Reference< RefCountedMutex > & refMutex,
18182 + const Reference< com::sun::star::sdbc::XConnection > & connection,
18183 + ConnectionSettings *pSettings )
18184 + : ReflectionBase(
18185 + getStatics().refl.keyDescriptor.implName,
18186 + getStatics().refl.keyDescriptor.serviceNames,
18190 + * getStatics().refl.keyDescriptor.pProps )
18194 +Reference< XPropertySet > KeyDescriptor::createDataDescriptor( ) throw (RuntimeException)
18196 + KeyDescriptor * pKeyDescriptor = new KeyDescriptor(
18197 + m_refMutex, m_conn, m_pSettings );
18198 + pKeyDescriptor->copyValuesFrom( this );
18200 + return Reference< XPropertySet > ( pKeyDescriptor );
18203 +Reference< XNameAccess > KeyDescriptor::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
18205 + // TODO: cash columns object !
18206 + if( !m_keyColumns.is() )
18208 + m_keyColumns = new KeyColumnDescriptors( m_refMutex, m_conn, m_pSettings );
18210 + return m_keyColumns;
18213 +Sequence<Type > KeyDescriptor::getTypes() throw( RuntimeException )
18215 + static cppu::OTypeCollection *pCollection;
18216 + if( ! pCollection )
18218 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
18219 + if( !pCollection )
18221 + static cppu::OTypeCollection collection(
18222 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
18223 + ReflectionBase::getTypes());
18224 + pCollection = &collection;
18227 + return pCollection->getTypes();
18230 +Sequence< sal_Int8> KeyDescriptor::getImplementationId() throw( RuntimeException )
18232 + return getStatics().refl.keyDescriptor.implementationId;
18235 +Any KeyDescriptor::queryInterface( const Type & reqType ) throw (RuntimeException)
18239 + ret = ReflectionBase::queryInterface( reqType );
18240 + if( ! ret.hasValue() )
18241 + ret = ::cppu::queryInterface(
18243 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ) );
18249 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
18250 +++ connectivity/source/drivers/postgresql/pq_xkey.hxx 2004-06-10 17:27:08.000000000 +0200
18252 +/*************************************************************************
18254 + * $RCSfile: pq_xkey.hxx,v $
18256 + * $Revision: 1.1.2.2 $
18258 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:08 $
18260 + * The Contents of this file are made available subject to the terms of
18261 + * either of the following licenses
18263 + * - GNU Lesser General Public License Version 2.1
18264 + * - Sun Industry Standards Source License Version 1.1
18266 + * Sun Microsystems Inc., October, 2000
18268 + * GNU Lesser General Public License Version 2.1
18269 + * =============================================
18270 + * Copyright 2000 by Sun Microsystems, Inc.
18271 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
18273 + * This library is free software; you can redistribute it and/or
18274 + * modify it under the terms of the GNU Lesser General Public
18275 + * License version 2.1, as published by the Free Software Foundation.
18277 + * This library is distributed in the hope that it will be useful,
18278 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
18279 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18280 + * Lesser General Public License for more details.
18282 + * You should have received a copy of the GNU Lesser General Public
18283 + * License along with this library; if not, write to the Free Software
18284 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18285 + * MA 02111-1307 USA
18288 + * Sun Industry Standards Source License Version 1.1
18289 + * =================================================
18290 + * The contents of this file are subject to the Sun Industry Standards
18291 + * Source License Version 1.1 (the "License"); You may not use this file
18292 + * except in compliance with the License. You may obtain a copy of the
18293 + * License at http://www.openoffice.org/license.html.
18295 + * Software provided under this License is provided on an "AS IS" basis,
18296 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18297 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
18298 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
18299 + * See the License for the specific provisions governing your rights and
18300 + * obligations concerning the Software.
18302 + * The Initial Developer of the Original Code is: Joerg Budischewski
18304 + * Copyright: 2000 by Sun Microsystems, Inc.
18306 + * All Rights Reserved.
18308 + * Contributor(s): Joerg Budischewski
18311 + ************************************************************************/
18313 +#ifndef HEADER_PQ_KEY_HXX_
18314 +#define HEADER_PQ_KEY_HXX_
18316 +#include <cppuhelper/component.hxx>
18317 +#include <cppuhelper/propshlp.hxx>
18319 +#include <com/sun/star/lang/XServiceInfo.hpp>
18320 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
18321 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
18323 +#include "pq_connection.hxx"
18324 +#include "pq_xbase.hxx"
18326 +namespace pq_sdbc_driver
18329 +class Key : public ReflectionBase,
18330 + public com::sun::star::sdbcx::XColumnsSupplier
18332 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XDatabaseMetaData > m_meta;
18333 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_keyColumns;
18335 + rtl::OUString m_schemaName;
18336 + rtl::OUString m_tableName;
18339 + Key( const ::rtl::Reference< RefCountedMutex > & refMutex,
18340 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
18341 + ConnectionSettings *pSettings,
18342 + const rtl::OUString &schemaName,
18343 + const rtl::OUString &tableName);
18345 +public: // XInterface
18346 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
18347 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
18348 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
18349 + const com::sun::star::uno::Type & reqType )
18350 + throw (com::sun::star::uno::RuntimeException);
18352 +public: // XColumnsSupplier
18353 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
18354 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
18356 +public: // XTypeProvider, first implemented by OPropertySetHelper
18357 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
18358 + throw( com::sun::star::uno::RuntimeException );
18359 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
18360 + throw( com::sun::star::uno::RuntimeException );
18362 +public: // XDataDescriptorFactory
18363 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
18364 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
18369 +class KeyDescriptor : public ReflectionBase, public com::sun::star::sdbcx::XColumnsSupplier
18371 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_keyColumns;
18374 + KeyDescriptor( const ::rtl::Reference< RefCountedMutex > & refMutex,
18375 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
18376 + ConnectionSettings *pSettings );
18378 +public: // XInterface
18379 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
18380 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
18381 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
18382 + const com::sun::star::uno::Type & reqType )
18383 + throw (com::sun::star::uno::RuntimeException);
18385 +public: // XColumnsSupplier
18386 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
18387 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
18389 +public: // XTypeProvider, first implemented by OPropertySetHelper
18390 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
18391 + throw( com::sun::star::uno::RuntimeException );
18392 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
18393 + throw( com::sun::star::uno::RuntimeException );
18395 +public: // XDataDescriptorFactory
18396 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
18397 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
18404 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
18405 +++ connectivity/source/drivers/postgresql/pq_xkeys.cxx 2004-08-29 10:33:32.000000000 +0200
18407 +/*************************************************************************
18409 + * $RCSfile: pq_xkeys.cxx,v $
18411 + * $Revision: 1.1.2.3 $
18413 + * last change: $Author: jbu $ $Date: 2004/08/29 08:33:32 $
18415 + * The Contents of this file are made available subject to the terms of
18416 + * either of the following licenses
18418 + * - GNU Lesser General Public License Version 2.1
18419 + * - Sun Industry Standards Source License Version 1.1
18421 + * Sun Microsystems Inc., October, 2000
18423 + * GNU Lesser General Public License Version 2.1
18424 + * =============================================
18425 + * Copyright 2000 by Sun Microsystems, Inc.
18426 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
18428 + * This library is free software; you can redistribute it and/or
18429 + * modify it under the terms of the GNU Lesser General Public
18430 + * License version 2.1, as published by the Free Software Foundation.
18432 + * This library is distributed in the hope that it will be useful,
18433 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
18434 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18435 + * Lesser General Public License for more details.
18437 + * You should have received a copy of the GNU Lesser General Public
18438 + * License along with this library; if not, write to the Free Software
18439 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18440 + * MA 02111-1307 USA
18443 + * Sun Industry Standards Source License Version 1.1
18444 + * =================================================
18445 + * The contents of this file are subject to the Sun Industry Standards
18446 + * Source License Version 1.1 (the "License"); You may not use this file
18447 + * except in compliance with the License. You may obtain a copy of the
18448 + * License at http://www.openoffice.org/license.html.
18450 + * Software provided under this License is provided on an "AS IS" basis,
18451 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18452 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
18453 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
18454 + * See the License for the specific provisions governing your rights and
18455 + * obligations concerning the Software.
18457 + * The Initial Developer of the Original Code is: Joerg Budischewski
18459 + * Copyright: 2000 by Sun Microsystems, Inc.
18461 + * All Rights Reserved.
18463 + * Contributor(s): Joerg Budischewski
18466 + ************************************************************************/
18469 +#include <hash_map>
18471 +#include <rtl/ustrbuf.hxx>
18472 +#include <rtl/strbuf.hxx>
18474 +#include <com/sun/star/sdbc/XRow.hpp>
18475 +#include <com/sun/star/sdbc/XParameters.hpp>
18476 +#include <com/sun/star/sdbc/KeyRule.hpp>
18477 +#include <com/sun/star/sdbcx/KeyType.hpp>
18479 +#include "pq_xkeys.hxx"
18480 +#include "pq_xkey.hxx"
18481 +#include "pq_statics.hxx"
18482 +#include "pq_tools.hxx"
18484 +using osl::MutexGuard;
18486 +using rtl::OUString;
18487 +using rtl::OUStringBuffer;
18488 +using rtl::OUStringToOString;
18490 +using com::sun::star::beans::XPropertySet;
18492 +using com::sun::star::uno::Any;
18493 +using com::sun::star::uno::makeAny;
18494 +using com::sun::star::uno::UNO_QUERY;
18495 +using com::sun::star::uno::Type;
18496 +using com::sun::star::uno::XInterface;
18497 +using com::sun::star::uno::Reference;
18498 +using com::sun::star::uno::Sequence;
18499 +using com::sun::star::uno::RuntimeException;
18501 +using com::sun::star::container::NoSuchElementException;
18502 +using com::sun::star::lang::WrappedTargetException;
18504 +using com::sun::star::sdbc::XRow;
18505 +using com::sun::star::sdbc::XCloseable;
18506 +using com::sun::star::sdbc::XStatement;
18507 +using com::sun::star::sdbc::XResultSet;
18508 +using com::sun::star::sdbc::XParameters;
18509 +using com::sun::star::sdbc::XPreparedStatement;
18510 +using com::sun::star::sdbc::XDatabaseMetaData;
18512 +namespace pq_sdbc_driver
18514 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
18517 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18518 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18519 + ConnectionSettings *pSettings,
18520 + const rtl::OUString &schemaName,
18521 + const rtl::OUString &tableName)
18522 + : Container( refMutex, origin, pSettings, getStatics().KEY ),
18523 + m_schemaName( schemaName ),
18524 + m_tableName( tableName )
18530 +static sal_Int32 string2keytype( const rtl::OUString &type )
18532 + sal_Int32 ret = com::sun::star::sdbcx::KeyType::UNIQUE;
18533 + if( type.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "p" ) ) == 0 )
18534 + ret = com::sun::star::sdbcx::KeyType::PRIMARY;
18535 + else if( type.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "f" ) ) == 0 )
18536 + ret = com::sun::star::sdbcx::KeyType::FOREIGN;
18540 +static sal_Int32 string2keyrule( const rtl::OUString & rule )
18542 + sal_Int32 ret = com::sun::star::sdbc::KeyRule::NO_ACTION;
18543 + if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "r" ) ) == 0 )
18544 + ret = com::sun::star::sdbc::KeyRule::RESTRICT;
18545 + else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "c" ) ) == 0 )
18546 + ret = com::sun::star::sdbc::KeyRule::CASCADE;
18547 + else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "n" ) ) == 0 )
18548 + ret = com::sun::star::sdbc::KeyRule::SET_NULL;
18549 + else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "d" ) ) == 0 )
18550 + ret = com::sun::star::sdbc::KeyRule::SET_DEFAULT;
18556 +// static void fillAttnum2attnameMap(
18557 +// Int2StringMap &map,
18558 +// const Reference< com::sun::star::sdbc::XConnection > &conn,
18559 +// const rtl::OUString &schema,
18560 +// const rtl::OUString &table )
18562 +// Reference< XPreparedStatement > prep = conn->prepareStatement(
18563 +// ASCII_STR( "SELECT attname,attnum "
18564 +// "FROM pg_attribute "
18565 +// "INNER JOIN pg_class ON attrelid = pg_class.oid "
18566 +// "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
18567 +// "WHERE relname=? AND nspname=?" ) );
18569 +// Reference< XParameters > paras( prep, UNO_QUERY );
18570 +// paras->setString( 1 , table );
18571 +// paras->setString( 2 , schema );
18572 +// Reference< XResultSet > rs = prep->executeQuery();
18574 +// Reference< XRow > xRow( rs , UNO_QUERY );
18575 +// while( rs->next() )
18577 +// map[ xRow->getInt(2) ] = xRow->getString(1);
18581 +// static Sequence< rtl::OUString > resolveColumnNames(
18582 +// const Int2StringMap &map, const rtl::OUString &array )
18584 +// Sequence< sal_Int32 > intArray = string2intarray( array );
18585 +// Sequence< ::rtl::OUString > ret( intArray.getLength() );
18586 +// for( int i = 0; i < intArray.getLength() ; i ++ )
18588 +// Int2StringMap::const_iterator ii = map.find( intArray[i] );
18589 +// if( ii != map.end() )
18590 +// ret[i] = ii->second;
18595 +void Keys::refresh()
18596 + throw (::com::sun::star::uno::RuntimeException)
18600 + if( isLog( m_pSettings, LogLevel::INFO ) )
18602 + rtl::OStringBuffer buf;
18603 + buf.append( "sdbcx.Keys get refreshed for table " );
18604 + buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) );
18605 + buf.append( "." );
18606 + buf.append( OUStringToOString( m_tableName,m_pSettings->encoding ) );
18607 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
18610 + osl::MutexGuard guard( m_refMutex->mutex );
18611 + Statics & st = getStatics();
18613 + Int2StringMap mainMap;
18614 + fillAttnum2attnameMap( mainMap, m_origin, m_schemaName, m_tableName );
18616 + Reference< XPreparedStatement > stmt = m_origin->prepareStatement(
18618 + "SELECT conname, " // 1
18620 + "confupdtype, " // 3
18621 + "confdeltype, " // 4
18622 + "class2.relname, " // 5
18623 + "nmsp2.nspname, " // 6
18626 + "FROM pg_constraint INNER JOIN pg_class ON conrelid = pg_class.oid "
18627 + "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
18628 + "LEFT JOIN pg_class AS class2 ON confrelid = class2.oid "
18629 + "LEFT JOIN pg_namespace AS nmsp2 ON class2.relnamespace=nmsp2.oid "
18630 + "WHERE pg_class.relname = ? AND pg_namespace.nspname = ?" ) );
18632 + Reference< XParameters > paras( stmt, UNO_QUERY );
18633 + paras->setString( 1 , m_tableName );
18634 + paras->setString( 2 , m_schemaName );
18635 + Reference< XResultSet > rs = stmt->executeQuery();
18637 + Reference< XRow > xRow( rs , UNO_QUERY );
18639 + String2IntMap map;
18640 + std::vector< Any, Allocator< Any> > vec;
18641 + sal_Int32 keyIndex = 0;
18642 + while( rs->next() )
18645 + new Key( m_refMutex, m_origin, m_pSettings , m_schemaName, m_tableName );
18646 + Reference< com::sun::star::beans::XPropertySet > prop = pKey;
18648 + pKey->setPropertyValue_NoBroadcast_public(
18649 + st.NAME, makeAny( xRow->getString( 1 ) ) );
18650 + sal_Int32 keyType = string2keytype( xRow->getString(2) );
18651 + pKey->setPropertyValue_NoBroadcast_public( st.TYPE, makeAny( keyType ) );
18652 + pKey->setPropertyValue_NoBroadcast_public(
18653 + st.UPDATE_RULE, makeAny( string2keyrule( xRow->getString(3) ) ) );
18654 + pKey->setPropertyValue_NoBroadcast_public(
18655 + st.DELETE_RULE, makeAny( string2keyrule( xRow->getString(4) ) ) );
18656 + pKey->setPropertyValue_NoBroadcast_public(
18657 + st.PRIVATE_COLUMNS,
18659 + convertMappedIntArray2StringArray(
18661 + string2intarray( xRow->getString( 7 ) ) ) ) );
18663 + if( com::sun::star::sdbcx::KeyType::FOREIGN == keyType )
18665 + OUStringBuffer buf( 128 );
18666 + buf.append( xRow->getString( 6 ) );
18667 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "." ) );
18668 + buf.append( xRow->getString( 5 ) );
18669 + pKey->setPropertyValue_NoBroadcast_public(
18670 + st.REFERENCED_TABLE, makeAny( buf.makeStringAndClear() ) );
18672 + Int2StringMap foreignMap;
18673 + fillAttnum2attnameMap( foreignMap, m_origin, xRow->getString(6), xRow->getString(5));
18674 + pKey->setPropertyValue_NoBroadcast_public(
18675 + st.PRIVATE_FOREIGN_COLUMNS,
18677 + convertMappedIntArray2StringArray(
18679 + string2intarray( xRow->getString(8) ) ) ) );
18682 + vec.push_back( makeAny( prop ) );
18683 + map[ xRow->getString( 1 ) ] = keyIndex;
18686 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
18687 + m_name2index.swap( map );
18689 + catch ( com::sun::star::sdbc::SQLException & e )
18691 + throw RuntimeException( e.Message , e.Context );
18694 + fire( RefreshedBroadcaster( *this ) );
18698 +void Keys::appendByDescriptor(
18699 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
18700 + throw (::com::sun::star::sdbc::SQLException,
18701 + ::com::sun::star::container::ElementExistException,
18702 + ::com::sun::star::uno::RuntimeException)
18704 + osl::MutexGuard guard( m_refMutex->mutex );
18706 + OUStringBuffer buf( 128 );
18707 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE " ) );
18708 + bufferQuoteQualifiedIdentifier( buf, m_schemaName, m_tableName );
18709 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ADD " ) );
18710 + bufferKey2TableConstraint( buf, descriptor );
18712 + Reference< XStatement > stmt =
18713 + m_origin->createStatement();
18714 + stmt->executeUpdate( buf.makeStringAndClear() );
18718 +void Keys::dropByIndex( sal_Int32 index )
18719 + throw (::com::sun::star::sdbc::SQLException,
18720 + ::com::sun::star::lang::IndexOutOfBoundsException,
18721 + ::com::sun::star::uno::RuntimeException)
18723 + osl::MutexGuard guard( m_refMutex->mutex );
18724 + if( index < 0 || index >= m_values.getLength() )
18726 + OUStringBuffer buf( 128 );
18727 + buf.appendAscii( "TABLES: Index out of range (allowed 0 to " );
18728 + buf.append( (sal_Int32)(m_values.getLength() -1) );
18729 + buf.appendAscii( ", got " );
18730 + buf.append( index );
18731 + buf.appendAscii( ")" );
18732 + throw com::sun::star::lang::IndexOutOfBoundsException(
18733 + buf.makeStringAndClear(), *this );
18737 + Reference< XPropertySet > set;
18738 + m_values[index] >>= set;
18740 + OUStringBuffer buf( 128 );
18741 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE " ) );
18742 + bufferQuoteQualifiedIdentifier( buf, m_schemaName, m_tableName );
18743 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " DROP CONSTRAINT " ) );
18744 + bufferQuoteIdentifier( buf, extractStringProperty( set , getStatics().NAME ) );
18745 + m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
18748 + Container::dropByIndex( index );
18752 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Keys::createDataDescriptor()
18753 + throw (::com::sun::star::uno::RuntimeException)
18755 + return new KeyDescriptor( m_refMutex, m_origin, m_pSettings );
18758 +Reference< com::sun::star::container::XIndexAccess > Keys::create(
18759 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18760 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18761 + ConnectionSettings *pSettings,
18762 + const rtl::OUString & schemaName,
18763 + const rtl::OUString & tableName)
18765 + Keys *pKeys = new Keys( refMutex, origin, pSettings, schemaName, tableName );
18766 + Reference< com::sun::star::container::XIndexAccess > ret = pKeys;
18767 + pKeys->refresh();
18771 +//_________________________________________________________________________________________
18772 +KeyDescriptors::KeyDescriptors(
18773 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18774 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18775 + ConnectionSettings *pSettings)
18776 + : Container( refMutex, origin, pSettings, getStatics().KEY )
18779 +Reference< com::sun::star::container::XIndexAccess > KeyDescriptors::create(
18780 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18781 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18782 + ConnectionSettings *pSettings)
18784 + return new KeyDescriptors( refMutex, origin, pSettings );
18787 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > KeyDescriptors::createDataDescriptor()
18788 + throw (::com::sun::star::uno::RuntimeException)
18790 + return new KeyDescriptor( m_refMutex, m_origin, m_pSettings );
18794 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
18795 +++ connectivity/source/drivers/postgresql/pq_xkeys.hxx 2004-06-10 17:27:10.000000000 +0200
18797 +/*************************************************************************
18799 + * $RCSfile: pq_xkeys.hxx,v $
18801 + * $Revision: 1.1.2.2 $
18803 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:10 $
18805 + * The Contents of this file are made available subject to the terms of
18806 + * either of the following licenses
18808 + * - GNU Lesser General Public License Version 2.1
18809 + * - Sun Industry Standards Source License Version 1.1
18811 + * Sun Microsystems Inc., October, 2000
18813 + * GNU Lesser General Public License Version 2.1
18814 + * =============================================
18815 + * Copyright 2000 by Sun Microsystems, Inc.
18816 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
18818 + * This library is free software; you can redistribute it and/or
18819 + * modify it under the terms of the GNU Lesser General Public
18820 + * License version 2.1, as published by the Free Software Foundation.
18822 + * This library is distributed in the hope that it will be useful,
18823 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
18824 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18825 + * Lesser General Public License for more details.
18827 + * You should have received a copy of the GNU Lesser General Public
18828 + * License along with this library; if not, write to the Free Software
18829 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18830 + * MA 02111-1307 USA
18833 + * Sun Industry Standards Source License Version 1.1
18834 + * =================================================
18835 + * The contents of this file are subject to the Sun Industry Standards
18836 + * Source License Version 1.1 (the "License"); You may not use this file
18837 + * except in compliance with the License. You may obtain a copy of the
18838 + * License at http://www.openoffice.org/license.html.
18840 + * Software provided under this License is provided on an "AS IS" basis,
18841 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18842 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
18843 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
18844 + * See the License for the specific provisions governing your rights and
18845 + * obligations concerning the Software.
18847 + * The Initial Developer of the Original Code is: Joerg Budischewski
18849 + * Copyright: 2000 by Sun Microsystems, Inc.
18851 + * All Rights Reserved.
18853 + * Contributor(s): Joerg Budischewski
18856 + ************************************************************************/
18858 +#ifndef _PQ_KEYS_HXX_
18859 +#define _PQ_KEYS_HXX_
18861 +#include "pq_xcontainer.hxx"
18863 +namespace pq_sdbc_driver
18865 +class Keys : public Container
18867 + rtl::OUString m_schemaName;
18868 + rtl::OUString m_tableName;
18870 +public: // instances Columns 'exception safe'
18871 + static com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > create(
18872 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18873 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18874 + ConnectionSettings *pSettings,
18875 + const rtl::OUString &schemaName,
18876 + const rtl::OUString &tableName);
18880 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18881 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18882 + ConnectionSettings *pSettings,
18883 + const rtl::OUString &schemaName,
18884 + const rtl::OUString &tableName);
18888 +public: // XAppend
18889 + virtual void SAL_CALL appendByDescriptor(
18890 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
18891 + throw (::com::sun::star::sdbc::SQLException,
18892 + ::com::sun::star::container::ElementExistException,
18893 + ::com::sun::star::uno::RuntimeException);
18896 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
18897 + throw (::com::sun::star::sdbc::SQLException,
18898 + ::com::sun::star::lang::IndexOutOfBoundsException,
18899 + ::com::sun::star::uno::RuntimeException);
18901 +public: // XRefreshable
18902 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
18904 +public: // XDataDescriptorFactory
18905 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
18906 + throw (::com::sun::star::uno::RuntimeException);
18910 +class KeyDescriptors : public Container
18912 +public: // instances Columns 'exception safe'
18913 + static com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > create(
18914 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18915 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18916 + ConnectionSettings *pSettings );
18920 + const ::rtl::Reference< RefCountedMutex > & refMutex,
18921 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
18922 + ConnectionSettings *pSettings );
18924 +public: // XDataDescriptorFactory
18925 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
18926 + throw (::com::sun::star::uno::RuntimeException);
18931 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
18932 +++ connectivity/source/drivers/postgresql/pq_xtable.cxx 2007-01-07 14:50:38.000000000 +0100
18934 +/*************************************************************************
18936 + * $RCSfile: pq_xtable.cxx,v $
18938 + * $Revision: 1.1.2.6 $
18940 + * last change: $Author: jbu $ $Date: 2007/01/07 13:50:38 $
18942 + * The Contents of this file are made available subject to the terms of
18943 + * either of the following licenses
18945 + * - GNU Lesser General Public License Version 2.1
18946 + * - Sun Industry Standards Source License Version 1.1
18948 + * Sun Microsystems Inc., October, 2000
18950 + * GNU Lesser General Public License Version 2.1
18951 + * =============================================
18952 + * Copyright 2000 by Sun Microsystems, Inc.
18953 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
18955 + * This library is free software; you can redistribute it and/or
18956 + * modify it under the terms of the GNU Lesser General Public
18957 + * License version 2.1, as published by the Free Software Foundation.
18959 + * This library is distributed in the hope that it will be useful,
18960 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
18961 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18962 + * Lesser General Public License for more details.
18964 + * You should have received a copy of the GNU Lesser General Public
18965 + * License along with this library; if not, write to the Free Software
18966 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18967 + * MA 02111-1307 USA
18970 + * Sun Industry Standards Source License Version 1.1
18971 + * =================================================
18972 + * The contents of this file are subject to the Sun Industry Standards
18973 + * Source License Version 1.1 (the "License"); You may not use this file
18974 + * except in compliance with the License. You may obtain a copy of the
18975 + * License at http://www.openoffice.org/license.html.
18977 + * Software provided under this License is provided on an "AS IS" basis,
18978 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18979 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
18980 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
18981 + * See the License for the specific provisions governing your rights and
18982 + * obligations concerning the Software.
18984 + * The Initial Developer of the Original Code is: Joerg Budischewski
18986 + * Copyright: 2000 by Sun Microsystems, Inc.
18988 + * All Rights Reserved.
18990 + * Contributor(s): Joerg Budischewski
18993 + ************************************************************************/
18995 +#include <rtl/ustrbuf.hxx>
18997 +#include <cppuhelper/typeprovider.hxx>
18998 +#include <cppuhelper/queryinterface.hxx>
19000 +#include <com/sun/star/beans/PropertyAttribute.hpp>
19002 +#include <com/sun/star/sdbc/XRow.hpp>
19003 +#include <com/sun/star/sdbc/XParameters.hpp>
19005 +#include "pq_xtable.hxx"
19006 +#include "pq_xtables.hxx"
19007 +#include "pq_xviews.hxx"
19008 +#include "pq_xindexes.hxx"
19009 +#include "pq_xkeys.hxx"
19010 +#include "pq_xcolumns.hxx"
19011 +#include "pq_tools.hxx"
19012 +#include "pq_statics.hxx"
19014 +using osl::MutexGuard;
19017 +using rtl::OUString;
19018 +using rtl::OUStringBuffer;
19019 +using rtl::OUStringToOString;
19021 +using com::sun::star::container::XNameAccess;
19022 +using com::sun::star::container::XIndexAccess;
19023 +using com::sun::star::container::ElementExistException;
19024 +using com::sun::star::container::NoSuchElementException;
19026 +using com::sun::star::uno::Reference;
19027 +using com::sun::star::uno::Exception;
19028 +using com::sun::star::uno::UNO_QUERY;
19029 +using com::sun::star::uno::XInterface;
19030 +using com::sun::star::uno::Sequence;
19031 +using com::sun::star::uno::Any;
19032 +using com::sun::star::uno::makeAny;
19033 +using com::sun::star::uno::Type;
19034 +using com::sun::star::uno::RuntimeException;
19036 +using com::sun::star::lang::IllegalArgumentException;
19037 +using com::sun::star::lang::IndexOutOfBoundsException;
19039 +using com::sun::star::beans::XPropertySetInfo;
19040 +using com::sun::star::beans::XFastPropertySet;
19041 +using com::sun::star::beans::XMultiPropertySet;
19042 +using com::sun::star::beans::XPropertySet;
19043 +using com::sun::star::beans::Property;
19045 +using com::sun::star::sdbc::XResultSet;
19046 +using com::sun::star::sdbc::XPreparedStatement;
19047 +using com::sun::star::sdbc::XStatement;
19048 +using com::sun::star::sdbc::XParameters;
19049 +using com::sun::star::sdbc::XRow;
19050 +using com::sun::star::sdbc::SQLException;
19052 +namespace pq_sdbc_driver
19054 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
19056 +Table::Table( const ::rtl::Reference< RefCountedMutex > & refMutex,
19057 + const Reference< com::sun::star::sdbc::XConnection > & connection,
19058 + ConnectionSettings *pSettings)
19059 + : ReflectionBase(
19060 + getStatics().refl.table.implName,
19061 + getStatics().refl.table.serviceNames,
19065 + * getStatics().refl.table.pProps ),
19069 +Reference< XPropertySet > Table::createDataDescriptor( ) throw (RuntimeException)
19071 + TableDescriptor * pTable = new TableDescriptor(
19072 + m_refMutex, m_conn, m_pSettings );
19073 + pTable->copyValuesFrom( this );
19075 + return Reference< XPropertySet > ( pTable );
19078 +Reference< XNameAccess > Table::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
19080 + if( ! m_columns.is() )
19082 + m_columns = Columns::create(
19086 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
19087 + extractStringProperty( this, getStatics().NAME ),
19090 + return m_columns;
19093 +Reference< XNameAccess > Table::getIndexes() throw (::com::sun::star::uno::RuntimeException)
19095 + if( ! m_indexes.is() )
19097 + m_indexes = ::pq_sdbc_driver::Indexes::create(
19101 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
19102 + extractStringProperty( this, getStatics().NAME ) );
19104 + return m_indexes;
19107 +Reference< XIndexAccess > Table::getKeys( ) throw (::com::sun::star::uno::RuntimeException)
19109 + if( ! m_keys.is() )
19111 + m_keys = ::pq_sdbc_driver::Keys::create(
19115 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
19116 + extractStringProperty( this, getStatics().NAME ) );
19121 +void Table::rename( const ::rtl::OUString& newName )
19122 + throw (::com::sun::star::sdbc::SQLException,
19123 + ::com::sun::star::container::ElementExistException,
19124 + ::com::sun::star::uno::RuntimeException)
19126 + MutexGuard guard( m_refMutex->mutex );
19127 + Statics & st = getStatics();
19129 + ::rtl::OUString oldName = extractStringProperty(this,st.NAME );
19130 + ::rtl::OUString schema = extractStringProperty(this,st.SCHEMA_NAME );
19131 + ::rtl::OUString fullOldName = concatQualified( schema, oldName );
19133 + OUString newTableName;
19134 + OUString newSchemaName;
19135 + // OOo2.0 passes schema + dot + new-table-name while
19136 + // OO1.1.x passes new Name without schema
19137 + // in case name contains a dot, it is interpreted as schema.tablename
19138 + if( newName.indexOf( '.' ) >= 0 )
19140 + splitConcatenatedIdentifier( newName, &newSchemaName, &newTableName );
19144 + newTableName = newName;
19145 + newSchemaName = schema;
19147 + ::rtl::OUString fullNewName = concatQualified( newSchemaName, newTableName );
19149 + if( extractStringProperty( this, st.TYPE ).equals( st.VIEW ) && m_pSettings->views.is() )
19151 + // maintain view list (really strange API !)
19152 + Any a = m_pSettings->pViewsImpl->getByName( fullOldName );
19153 + Reference< com::sun::star::sdbcx::XRename > rename;
19155 + if( rename.is() )
19157 + rename->rename( newName );
19158 + setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
19163 + if( ! newSchemaName.equals(schema) )
19165 + // try new schema name first
19168 + OUStringBuffer buf(128);
19169 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
19170 + bufferQuoteQualifiedIdentifier(buf, schema, oldName );
19171 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("SET SCHEMA" ) );
19172 + bufferQuoteIdentifier( buf, newSchemaName );
19173 + Reference< XStatement > statement = m_conn->createStatement();
19174 + statement->executeUpdate( buf.makeStringAndClear() );
19175 + setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
19176 + disposeNoThrow( statement );
19177 + schema = newSchemaName;
19179 + catch( com::sun::star::sdbc::SQLException &e )
19181 + OUStringBuffer buf( e.Message );
19182 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ) );
19183 + e.Message = buf.makeStringAndClear();
19188 + if( ! newTableName.equals( oldName ) ) // might also be just the change of a schema name
19190 + OUStringBuffer buf(128);
19191 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
19192 + bufferQuoteQualifiedIdentifier(buf, schema, oldName );
19193 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("RENAME TO" ) );
19194 + bufferQuoteIdentifier( buf, newTableName );
19195 + Reference< XStatement > statement = m_conn->createStatement();
19196 + statement->executeUpdate( buf.makeStringAndClear() );
19197 + disposeNoThrow( statement );
19200 + setPropertyValue_NoBroadcast_public( st.NAME, makeAny(newTableName) );
19201 + // inform the container of the name change !
19202 + if( m_pSettings->tables.is() )
19204 + m_pSettings->pTablesImpl->rename( fullOldName, fullNewName );
19208 +void Table::alterColumnByName(
19209 + const ::rtl::OUString& colName,
19210 + const Reference< XPropertySet >& descriptor )
19211 + throw (SQLException,NoSuchElementException,RuntimeException)
19213 + Reference< com::sun::star::container::XNameAccess > colums =
19214 + Reference< com::sun::star::container::XNameAccess > ( getColumns(), UNO_QUERY );
19216 + OUString newName = extractStringProperty(descriptor, getStatics().NAME );
19217 + ::pq_sdbc_driver::alterColumnByDescriptor(
19218 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
19219 + extractStringProperty( this, getStatics().NAME ),
19220 + m_pSettings->encoding,
19221 + m_conn->createStatement(),
19222 + Reference< com::sun::star::beans::XPropertySet>( colums->getByName( colName ), UNO_QUERY) ,
19225 + if( colName != newName )
19227 +// m_pColumns->rename( colName, newName );
19228 + m_pColumns->refresh();
19232 +void Table::alterColumnByIndex(
19234 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
19235 + throw (SQLException,IndexOutOfBoundsException,RuntimeException)
19237 + Reference< com::sun::star::container::XIndexAccess > colums =
19238 + Reference< com::sun::star::container::XIndexAccess>( getColumns(), UNO_QUERY );
19239 + Reference< com::sun::star::beans::XPropertySet> column(colums->getByIndex( index ), UNO_QUERY );
19240 + OUString oldName = extractStringProperty( column, getStatics().NAME );
19241 + OUString newName = extractStringProperty( descriptor, getStatics().NAME );
19242 + ::pq_sdbc_driver::alterColumnByDescriptor(
19243 + extractStringProperty( this, getStatics().SCHEMA_NAME ),
19244 + extractStringProperty( this, getStatics().NAME ),
19245 + m_pSettings->encoding,
19246 + m_conn->createStatement(),
19249 +// m_pColumns->rename( oldName, newName );
19250 + m_pColumns->refresh();
19253 +Sequence<Type > Table::getTypes() throw( RuntimeException )
19255 + static cppu::OTypeCollection *pCollection;
19256 + if( ! pCollection )
19258 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
19259 + if( !pCollection )
19261 + static cppu::OTypeCollection collection(
19262 + getCppuType( (Reference< com::sun::star::sdbcx::XIndexesSupplier> *) 0 ),
19263 + getCppuType( (Reference< com::sun::star::sdbcx::XKeysSupplier> *) 0 ),
19264 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
19265 + getCppuType( (Reference< com::sun::star::sdbcx::XRename> *) 0 ),
19266 + getCppuType( (Reference< com::sun::star::sdbcx::XAlterTable> *) 0 ),
19267 + ReflectionBase::getTypes());
19268 + pCollection = &collection;
19271 + return pCollection->getTypes();
19274 +Sequence< sal_Int8> Table::getImplementationId() throw( RuntimeException )
19276 + return getStatics().refl.table.implementationId;
19279 +Any Table::queryInterface( const Type & reqType ) throw (RuntimeException)
19283 + ret = ReflectionBase::queryInterface( reqType );
19284 + if( ! ret.hasValue() )
19285 + ret = ::cppu::queryInterface(
19287 + static_cast< com::sun::star::sdbcx::XIndexesSupplier * > ( this ),
19288 + static_cast< com::sun::star::sdbcx::XKeysSupplier * > ( this ),
19289 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ),
19290 + static_cast< com::sun::star::sdbcx::XRename * > ( this ),
19291 + static_cast< com::sun::star::sdbcx::XAlterTable * > ( this )
19296 +::com::sun::star::uno::Any Table::getPropertyValue(const ::rtl::OUString& aPropertyName)
19297 + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
19299 + return ReflectionBase::getPropertyValue( aPropertyName );
19303 +::rtl::OUString Table::getName( ) throw (::com::sun::star::uno::RuntimeException)
19305 + Statics & st = getStatics();
19306 + return concatQualified(
19307 + extractStringProperty( this, st.SCHEMA_NAME ),
19308 + extractStringProperty( this, st.NAME ) );
19311 +void Table::setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException)
19318 +//________________________________________________________________________
19319 +TableDescriptor::TableDescriptor(
19320 + const ::rtl::Reference< RefCountedMutex > & refMutex,
19321 + const Reference< com::sun::star::sdbc::XConnection > & connection,
19322 + ConnectionSettings *pSettings)
19323 + : ReflectionBase(
19324 + getStatics().refl.tableDescriptor.implName,
19325 + getStatics().refl.tableDescriptor.serviceNames,
19329 + * getStatics().refl.tableDescriptor.pProps )
19333 +Reference< XNameAccess > TableDescriptor::getColumns( ) throw (::com::sun::star::uno::RuntimeException)
19335 + if( ! m_columns.is() )
19337 + m_columns = new ColumnDescriptors(m_refMutex, m_conn, m_pSettings );
19339 + return m_columns;
19342 +Reference< XNameAccess > TableDescriptor::getIndexes() throw (::com::sun::star::uno::RuntimeException)
19344 + if( ! m_indexes.is() )
19346 + m_indexes = ::pq_sdbc_driver::IndexDescriptors::create(
19351 + return m_indexes;
19354 +Reference< XIndexAccess > TableDescriptor::getKeys( ) throw (::com::sun::star::uno::RuntimeException)
19356 + if( ! m_keys.is() )
19358 + m_keys = ::pq_sdbc_driver::KeyDescriptors::create(
19367 +Sequence<Type > TableDescriptor::getTypes() throw( RuntimeException )
19369 + static cppu::OTypeCollection *pCollection;
19370 + if( ! pCollection )
19372 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
19373 + if( !pCollection )
19375 + static cppu::OTypeCollection collection(
19376 + getCppuType( (Reference< com::sun::star::sdbcx::XIndexesSupplier> *) 0 ),
19377 + getCppuType( (Reference< com::sun::star::sdbcx::XKeysSupplier> *) 0 ),
19378 + getCppuType( (Reference< com::sun::star::sdbcx::XColumnsSupplier> *) 0 ),
19379 + ReflectionBase::getTypes());
19380 + pCollection = &collection;
19383 + return pCollection->getTypes();
19386 +Sequence< sal_Int8> TableDescriptor::getImplementationId() throw( RuntimeException )
19388 + return getStatics().refl.tableDescriptor.implementationId;
19391 +Any TableDescriptor::queryInterface( const Type & reqType ) throw (RuntimeException)
19395 + ret = ReflectionBase::queryInterface( reqType );
19396 + if( ! ret.hasValue() )
19397 + ret = ::cppu::queryInterface(
19399 + static_cast< com::sun::star::sdbcx::XIndexesSupplier * > ( this ),
19400 + static_cast< com::sun::star::sdbcx::XKeysSupplier * > ( this ),
19401 + static_cast< com::sun::star::sdbcx::XColumnsSupplier * > ( this ));
19406 +Reference< XPropertySet > TableDescriptor::createDataDescriptor( ) throw (RuntimeException)
19408 + TableDescriptor * pTable = new TableDescriptor(
19409 + m_refMutex, m_conn, m_pSettings );
19411 + // TODO: deep copies
19412 + pTable->m_values = m_values;
19414 + return Reference< XPropertySet > ( pTable );
19418 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
19419 +++ connectivity/source/drivers/postgresql/pq_xtable.hxx 2004-06-10 17:27:10.000000000 +0200
19421 +/*************************************************************************
19423 + * $RCSfile: pq_xtable.hxx,v $
19425 + * $Revision: 1.1.2.2 $
19427 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:10 $
19429 + * The Contents of this file are made available subject to the terms of
19430 + * either of the following licenses
19432 + * - GNU Lesser General Public License Version 2.1
19433 + * - Sun Industry Standards Source License Version 1.1
19435 + * Sun Microsystems Inc., October, 2000
19437 + * GNU Lesser General Public License Version 2.1
19438 + * =============================================
19439 + * Copyright 2000 by Sun Microsystems, Inc.
19440 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
19442 + * This library is free software; you can redistribute it and/or
19443 + * modify it under the terms of the GNU Lesser General Public
19444 + * License version 2.1, as published by the Free Software Foundation.
19446 + * This library is distributed in the hope that it will be useful,
19447 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
19448 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19449 + * Lesser General Public License for more details.
19451 + * You should have received a copy of the GNU Lesser General Public
19452 + * License along with this library; if not, write to the Free Software
19453 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19454 + * MA 02111-1307 USA
19457 + * Sun Industry Standards Source License Version 1.1
19458 + * =================================================
19459 + * The contents of this file are subject to the Sun Industry Standards
19460 + * Source License Version 1.1 (the "License"); You may not use this file
19461 + * except in compliance with the License. You may obtain a copy of the
19462 + * License at http://www.openoffice.org/license.html.
19464 + * Software provided under this License is provided on an "AS IS" basis,
19465 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19466 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
19467 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
19468 + * See the License for the specific provisions governing your rights and
19469 + * obligations concerning the Software.
19471 + * The Initial Developer of the Original Code is: Joerg Budischewski
19473 + * Copyright: 2000 by Sun Microsystems, Inc.
19475 + * All Rights Reserved.
19477 + * Contributor(s): Joerg Budischewski
19480 + ************************************************************************/
19482 +#ifndef _PQ_TABLE_HXX_
19483 +#define _PQ_TABLE_HXX_
19485 +#include <cppuhelper/component.hxx>
19486 +#include <cppuhelper/propshlp.hxx>
19488 +#include <com/sun/star/lang/XServiceInfo.hpp>
19489 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
19490 +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
19491 +#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
19492 +#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
19493 +#include <com/sun/star/sdbcx/XRename.hpp>
19494 +#include <com/sun/star/sdbcx/XAlterTable.hpp>
19495 +#include <com/sun/star/container/XNamed.hpp>
19497 +#include "pq_xbase.hxx"
19499 +namespace pq_sdbc_driver
19504 +class Table : public ReflectionBase,
19505 + public com::sun::star::sdbcx::XColumnsSupplier,
19506 + public com::sun::star::sdbcx::XIndexesSupplier,
19507 + public com::sun::star::sdbcx::XKeysSupplier,
19508 + public com::sun::star::sdbcx::XRename,
19509 + public com::sun::star::sdbcx::XAlterTable
19511 + ::com::sun::star::uno::Reference< com::sun::star::sdbc::XDatabaseMetaData > m_meta;
19512 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_columns;
19513 + ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_keys;
19514 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_indexes;
19515 + Columns *m_pColumns;
19518 + Table( const ::rtl::Reference< RefCountedMutex > & refMutex,
19519 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
19520 + ConnectionSettings *pSettings);
19524 +public: // XInterface
19525 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
19526 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
19527 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
19528 + const com::sun::star::uno::Type & reqType )
19529 + throw (com::sun::star::uno::RuntimeException);
19531 +public: // XTypeProvider, first implemented by OPropertySetHelper
19532 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
19533 + throw( com::sun::star::uno::RuntimeException );
19534 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
19535 + throw( com::sun::star::uno::RuntimeException );
19537 +public: // XDataDescriptorFactory
19538 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
19539 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
19541 +public: // XColumnsSupplier
19542 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
19543 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
19545 +public: // XIndexesSupplier
19546 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
19547 + getIndexes( ) throw (::com::sun::star::uno::RuntimeException);
19549 +public: // XKeysSupplier
19550 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL
19551 + getKeys( ) throw (::com::sun::star::uno::RuntimeException);
19553 +public: // XRename
19554 + virtual void SAL_CALL rename( const ::rtl::OUString& newName )
19555 + throw (::com::sun::star::sdbc::SQLException,
19556 + ::com::sun::star::container::ElementExistException,
19557 + ::com::sun::star::uno::RuntimeException);
19559 +public: // XAlterTable
19561 + virtual void SAL_CALL alterColumnByName(
19562 + const ::rtl::OUString& colName,
19563 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
19564 + throw (::com::sun::star::sdbc::SQLException,
19565 + ::com::sun::star::container::NoSuchElementException,
19566 + ::com::sun::star::uno::RuntimeException);
19568 + virtual void SAL_CALL alterColumnByIndex(
19570 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
19571 + throw (::com::sun::star::sdbc::SQLException,
19572 + ::com::sun::star::lang::IndexOutOfBoundsException,
19573 + ::com::sun::star::uno::RuntimeException);
19575 +public: // TODO: remove again
19576 + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
19577 + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
19580 + virtual ::rtl::OUString SAL_CALL getName( ) throw (::com::sun::star::uno::RuntimeException);
19581 + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
19586 +class TableDescriptor
19587 + : public ReflectionBase,
19588 + public com::sun::star::sdbcx::XColumnsSupplier,
19589 + public com::sun::star::sdbcx::XIndexesSupplier,
19590 + public com::sun::star::sdbcx::XKeysSupplier
19592 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_columns;
19593 + ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_keys;
19594 + ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_indexes;
19598 + const ::rtl::Reference< RefCountedMutex > & refMutex,
19599 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
19600 + ConnectionSettings *pSettings);
19602 +public: // XInterface
19603 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
19604 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
19605 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
19606 + const com::sun::star::uno::Type & reqType )
19607 + throw (com::sun::star::uno::RuntimeException);
19609 +public: // XTypeProvider, first implemented by OPropertySetHelper
19610 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
19611 + throw( com::sun::star::uno::RuntimeException );
19612 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
19613 + throw( com::sun::star::uno::RuntimeException );
19615 +public: // XColumnsSupplier
19616 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
19617 + getColumns( ) throw (::com::sun::star::uno::RuntimeException);
19619 +public: // XIndexesSupplier
19620 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
19621 + getIndexes( ) throw (::com::sun::star::uno::RuntimeException);
19623 +public: // XKeysSupplier
19624 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL
19625 + getKeys( ) throw (::com::sun::star::uno::RuntimeException);
19627 +public: // XDataDescriptorFactory
19628 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
19629 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
19633 +void copyProperties(
19634 + ReflectionBase *target,
19635 + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > & source );
19641 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
19642 +++ connectivity/source/drivers/postgresql/pq_xtables.cxx 2006-05-01 21:19:08.000000000 +0200
19644 +/*************************************************************************
19646 + * $RCSfile: pq_xtables.cxx,v $
19648 + * $Revision: 1.1.2.4 $
19650 + * last change: $Author: jbu $ $Date: 2006/05/01 19:19:08 $
19652 + * The Contents of this file are made available subject to the terms of
19653 + * either of the following licenses
19655 + * - GNU Lesser General Public License Version 2.1
19656 + * - Sun Industry Standards Source License Version 1.1
19658 + * Sun Microsystems Inc., October, 2000
19660 + * GNU Lesser General Public License Version 2.1
19661 + * =============================================
19662 + * Copyright 2000 by Sun Microsystems, Inc.
19663 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
19665 + * This library is free software; you can redistribute it and/or
19666 + * modify it under the terms of the GNU Lesser General Public
19667 + * License version 2.1, as published by the Free Software Foundation.
19669 + * This library is distributed in the hope that it will be useful,
19670 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
19671 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19672 + * Lesser General Public License for more details.
19674 + * You should have received a copy of the GNU Lesser General Public
19675 + * License along with this library; if not, write to the Free Software
19676 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19677 + * MA 02111-1307 USA
19680 + * Sun Industry Standards Source License Version 1.1
19681 + * =================================================
19682 + * The contents of this file are subject to the Sun Industry Standards
19683 + * Source License Version 1.1 (the "License"); You may not use this file
19684 + * except in compliance with the License. You may obtain a copy of the
19685 + * License at http://www.openoffice.org/license.html.
19687 + * Software provided under this License is provided on an "AS IS" basis,
19688 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19689 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
19690 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
19691 + * See the License for the specific provisions governing your rights and
19692 + * obligations concerning the Software.
19694 + * The Initial Developer of the Original Code is: Joerg Budischewski
19696 + * Copyright: 2000 by Sun Microsystems, Inc.
19698 + * All Rights Reserved.
19700 + * Contributor(s): Joerg Budischewski
19703 + ************************************************************************/
19707 +#include <rtl/ustrbuf.hxx>
19709 +#include <com/sun/star/sdbc/XRow.hpp>
19710 +#include <com/sun/star/sdbc/XParameters.hpp>
19711 +#include <com/sun/star/sdbcx/Privilege.hpp>
19712 +#include <com/sun/star/sdbcx/KeyType.hpp>
19713 +#include <com/sun/star/sdbc/KeyRule.hpp>
19714 +#include <com/sun/star/sdbc/DataType.hpp>
19716 +#include "pq_xtables.hxx"
19717 +#include "pq_xviews.hxx"
19718 +#include "pq_xtable.hxx"
19719 +#include "pq_statics.hxx"
19720 +#include "pq_tools.hxx"
19722 +using osl::MutexGuard;
19724 +using rtl::OUString;
19725 +using rtl::OUStringBuffer;
19726 +using rtl::OUStringToOString;
19728 +using com::sun::star::beans::XPropertySet;
19730 +using com::sun::star::uno::Any;
19731 +using com::sun::star::uno::makeAny;
19732 +using com::sun::star::uno::UNO_QUERY;
19733 +using com::sun::star::uno::Type;
19734 +using com::sun::star::uno::XInterface;
19735 +using com::sun::star::uno::Reference;
19736 +using com::sun::star::uno::Sequence;
19737 +using com::sun::star::uno::RuntimeException;
19739 +using com::sun::star::container::NoSuchElementException;
19740 +using com::sun::star::container::XEnumerationAccess;
19741 +using com::sun::star::container::XEnumeration;
19742 +using com::sun::star::lang::WrappedTargetException;
19744 +using com::sun::star::sdbc::XRow;
19745 +// using com::sun::star::sdbc::DataType;
19746 +using com::sun::star::sdbc::XCloseable;
19747 +using com::sun::star::sdbc::XStatement;
19748 +using com::sun::star::sdbc::XResultSet;
19749 +using com::sun::star::sdbc::XParameters;
19750 +using com::sun::star::sdbc::XPreparedStatement;
19751 +using com::sun::star::sdbc::XDatabaseMetaData;
19752 +using com::sun::star::sdbcx::XColumnsSupplier;
19753 +using com::sun::star::sdbcx::XKeysSupplier;
19754 +using com::sun::star::sdbcx::XViewsSupplier;
19755 +// using com::sun::star::sdbcx::Privilege;
19757 +namespace pq_sdbc_driver
19759 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
19761 + const ::rtl::Reference< RefCountedMutex > & refMutex,
19762 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
19763 + ConnectionSettings *pSettings )
19764 + : Container( refMutex, origin, pSettings, getStatics().TABLE )
19770 +void Tables::refresh()
19771 + throw (::com::sun::star::uno::RuntimeException)
19775 + osl::MutexGuard guard( m_refMutex->mutex );
19776 + Statics & st = getStatics();
19778 + Reference< XDatabaseMetaData > meta = m_origin->getMetaData();
19780 + Reference< XResultSet > rs =
19781 + meta->getTables( Any(), st.cPERCENT,st.cPERCENT, Sequence< OUString > () );
19783 + Reference< XRow > xRow( rs , UNO_QUERY );
19785 + String2IntMap map;
19787 + std::vector< Any, Allocator< Any> > vec;
19788 + sal_Int32 tableIndex = 0;
19789 + while( rs->next() )
19791 + // if creating all these tables turns out to have too bad performance, we might
19792 + // instead offer a factory interface
19794 + new Table( m_refMutex, m_origin, m_pSettings );
19795 + Reference< com::sun::star::beans::XPropertySet > prop = pTable;
19797 + OUString name = xRow->getString( TABLE_INDEX_NAME+1);
19798 + OUString schema = xRow->getString( TABLE_INDEX_SCHEMA+1);
19799 + pTable->setPropertyValue_NoBroadcast_public(
19800 + st.CATALOG_NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
19801 + pTable->setPropertyValue_NoBroadcast_public( st.NAME , makeAny( name ) );
19802 + pTable->setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME , makeAny( schema ));
19803 + pTable->setPropertyValue_NoBroadcast_public(
19804 + st.TYPE , makeAny( xRow->getString( TABLE_INDEX_TYPE+1) ) );
19805 + pTable->setPropertyValue_NoBroadcast_public(
19806 + st.DESCRIPTION , makeAny( xRow->getString( TABLE_INDEX_REMARKS+1) ) );
19807 + pTable->setPropertyValue_NoBroadcast_public(
19809 + makeAny( (sal_Int32)
19810 + ( com::sun::star::sdbcx::Privilege::SELECT |
19811 + com::sun::star::sdbcx::Privilege::INSERT |
19812 + com::sun::star::sdbcx::Privilege::UPDATE |
19813 + com::sun::star::sdbcx::Privilege::DELETE |
19814 + com::sun::star::sdbcx::Privilege::READ |
19815 + com::sun::star::sdbcx::Privilege::CREATE |
19816 + com::sun::star::sdbcx::Privilege::ALTER |
19817 + com::sun::star::sdbcx::Privilege::REFERENCE |
19818 + com::sun::star::sdbcx::Privilege::DROP ) ) );
19820 + vec.push_back( makeAny( prop ) );
19821 + OUStringBuffer buf( name.getLength() + schema.getLength() + 1);
19822 + buf.append( schema ).appendAscii( "." ).append( name );
19823 + map[ buf.makeStringAndClear() ] = tableIndex;
19826 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
19827 + m_name2index.swap( map );
19829 + catch ( com::sun::star::sdbc::SQLException & e )
19831 + throw RuntimeException( e.Message , e.Context );
19834 + fire( RefreshedBroadcaster( *this ) );
19838 +static void appendColumnList(
19839 + OUStringBuffer &buf, const Reference< XColumnsSupplier > & columnSupplier, sal_Int32 encoding )
19841 + if( columnSupplier.is() )
19843 + Reference< XEnumerationAccess > columns( columnSupplier->getColumns(),UNO_QUERY );
19844 + if( columns.is() )
19846 + Reference< XEnumeration > xEnum( columns->createEnumeration() );
19847 + bool first = true;
19848 + Statics & st = getStatics();
19850 + while( xEnum.is() && xEnum->hasMoreElements() )
19858 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
19860 + Reference< XPropertySet > column( xEnum->nextElement(), UNO_QUERY );
19861 + OUString name = extractStringProperty( column, st.NAME );
19862 + OUString defaultValue = extractStringProperty( column, st.DEFAULT_VALUE );
19863 + sal_Bool isNullable = extractBoolProperty( column, st.IS_NULLABLE );
19864 + sal_Bool isAutoIncrement = extractBoolProperty( column, st.IS_AUTO_INCREMENT );
19866 + bufferQuoteIdentifier( buf, name );
19868 + OUString type = sqltype2string( column );
19869 + if( isAutoIncrement )
19871 + sal_Int32 dataType;
19872 + column->getPropertyValue( st.TYPE ) >>= dataType;
19873 + if( com::sun::star::sdbc::DataType::INTEGER == dataType )
19875 + buf.appendAscii( " serial ");
19876 + isNullable = sal_False;
19878 + else if( com::sun::star::sdbc::DataType::BIGINT == dataType )
19880 + buf.appendAscii( " serial8 " );
19881 + isNullable = sal_False;
19884 + buf.append( type );
19888 + buf.append( type );
19890 + if( defaultValue.getLength() )
19892 + bufferQuoteConstant( buf, defaultValue, encoding );
19895 + if( ! isNullable )
19896 +// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NULL " ) );
19898 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL " ) );
19905 +static void appendKeyList(
19906 + OUStringBuffer & buf, const Reference< XKeysSupplier > &keySupplier )
19908 + if( keySupplier.is() )
19910 + Reference< XEnumerationAccess > keys( keySupplier->getKeys(), UNO_QUERY );
19913 + Statics &st = getStatics();
19914 + Reference< XEnumeration > xEnum = keys->createEnumeration();
19915 + while( xEnum.is() && xEnum->hasMoreElements() )
19917 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
19918 + Reference< XPropertySet > key( xEnum->nextElement(), UNO_QUERY );
19919 + bufferKey2TableConstraint( buf, key );
19925 +void Tables::appendByDescriptor(
19926 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
19927 + throw (::com::sun::star::sdbc::SQLException,
19928 + ::com::sun::star::container::ElementExistException,
19929 + ::com::sun::star::uno::RuntimeException)
19931 + osl::MutexGuard guard( m_refMutex->mutex );
19932 + Reference< XStatement > stmt =
19933 + m_origin->createStatement();
19935 + Statics &st = getStatics();
19936 + OUString name,schema;
19937 + descriptor->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
19938 + descriptor->getPropertyValue( st.NAME ) >>= name;
19940 + TransactionGuard transaction( stmt );
19942 + OUStringBuffer buf( 128 );
19943 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CREATE TABLE" ) );
19944 + bufferQuoteQualifiedIdentifier( buf, schema, name );
19945 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(" ) );
19948 + Reference< XColumnsSupplier > supplier( descriptor, UNO_QUERY );
19949 + appendColumnList( buf, supplier, m_pSettings->encoding );
19951 + appendKeyList( buf, Reference< XKeysSupplier >( descriptor, UNO_QUERY ) );
19953 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ") " ) );
19954 + // execute the creation !
19955 + transaction.executeUpdate( buf.makeStringAndClear() );
19957 + // description ....
19958 + OUString description = extractStringProperty( descriptor, st.DESCRIPTION );
19959 + if( description.getLength() )
19961 + buf = OUStringBuffer( 128 );
19962 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON TABLE" ) );
19963 + bufferQuoteQualifiedIdentifier( buf, schema, name );
19964 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
19965 + bufferQuoteConstant( buf, description, m_pSettings->encoding );
19967 + transaction.executeUpdate( buf.makeStringAndClear() );
19970 + // column descriptions
19971 + if( supplier.is() )
19973 + Reference< XEnumerationAccess > columns( supplier->getColumns(),UNO_QUERY );
19974 + if( columns.is() )
19976 + Reference< XEnumeration > xEnum( columns->createEnumeration() );
19977 + while( xEnum.is() && xEnum->hasMoreElements() )
19979 + Reference< XPropertySet > column( xEnum->nextElement(), UNO_QUERY );
19980 + // help text seems to be used by OOo rather than Description
19981 +// OUString description = extractStringProperty( column, st.HELP_TEXT );
19982 + OUString helpText = extractStringProperty( column,st.DESCRIPTION );
19983 + if( description.getLength() )
19985 + buf = OUStringBuffer( 128 );
19986 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN " ) );
19987 + bufferQuoteQualifiedIdentifier(
19988 + buf, schema, name, extractStringProperty( column, st.NAME ) );
19989 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
19990 + bufferQuoteConstant(
19991 + buf, description,m_pSettings->encoding );
19992 + transaction.executeUpdate( buf.makeStringAndClear() );
19998 + transaction.commit();
20000 + disposeNoThrow( stmt );
20001 + // TODO: cheaper recalculate
20002 +// Container::append( concatQualified( schema, name ), descriptor ); // maintain the lists
20005 + // increase the vector
20006 +// sal_Int32 index = m_values.getLength();
20007 +// m_values.realloc( index + 1 );
20009 +// Table * pTable =
20010 +// new Table( m_refMutex, m_origin, m_pSettings, false /*modifiable*/ );
20011 +// Reference< com::sun::star::beans::XPropertySet > prop = pTable;
20012 +// copyProperties( pTable, descriptor );
20013 +// m_values[index] = makeAny( prop );
20014 +// OUStringBuffer buf( name.getLength() + 1 + schema.getLength() );
20015 +// buf.append( schema ).appendAscii( "." ).append( name );
20016 +// m_name2index[ buf.makeStringAndClear() ] = index;
20019 +// void Tables::dropByName( const ::rtl::OUString& elementName )
20020 +// throw (::com::sun::star::sdbc::SQLException,
20021 +// ::com::sun::star::container::NoSuchElementException,
20022 +// ::com::sun::star::uno::RuntimeException)
20024 +// String2IntMap::const_iterator ii = m_name2index.find( elementName );
20025 +// if( ii == m_name2index.end() )
20027 +// OUStringBuffer buf( 128 );
20028 +// buf.appendAscii( "Table " );
20029 +// buf.append( elementName );
20030 +// buf.appendAscii( " is unknown, so it can't be dropped" );
20031 +// throw com::sun::star::container::NoSuchElementException(
20032 +// buf.makeStringAndClear(), *this );
20034 +// dropByIndex( ii->second );
20037 +void Tables::dropByIndex( sal_Int32 index )
20038 + throw (::com::sun::star::sdbc::SQLException,
20039 + ::com::sun::star::lang::IndexOutOfBoundsException,
20040 + ::com::sun::star::uno::RuntimeException)
20042 + osl::MutexGuard guard( m_refMutex->mutex );
20043 + if( index < 0 || index >= m_values.getLength() )
20045 + OUStringBuffer buf( 128 );
20046 + buf.appendAscii( "TABLES: Index out of range (allowed 0 to " );
20047 + buf.append( (sal_Int32) (m_values.getLength() -1) );
20048 + buf.appendAscii( ", got " );
20049 + buf.append( index );
20050 + buf.appendAscii( ")" );
20051 + throw com::sun::star::lang::IndexOutOfBoundsException(
20052 + buf.makeStringAndClear(), *this );
20055 + Reference< XPropertySet > set;
20056 + m_values[index] >>= set;
20057 + Statics &st = getStatics();
20058 + OUString name,schema;
20059 + set->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
20060 + set->getPropertyValue( st.NAME ) >>= name;
20061 + if( extractStringProperty( set, st.TYPE ).equals( st.VIEW ) && m_pSettings->views.is() )
20063 + m_pSettings->pViewsImpl->dropByName( concatQualified( schema, name ) );
20067 + OUStringBuffer update( 128 );
20068 + update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP " ) );
20069 + if( extractStringProperty( set, st.TYPE ).equals( st.VIEW ) )
20070 + update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VIEW " ) );
20072 + update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TABLE " ) );
20073 + bufferQuoteQualifiedIdentifier( update, schema, name );
20074 + Reference< XStatement > stmt = m_origin->createStatement( );
20075 + DisposeGuard dispGuard( stmt );
20076 + stmt->executeUpdate( update.makeStringAndClear() );
20079 + Container::dropByIndex( index );
20083 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Tables::createDataDescriptor()
20084 + throw (::com::sun::star::uno::RuntimeException)
20086 + return new TableDescriptor( m_refMutex, m_origin, m_pSettings );
20089 +Reference< com::sun::star::container::XNameAccess > Tables::create(
20090 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20091 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20092 + ConnectionSettings *pSettings,
20093 + Tables **ppTables)
20095 + *ppTables = new Tables( refMutex, origin, pSettings );
20096 + Reference< com::sun::star::container::XNameAccess > ret = *ppTables;
20097 + (*ppTables)->refresh();
20102 +void Tables::disposing()
20104 + Container::disposing();
20108 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
20109 +++ connectivity/source/drivers/postgresql/pq_xtables.hxx 2004-06-10 17:27:11.000000000 +0200
20111 +/*************************************************************************
20113 + * $RCSfile: pq_xtables.hxx,v $
20115 + * $Revision: 1.1.2.2 $
20117 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:11 $
20119 + * The Contents of this file are made available subject to the terms of
20120 + * either of the following licenses
20122 + * - GNU Lesser General Public License Version 2.1
20123 + * - Sun Industry Standards Source License Version 1.1
20125 + * Sun Microsystems Inc., October, 2000
20127 + * GNU Lesser General Public License Version 2.1
20128 + * =============================================
20129 + * Copyright 2000 by Sun Microsystems, Inc.
20130 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
20132 + * This library is free software; you can redistribute it and/or
20133 + * modify it under the terms of the GNU Lesser General Public
20134 + * License version 2.1, as published by the Free Software Foundation.
20136 + * This library is distributed in the hope that it will be useful,
20137 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20138 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20139 + * Lesser General Public License for more details.
20141 + * You should have received a copy of the GNU Lesser General Public
20142 + * License along with this library; if not, write to the Free Software
20143 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20144 + * MA 02111-1307 USA
20147 + * Sun Industry Standards Source License Version 1.1
20148 + * =================================================
20149 + * The contents of this file are subject to the Sun Industry Standards
20150 + * Source License Version 1.1 (the "License"); You may not use this file
20151 + * except in compliance with the License. You may obtain a copy of the
20152 + * License at http://www.openoffice.org/license.html.
20154 + * Software provided under this License is provided on an "AS IS" basis,
20155 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20156 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20157 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20158 + * See the License for the specific provisions governing your rights and
20159 + * obligations concerning the Software.
20161 + * The Initial Developer of the Original Code is: Joerg Budischewski
20163 + * Copyright: 2000 by Sun Microsystems, Inc.
20165 + * All Rights Reserved.
20167 + * Contributor(s): Joerg Budischewski
20170 + ************************************************************************/
20172 +#ifndef _PQ_TABLES_HXX_
20173 +#define _PQ_TABLES_HXX_
20175 +#include "pq_xcontainer.hxx"
20177 +namespace pq_sdbc_driver
20180 +class Tables : public Container
20183 +public: // instances Tables 'exception safe'
20184 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
20185 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20186 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20187 + ConnectionSettings *pSettings,
20188 + Tables ** ppTables);
20192 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20193 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20194 + ConnectionSettings *pSettings );
20196 + virtual ~Tables();
20198 +public: // XAppend
20199 + virtual void SAL_CALL appendByDescriptor(
20200 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
20201 + throw (::com::sun::star::sdbc::SQLException,
20202 + ::com::sun::star::container::ElementExistException,
20203 + ::com::sun::star::uno::RuntimeException);
20206 +// virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
20207 +// throw (::com::sun::star::sdbc::SQLException,
20208 +// ::com::sun::star::container::NoSuchElementException,
20209 +// ::com::sun::star::uno::RuntimeException);
20210 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
20211 + throw (::com::sun::star::sdbc::SQLException,
20212 + ::com::sun::star::lang::IndexOutOfBoundsException,
20213 + ::com::sun::star::uno::RuntimeException);
20215 +public: // XRefreshable
20216 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
20218 +public: // XDataDescriptorFactory
20219 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
20220 + throw (::com::sun::star::uno::RuntimeException);
20223 + virtual void SAL_CALL disposing();
20229 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
20230 +++ connectivity/source/drivers/postgresql/pq_xuser.cxx 2006-01-22 16:14:40.000000000 +0100
20232 +/*************************************************************************
20234 + * $RCSfile: pq_xuser.cxx,v $
20236 + * $Revision: 1.1.2.3 $
20238 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:40 $
20240 + * The Contents of this file are made available subject to the terms of
20241 + * either of the following licenses
20243 + * - GNU Lesser General Public License Version 2.1
20244 + * - Sun Industry Standards Source License Version 1.1
20246 + * Sun Microsystems Inc., October, 2000
20248 + * GNU Lesser General Public License Version 2.1
20249 + * =============================================
20250 + * Copyright 2000 by Sun Microsystems, Inc.
20251 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
20253 + * This library is free software; you can redistribute it and/or
20254 + * modify it under the terms of the GNU Lesser General Public
20255 + * License version 2.1, as published by the Free Software Foundation.
20257 + * This library is distributed in the hope that it will be useful,
20258 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20259 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20260 + * Lesser General Public License for more details.
20262 + * You should have received a copy of the GNU Lesser General Public
20263 + * License along with this library; if not, write to the Free Software
20264 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20265 + * MA 02111-1307 USA
20268 + * Sun Industry Standards Source License Version 1.1
20269 + * =================================================
20270 + * The contents of this file are subject to the Sun Industry Standards
20271 + * Source License Version 1.1 (the "License"); You may not use this file
20272 + * except in compliance with the License. You may obtain a copy of the
20273 + * License at http://www.openoffice.org/license.html.
20275 + * Software provided under this License is provided on an "AS IS" basis,
20276 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20277 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20278 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20279 + * See the License for the specific provisions governing your rights and
20280 + * obligations concerning the Software.
20282 + * The Initial Developer of the Original Code is: Joerg Budischewski
20284 + * Copyright: 2000 by Sun Microsystems, Inc.
20286 + * All Rights Reserved.
20288 + * Contributor(s): Joerg Budischewski
20291 + ************************************************************************/
20293 +#include <rtl/ustrbuf.hxx>
20295 +#include <cppuhelper/typeprovider.hxx>
20296 +#include <cppuhelper/queryinterface.hxx>
20298 +#include <com/sun/star/beans/PropertyAttribute.hpp>
20300 +#include <com/sun/star/sdbc/XRow.hpp>
20301 +#include <com/sun/star/sdbc/XParameters.hpp>
20303 +#include "pq_xuser.hxx"
20304 +#include "pq_tools.hxx"
20305 +#include "pq_statics.hxx"
20307 +using osl::MutexGuard;
20310 +using rtl::OUString;
20311 +using rtl::OUStringBuffer;
20313 +using com::sun::star::container::XNameAccess;
20314 +using com::sun::star::container::XIndexAccess;
20315 +using com::sun::star::container::ElementExistException;
20316 +using com::sun::star::container::NoSuchElementException;
20318 +using com::sun::star::uno::Reference;
20319 +using com::sun::star::uno::Exception;
20320 +using com::sun::star::uno::UNO_QUERY;
20321 +using com::sun::star::uno::XInterface;
20322 +using com::sun::star::uno::Sequence;
20323 +using com::sun::star::uno::Any;
20324 +using com::sun::star::uno::makeAny;
20325 +using com::sun::star::uno::Type;
20326 +using com::sun::star::uno::RuntimeException;
20328 +using com::sun::star::lang::IllegalArgumentException;
20329 +using com::sun::star::lang::IndexOutOfBoundsException;
20331 +using com::sun::star::beans::XPropertySetInfo;
20332 +using com::sun::star::beans::XFastPropertySet;
20333 +using com::sun::star::beans::XMultiPropertySet;
20334 +using com::sun::star::beans::XPropertySet;
20335 +using com::sun::star::beans::Property;
20337 +using com::sun::star::sdbc::XResultSet;
20338 +using com::sun::star::sdbc::XPreparedStatement;
20339 +using com::sun::star::sdbc::XStatement;
20340 +using com::sun::star::sdbc::XParameters;
20341 +using com::sun::star::sdbc::XRow;
20342 +using com::sun::star::sdbc::SQLException;
20344 +namespace pq_sdbc_driver
20347 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
20349 +User::User( const ::rtl::Reference< RefCountedMutex > & refMutex,
20350 + const Reference< com::sun::star::sdbc::XConnection > & connection,
20351 + ConnectionSettings *pSettings )
20352 + : ReflectionBase(
20353 + getStatics().refl.user.implName,
20354 + getStatics().refl.user.serviceNames,
20358 + * getStatics().refl.user.pProps )
20361 +Reference< XPropertySet > User::createDataDescriptor( ) throw (RuntimeException)
20363 + UserDescriptor * pUser = new UserDescriptor( m_refMutex, m_conn, m_pSettings );
20364 + pUser->copyValuesFrom( this );
20366 + return Reference< XPropertySet > ( pUser );
20370 +Sequence<Type > User::getTypes() throw( RuntimeException )
20372 + static cppu::OTypeCollection *pCollection;
20373 + if( ! pCollection )
20375 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
20376 + if( !pCollection )
20378 + static cppu::OTypeCollection collection(
20379 + getCppuType( (Reference< com::sun::star::sdbcx::XUser> *) 0 ),
20380 + ReflectionBase::getTypes());
20381 + pCollection = &collection;
20384 + return pCollection->getTypes();
20387 +Sequence< sal_Int8> User::getImplementationId() throw( RuntimeException )
20389 + return getStatics().refl.user.implementationId;
20392 +Any User::queryInterface( const Type & reqType ) throw (RuntimeException)
20396 + ret = ReflectionBase::queryInterface( reqType );
20397 + if( ! ret.hasValue() )
20398 + ret = ::cppu::queryInterface(
20400 + static_cast< com::sun::star::sdbcx::XUser * > ( this ) );
20405 +void User::changePassword(
20406 + const ::rtl::OUString& oldPassword, const ::rtl::OUString& newPassword )
20407 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
20409 + rtl::OUStringBuffer buf(128);
20410 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER USER " ) );
20411 + bufferQuoteIdentifier( buf, extractStringProperty( this, getStatics().NAME ) );
20412 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
20413 + bufferQuoteConstant( buf, newPassword, m_pSettings->encoding );
20414 + Reference< XStatement > stmt = m_conn->createStatement();
20415 + DisposeGuard guard( stmt );
20416 + stmt->executeUpdate( buf.makeStringAndClear() );
20419 +sal_Int32 User::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType )
20420 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
20422 + sal_Int32 ret = 0xffffffff;
20423 + if( isLog( m_pSettings, LogLevel::INFO ) )
20425 + Statics & st = getStatics();
20426 + rtl::OUString user = extractStringProperty( this, st.NAME );
20428 + rtl::OUStringBuffer buf( 128 );
20429 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("User::getPrivileges[") );
20430 + buf.append( extractStringProperty( this, st.NAME ) );
20431 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "] got called for " ) );
20432 + buf.append( objName );
20433 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(type=" ) );
20434 + buf.append( objType );
20435 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
20436 + log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
20438 + // all privileges
20442 +sal_Int32 User::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType )
20443 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
20445 + // all privileges
20446 + return 0xffffffff;
20449 +void User::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
20450 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
20452 + throw com::sun::star::sdbc::SQLException(
20453 + ASCII_STR( "pq_driver: privilege change not implemented yet" ),
20454 + *this, OUString(), 1, Any() );
20457 +void User::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
20458 + throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
20460 + throw com::sun::star::sdbc::SQLException(
20461 + ASCII_STR( "pq_driver: privilege change not implemented yet" ),
20462 + *this, OUString(), 1, Any() );
20465 +//______________________________________________________________________________________
20466 +UserDescriptor::UserDescriptor(
20467 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20468 + const Reference< com::sun::star::sdbc::XConnection > & connection,
20469 + ConnectionSettings *pSettings )
20470 + : ReflectionBase(
20471 + getStatics().refl.userDescriptor.implName,
20472 + getStatics().refl.userDescriptor.serviceNames,
20476 + * getStatics().refl.userDescriptor.pProps )
20479 +Reference< XPropertySet > UserDescriptor::createDataDescriptor( ) throw (RuntimeException)
20481 + UserDescriptor * pUser = new UserDescriptor( m_refMutex, m_conn, m_pSettings );
20482 + pUser->copyValuesFrom( this );
20484 + return Reference< XPropertySet > ( pUser );
20489 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
20490 +++ connectivity/source/drivers/postgresql/pq_xuser.hxx 2004-06-10 17:27:12.000000000 +0200
20492 +/*************************************************************************
20494 + * $RCSfile: pq_xuser.hxx,v $
20496 + * $Revision: 1.1.2.2 $
20498 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:12 $
20500 + * The Contents of this file are made available subject to the terms of
20501 + * either of the following licenses
20503 + * - GNU Lesser General Public License Version 2.1
20504 + * - Sun Industry Standards Source License Version 1.1
20506 + * Sun Microsystems Inc., October, 2000
20508 + * GNU Lesser General Public License Version 2.1
20509 + * =============================================
20510 + * Copyright 2000 by Sun Microsystems, Inc.
20511 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
20513 + * This library is free software; you can redistribute it and/or
20514 + * modify it under the terms of the GNU Lesser General Public
20515 + * License version 2.1, as published by the Free Software Foundation.
20517 + * This library is distributed in the hope that it will be useful,
20518 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20519 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20520 + * Lesser General Public License for more details.
20522 + * You should have received a copy of the GNU Lesser General Public
20523 + * License along with this library; if not, write to the Free Software
20524 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20525 + * MA 02111-1307 USA
20528 + * Sun Industry Standards Source License Version 1.1
20529 + * =================================================
20530 + * The contents of this file are subject to the Sun Industry Standards
20531 + * Source License Version 1.1 (the "License"); You may not use this file
20532 + * except in compliance with the License. You may obtain a copy of the
20533 + * License at http://www.openoffice.org/license.html.
20535 + * Software provided under this License is provided on an "AS IS" basis,
20536 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20537 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20538 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20539 + * See the License for the specific provisions governing your rights and
20540 + * obligations concerning the Software.
20542 + * The Initial Developer of the Original Code is: Joerg Budischewski
20544 + * Copyright: 2000 by Sun Microsystems, Inc.
20546 + * All Rights Reserved.
20548 + * Contributor(s): Joerg Budischewski
20551 + ************************************************************************/
20553 +#ifndef HEADER_PQ_USER_HXX_
20554 +#define HEADER_PQ_USER_HXX_
20556 +#include <cppuhelper/component.hxx>
20557 +#include <cppuhelper/propshlp.hxx>
20559 +#include <com/sun/star/lang/XServiceInfo.hpp>
20560 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
20561 +#include <com/sun/star/sdbcx/XUser.hpp>
20563 +#include "pq_xbase.hxx"
20565 +namespace pq_sdbc_driver
20568 +class User : public ReflectionBase,
20569 + public com::sun::star::sdbcx::XUser
20573 + User( const ::rtl::Reference< RefCountedMutex > & refMutex,
20574 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
20575 + ConnectionSettings *pSettings);
20579 +public: // XInterface
20580 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
20581 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
20582 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
20583 + const com::sun::star::uno::Type & reqType )
20584 + throw (com::sun::star::uno::RuntimeException);
20586 +public: // XTypeProvider, first implemented by OPropertySetHelper
20587 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
20588 + throw( com::sun::star::uno::RuntimeException );
20589 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
20590 + throw( com::sun::star::uno::RuntimeException );
20592 +public: // XDataDescriptorFactory
20593 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
20594 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
20596 +public: // XUser : XAuthorizable
20598 + virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
20599 + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
20600 + virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
20601 + virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
20602 + virtual void SAL_CALL changePassword( const ::rtl::OUString& oldPassword, const ::rtl::OUString& newPassword ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
20607 +class UserDescriptor : public ReflectionBase
20611 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20612 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
20613 + ConnectionSettings *pSettings);
20615 +public: // XDataDescriptorFactory
20616 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
20617 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
20624 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
20625 +++ connectivity/source/drivers/postgresql/pq_xusers.cxx 2006-01-22 16:14:41.000000000 +0100
20627 +/*************************************************************************
20629 + * $RCSfile: pq_xusers.cxx,v $
20631 + * $Revision: 1.1.2.4 $
20633 + * last change: $Author: jbu $ $Date: 2006/01/22 15:14:41 $
20635 + * The Contents of this file are made available subject to the terms of
20636 + * either of the following licenses
20638 + * - GNU Lesser General Public License Version 2.1
20639 + * - Sun Industry Standards Source License Version 1.1
20641 + * Sun Microsystems Inc., October, 2000
20643 + * GNU Lesser General Public License Version 2.1
20644 + * =============================================
20645 + * Copyright 2000 by Sun Microsystems, Inc.
20646 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
20648 + * This library is free software; you can redistribute it and/or
20649 + * modify it under the terms of the GNU Lesser General Public
20650 + * License version 2.1, as published by the Free Software Foundation.
20652 + * This library is distributed in the hope that it will be useful,
20653 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20654 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20655 + * Lesser General Public License for more details.
20657 + * You should have received a copy of the GNU Lesser General Public
20658 + * License along with this library; if not, write to the Free Software
20659 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20660 + * MA 02111-1307 USA
20663 + * Sun Industry Standards Source License Version 1.1
20664 + * =================================================
20665 + * The contents of this file are subject to the Sun Industry Standards
20666 + * Source License Version 1.1 (the "License"); You may not use this file
20667 + * except in compliance with the License. You may obtain a copy of the
20668 + * License at http://www.openoffice.org/license.html.
20670 + * Software provided under this License is provided on an "AS IS" basis,
20671 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20672 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20673 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20674 + * See the License for the specific provisions governing your rights and
20675 + * obligations concerning the Software.
20677 + * The Initial Developer of the Original Code is: Joerg Budischewski
20679 + * Copyright: 2000 by Sun Microsystems, Inc.
20681 + * All Rights Reserved.
20683 + * Contributor(s): Joerg Budischewski
20686 + ************************************************************************/
20690 +#include <rtl/ustrbuf.hxx>
20692 +#include <com/sun/star/sdbc/XRow.hpp>
20693 +#include <com/sun/star/sdbc/XParameters.hpp>
20694 +#include <com/sun/star/sdbcx/Privilege.hpp>
20696 +#include "pq_xusers.hxx"
20697 +#include "pq_xuser.hxx"
20698 +#include "pq_statics.hxx"
20699 +#include "pq_tools.hxx"
20701 +using osl::MutexGuard;
20703 +using rtl::OUString;
20704 +using rtl::OUStringBuffer;
20705 +using rtl::OUStringToOString;
20707 +using com::sun::star::beans::XPropertySet;
20709 +using com::sun::star::uno::Any;
20710 +using com::sun::star::uno::makeAny;
20711 +using com::sun::star::uno::UNO_QUERY;
20712 +using com::sun::star::uno::Type;
20713 +using com::sun::star::uno::XInterface;
20714 +using com::sun::star::uno::Reference;
20715 +using com::sun::star::uno::Sequence;
20716 +using com::sun::star::uno::RuntimeException;
20718 +using com::sun::star::container::NoSuchElementException;
20719 +using com::sun::star::lang::WrappedTargetException;
20721 +using com::sun::star::sdbc::XRow;
20722 +using com::sun::star::sdbc::XCloseable;
20723 +using com::sun::star::sdbc::XStatement;
20724 +using com::sun::star::sdbc::XResultSet;
20725 +using com::sun::star::sdbc::XParameters;
20726 +using com::sun::star::sdbc::XPreparedStatement;
20727 +using com::sun::star::sdbc::XDatabaseMetaData;
20729 +namespace pq_sdbc_driver
20731 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
20733 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20734 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20735 + ConnectionSettings *pSettings )
20736 + : Container( refMutex, origin, pSettings, getStatics().USER )
20742 +void Users::refresh()
20743 + throw (::com::sun::star::uno::RuntimeException)
20747 + osl::MutexGuard guard( m_refMutex->mutex );
20748 + Statics & st = getStatics();
20750 + Reference< XStatement > stmt = m_origin->createStatement();
20752 + Reference< XResultSet > rs =
20753 + stmt->executeQuery( ASCII_STR( "SELECT usename FROM pg_shadow" ) );
20755 + Reference< XRow > xRow( rs , UNO_QUERY );
20757 + String2IntMap map;
20759 + std::vector< Any, Allocator< Any> > vec;
20760 + sal_Int32 tableIndex = 0;
20761 + while( rs->next() )
20764 + new User( m_refMutex, m_origin, m_pSettings );
20765 + Reference< com::sun::star::beans::XPropertySet > prop = pUser;
20767 + OUString name = xRow->getString( 1);
20768 + pUser->setPropertyValue_NoBroadcast_public(
20769 + st.NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
20771 + vec.push_back( makeAny(prop ) );
20772 + map[ name ] = tableIndex;
20775 + m_values = Sequence< com::sun::star::uno::Any > ( & vec[0] , vec.size() );
20776 + m_name2index.swap( map );
20778 + catch ( com::sun::star::sdbc::SQLException & e )
20780 + throw RuntimeException( e.Message , e.Context );
20783 + fire( RefreshedBroadcaster( *this ) );
20787 +void Users::appendByDescriptor(
20788 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
20789 + throw (::com::sun::star::sdbc::SQLException,
20790 + ::com::sun::star::container::ElementExistException,
20791 + ::com::sun::star::uno::RuntimeException)
20793 + osl::MutexGuard guard( m_refMutex->mutex );
20794 + Statics &st = getStatics();
20796 + OUStringBuffer update( 128 );
20797 + update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE USER " ) );
20798 + bufferQuoteIdentifier( update, extractStringProperty( descriptor, getStatics().NAME ) );
20799 + update.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
20800 + bufferQuoteConstant( update, extractStringProperty( descriptor, getStatics().PASSWORD ), m_pSettings->encoding );
20802 + Reference< XStatement > stmt = m_origin->createStatement( );
20803 + DisposeGuard disposeGuard( stmt );
20804 + stmt->executeUpdate( update.makeStringAndClear() );
20807 +void Users::dropByName( const ::rtl::OUString& elementName )
20808 + throw (::com::sun::star::sdbc::SQLException,
20809 + ::com::sun::star::container::NoSuchElementException,
20810 + ::com::sun::star::uno::RuntimeException)
20812 + String2IntMap::const_iterator ii = m_name2index.find( elementName );
20813 + if( ii == m_name2index.end() )
20815 + OUStringBuffer buf( 128 );
20816 + buf.appendAscii( "User " );
20817 + buf.append( elementName );
20818 + buf.appendAscii( " is unknown, so it can't be dropped" );
20819 + throw com::sun::star::container::NoSuchElementException(
20820 + buf.makeStringAndClear(), *this );
20822 + dropByIndex( ii->second );
20825 +void Users::dropByIndex( sal_Int32 index )
20826 + throw (::com::sun::star::sdbc::SQLException,
20827 + ::com::sun::star::lang::IndexOutOfBoundsException,
20828 + ::com::sun::star::uno::RuntimeException)
20831 + osl::MutexGuard guard( m_refMutex->mutex );
20832 + if( index < 0 || index >= m_values.getLength() )
20834 + OUStringBuffer buf( 128 );
20835 + buf.appendAscii( "USERS: Index out of range (allowed 0 to " );
20836 + buf.append( (sal_Int32) (m_values.getLength() -1) );
20837 + buf.appendAscii( ", got " );
20838 + buf.append( index );
20839 + buf.appendAscii( ")" );
20840 + throw com::sun::star::lang::IndexOutOfBoundsException(
20841 + buf.makeStringAndClear(), *this );
20844 + Reference< XPropertySet > set;
20845 + m_values[index] >>= set;
20846 + Statics &st = getStatics();
20848 + set->getPropertyValue( getStatics().NAME ) >>= name;
20850 + OUStringBuffer update( 128 );
20851 + update.appendAscii( "DROP USER " );
20852 + bufferQuoteIdentifier( update, name );
20854 + Reference< XStatement > stmt = m_origin->createStatement( );
20855 + DisposeGuard disposeGuard( stmt );
20856 + stmt->executeUpdate( update.makeStringAndClear() );
20860 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Users::createDataDescriptor()
20861 + throw (::com::sun::star::uno::RuntimeException)
20863 + return new UserDescriptor( m_refMutex, m_origin, m_pSettings );
20866 +Reference< com::sun::star::container::XNameAccess > Users::create(
20867 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20868 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20869 + ConnectionSettings *pSettings )
20871 + Users *pUsers = new Users( refMutex, origin, pSettings );
20872 + Reference< com::sun::star::container::XNameAccess > ret = pUsers;
20873 + pUsers->refresh();
20878 +void Users::disposing()
20883 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
20884 +++ connectivity/source/drivers/postgresql/pq_xusers.hxx 2004-05-09 21:47:25.000000000 +0200
20886 +/*************************************************************************
20888 + * $RCSfile: pq_xusers.hxx,v $
20890 + * $Revision: 1.1.2.1 $
20892 + * last change: $Author: jbu $ $Date: 2004/05/09 19:47:25 $
20894 + * The Contents of this file are made available subject to the terms of
20895 + * either of the following licenses
20897 + * - GNU Lesser General Public License Version 2.1
20898 + * - Sun Industry Standards Source License Version 1.1
20900 + * Sun Microsystems Inc., October, 2000
20902 + * GNU Lesser General Public License Version 2.1
20903 + * =============================================
20904 + * Copyright 2000 by Sun Microsystems, Inc.
20905 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
20907 + * This library is free software; you can redistribute it and/or
20908 + * modify it under the terms of the GNU Lesser General Public
20909 + * License version 2.1, as published by the Free Software Foundation.
20911 + * This library is distributed in the hope that it will be useful,
20912 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20913 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20914 + * Lesser General Public License for more details.
20916 + * You should have received a copy of the GNU Lesser General Public
20917 + * License along with this library; if not, write to the Free Software
20918 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20919 + * MA 02111-1307 USA
20922 + * Sun Industry Standards Source License Version 1.1
20923 + * =================================================
20924 + * The contents of this file are subject to the Sun Industry Standards
20925 + * Source License Version 1.1 (the "License"); You may not use this file
20926 + * except in compliance with the License. You may obtain a copy of the
20927 + * License at http://www.openoffice.org/license.html.
20929 + * Software provided under this License is provided on an "AS IS" basis,
20930 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20931 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20932 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20933 + * See the License for the specific provisions governing your rights and
20934 + * obligations concerning the Software.
20936 + * The Initial Developer of the Original Code is: Joerg Budischewski
20938 + * Copyright: 2000 by Sun Microsystems, Inc.
20940 + * All Rights Reserved.
20942 + * Contributor(s): Joerg Budischewski
20945 + ************************************************************************/
20947 +#ifndef HEADER_PQ_USERS_HXX_
20948 +#define HEADER_PQ_USERS_HXX_
20950 +#include "pq_xcontainer.hxx"
20952 +namespace pq_sdbc_driver
20955 +class Users : public Container
20958 +public: // instances Tables 'exception safe'
20959 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
20960 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20961 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20962 + ConnectionSettings *pSettings );
20966 + const ::rtl::Reference< RefCountedMutex > & refMutex,
20967 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
20968 + ConnectionSettings *pSettings );
20970 + virtual ~Users();
20972 +public: // XAppend
20973 + virtual void SAL_CALL appendByDescriptor(
20974 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
20975 + throw (::com::sun::star::sdbc::SQLException,
20976 + ::com::sun::star::container::ElementExistException,
20977 + ::com::sun::star::uno::RuntimeException);
20980 + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
20981 + throw (::com::sun::star::sdbc::SQLException,
20982 + ::com::sun::star::container::NoSuchElementException,
20983 + ::com::sun::star::uno::RuntimeException);
20984 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
20985 + throw (::com::sun::star::sdbc::SQLException,
20986 + ::com::sun::star::lang::IndexOutOfBoundsException,
20987 + ::com::sun::star::uno::RuntimeException);
20989 +public: // XRefreshable
20990 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
20992 +public: // XDataDescriptorFactory
20993 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
20994 + throw (::com::sun::star::uno::RuntimeException);
20997 + virtual void SAL_CALL disposing();
21002 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
21003 +++ connectivity/source/drivers/postgresql/pq_xview.cxx 2007-01-07 14:50:38.000000000 +0100
21005 +/*************************************************************************
21007 + * $RCSfile: pq_xview.cxx,v $
21009 + * $Revision: 1.1.2.5 $
21011 + * last change: $Author: jbu $ $Date: 2007/01/07 13:50:38 $
21013 + * The Contents of this file are made available subject to the terms of
21014 + * either of the following licenses
21016 + * - GNU Lesser General Public License Version 2.1
21017 + * - Sun Industry Standards Source License Version 1.1
21019 + * Sun Microsystems Inc., October, 2000
21021 + * GNU Lesser General Public License Version 2.1
21022 + * =============================================
21023 + * Copyright 2000 by Sun Microsystems, Inc.
21024 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
21026 + * This library is free software; you can redistribute it and/or
21027 + * modify it under the terms of the GNU Lesser General Public
21028 + * License version 2.1, as published by the Free Software Foundation.
21030 + * This library is distributed in the hope that it will be useful,
21031 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21032 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21033 + * Lesser General Public License for more details.
21035 + * You should have received a copy of the GNU Lesser General Public
21036 + * License along with this library; if not, write to the Free Software
21037 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21038 + * MA 02111-1307 USA
21041 + * Sun Industry Standards Source License Version 1.1
21042 + * =================================================
21043 + * The contents of this file are subject to the Sun Industry Standards
21044 + * Source License Version 1.1 (the "License"); You may not use this file
21045 + * except in compliance with the License. You may obtain a copy of the
21046 + * License at http://www.openoffice.org/license.html.
21048 + * Software provided under this License is provided on an "AS IS" basis,
21049 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21050 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
21051 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21052 + * See the License for the specific provisions governing your rights and
21053 + * obligations concerning the Software.
21055 + * The Initial Developer of the Original Code is: Joerg Budischewski
21057 + * Copyright: 2000 by Sun Microsystems, Inc.
21059 + * All Rights Reserved.
21061 + * Contributor(s): Joerg Budischewski
21064 + ************************************************************************/
21066 +#include <rtl/ustrbuf.hxx>
21068 +#include <cppuhelper/typeprovider.hxx>
21069 +#include <cppuhelper/queryinterface.hxx>
21071 +#include <com/sun/star/beans/PropertyAttribute.hpp>
21073 +#include <com/sun/star/sdbc/XRow.hpp>
21074 +#include <com/sun/star/sdbc/XParameters.hpp>
21076 +#include "pq_xview.hxx"
21077 +#include "pq_xviews.hxx"
21078 +#include "pq_statics.hxx"
21079 +#include "pq_tools.hxx"
21081 +using osl::MutexGuard;
21084 +using rtl::OUString;
21085 +using rtl::OUStringBuffer;
21086 +using rtl::OUStringToOString;
21088 +using com::sun::star::container::XNameAccess;
21089 +using com::sun::star::container::XIndexAccess;
21090 +using com::sun::star::container::ElementExistException;
21091 +using com::sun::star::container::NoSuchElementException;
21093 +using com::sun::star::uno::Reference;
21094 +using com::sun::star::uno::Exception;
21095 +using com::sun::star::uno::UNO_QUERY;
21096 +using com::sun::star::uno::XInterface;
21097 +using com::sun::star::uno::Sequence;
21098 +using com::sun::star::uno::Any;
21099 +using com::sun::star::uno::makeAny;
21100 +using com::sun::star::uno::Type;
21101 +using com::sun::star::uno::RuntimeException;
21103 +using com::sun::star::lang::IllegalArgumentException;
21104 +using com::sun::star::lang::IndexOutOfBoundsException;
21106 +using com::sun::star::beans::XPropertySetInfo;
21107 +using com::sun::star::beans::XFastPropertySet;
21108 +using com::sun::star::beans::XMultiPropertySet;
21109 +using com::sun::star::beans::XPropertySet;
21110 +using com::sun::star::beans::Property;
21112 +using com::sun::star::sdbc::XResultSet;
21113 +using com::sun::star::sdbc::XPreparedStatement;
21114 +using com::sun::star::sdbc::XStatement;
21115 +using com::sun::star::sdbc::XParameters;
21116 +using com::sun::star::sdbc::XRow;
21117 +using com::sun::star::sdbc::SQLException;
21119 +namespace pq_sdbc_driver
21121 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
21123 +View::View( const ::rtl::Reference< RefCountedMutex > & refMutex,
21124 + const Reference< com::sun::star::sdbc::XConnection > & connection,
21125 + ConnectionSettings *pSettings)
21126 + : ReflectionBase(
21127 + getStatics().refl.view.implName,
21128 + getStatics().refl.view.serviceNames,
21132 + * getStatics().refl.view.pProps )
21135 +Reference< XPropertySet > View::createDataDescriptor( ) throw (RuntimeException)
21137 + ViewDescriptor * pView = new ViewDescriptor(
21138 + m_refMutex, m_conn, m_pSettings );
21139 + pView->copyValuesFrom( this );
21141 + return Reference< XPropertySet > ( pView );
21144 +void View::rename( const ::rtl::OUString& newName )
21145 + throw (::com::sun::star::sdbc::SQLException,
21146 + ::com::sun::star::container::ElementExistException,
21147 + ::com::sun::star::uno::RuntimeException)
21149 + MutexGuard guard( m_refMutex->mutex );
21151 + Statics & st = getStatics();
21153 + ::rtl::OUString oldName = extractStringProperty(this,st.NAME );
21154 + ::rtl::OUString schema = extractStringProperty(this,st.SCHEMA_NAME );
21155 + ::rtl::OUString fullOldName = concatQualified( schema, oldName );
21157 + OUString newTableName;
21158 + OUString newSchemaName;
21159 + // OOo2.0 passes schema + dot + new-table-name while
21160 + // OO1.1.x passes new Name without schema
21161 + // in case name contains a dot, it is interpreted as schema.tablename
21162 + if( newName.indexOf( '.' ) >= 0 )
21164 + splitConcatenatedIdentifier( newName, &newSchemaName, &newTableName );
21168 + newTableName = newName;
21169 + newSchemaName = schema;
21171 + ::rtl::OUString fullNewName = concatQualified( newSchemaName, newTableName );
21173 + if( ! schema.equals( newSchemaName ) )
21177 + OUStringBuffer buf(128);
21178 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
21179 + bufferQuoteQualifiedIdentifier(buf, schema, oldName );
21180 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("SET SCHEMA" ) );
21181 + bufferQuoteIdentifier( buf, newSchemaName );
21182 + Reference< XStatement > statement = m_conn->createStatement();
21183 + statement->executeUpdate( buf.makeStringAndClear() );
21184 + setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
21185 + disposeNoThrow( statement );
21186 + schema = newSchemaName;
21188 + catch( com::sun::star::sdbc::SQLException &e )
21190 + OUStringBuffer buf( e.Message );
21191 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ) );
21192 + e.Message = buf.makeStringAndClear();
21197 + if( ! oldName.equals( newTableName ) )
21199 + OUStringBuffer buf(128);
21200 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
21201 + bufferQuoteQualifiedIdentifier( buf, schema, oldName );
21202 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("RENAME TO" ) );
21203 + bufferQuoteIdentifier( buf, newTableName );
21204 + Reference< XStatement > statement = m_conn->createStatement();
21205 + statement->executeUpdate( buf.makeStringAndClear() );
21206 + setPropertyValue_NoBroadcast_public( st.NAME, makeAny(newTableName) );
21209 + // inform the container of the name change !
21210 + if( m_pSettings->views.is() )
21212 + m_pSettings->pViewsImpl->rename( fullOldName, fullNewName );
21216 +Sequence<Type > View::getTypes() throw( RuntimeException )
21218 + static cppu::OTypeCollection *pCollection;
21219 + if( ! pCollection )
21221 + MutexGuard guard( osl::Mutex::getGlobalMutex() );
21222 + if( !pCollection )
21224 + static cppu::OTypeCollection collection(
21225 + getCppuType( (Reference< com::sun::star::sdbcx::XRename> *) 0 ),
21226 + ReflectionBase::getTypes());
21227 + pCollection = &collection;
21230 + return pCollection->getTypes();
21233 +Sequence< sal_Int8> View::getImplementationId() throw( RuntimeException )
21235 + return getStatics().refl.view.implementationId;
21238 +Any View::queryInterface( const Type & reqType ) throw (RuntimeException)
21242 + ret = ReflectionBase::queryInterface( reqType );
21243 + if( ! ret.hasValue() )
21244 + ret = ::cppu::queryInterface(
21246 + static_cast< com::sun::star::sdbcx::XRename * > ( this )
21251 +::rtl::OUString View::getName( ) throw (::com::sun::star::uno::RuntimeException)
21253 + Statics & st = getStatics();
21254 + return concatQualified(
21255 + extractStringProperty( this, st.SCHEMA_NAME ),
21256 + extractStringProperty( this, st.NAME ) );
21259 +void View::setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException)
21264 +//____________________________________________________________________________________________
21266 +ViewDescriptor::ViewDescriptor(
21267 + const ::rtl::Reference< RefCountedMutex > & refMutex,
21268 + const Reference< com::sun::star::sdbc::XConnection > & connection,
21269 + ConnectionSettings *pSettings)
21270 + : ReflectionBase(
21271 + getStatics().refl.viewDescriptor.implName,
21272 + getStatics().refl.viewDescriptor.serviceNames,
21276 + * getStatics().refl.viewDescriptor.pProps )
21279 +Reference< XPropertySet > ViewDescriptor::createDataDescriptor( ) throw (RuntimeException)
21281 + ViewDescriptor * pView = new ViewDescriptor(
21282 + m_refMutex, m_conn, m_pSettings );
21283 + pView->copyValuesFrom( this );
21285 + return Reference< XPropertySet > ( pView );
21290 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
21291 +++ connectivity/source/drivers/postgresql/pq_xview.hxx 2004-06-10 17:27:13.000000000 +0200
21293 +/*************************************************************************
21295 + * $RCSfile: pq_xview.hxx,v $
21297 + * $Revision: 1.1.2.2 $
21299 + * last change: $Author: jbu $ $Date: 2004/06/10 15:27:13 $
21301 + * The Contents of this file are made available subject to the terms of
21302 + * either of the following licenses
21304 + * - GNU Lesser General Public License Version 2.1
21305 + * - Sun Industry Standards Source License Version 1.1
21307 + * Sun Microsystems Inc., October, 2000
21309 + * GNU Lesser General Public License Version 2.1
21310 + * =============================================
21311 + * Copyright 2000 by Sun Microsystems, Inc.
21312 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
21314 + * This library is free software; you can redistribute it and/or
21315 + * modify it under the terms of the GNU Lesser General Public
21316 + * License version 2.1, as published by the Free Software Foundation.
21318 + * This library is distributed in the hope that it will be useful,
21319 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21320 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21321 + * Lesser General Public License for more details.
21323 + * You should have received a copy of the GNU Lesser General Public
21324 + * License along with this library; if not, write to the Free Software
21325 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21326 + * MA 02111-1307 USA
21329 + * Sun Industry Standards Source License Version 1.1
21330 + * =================================================
21331 + * The contents of this file are subject to the Sun Industry Standards
21332 + * Source License Version 1.1 (the "License"); You may not use this file
21333 + * except in compliance with the License. You may obtain a copy of the
21334 + * License at http://www.openoffice.org/license.html.
21336 + * Software provided under this License is provided on an "AS IS" basis,
21337 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21338 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
21339 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21340 + * See the License for the specific provisions governing your rights and
21341 + * obligations concerning the Software.
21343 + * The Initial Developer of the Original Code is: Joerg Budischewski
21345 + * Copyright: 2000 by Sun Microsystems, Inc.
21347 + * All Rights Reserved.
21349 + * Contributor(s): Joerg Budischewski
21352 + ************************************************************************/
21354 +#ifndef PQ_XVIEW_HXX
21355 +#define PQ_XVIEW_HXX
21357 +#include <cppuhelper/component.hxx>
21358 +#include <cppuhelper/propshlp.hxx>
21360 +#include <com/sun/star/lang/XServiceInfo.hpp>
21361 +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
21362 +#include <com/sun/star/sdbcx/XRename.hpp>
21363 +#include <com/sun/star/container/XNamed.hpp>
21365 +#include "pq_xbase.hxx"
21367 +namespace pq_sdbc_driver
21370 +class View : public ReflectionBase,
21371 + public com::sun::star::sdbcx::XRename
21374 + View( const ::rtl::Reference< RefCountedMutex > & refMutex,
21375 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
21376 + ConnectionSettings *pSettings);
21380 +public: // XInterface
21381 + virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
21382 + virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
21383 + virtual com::sun::star::uno::Any SAL_CALL queryInterface(
21384 + const com::sun::star::uno::Type & reqType )
21385 + throw (com::sun::star::uno::RuntimeException);
21387 +public: // XTypeProvider, first implemented by OPropertySetHelper
21388 + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
21389 + throw( com::sun::star::uno::RuntimeException );
21390 + virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
21391 + throw( com::sun::star::uno::RuntimeException );
21393 +public: // XDataDescriptorFactory
21394 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
21395 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
21397 +public: // XRename
21398 + virtual void SAL_CALL rename( const ::rtl::OUString& newName )
21399 + throw (::com::sun::star::sdbc::SQLException,
21400 + ::com::sun::star::container::ElementExistException,
21401 + ::com::sun::star::uno::RuntimeException);
21404 + virtual ::rtl::OUString SAL_CALL getName( ) throw (::com::sun::star::uno::RuntimeException);
21405 + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
21410 +class ViewDescriptor : public ReflectionBase
21413 + ViewDescriptor( const ::rtl::Reference< RefCountedMutex > & refMutex,
21414 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
21415 + ConnectionSettings *pSettings);
21417 +public: // XDataDescriptorFactory
21418 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL
21419 + createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
21426 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
21427 +++ connectivity/source/drivers/postgresql/pq_xviews.cxx 2006-05-01 21:19:09.000000000 +0200
21429 +/*************************************************************************
21431 + * $RCSfile: pq_xviews.cxx,v $
21433 + * $Revision: 1.1.2.4 $
21435 + * last change: $Author: jbu $ $Date: 2006/05/01 19:19:09 $
21437 + * The Contents of this file are made available subject to the terms of
21438 + * either of the following licenses
21440 + * - GNU Lesser General Public License Version 2.1
21441 + * - Sun Industry Standards Source License Version 1.1
21443 + * Sun Microsystems Inc., October, 2000
21445 + * GNU Lesser General Public License Version 2.1
21446 + * =============================================
21447 + * Copyright 2000 by Sun Microsystems, Inc.
21448 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
21450 + * This library is free software; you can redistribute it and/or
21451 + * modify it under the terms of the GNU Lesser General Public
21452 + * License version 2.1, as published by the Free Software Foundation.
21454 + * This library is distributed in the hope that it will be useful,
21455 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21456 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21457 + * Lesser General Public License for more details.
21459 + * You should have received a copy of the GNU Lesser General Public
21460 + * License along with this library; if not, write to the Free Software
21461 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21462 + * MA 02111-1307 USA
21465 + * Sun Industry Standards Source License Version 1.1
21466 + * =================================================
21467 + * The contents of this file are subject to the Sun Industry Standards
21468 + * Source License Version 1.1 (the "License"); You may not use this file
21469 + * except in compliance with the License. You may obtain a copy of the
21470 + * License at http://www.openoffice.org/license.html.
21472 + * Software provided under this License is provided on an "AS IS" basis,
21473 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21474 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
21475 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21476 + * See the License for the specific provisions governing your rights and
21477 + * obligations concerning the Software.
21479 + * The Initial Developer of the Original Code is: Joerg Budischewski
21481 + * Copyright: 2000 by Sun Microsystems, Inc.
21483 + * All Rights Reserved.
21485 + * Contributor(s): Joerg Budischewski
21488 + ************************************************************************/
21492 +#include <rtl/ustrbuf.hxx>
21494 +#include <com/sun/star/sdbc/XRow.hpp>
21495 +#include <com/sun/star/sdbc/XParameters.hpp>
21496 +#include <com/sun/star/sdbcx/Privilege.hpp>
21498 +#include "pq_xviews.hxx"
21499 +#include "pq_xview.hxx"
21500 +#include "pq_xtables.hxx"
21501 +#include "pq_statics.hxx"
21502 +#include "pq_tools.hxx"
21504 +using osl::MutexGuard;
21506 +using rtl::OUString;
21507 +using rtl::OUStringBuffer;
21508 +using rtl::OUStringToOString;
21510 +using com::sun::star::beans::XPropertySet;
21512 +using com::sun::star::uno::Any;
21513 +using com::sun::star::uno::makeAny;
21514 +using com::sun::star::uno::UNO_QUERY;
21515 +using com::sun::star::uno::Type;
21516 +using com::sun::star::uno::XInterface;
21517 +using com::sun::star::uno::Reference;
21518 +using com::sun::star::uno::Sequence;
21519 +using com::sun::star::uno::RuntimeException;
21521 +using com::sun::star::container::NoSuchElementException;
21522 +using com::sun::star::lang::WrappedTargetException;
21524 +using com::sun::star::sdbc::XRow;
21525 +using com::sun::star::sdbc::XCloseable;
21526 +using com::sun::star::sdbc::XStatement;
21527 +using com::sun::star::sdbc::XResultSet;
21528 +using com::sun::star::sdbc::XParameters;
21529 +using com::sun::star::sdbc::XPreparedStatement;
21530 +using com::sun::star::sdbc::XDatabaseMetaData;
21532 +// using com::sun::star::sdbcx::Privilege;
21534 +namespace pq_sdbc_driver
21536 +#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
21538 + const ::rtl::Reference< RefCountedMutex > & refMutex,
21539 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
21540 + ConnectionSettings *pSettings )
21541 + : Container( refMutex, origin, pSettings, getStatics().VIEW )
21547 +void Views::refresh()
21548 + throw (::com::sun::star::uno::RuntimeException)
21552 + osl::MutexGuard guard( m_refMutex->mutex );
21553 + Statics & st = getStatics();
21555 + Reference< XStatement > stmt = m_origin->createStatement();
21557 + Reference< XResultSet > rs = stmt->executeQuery(
21558 + ASCII_STR( "SELECT "
21559 + "DISTINCT ON( pg_namespace.nspname, relname) " // needed because of duplicates
21560 + "pg_namespace.nspname," // 1
21562 + "pg_get_viewdef(ev_class) " // 3
21563 + "FROM pg_namespace, pg_class, pg_rewrite "
21564 + "WHERE pg_namespace.oid = relnamespace "
21565 + "AND pg_class.oid = ev_class "
21566 + "AND relkind='v'" ) );
21568 + Reference< XRow > xRow( rs , UNO_QUERY );
21570 + std::vector< Any, Allocator< Any> > vec;
21571 + String2IntMap map;
21572 + sal_Int32 viewIndex = 0;
21574 + while( rs->next() )
21576 + rtl::OUString table, schema, command;
21577 + schema = xRow->getString( 1 );
21578 + table = xRow->getString( 2 );
21579 + command = xRow->getString( 3 );
21581 + View *pView = new View (m_refMutex, m_origin, m_pSettings );
21582 + Reference< com::sun::star::beans::XPropertySet > prop = pView;
21584 + pView->setPropertyValue_NoBroadcast_public(st.NAME , makeAny(table) );
21585 + pView->setPropertyValue_NoBroadcast_public(st.SCHEMA_NAME, makeAny(schema) );
21586 + pView->setPropertyValue_NoBroadcast_public(st.COMMAND, makeAny(command) );
21587 + vec.push_back( makeAny( prop ) );
21589 + OUStringBuffer buf( table.getLength() + schema.getLength() + 1);
21590 + buf.append( schema ).appendAscii( "." ).append( table );
21591 + map[ buf.makeStringAndClear() ] = viewIndex;
21595 + m_values = Sequence< com::sun::star::uno::Any > ( &vec[0], vec.size() );
21596 + m_name2index.swap( map );
21598 + catch ( com::sun::star::sdbc::SQLException & e )
21600 + throw RuntimeException( e.Message , e.Context );
21602 + fire( RefreshedBroadcaster( *this ) );
21606 +void Views::appendByDescriptor(
21607 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
21608 + throw (::com::sun::star::sdbc::SQLException,
21609 + ::com::sun::star::container::ElementExistException,
21610 + ::com::sun::star::uno::RuntimeException)
21612 + osl::MutexGuard guard( m_refMutex->mutex );
21614 + Statics &st = getStatics();
21615 + OUString name,schema,command;
21616 + descriptor->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
21617 + descriptor->getPropertyValue( st.NAME ) >>= name;
21618 + descriptor->getPropertyValue( st.COMMAND ) >>= command;
21620 + Reference< XStatement > stmt = m_origin->createStatement();
21622 + OUStringBuffer buf( 128 );
21624 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE VIEW " ) );
21625 + bufferQuoteQualifiedIdentifier( buf, schema, name );
21626 + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AS " ) );
21627 + buf.append( command );
21629 + stmt->executeUpdate( buf.makeStringAndClear() );
21631 + disposeNoThrow( stmt );
21633 + if( m_pSettings->tables.is() )
21635 + m_pSettings->pTablesImpl->refresh();
21637 + // increase the vector
21638 +// sal_Int32 index = m_values.getLength();
21639 +// m_values.realloc( index + 1 );
21642 +// new View( m_refMutex, m_origin, m_pSettings, false /*modifiable*/ );
21643 +// Reference< com::sun::star::beans::XPropertySet > prop = pTable;
21644 +// copyProperties( pTable, descriptor );
21645 +// m_values[index] = makeAny( prop );
21646 +// OUStringBuffer buf( name.getLength() + 1 + schema.getLength() );
21647 +// buf.append( schema ).appendAscii( "." ).append( name );
21648 +// m_name2index[ buf.makeStringAndClear() ] = index;
21651 +void Views::dropByName( const ::rtl::OUString& elementName )
21652 + throw (::com::sun::star::sdbc::SQLException,
21653 + ::com::sun::star::container::NoSuchElementException,
21654 + ::com::sun::star::uno::RuntimeException)
21656 + String2IntMap::const_iterator ii = m_name2index.find( elementName );
21657 + if( ii == m_name2index.end() )
21659 + OUStringBuffer buf( 128 );
21660 + buf.appendAscii( "View " );
21661 + buf.append( elementName );
21662 + buf.appendAscii( " is unknown, so it can't be dropped" );
21663 + throw com::sun::star::container::NoSuchElementException(
21664 + buf.makeStringAndClear(), *this );
21666 + dropByIndex( ii->second );
21669 +void Views::dropByIndex( sal_Int32 index )
21670 + throw (::com::sun::star::sdbc::SQLException,
21671 + ::com::sun::star::lang::IndexOutOfBoundsException,
21672 + ::com::sun::star::uno::RuntimeException)
21674 +// throw SQLException(
21675 +// ASCII_STR( "view deletion not supported" ), *this, OUString(), 1, Any() );
21676 + osl::MutexGuard guard( m_refMutex->mutex );
21677 + if( index < 0 || index >= m_values.getLength() )
21679 + OUStringBuffer buf( 128 );
21680 + buf.appendAscii( "VIEWS: Index out of range (allowed 0 to " );
21681 + buf.append( (sal_Int32) (m_values.getLength() -1) );
21682 + buf.appendAscii( ", got " );
21683 + buf.append( index );
21684 + buf.appendAscii( ")" );
21685 + throw com::sun::star::lang::IndexOutOfBoundsException(
21686 + buf.makeStringAndClear(), *this );
21689 + Reference< XPropertySet > set;
21690 + m_values[index] >>= set;
21691 + Statics &st = getStatics();
21692 + OUString name,schema;
21693 + set->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
21694 + set->getPropertyValue( st.NAME ) >>= name;
21696 + OUStringBuffer update( 128 );
21697 + update.appendAscii( "DROP VIEW \"" ).append( schema ).appendAscii( "\".\"" );
21698 + update.append( name ).appendAscii( "\"" );
21700 + Reference< XStatement > stmt = m_origin->createStatement( );
21702 + stmt->executeUpdate( update.makeStringAndClear() );
21706 +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > Views::createDataDescriptor()
21707 + throw (::com::sun::star::uno::RuntimeException)
21709 + return new ViewDescriptor( m_refMutex, m_origin, m_pSettings );
21712 +Reference< com::sun::star::container::XNameAccess > Views::create(
21713 + const ::rtl::Reference< RefCountedMutex > & refMutex,
21714 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
21715 + ConnectionSettings *pSettings,
21718 + *ppViews = new Views( refMutex, origin, pSettings );
21719 + Reference< com::sun::star::container::XNameAccess > ret = *ppViews;
21720 + (*ppViews)->refresh();
21725 +void Views::disposing()
21727 + Container::disposing();
21733 --- /dev/null 2007-08-27 20:56:43.916000000 +0200
21734 +++ connectivity/source/drivers/postgresql/pq_xviews.hxx 2004-05-09 21:47:26.000000000 +0200
21736 +/*************************************************************************
21738 + * $RCSfile: pq_xviews.hxx,v $
21740 + * $Revision: 1.1.2.1 $
21742 + * last change: $Author: jbu $ $Date: 2004/05/09 19:47:26 $
21744 + * The Contents of this file are made available subject to the terms of
21745 + * either of the following licenses
21747 + * - GNU Lesser General Public License Version 2.1
21748 + * - Sun Industry Standards Source License Version 1.1
21750 + * Sun Microsystems Inc., October, 2000
21752 + * GNU Lesser General Public License Version 2.1
21753 + * =============================================
21754 + * Copyright 2000 by Sun Microsystems, Inc.
21755 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
21757 + * This library is free software; you can redistribute it and/or
21758 + * modify it under the terms of the GNU Lesser General Public
21759 + * License version 2.1, as published by the Free Software Foundation.
21761 + * This library is distributed in the hope that it will be useful,
21762 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21763 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21764 + * Lesser General Public License for more details.
21766 + * You should have received a copy of the GNU Lesser General Public
21767 + * License along with this library; if not, write to the Free Software
21768 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21769 + * MA 02111-1307 USA
21772 + * Sun Industry Standards Source License Version 1.1
21773 + * =================================================
21774 + * The contents of this file are subject to the Sun Industry Standards
21775 + * Source License Version 1.1 (the "License"); You may not use this file
21776 + * except in compliance with the License. You may obtain a copy of the
21777 + * License at http://www.openoffice.org/license.html.
21779 + * Software provided under this License is provided on an "AS IS" basis,
21780 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21781 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
21782 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21783 + * See the License for the specific provisions governing your rights and
21784 + * obligations concerning the Software.
21786 + * The Initial Developer of the Original Code is: Joerg Budischewski
21788 + * Copyright: 2000 by Sun Microsystems, Inc.
21790 + * All Rights Reserved.
21792 + * Contributor(s): Joerg Budischewski
21795 + ************************************************************************/
21797 +#ifndef _PQ_VIEWS_HXX_
21798 +#define _PQ_VIEWS_HXX_
21800 +#include "pq_xcontainer.hxx"
21802 +namespace pq_sdbc_driver
21805 +class Views : public Container
21808 +public: // instances Views 'exception safe'
21809 + static com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > create(
21810 + const ::rtl::Reference< RefCountedMutex > & refMutex,
21811 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
21812 + ConnectionSettings *pSettings,
21813 + Views **ppViews );
21817 + const ::rtl::Reference< RefCountedMutex > & refMutex,
21818 + const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
21819 + ConnectionSettings *pSettings);
21821 + virtual ~Views();
21823 +public: // XAppend
21824 + virtual void SAL_CALL appendByDescriptor(
21825 + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor )
21826 + throw (::com::sun::star::sdbc::SQLException,
21827 + ::com::sun::star::container::ElementExistException,
21828 + ::com::sun::star::uno::RuntimeException);
21831 + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName )
21832 + throw (::com::sun::star::sdbc::SQLException,
21833 + ::com::sun::star::container::NoSuchElementException,
21834 + ::com::sun::star::uno::RuntimeException);
21835 + virtual void SAL_CALL dropByIndex( sal_Int32 index )
21836 + throw (::com::sun::star::sdbc::SQLException,
21837 + ::com::sun::star::lang::IndexOutOfBoundsException,
21838 + ::com::sun::star::uno::RuntimeException);
21840 +public: // XRefreshable
21841 + virtual void SAL_CALL refresh( ) throw (::com::sun::star::uno::RuntimeException);
21843 +public: // XDataDescriptorFactory
21844 + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( )
21845 + throw (::com::sun::star::uno::RuntimeException);
21848 + virtual void SAL_CALL disposing();