2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-09-27 13:52:10 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 05:31:47 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "KeySet.hxx"
|
2004-06-01 09:08:36 +00:00
|
|
|
#include "core_resource.hxx"
|
|
|
|
#include "core_resource.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XParameters.hpp>
|
2002-07-25 05:38:47 +00:00
|
|
|
#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
|
2001-01-24 08:52:19 +00:00
|
|
|
#include <com/sun/star/sdbc/XColumnLocate.hpp>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/container/XIndexAccess.hpp>
|
2000-10-25 06:32:52 +00:00
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "apitools.hxx"
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
2004-10-22 07:54:05 +00:00
|
|
|
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
|
2001-02-01 13:23:57 +00:00
|
|
|
#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
|
2001-01-22 06:38:24 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2001-01-24 08:52:19 +00:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.hpp>
|
2001-01-31 11:35:35 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
2006-07-10 14:02:45 +00:00
|
|
|
#include <connectivity/dbexception.hxx>
|
2001-02-01 13:23:57 +00:00
|
|
|
#include <list>
|
2002-07-25 05:38:47 +00:00
|
|
|
#include <algorithm>
|
2008-03-05 15:48:50 +00:00
|
|
|
#include <string.h>
|
2001-04-02 10:14:53 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2001-07-19 08:29:22 +00:00
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
2004-03-15 14:45:30 +00:00
|
|
|
#include "querycomposer.hxx"
|
2005-01-05 11:26:22 +00:00
|
|
|
#include "composertools.hxx"
|
2005-09-23 11:02:11 +00:00
|
|
|
#include <tools/debug.hxx>
|
2010-07-08 12:21:55 +02:00
|
|
|
#include "PrivateRow.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
using namespace dbaccess;
|
2006-07-10 14:02:45 +00:00
|
|
|
using namespace ::connectivity;
|
|
|
|
using namespace ::dbtools;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
2001-01-24 08:52:19 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::util;
|
2001-04-02 10:14:53 +00:00
|
|
|
using namespace ::com::sun::star::io;
|
2006-08-15 09:41:07 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-01-22 06:38:24 +00:00
|
|
|
using namespace ::cppu;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::osl;
|
2013-02-27 06:53:34 +01:00
|
|
|
using std::vector;
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2004-08-02 14:00:09 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void lcl_fillIndexColumns(const Reference<XIndexAccess>& _xIndexes, ::std::vector< Reference<XNameAccess> >& _rAllIndexColumns)
|
|
|
|
{
|
|
|
|
if ( _xIndexes.is() )
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xIndexColsSup;
|
|
|
|
sal_Int32 nCount = _xIndexes->getCount();
|
|
|
|
for(sal_Int32 j = 0 ; j < nCount ; ++j)
|
|
|
|
{
|
|
|
|
xIndexColsSup.set(_xIndexes->getByIndex(j),UNO_QUERY);
|
|
|
|
if( xIndexColsSup.is()
|
|
|
|
&& comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
|
|
|
|
&& !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
|
|
|
|
)
|
|
|
|
_rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-04 17:40:30 +02:00
|
|
|
|
|
|
|
template < typename T > inline void tryDispose( Reference<T> &r )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::comphelper::disposeComponent(r);
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
r = NULL;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "Unknown Exception occurred");
|
2012-06-04 17:40:30 +02:00
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:00:09 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-10-30 13:22:10 +00:00
|
|
|
OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
|
2008-06-06 12:58:16 +00:00
|
|
|
const Reference< XIndexAccess>& _xTableKeys,
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString& _rUpdateTableName, // this can be the alias or the full qualified name
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
|
2010-11-24 14:23:06 +01:00
|
|
|
const ORowSetValueVector& _aParameterValueForCache,
|
2011-01-06 12:32:17 +01:00
|
|
|
sal_Int32 i_nMaxRows,
|
|
|
|
sal_Int32& o_nRowCount)
|
2010-11-24 14:23:06 +01:00
|
|
|
:OCacheSet(i_nMaxRows)
|
|
|
|
,m_aParameterValueForCache(_aParameterValueForCache)
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
,m_pKeyColumnNames(NULL)
|
2006-06-20 01:35:08 +00:00
|
|
|
,m_pColumnNames(NULL)
|
2010-01-19 09:16:12 +00:00
|
|
|
,m_pParameterNames(NULL)
|
2006-08-15 09:41:07 +00:00
|
|
|
,m_pForeignColumnNames(NULL)
|
2006-06-20 01:35:08 +00:00
|
|
|
,m_xTable(_xTable)
|
2008-06-06 12:58:16 +00:00
|
|
|
,m_xTableKeys(_xTableKeys)
|
2001-02-01 13:23:57 +00:00
|
|
|
,m_xComposer(_xComposer)
|
|
|
|
,m_sUpdateTableName(_rUpdateTableName)
|
2011-01-06 12:32:17 +01:00
|
|
|
,m_rRowCount(o_nRowCount)
|
2014-04-17 11:16:55 +02:00
|
|
|
,m_bRowCountFinal(false)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-07-19 08:29:22 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
OKeySet::~OKeySet()
|
|
|
|
{
|
2012-06-04 17:40:30 +02:00
|
|
|
tryDispose(m_xSet);
|
2013-02-27 06:53:34 +01:00
|
|
|
// m_xStatement is necessarily one of those
|
|
|
|
const vStatements_t::const_iterator end(m_vStatements.end());
|
|
|
|
for(vStatements_t::iterator i(m_vStatements.begin());
|
|
|
|
i != end;
|
|
|
|
++i)
|
|
|
|
{
|
|
|
|
tryDispose(i->second);
|
|
|
|
}
|
2012-06-04 17:40:30 +02:00
|
|
|
|
2003-12-01 09:33:47 +00:00
|
|
|
m_xComposer = NULL;
|
2005-09-23 11:02:11 +00:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::initColumns()
|
2001-07-19 08:29:22 +00:00
|
|
|
{
|
2003-12-01 09:33:47 +00:00
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
2014-05-06 07:44:11 +02:00
|
|
|
bool bCase = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
|
2010-07-08 12:21:55 +02:00
|
|
|
m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
}
|
2011-09-22 15:00:08 +01:00
|
|
|
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2010-09-22 11:08:30 +02:00
|
|
|
void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable,
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString& i_rUpdateTableName,
|
2010-09-22 11:08:30 +02:00
|
|
|
const Reference<XDatabaseMetaData>& i_xMeta,
|
2010-10-18 12:38:57 +02:00
|
|
|
const Reference<XNameAccess>& i_xQueryColumns,
|
|
|
|
::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
// first ask the database itself for the best columns which can be used
|
2013-01-05 19:12:07 -02:00
|
|
|
Sequence< OUString> aBestColumnNames;
|
2010-07-08 12:21:55 +02:00
|
|
|
Reference<XNameAccess> xKeyColumns = getPrimaryKeyColumns_throw(i_aTable);
|
|
|
|
if ( xKeyColumns.is() )
|
|
|
|
aBestColumnNames = xKeyColumns->getElementNames();
|
2010-07-06 15:20:20 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
|
|
|
|
const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
|
|
|
|
// locate parameter in select columns
|
|
|
|
Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
|
|
|
|
const sal_Int32 nParaCount = xQueryParameters->getCount();
|
2013-01-05 19:12:07 -02:00
|
|
|
Sequence< OUString> aParameterColumns(nParaCount);
|
2010-07-08 12:21:55 +02:00
|
|
|
for(sal_Int32 i = 0; i< nParaCount;++i)
|
2010-04-19 11:50:35 +02:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
|
|
|
|
xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
|
2010-04-19 11:50:35 +02:00
|
|
|
}
|
2010-09-01 13:09:46 +02:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sUpdateTableName( i_rUpdateTableName );
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( sUpdateTableName.isEmpty() )
|
2010-09-01 13:09:46 +02:00
|
|
|
{
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." );
|
2010-09-22 11:08:30 +02:00
|
|
|
// If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement,
|
|
|
|
// then the below code will not produce correct results.
|
|
|
|
// For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named
|
|
|
|
// "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is
|
|
|
|
// already lost here.
|
2013-02-27 06:30:56 +01:00
|
|
|
// now getColumnPositions would traverse the columns, and check which of them belong to the table denoted
|
2010-09-22 11:08:30 +02:00
|
|
|
// by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table
|
|
|
|
// named "alias", there will be no matching - so getColumnPositions wouldn't find anything.
|
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sCatalog, sSchema, sTable;
|
2010-09-22 11:08:30 +02:00
|
|
|
Reference<XPropertySet> xTableProp( i_aTable, UNO_QUERY_THROW );
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_CATALOGNAME )>>= sCatalog;
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema;
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_NAME ) >>= sTable;
|
2014-03-31 16:46:08 +02:00
|
|
|
sUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, false, ::dbtools::eInDataManipulation );
|
2010-09-01 13:09:46 +02:00
|
|
|
}
|
2010-09-22 11:08:30 +02:00
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sUpdateTableName,(*o_pKeyColumnNames),true);
|
2010-09-22 11:08:30 +02:00
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sUpdateTableName,(*m_pColumnNames),true);
|
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sUpdateTableName,(*m_pParameterNames),true);
|
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
if ( o_pKeyColumnNames->empty() )
|
2010-09-01 13:09:46 +02:00
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
::dbtools::throwGenericSQLException("Could not find any key column.", *this );
|
2010-09-01 13:09:46 +02:00
|
|
|
}
|
2001-12-05 13:56:24 +00:00
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
for ( SelectColumnsMetaData::const_iterator keyColumn = o_pKeyColumnNames->begin();
|
|
|
|
keyColumn != o_pKeyColumnNames->end();
|
2010-09-22 11:08:30 +02:00
|
|
|
++keyColumn
|
|
|
|
)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2010-09-22 11:08:30 +02:00
|
|
|
if ( !xTblColumns->hasByName( keyColumn->second.sRealName ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Reference<XPropertySet> xProp( xTblColumns->getByName( keyColumn->second.sRealName ), UNO_QUERY );
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bAuto = false;
|
2010-09-22 11:08:30 +02:00
|
|
|
if ( ( xProp->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= bAuto ) && bAuto )
|
|
|
|
m_aAutoColumns.push_back( keyColumn->first );
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2011-09-22 15:00:08 +01:00
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
|
|
|
|
2012-01-18 12:30:36 +01:00
|
|
|
namespace
|
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
void appendOneKeyColumnClause( const OUString &tblName, const OUString &colName, const connectivity::ORowSetValue &_rValue, OUStringBuffer &o_buf )
|
2012-01-18 12:30:36 +01:00
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
static const OUString s_sDot(".");
|
|
|
|
OUString fullName;
|
|
|
|
if (tblName.isEmpty())
|
|
|
|
fullName = colName;
|
|
|
|
else
|
|
|
|
fullName = tblName + s_sDot + colName;
|
|
|
|
if ( _rValue.isNull() )
|
|
|
|
{
|
|
|
|
o_buf.append(fullName + " IS NULL ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
o_buf.append(fullName + " = ? ");
|
|
|
|
}
|
2012-01-18 12:30:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OKeySet::setOneKeyColumnParameter( sal_Int32 &nPos, const Reference< XParameters > &_xParameter, const connectivity::ORowSetValue &_rValue, sal_Int32 _nType, sal_Int32 _nScale ) const
|
|
|
|
{
|
|
|
|
if ( _rValue.isNull() )
|
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
// Nothing to do, appendOneKeyColumnClause took care of it,
|
|
|
|
// the "IS NULL" is hardcoded in the query
|
2012-01-18 12:30:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setParameter( nPos++, _xParameter, _rValue, _nType, _nScale );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer OKeySet::createKeyFilter()
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
|
|
|
|
|
|
|
|
static const OUString aAnd(" AND ");
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString aQuote = getIdentifierQuoteString();
|
|
|
|
OUStringBuffer aFilter;
|
2001-07-19 08:29:22 +00:00
|
|
|
// create the where clause
|
2010-07-20 10:45:17 +02:00
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
2013-02-27 06:53:34 +01:00
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
|
|
|
|
for(SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd; ++aPosIter)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
if ( ! aFilter.isEmpty() )
|
|
|
|
aFilter.append(aAnd);
|
|
|
|
appendOneKeyColumnClause(::dbtools::quoteTableName(xMeta, aPosIter->second.sTableName, ::dbtools::eInDataManipulation),
|
|
|
|
::dbtools::quoteName(aQuote, aPosIter->second.sRealName),
|
|
|
|
*aIter++,
|
2012-01-18 12:30:36 +01:00
|
|
|
aFilter);
|
2013-02-27 06:53:34 +01:00
|
|
|
}
|
|
|
|
aPosEnd = m_pForeignColumnNames->end();
|
|
|
|
for(SelectColumnsMetaData::const_iterator aPosIter = m_pForeignColumnNames->begin(); aPosIter != aPosEnd; ++aPosIter)
|
|
|
|
{
|
|
|
|
if ( ! aFilter.isEmpty() )
|
2009-07-03 12:24:35 +00:00
|
|
|
aFilter.append(aAnd);
|
2013-02-27 06:53:34 +01:00
|
|
|
appendOneKeyColumnClause(::dbtools::quoteTableName(xMeta, aPosIter->second.sTableName, ::dbtools::eInDataManipulation),
|
|
|
|
::dbtools::quoteName(aQuote, aPosIter->second.sRealName),
|
|
|
|
*aIter++,
|
|
|
|
aFilter);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
return aFilter;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
void OKeySet::construct(const Reference< XResultSet>& _xDriverSet, const OUString& i_sRowSetFilter)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
|
2013-02-27 06:53:34 +01:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
initColumns();
|
|
|
|
|
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
2013-02-27 06:53:34 +01:00
|
|
|
Reference<XColumnsSupplier> xQueryColSup(m_xComposer, UNO_QUERY);
|
2010-07-08 12:21:55 +02:00
|
|
|
const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
|
2013-02-27 06:53:34 +01:00
|
|
|
findTableColumnsMatching_throw( makeAny(m_xTable), m_sUpdateTableName, xMeta, xQueryColumns, m_pKeyColumnNames );
|
2004-11-17 13:41:21 +00:00
|
|
|
|
2010-03-17 09:11:06 +00:00
|
|
|
Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
|
2005-03-10 15:30:40 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
|
|
|
|
Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
|
2010-03-17 09:11:06 +00:00
|
|
|
xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
|
2006-08-15 09:41:07 +00:00
|
|
|
Reference<XTablesSupplier> xTabSup(xAnalyzer,uno::UNO_QUERY);
|
2007-11-21 14:31:36 +00:00
|
|
|
Reference<XNameAccess> xSelectTables(xTabSup->getTables(),uno::UNO_QUERY);
|
2013-01-05 19:12:07 -02:00
|
|
|
const Sequence< OUString> aSeq = xSelectTables->getElementNames();
|
2007-11-21 14:31:36 +00:00
|
|
|
if ( aSeq.getLength() > 1 ) // special handling for join
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString* pIter = aSeq.getConstArray();
|
2013-02-27 06:32:38 +01:00
|
|
|
const OUString* const pEnd = pIter + aSeq.getLength();
|
2007-11-21 14:31:36 +00:00
|
|
|
for(;pIter != pEnd;++pIter)
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2007-11-21 14:31:36 +00:00
|
|
|
if ( *pIter != m_sUpdateTableName )
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2007-11-21 14:31:36 +00:00
|
|
|
connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY);
|
|
|
|
Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY);
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::eInDataManipulation, false, false, false );
|
2007-11-21 14:31:36 +00:00
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
::dbaccess::getColumnPositions(xQueryColumns, xSelColSup->getColumns()->getElementNames(), sSelectTableName, (*m_pForeignColumnNames), true);
|
2006-08-15 09:41:07 +00:00
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
// LEM: there used to be a break here; however, I see no reason to stop
|
|
|
|
// at first non-updateTable, so I removed it. (think of multiple joins...)
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
}
|
2013-02-27 06:53:34 +01:00
|
|
|
|
|
|
|
// the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
|
|
|
|
// without extra variable to be set
|
|
|
|
OKeySetValue keySetValue((ORowSetValueVector *)NULL,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL));
|
|
|
|
m_aKeyMap.insert(OKeySetMatrix::value_type(0, keySetValue));
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
}
|
|
|
|
|
2013-12-12 20:13:40 +01:00
|
|
|
void OKeySet::reset(const Reference< XResultSet>& _xDriverSet)
|
|
|
|
{
|
|
|
|
OCacheSet::construct(_xDriverSet, m_sRowSetFilter);
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bRowCountFinal = false;
|
2013-12-12 20:13:40 +01:00
|
|
|
m_aKeyMap.clear();
|
|
|
|
OKeySetValue keySetValue((ORowSetValueVector *)NULL,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL));
|
|
|
|
m_aKeyMap.insert(OKeySetMatrix::value_type(0,keySetValue));
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
}
|
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
void OKeySet::ensureStatement( )
|
|
|
|
{
|
|
|
|
// do we already have a statement for the current combination of NULLness
|
|
|
|
// of key & foreign columns?
|
|
|
|
FilterColumnsNULL_t FilterColumnsNULL;
|
|
|
|
FilterColumnsNULL.reserve(m_aKeyIter->second.first->get().size());
|
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
|
|
|
|
const connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aEnd = m_aKeyIter->second.first->get().end();
|
|
|
|
for( ; aIter != aEnd; ++aIter )
|
|
|
|
FilterColumnsNULL.push_back(aIter->isNull());
|
|
|
|
vStatements_t::iterator pNewStatement(m_vStatements.find(FilterColumnsNULL));
|
|
|
|
if(pNewStatement == m_vStatements.end())
|
|
|
|
{
|
|
|
|
// no: make a new one
|
|
|
|
makeNewStatement();
|
|
|
|
std::pair< vStatements_t::iterator, bool > insert_result
|
|
|
|
(m_vStatements.insert(vStatements_t::value_type(FilterColumnsNULL, m_xStatement)));
|
2013-04-09 01:47:23 +03:00
|
|
|
(void) insert_result; // WaE: unused variable
|
2013-02-27 06:53:34 +01:00
|
|
|
assert(insert_result.second);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// yes: use it
|
|
|
|
m_xStatement = pNewStatement->second;
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2013-02-27 06:53:34 +01:00
|
|
|
|
|
|
|
void OKeySet::makeNewStatement()
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
|
|
|
|
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
|
|
|
|
Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
|
|
|
|
xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
|
|
|
|
|
|
|
|
OUStringBuffer aFilter(createKeyFilter());
|
|
|
|
executeStatement(aFilter, xAnalyzer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OKeySet::executeStatement(OUStringBuffer& io_aFilter, Reference<XSingleSelectQueryComposer>& io_xAnalyzer)
|
|
|
|
{
|
|
|
|
bool bFilterSet = !m_sRowSetFilter.isEmpty();
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bFilterSet )
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
{
|
2009-12-07 11:22:08 +00:00
|
|
|
FilterCreator aFilterCreator;
|
2013-02-27 06:53:34 +01:00
|
|
|
aFilterCreator.append( m_sRowSetFilter );
|
2010-07-08 12:21:55 +02:00
|
|
|
aFilterCreator.append( io_aFilter.makeStringAndClear() );
|
|
|
|
io_aFilter = aFilterCreator.getComposedAndClear();
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
io_xAnalyzer->setFilter(io_aFilter.makeStringAndClear());
|
|
|
|
if ( bFilterSet )
|
|
|
|
{
|
|
|
|
Sequence< Sequence< PropertyValue > > aFilter2 = io_xAnalyzer->getStructuredFilter();
|
|
|
|
const Sequence< PropertyValue >* pOr = aFilter2.getConstArray();
|
|
|
|
const Sequence< PropertyValue >* pOrEnd = pOr + aFilter2.getLength();
|
|
|
|
for(;pOr != pOrEnd;++pOr)
|
|
|
|
{
|
|
|
|
const PropertyValue* pAnd = pOr->getConstArray();
|
|
|
|
const PropertyValue* pAndEnd = pAnd + pOr->getLength();
|
|
|
|
for(;pAnd != pAndEnd;++pAnd)
|
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sValue;
|
2012-04-06 19:49:53 +02:00
|
|
|
if ( !(pAnd->Value >>= sValue) || !( sValue == "?" || sValue.matchAsciiL( ":",1,0 ) ) )
|
2010-07-08 12:21:55 +02:00
|
|
|
{ // we have a criteria which has to be taken into account for updates
|
|
|
|
m_aFilterColumns.push_back(pAnd->Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_xStatement = m_xConnection->prepareStatement(io_xAnalyzer->getQueryWithSubstitution());
|
|
|
|
::comphelper::disposeComponent(io_xAnalyzer);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
void OKeySet::invalidateRow()
|
|
|
|
{
|
|
|
|
m_xRow = NULL;
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
|
|
|
}
|
|
|
|
|
2006-06-20 01:35:08 +00:00
|
|
|
Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(),
|
|
|
|
"getBookmark is only possible when we stand on a valid row!");
|
|
|
|
return makeAny(m_aKeyIter->first);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter != m_aKeyMap.end();
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
|
|
|
|
if(m_aKeyIter != m_aKeyMap.end())
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
return relative(rows);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
invalidateRow();
|
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-06-20 01:35:08 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nFirst = 0, nSecond = 0;
|
2006-06-20 01:35:08 +00:00
|
|
|
_first >>= nFirst;
|
|
|
|
_second >>= nSecond;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
return ::comphelper::getINT32(bookmark);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// ::com::sun::star::sdbcx::XDeleteRows
|
|
|
|
Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& _xTable) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer aSql("DELETE FROM " + m_aComposedTableName + " WHERE ");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-06-04 17:35:52 +02:00
|
|
|
// list all columns that should be set
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString aQuote = getIdentifierQuoteString();
|
|
|
|
static OUString aAnd(" AND ");
|
|
|
|
static OUString aOr(" OR ");
|
|
|
|
static OUString aEqual(" = ?");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2013-10-02 19:00:17 +02:00
|
|
|
// use keys for exact positioning
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer aCondition("( ");
|
2004-03-15 14:45:30 +00:00
|
|
|
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin();
|
2013-02-27 06:32:38 +01:00
|
|
|
const SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aPosEnd;++aIter)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
aCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName) + aEqual + aAnd);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2013-02-27 06:32:38 +01:00
|
|
|
aCondition.setLength(aCondition.getLength() - aAnd.getLength());
|
2013-10-02 19:00:17 +02:00
|
|
|
// sCon is (parenthesised) the condition to locate ONE row
|
|
|
|
// e.g. ( colName1 = ? AND colName2 = ? AND colName3 = ? )
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString sCon( aCondition.makeStringAndClear() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2013-10-02 19:00:17 +02:00
|
|
|
// since we need to delete all rows in "rows",
|
|
|
|
// we need to OR as many row locators.
|
|
|
|
const Any* pBegin = rows.getConstArray();
|
|
|
|
const Any* const pEnd = pBegin + rows.getLength();
|
2000-09-18 23:16:46 +00:00
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(sCon + aOr);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-3);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-11-08 02:50:53 -06:00
|
|
|
// now create end execute the prepared statement
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
|
2000-09-18 23:16:46 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2013-10-02 19:00:17 +02:00
|
|
|
// now, fill in the parameters in the row locators
|
2000-09-18 23:16:46 +00:00
|
|
|
pBegin = rows.getConstArray();
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Int32 i=1;
|
2000-09-18 23:16:46 +00:00
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2001-02-01 13:23:57 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(*pBegin));
|
2013-10-02 19:00:17 +02:00
|
|
|
// LEM FIXME: what happens if m_aKeyIter == m_aKeyMap.end() ?
|
|
|
|
// the whole operation fails because there are unfilled parameters
|
|
|
|
// the remaining rows *are* deleted?
|
|
|
|
// check what happens vs what is supposed to happen
|
|
|
|
// (cf documentation of ::com::sun::star::sdbcx::XDeleteRows)
|
2001-02-01 13:23:57 +00:00
|
|
|
if(m_aKeyIter != m_aKeyMap.end())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyIter = m_aKeyIter->second.first->get().begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyEnd = m_aKeyIter->second.first->get().end();
|
2008-01-30 07:28:36 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(sal_uInt16 j = 0;aKeyIter != aKeyEnd;++aKeyIter,++j,++aPosIter)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2008-01-30 07:28:36 +00:00
|
|
|
setParameter(i++,xParameter,*aKeyIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bOk = xPrep->executeUpdate() > 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
Sequence< sal_Int32 > aRet(rows.getLength());
|
|
|
|
memset(aRet.getArray(),bOk,sizeof(sal_Int32)*aRet.getLength());
|
2001-01-22 06:38:24 +00:00
|
|
|
if(bOk)
|
|
|
|
{
|
2006-06-20 01:35:08 +00:00
|
|
|
pBegin = rows.getConstArray();
|
2001-01-22 06:38:24 +00:00
|
|
|
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nPos = 0;
|
2001-01-24 08:52:19 +00:00
|
|
|
*pBegin >>= nPos;
|
2001-06-22 12:07:17 +00:00
|
|
|
if(m_aKeyIter == m_aKeyMap.find(nPos) && m_aKeyIter != m_aKeyMap.end())
|
|
|
|
++m_aKeyIter;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyMap.erase(nPos);
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bDeleted = true;
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-12-20 11:25:37 +01:00
|
|
|
void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOriginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2013-11-04 13:33:17 +02:00
|
|
|
OUStringBuffer aSql = "UPDATE " + m_aComposedTableName + " SET ";
|
2001-02-01 13:23:57 +00:00
|
|
|
// list all cloumns that should be set
|
2013-01-05 19:12:07 -02:00
|
|
|
static OUString aPara(" = ?,");
|
|
|
|
OUString aQuote = getIdentifierQuoteString();
|
|
|
|
static OUString aAnd(" AND ");
|
|
|
|
OUString sIsNull(" IS NULL");
|
|
|
|
OUString sParam(" = ?");
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-02-27 06:30:56 +01:00
|
|
|
// use keys and indexes for exact postioning
|
2001-02-01 13:23:57 +00:00
|
|
|
// first the keys
|
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
|
|
|
|
|
|
|
// second the indexes
|
|
|
|
Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xIndexes;
|
2004-08-02 14:00:09 +00:00
|
|
|
if ( xIndexSup.is() )
|
|
|
|
xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
::std::vector< Reference<XNameAccess> > aAllIndexColumns;
|
2004-08-02 14:00:09 +00:00
|
|
|
lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer sKeyCondition,sIndexCondition;
|
2001-08-14 10:51:34 +00:00
|
|
|
::std::vector<sal_Int32> aIndexColumnPositions;
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
const sal_Int32 nOldLength = aSql.getLength();
|
2004-03-15 14:45:30 +00:00
|
|
|
sal_Int32 i = 1;
|
2001-02-01 13:23:57 +00:00
|
|
|
// here we build the condition part for the update statement
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
|
|
|
for(;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-11-11 14:16:42 +01:00
|
|
|
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2013-12-20 11:25:37 +01:00
|
|
|
if((_rOriginalRow->get())[aIter->second.nPosition].isNull())
|
2009-07-03 12:24:35 +00:00
|
|
|
sKeyCondition.append(sIsNull);
|
2001-02-01 13:23:57 +00:00
|
|
|
else
|
2009-07-03 12:24:35 +00:00
|
|
|
sKeyCondition.append(sParam);
|
|
|
|
sKeyCondition.append(aAnd);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2001-08-14 10:51:34 +00:00
|
|
|
else
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
|
2001-08-14 10:51:34 +00:00
|
|
|
for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aIndexIter != aIndexEnd;++aIndexIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2001-08-14 10:51:34 +00:00
|
|
|
if((*aIndexIter)->hasByName(aIter->first))
|
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2013-12-20 11:25:37 +01:00
|
|
|
if((_rOriginalRow->get())[aIter->second.nPosition].isNull())
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(sIsNull);
|
2001-08-14 10:51:34 +00:00
|
|
|
else
|
2002-03-18 12:59:43 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(sParam);
|
2006-07-10 14:02:45 +00:00
|
|
|
aIndexColumnPositions.push_back(aIter->second.nPosition);
|
2002-03-18 12:59:43 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(aAnd);
|
2001-08-14 10:51:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName) + aPara);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
if( aSql.getLength() != nOldLength )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-1);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-03-09 21:47:17 +01:00
|
|
|
if(!sKeyCondition.isEmpty() || !sIndexCondition.isEmpty())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(" WHERE ");
|
2013-03-09 21:47:17 +01:00
|
|
|
if(!sKeyCondition.isEmpty() && !sIndexCondition.isEmpty())
|
2001-08-14 10:51:34 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(sKeyCondition.makeStringAndClear() + sIndexCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2013-03-09 21:47:17 +01:00
|
|
|
else if(!sKeyCondition.isEmpty())
|
2001-08-14 10:51:34 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sKeyCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2013-03-09 21:47:17 +01:00
|
|
|
else if(!sIndexCondition.isEmpty())
|
2001-08-14 10:51:34 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sIndexCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-5); // remove the last AND
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// now create end execute the prepared statement
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sEmpty;
|
2013-12-20 11:25:37 +01:00
|
|
|
executeUpdate(_rInsertRow ,_rOriginalRow,aSql.makeStringAndClear(),sEmpty,aIndexColumnPositions);
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-12-20 11:25:37 +01:00
|
|
|
void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOriginalRow,const OUString& i_sSQL,const OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
// now create end execute the prepared statement
|
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2010-03-24 10:16:28 +00:00
|
|
|
bool bRefetch = true;
|
|
|
|
Reference<XRow> xRow;
|
2010-07-08 12:21:55 +02:00
|
|
|
sal_Int32 i = 1;
|
|
|
|
// first the set values
|
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
|
|
|
sal_uInt16 j = 0;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2004-03-02 11:41:09 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sal_Int32 nPos = aIter->second.nPosition;
|
|
|
|
if((_rInsertRow->get())[nPos].isModified())
|
2010-03-24 10:16:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bRefetch )
|
2010-03-24 10:16:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
|
2010-03-24 10:16:28 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
impl_convertValue_throw(_rInsertRow,aIter->second);
|
2013-12-20 11:25:37 +01:00
|
|
|
(_rInsertRow->get())[nPos].setSigned((_rOriginalRow->get())[nPos].isSigned());
|
2010-07-08 12:21:55 +02:00
|
|
|
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
|
2010-03-24 10:16:28 +00:00
|
|
|
}
|
2004-03-02 11:41:09 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
// and then the values of the where condition
|
2010-07-08 12:21:55 +02:00
|
|
|
aIter = m_pKeyColumnNames->begin();
|
|
|
|
aEnd = m_pKeyColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
j = 0;
|
2010-07-08 12:21:55 +02:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
2013-12-20 11:25:37 +01:00
|
|
|
setParameter(i++,xParameter,(_rOriginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( !_aIndexColumnPositions.empty() )
|
2001-08-14 10:51:34 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
// now we have to set the index values
|
|
|
|
::std::vector<sal_Int32>::const_iterator aIdxColIter = _aIndexColumnPositions.begin();
|
|
|
|
::std::vector<sal_Int32>::const_iterator aIdxColEnd = _aIndexColumnPositions.end();
|
|
|
|
j = 0;
|
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
|
|
|
|
{
|
2013-12-20 11:25:37 +01:00
|
|
|
setParameter(i,xParameter,(_rOriginalRow->get())[*aIdxColIter],(_rOriginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
const sal_Int32 nRowsUpdated = xPrep->executeUpdate();
|
|
|
|
m_bUpdated = nRowsUpdated > 0;
|
2001-02-01 13:23:57 +00:00
|
|
|
if(m_bUpdated)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2010-01-19 09:16:12 +00:00
|
|
|
const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
|
|
|
|
m_aKeyIter = m_aKeyMap.find(nBookmark);
|
2010-04-20 13:33:34 +02:00
|
|
|
m_aKeyIter->second.second.first = 2;
|
|
|
|
m_aKeyIter->second.second.second = xRow;
|
2010-01-19 09:16:12 +00:00
|
|
|
copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
|
2010-07-08 12:21:55 +02:00
|
|
|
tryRefetch(_rInsertRow,bRefetch);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2013-02-28 18:06:50 +01:00
|
|
|
OUStringBuffer aSql( "INSERT INTO " + m_aComposedTableName + " ( ");
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
// set values and column names
|
2013-12-13 11:24:35 +02:00
|
|
|
OUStringBuffer aValues(" VALUES ( ");
|
2013-01-05 19:12:07 -02:00
|
|
|
static OUString aPara("?,");
|
|
|
|
OUString aQuote = getIdentifierQuoteString();
|
|
|
|
static OUString aComma(",");
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
sal_Int32 j = 1;
|
2010-07-08 12:21:55 +02:00
|
|
|
bool bRefetch = true;
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bModified = false;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
|
2001-07-03 09:58:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bRefetch )
|
|
|
|
{
|
|
|
|
bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
|
|
|
|
}
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName) + aComma);
|
2009-07-03 12:24:35 +00:00
|
|
|
aValues.append(aPara);
|
2014-04-17 11:16:55 +02:00
|
|
|
bModified = true;
|
2001-07-03 09:58:28 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2005-03-18 09:04:30 +00:00
|
|
|
if ( !bModified )
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2011-11-26 00:48:17 -05:00
|
|
|
aSql[aSql.getLength() - 1] = ')';
|
|
|
|
aValues[aValues.getLength() - 1] = ')';
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aValues.makeStringAndClear());
|
2001-02-01 13:23:57 +00:00
|
|
|
// now create,fill and execute the prepared statement
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sEmpty;
|
2010-07-08 12:21:55 +02:00
|
|
|
executeInsert(_rInsertRow,aSql.makeStringAndClear(),sEmpty,bRefetch);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const OUString& i_sSQL,const OUString& i_sTableName,bool bRefetch )
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
// now create,fill and execute the prepared statement
|
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(sal_Int32 i = 1;aIter != aEnd;++aIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2001-07-03 09:58:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
const sal_Int32 nPos = aIter->second.nPosition;
|
|
|
|
if((_rInsertRow->get())[nPos].isModified())
|
2004-03-02 11:41:09 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if((_rInsertRow->get())[nPos].isNull())
|
|
|
|
xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
impl_convertValue_throw(_rInsertRow,aIter->second);
|
|
|
|
(_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
|
|
|
|
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
|
|
|
|
}
|
2004-03-02 11:41:09 +00:00
|
|
|
}
|
2001-07-03 09:58:28 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_bInserted = xPrep->executeUpdate() > 0;
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bAutoValuesFetched = false;
|
2002-07-25 05:38:47 +00:00
|
|
|
if ( m_bInserted )
|
|
|
|
{
|
2005-03-18 09:04:30 +00:00
|
|
|
// first insert the default values into the insertrow
|
2009-07-03 12:24:35 +00:00
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2005-03-18 09:04:30 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() )
|
|
|
|
(_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue;
|
2005-03-18 09:04:30 +00:00
|
|
|
}
|
2002-07-25 05:38:47 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XGeneratedResultSet > xGRes(xPrep, UNO_QUERY);
|
|
|
|
if ( xGRes.is() )
|
|
|
|
{
|
|
|
|
Reference< XResultSet > xRes = xGRes->getGeneratedValues();
|
|
|
|
Reference< XRow > xRow(xRes,UNO_QUERY);
|
|
|
|
if ( xRow.is() && xRes->next() )
|
|
|
|
{
|
|
|
|
Reference< XResultSetMetaDataSupplier > xMdSup(xRes,UNO_QUERY);
|
|
|
|
Reference< XResultSetMetaData > xMd = xMdSup->getMetaData();
|
|
|
|
sal_Int32 nColumnCount = xMd->getColumnCount();
|
2013-01-05 19:12:07 -02:00
|
|
|
::std::vector< OUString >::iterator aAutoIter = m_aAutoColumns.begin();
|
|
|
|
::std::vector< OUString >::iterator aAutoEnd = m_aAutoColumns.end();
|
2002-07-25 05:38:47 +00:00
|
|
|
for (sal_Int32 i = 1;aAutoIter != aAutoEnd && i <= nColumnCount; ++aAutoIter,++i)
|
|
|
|
{
|
2005-02-16 14:57:55 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sColumnName( xMd->getColumnName(i) );
|
2002-07-25 05:38:47 +00:00
|
|
|
#endif
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
2005-09-23 11:02:11 +00:00
|
|
|
if ( aFind != m_pKeyColumnNames->end() )
|
2012-01-16 19:38:01 +01:00
|
|
|
(_rInsertRow->get())[aFind->second.nPosition].fill(i, aFind->second.nType, xRow);
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
2014-04-17 11:16:55 +02:00
|
|
|
bAutoValuesFetched = true;
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2002-07-25 05:38:47 +00:00
|
|
|
{
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "Could not execute GeneratedKeys() stmt");
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-29 15:35:26 +00:00
|
|
|
::comphelper::disposeComponent(xPrep);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() && !bAutoValuesFetched && m_bInserted )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2001-11-29 15:35:26 +00:00
|
|
|
// first check if all key column values were set
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString sMax(" MAX(");
|
|
|
|
const OUString sMaxEnd("),");
|
|
|
|
const OUString sQuote = getIdentifierQuoteString();
|
|
|
|
OUString sMaxStmt;
|
2009-07-03 12:24:35 +00:00
|
|
|
aEnd = m_pKeyColumnNames->end();
|
2013-01-05 19:12:07 -02:00
|
|
|
::std::vector< OUString >::iterator aAutoIter = m_aAutoColumns.begin();
|
|
|
|
::std::vector< OUString >::iterator aAutoEnd = m_aAutoColumns.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for (;aAutoIter != aAutoEnd; ++aAutoIter)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
|
|
|
// we will only fetch values which are keycolumns
|
2010-08-31 13:42:47 +02:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
|
|
|
if ( aFind != aEnd )
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
sMaxStmt += sMax;
|
2010-08-31 13:42:47 +02:00
|
|
|
sMaxStmt += ::dbtools::quoteName( sQuote,aFind->second.sRealName
|
|
|
|
);
|
2009-07-03 12:24:35 +00:00
|
|
|
sMaxStmt += sMaxEnd;
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-22 09:07:04 +00:00
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
if(!sMaxStmt.isEmpty())
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,OUString(" "));
|
2013-03-08 04:51:28 +01:00
|
|
|
OUString sStmt = "SELECT " + sMaxStmt + "FROM ";
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sCatalog,sSchema,sTable;
|
2010-09-01 13:09:46 +02:00
|
|
|
::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
|
|
|
|
sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
|
2001-12-05 13:56:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// now fetch the autoincrement values
|
|
|
|
Reference<XStatement> xStatement = m_xConnection->createStatement();
|
|
|
|
Reference<XResultSet> xRes = xStatement->executeQuery(sStmt);
|
|
|
|
Reference<XRow> xRow(xRes,UNO_QUERY);
|
|
|
|
if(xRow.is() && xRes->next())
|
|
|
|
{
|
|
|
|
aAutoIter = m_aAutoColumns.begin();
|
2005-03-18 09:04:30 +00:00
|
|
|
for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
|
|
|
// we will only fetch values which are keycolumns
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
2009-07-03 12:24:35 +00:00
|
|
|
if ( aFind != aEnd )
|
2012-01-16 19:38:01 +01:00
|
|
|
(_rInsertRow->get())[aFind->second.nPosition].fill(i, aFind->second.nType, xRow);
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
::comphelper::disposeComponent(xStatement);
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "Could not fetch with MAX() ");
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
2002-08-22 09:07:04 +00:00
|
|
|
if ( m_bInserted )
|
2002-07-25 05:38:47 +00:00
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
|
|
|
|
--aKeyIter;
|
2010-07-08 12:21:55 +02:00
|
|
|
ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
|
2010-01-19 09:16:12 +00:00
|
|
|
copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
|
|
|
|
|
2012-10-25 21:02:50 +02:00
|
|
|
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(1,(Reference<XRow>)NULL)))).first;
|
2001-01-24 08:52:19 +00:00
|
|
|
// now we set the bookmark for this row
|
2008-12-30 13:32:01 +00:00
|
|
|
(_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
|
2010-07-08 12:21:55 +02:00
|
|
|
tryRefetch(_rInsertRow,bRefetch);
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
|
|
|
|
{
|
|
|
|
if ( bRefetch )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-01-18 13:10:12 +01:00
|
|
|
bRefetch = doTryRefetch_throw();
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
bRefetch = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bRefetch )
|
|
|
|
{
|
|
|
|
m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get());
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-01-19 09:16:12 +00:00
|
|
|
void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark)
|
2006-05-04 07:35:48 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
|
2010-01-19 09:16:12 +00:00
|
|
|
|
|
|
|
// check the if the parameter values have been changed
|
|
|
|
OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
|
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
|
|
|
|
|
|
|
|
bool bChanged = false;
|
|
|
|
SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
|
|
|
|
for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
|
|
|
|
{
|
|
|
|
ORowSetValue aValue(*aParaValuesIter);
|
|
|
|
aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
|
|
|
|
if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
|
|
|
|
{
|
|
|
|
ORowSetValueVector aCopy(m_aParameterValueForCache);
|
|
|
|
(aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
|
|
|
|
m_aUpdatedParameter[i_nBookmark] = aCopy;
|
|
|
|
bChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bChanged )
|
|
|
|
{
|
|
|
|
m_aUpdatedParameter.erase(i_nBookmark);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the key values
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2013-02-27 06:32:38 +01:00
|
|
|
const SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
2006-05-04 07:35:48 +00:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
{
|
2010-10-28 14:15:54 +02:00
|
|
|
impl_convertValue_throw(_rInsertRow,aPosIter->second);
|
2008-12-30 13:32:01 +00:00
|
|
|
*aIter = (_rInsertRow->get())[aPosIter->second.nPosition];
|
2006-07-10 14:02:45 +00:00
|
|
|
aIter->setTypeKind(aPosIter->second.nType);
|
2006-05-04 07:35:48 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer aSql("DELETE FROM " + m_aComposedTableName + " WHERE ");
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// list all cloumns that should be set
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString aQuote = getIdentifierQuoteString();
|
|
|
|
static OUString aAnd(" AND ");
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// use keys and indexes for excat postioning
|
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
|
|
|
// second the indexes
|
|
|
|
Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xIndexes;
|
2004-08-02 14:00:09 +00:00
|
|
|
if ( xIndexSup.is() )
|
|
|
|
xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// Reference<XColumnsSupplier>
|
|
|
|
::std::vector< Reference<XNameAccess> > aAllIndexColumns;
|
2004-08-02 14:00:09 +00:00
|
|
|
lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
OUStringBuffer sIndexCondition;
|
2004-08-02 14:00:09 +00:00
|
|
|
::std::vector<sal_Int32> aIndexColumnPositions;
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
|
|
|
|
sal_Int32 i = 1;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(i = 1;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-11-11 14:16:42 +01:00
|
|
|
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "can a primary key be null");
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(" IS NULL");
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2013-01-05 19:12:07 -02:00
|
|
|
aSql.append(" = ?");
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aAnd);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2004-08-02 14:00:09 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
|
2004-08-02 14:00:09 +00:00
|
|
|
for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aIndexIter != aIndexEnd;++aIndexIter)
|
2004-08-02 14:00:09 +00:00
|
|
|
{
|
|
|
|
if((*aIndexIter)->hasByName(aIter->first))
|
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
|
2013-01-05 19:12:07 -02:00
|
|
|
sIndexCondition.append(" IS NULL");
|
2004-08-02 14:00:09 +00:00
|
|
|
else
|
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
sIndexCondition.append(" = ?");
|
2006-07-10 14:02:45 +00:00
|
|
|
aIndexColumnPositions.push_back(aIter->second.nPosition);
|
2004-08-02 14:00:09 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(aAnd);
|
2004-08-02 14:00:09 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sIndexCondition.makeStringAndClear());
|
|
|
|
aSql.setLength(aSql.getLength()-5);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// now create end execute the prepared statement
|
2009-07-03 12:24:35 +00:00
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2001-10-30 13:22:10 +00:00
|
|
|
aIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aEnd = (*m_pKeyColumnNames).end();
|
2004-08-02 14:00:09 +00:00
|
|
|
i = 1;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
setParameter(i,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 14:00:09 +00:00
|
|
|
// now we have to set the index values
|
|
|
|
::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
|
2009-11-11 14:16:42 +01:00
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter)
|
2004-08-02 14:00:09 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
|
2004-08-02 14:00:09 +00:00
|
|
|
}
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
m_bDeleted = xPrep->executeUpdate() > 0;
|
|
|
|
|
|
|
|
if(m_bDeleted)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
sal_Int32 nBookmark = ::comphelper::getINT32((_rDeleteRow->get())[0].getAny());
|
2003-06-25 10:02:13 +00:00
|
|
|
if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end())
|
2001-06-22 12:07:17 +00:00
|
|
|
++m_aKeyIter;
|
2003-06-25 10:02:13 +00:00
|
|
|
m_aKeyMap.erase(nBookmark);
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bDeleted = true;
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::moveToInsertRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XNameAccess> OKeySet::getKeyColumns() const
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2013-02-27 06:30:56 +01:00
|
|
|
// use keys and indexes for exact postioning
|
2001-01-24 08:52:19 +00:00
|
|
|
// first the keys
|
2008-06-06 12:58:16 +00:00
|
|
|
|
|
|
|
Reference<XIndexAccess> xKeys = m_xTableKeys;
|
|
|
|
if ( !xKeys.is() )
|
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XPropertySet> xSet(m_xTable,UNO_QUERY);
|
|
|
|
const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
|
|
|
|
return xPrimaryKeyColumns;
|
2008-06-06 12:58:16 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
Reference<XColumnsSupplier> xKeyColsSup;
|
|
|
|
Reference<XNameAccess> xKeyColumns;
|
|
|
|
if(xKeys.is())
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp;
|
2004-08-02 14:00:09 +00:00
|
|
|
sal_Int32 nCount = xKeys->getCount();
|
|
|
|
for(sal_Int32 i = 0;i< nCount;++i)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2004-08-02 14:00:09 +00:00
|
|
|
xProp.set(xKeys->getByIndex(i),UNO_QUERY);
|
|
|
|
if ( xProp.is() )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2004-08-02 14:00:09 +00:00
|
|
|
sal_Int32 nKeyType = 0;
|
|
|
|
xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
|
|
|
|
if(KeyType::PRIMARY == nKeyType)
|
|
|
|
{
|
|
|
|
xKeyColsSup.set(xProp,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
|
|
|
|
xKeyColumns = xKeyColsSup->getColumns();
|
|
|
|
break;
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
return xKeyColumns;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
if(isAfterLast())
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2012-05-15 18:37:43 +02:00
|
|
|
++m_aKeyIter;
|
2012-06-01 14:52:46 +02:00
|
|
|
if(!m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end())
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2012-06-01 14:52:46 +02:00
|
|
|
// not yet all records fetched, but we reached the end of those we fetched
|
|
|
|
// try to fetch one more row
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if (fetchRow())
|
|
|
|
{
|
|
|
|
OSL_ENSURE(!isAfterLast(), "fetchRow succeeded, but isAfterLast()");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2012-06-01 14:52:46 +02:00
|
|
|
{
|
|
|
|
// nope, we arrived at end of data
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
2012-06-01 14:52:46 +02:00
|
|
|
OSL_ENSURE(isAfterLast(), "fetchRow failed, but not end of data");
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
return !isAfterLast();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::isBeforeFirst( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
return m_aKeyIter == m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::isAfterLast( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::isFirst( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyMap.begin();
|
|
|
|
++aTemp;
|
|
|
|
return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::isLast( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
if(!m_bRowCountFinal)
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyMap.end();
|
|
|
|
--aTemp;
|
|
|
|
return m_aKeyIter == aTemp;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
fillAllRows();
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
++m_aKeyIter;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if(m_aKeyIter == m_aKeyMap.end())
|
|
|
|
{
|
|
|
|
if (!fetchRow())
|
|
|
|
{
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-01-06 12:32:17 +01:00
|
|
|
else
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
return last_checked(sal_True);
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OKeySet::last_checked( sal_Bool /* i_bFetchRow */ )
|
2010-12-02 13:16:48 +01:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
bool fetchedRow = fillAllRows();
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
--m_aKeyIter;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if ( !fetchedRow )
|
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!");
|
|
|
|
OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!");
|
|
|
|
|
2002-10-01 08:03:59 +00:00
|
|
|
return ::std::distance(m_aKeyMap.begin(),m_aKeyIter);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
|
2010-12-02 13:16:48 +01:00
|
|
|
{
|
|
|
|
return absolute_checked(row,sal_True);
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OKeySet::absolute_checked( sal_Int32 row, sal_Bool /* i_bFetchRow */ )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
OSL_ENSURE(row,"absolute(0) isn't allowed!");
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
bool fetchedRow = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
if(row < 0)
|
|
|
|
{
|
|
|
|
if(!m_bRowCountFinal)
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
fetchedRow = fillAllRows();
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
for(;row < 0 && m_aKeyIter != m_aKeyMap.begin();++row)
|
2012-04-29 16:34:25 +02:00
|
|
|
--m_aKeyIter;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-02 10:14:53 +00:00
|
|
|
if(row >= (sal_Int32)m_aKeyMap.size())
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
// we don't have this row
|
2001-01-24 08:52:19 +00:00
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
// but there may still be rows to fetch.
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bNext = true;
|
2001-01-24 08:52:19 +00:00
|
|
|
for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i)
|
|
|
|
bNext = fetchRow();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
// it is guaranteed that the above loop has executed at least once,
|
|
|
|
// that is fetchRow called at least once.
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( bNext )
|
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
fetchedRow = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// reached end of data before desired row
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
return false;
|
2010-12-02 13:16:48 +01:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
{
|
|
|
|
// no more rows to fetch -> fail
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
return false;
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
for(;row > 0 && m_aKeyIter != m_aKeyMap.end();--row)
|
|
|
|
++m_aKeyIter;
|
|
|
|
}
|
|
|
|
}
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if ( !fetchedRow )
|
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
if(!rows)
|
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
return absolute(getRow()+rows);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OKeySet::previous_checked( sal_Bool /* i_bFetchRow */ )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = false;
|
2001-01-24 08:52:19 +00:00
|
|
|
if(m_aKeyIter != m_aKeyMap.begin())
|
|
|
|
{
|
|
|
|
--m_aKeyIter;
|
2012-07-16 23:58:18 +02:00
|
|
|
invalidateRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
return m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException)
|
2010-12-02 13:16:48 +01:00
|
|
|
{
|
|
|
|
return previous_checked(sal_True);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-01-18 13:10:12 +01:00
|
|
|
bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
ensureStatement( );
|
2012-01-18 13:10:12 +01:00
|
|
|
// we just reassign the base members
|
2001-01-24 08:52:19 +00:00
|
|
|
Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
|
2001-12-05 13:56:24 +00:00
|
|
|
OSL_ENSURE(xParameter.is(),"No Parameter interface!");
|
|
|
|
xParameter->clearParameters();
|
2010-01-19 09:16:12 +00:00
|
|
|
|
2001-07-09 06:00:18 +00:00
|
|
|
sal_Int32 nPos=1;
|
2010-01-19 09:16:12 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
|
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
|
|
|
|
OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
|
|
|
|
if ( aUpdateFind == m_aUpdatedParameter.end() )
|
|
|
|
{
|
|
|
|
aParaIter = m_aParameterValueForCache.get().begin();
|
|
|
|
aParaEnd = m_aParameterValueForCache.get().end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aParaIter = aUpdateFind->second.get().begin();
|
|
|
|
aParaEnd = aUpdateFind->second.get().end();
|
|
|
|
}
|
|
|
|
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
|
|
|
|
{
|
|
|
|
::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
|
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
|
|
|
|
// now set the primary key column values
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
|
2013-02-27 06:32:38 +01:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
|
2012-01-18 12:30:36 +01:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2013-02-27 06:32:38 +01:00
|
|
|
aPosIter = m_pForeignColumnNames->begin();
|
|
|
|
aPosEnd = m_pForeignColumnNames->end();
|
2012-01-18 12:30:36 +01:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
m_xSet = m_xStatement->executeQuery();
|
2012-01-18 13:10:12 +01:00
|
|
|
OSL_ENSURE(m_xSet.is(),"No resultset from statement!");
|
2012-01-18 13:51:14 +01:00
|
|
|
return m_xSet->next();
|
2012-01-18 13:10:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
|
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
invalidateRow();
|
2012-01-18 13:10:12 +01:00
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
if(isBeforeFirst() || isAfterLast())
|
2012-06-01 15:42:27 +02:00
|
|
|
return;
|
|
|
|
|
2012-01-18 13:10:12 +01:00
|
|
|
if ( m_aKeyIter->second.second.second.is() )
|
|
|
|
{
|
|
|
|
m_xRow = m_aKeyIter->second.second.second;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bOK = doTryRefetch_throw();
|
2009-11-27 10:17:16 +01:00
|
|
|
if ( !bOK )
|
2011-01-06 12:32:17 +01:00
|
|
|
{
|
2012-06-01 11:42:53 +02:00
|
|
|
// This row has disappeared; remove it.
|
2011-01-06 12:32:17 +01:00
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyIter;
|
2012-06-01 11:42:53 +02:00
|
|
|
// use *next* row
|
2011-01-06 12:32:17 +01:00
|
|
|
++m_aKeyIter;
|
|
|
|
m_aKeyMap.erase(aTemp);
|
2012-06-01 11:42:53 +02:00
|
|
|
|
|
|
|
// adjust RowCount for the row we have removed
|
|
|
|
if (m_rRowCount > 0)
|
|
|
|
--m_rRowCount;
|
|
|
|
else
|
2013-06-29 17:38:04 +03:00
|
|
|
SAL_WARN("dbaccess", "m_rRowCount got out of sync: non-empty m_aKeyMap, but m_rRowCount <= 0");
|
2012-06-01 11:42:53 +02:00
|
|
|
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if (m_aKeyIter == m_aKeyMap.end())
|
|
|
|
{
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
|
|
|
if (!isAfterLast())
|
|
|
|
{
|
|
|
|
// it was the last fetched row,
|
|
|
|
// but there may be another one to fetch
|
|
|
|
if (!fetchRow())
|
|
|
|
{
|
|
|
|
// nope, that really was the last
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
OSL_ENSURE(isAfterLast(), "fetchRow() failed but not isAfterLast()!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Now, either fetchRow has set m_xRow or isAfterLast()
|
|
|
|
}
|
|
|
|
else
|
2012-06-01 11:42:53 +02:00
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
refreshRow();
|
2012-06-01 11:42:53 +02:00
|
|
|
}
|
2011-01-06 12:32:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_xRow.set(m_xSet,UNO_QUERY);
|
2012-01-18 13:10:12 +01:00
|
|
|
OSL_ENSURE(m_xRow.is(),"No row from statement!");
|
2011-01-06 12:32:17 +01:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OKeySet::fetchRow()
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2001-06-22 12:07:17 +00:00
|
|
|
// fetch the next row and append on the keyset
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bRet = false;
|
2010-11-24 14:23:06 +01:00
|
|
|
if ( !m_bRowCountFinal && (!m_nMaxRows || sal_Int32(m_aKeyMap.size()) < m_nMaxRows) )
|
2006-07-10 14:02:45 +00:00
|
|
|
bRet = m_xDriverSet->next();
|
|
|
|
if ( bRet )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-08-15 09:41:07 +00:00
|
|
|
ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size() + m_pForeignColumnNames->size());
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
2012-12-05 18:09:57 +01:00
|
|
|
m_xRow.set(m_xDriverRow, UNO_QUERY_THROW);
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = aKeyRow->get().begin();
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
// copy key columns
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2009-04-23 10:42:05 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
|
|
|
const SelectColumnDescription& rColDesc = aPosIter->second;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
aIter->fill(rColDesc.nPosition, rColDesc.nType, m_xRow);
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
// copy missing columns from other tables
|
2006-08-15 09:41:07 +00:00
|
|
|
aPosIter = (*m_pForeignColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aPosEnd = (*m_pForeignColumnNames).end();
|
2009-04-23 10:42:05 +00:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-07-10 14:02:45 +00:00
|
|
|
const SelectColumnDescription& rColDesc = aPosIter->second;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
aIter->fill(rColDesc.nPosition, rColDesc.nType, m_xRow);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2012-10-25 21:02:50 +02:00
|
|
|
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL)))).first;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bRowCountFinal = true;
|
2001-01-24 08:52:19 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
bool OKeySet::fillAllRows()
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
if(m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
while(fetchRow())
|
|
|
|
;
|
i#102625 avoid fetching same row twice in different queries
We do a "SELECT * FROM table" just to fetch the primary key columns;
so reuse the same XResultSet to fetch all columns.
Else, we immediately issue a "SELECT * FROM table WHERE
primary_key=current_value" to read the other columns, which is
wasteful and particularly silly.
Commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b already tried
to do that, but was essentially reverted piecewise because
it caused fdo#47520, fdo#48345, fdo#50372.
Commit c08067d6da94743d53217cbc26cffae00a22dc3a thought it did that,
but actually reverted commit 1ae17f5b03cc14844fb600ca3573a96deb37ab3b.
This implementation fetches the whole current row and caches it in memory;
only one row is cached: when the current row changes, the cache contains
the new current row.
This could be problematic (wrt to memory consumption) if the current
row is big (e.g. with BLOBs) and nobody is interested in the data
anyway (as would often be the case with BLOBs). Note that because of
our "SELECT *", the driver most probably has it in memory already
anyway, so we don't make the situation that much worse.
This could be incrementally improved with a heuristic of not
preemptively caching binary data (and also not LONGVARCHAR / TEXT /
MEMO / ...); a getFOO on these columns would issue a specific "SELECT
column FROM table WHERE primary_key=current_value" each time.
The *real* complete fix to all these issues would be to not do "SELECT
*" at all. Use "SELECT pkey_col1, pkey_col2, ..." when we are only
interested in the key columns. As to data, somehow figure out which
columns were ar interested in and "SELECT" only these (and maybe only
those with "small datatype"?). Interesting columns could be determined
by our caller (creator) as an argument to our constructor, or some
heuristic (no binary data, no "big" unbound data).
Also be extra smart and use *(m_aKeyIter) when getFOO is called
on a column included in it (and don't include it in any subsequent
SELECT).
However, there are several pitfalls.
One is buggy drivers that give use column names of columns that we
cannot fetch :-| Using "SELECT *" works around that because the driver
there *obviously* gives us only fetchable columns in the result.
Another one is the very restrictive nature of some database access
technologies. Take for example ODBC:
- Data can be fetched only *once* (with the SQLGetData interface;
bound columns offer a way around that, but that's viable only for
constant-length data, not variable-length data).
This could be addressed by an intelligent & lazy cache.
- Data must be fetched in increasing order of column number
(again, this is about SQLGetData).
This is a harder issue. The current solution has the nice advantage
of completely isolating the rest of LibO from these restrictions.
I don't currently see how to cleanly avoid (potentially
unnecessarily) caching column 4 if we are asked for column 3 then
column 5, just in case we are asked for column 4 later on, unless
we issue a specific "SELECT column4" later. But the latter would be
quite expensive in terms of app-to-database roudtripe times :-( and
thus creates another performance issue.
Change-Id: I999b3f8f0b8a215acb390ffefc839235346e8353
2012-06-04 17:54:30 +02:00
|
|
|
return true;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
// XRow
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OKeySet::wasNull( ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
if ( ! m_xRow.is() )
|
2013-01-05 19:12:07 -02:00
|
|
|
throwGenericSQLException("Must call getFOO() for some FOO before wasNull()", *this);
|
2012-07-16 23:58:18 +02:00
|
|
|
|
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null! I've thrown, but function execution continued?");
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->wasNull();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-07-16 23:58:18 +02:00
|
|
|
inline void OKeySet::ensureRowForData( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
if (! m_xRow.is() )
|
|
|
|
refreshRow();
|
|
|
|
if (! m_xRow.is() )
|
|
|
|
throwSQLException("Failed to refetch row", "02000", *this, -2);
|
|
|
|
|
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null! I've called throwSQLException but execution continued?");
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OKeySet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getString(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL OKeySet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getBoolean(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int8 SAL_CALL OKeySet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getByte(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int16 SAL_CALL OKeySet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getShort(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL OKeySet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getInt(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int64 SAL_CALL OKeySet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getLong(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
float SAL_CALL OKeySet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getFloat(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
double SAL_CALL OKeySet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getDouble(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Sequence< sal_Int8 > SAL_CALL OKeySet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getBytes(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::util::Date SAL_CALL OKeySet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getDate(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::util::Time SAL_CALL OKeySet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getTime(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
::com::sun::star::util::DateTime SAL_CALL OKeySet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getTimestamp(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getBinaryStream(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getCharacterStream(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Any SAL_CALL OKeySet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getObject(columnIndex,typeMap);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< XRef > SAL_CALL OKeySet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getRef(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< XBlob > SAL_CALL OKeySet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getBlob(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< XClob > SAL_CALL OKeySet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getClob(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Reference< XArray > SAL_CALL OKeySet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2012-07-16 23:58:18 +02:00
|
|
|
ensureRowForData();
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->getArray(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::rowUpdated( ) throw(SQLException, RuntimeException)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2010-04-20 13:33:34 +02:00
|
|
|
return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2;
|
2001-06-22 12:07:17 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::rowInserted( ) throw(SQLException, RuntimeException)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2010-04-20 13:33:34 +02:00
|
|
|
return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1;
|
2001-06-22 12:07:17 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException)
|
2001-06-22 12:07:17 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bDeleted = m_bDeleted;
|
|
|
|
m_bDeleted = false;
|
2001-06-22 12:07:17 +00:00
|
|
|
return bDeleted;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
namespace dbaccess
|
|
|
|
{
|
2010-01-20 20:09:04 +00:00
|
|
|
|
|
|
|
void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns,
|
2013-01-05 19:12:07 -02:00
|
|
|
const ::com::sun::star::uno::Sequence< OUString >& _aColumnNames,
|
|
|
|
const OUString& _rsUpdateTableName,
|
2010-02-15 09:53:53 +01:00
|
|
|
SelectColumnsMetaData& o_rColumnNames,
|
|
|
|
bool i_bAppendTableName)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
|
|
|
// get the real name of the columns
|
2013-01-05 19:12:07 -02:00
|
|
|
Sequence< OUString> aSelNames(_rxQueryColumns->getElementNames());
|
|
|
|
const OUString* pSelIter = aSelNames.getConstArray();
|
|
|
|
const OUString* pSelEnd = pSelIter + aSelNames.getLength();
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-01-05 19:12:07 -02:00
|
|
|
const OUString* pTblColumnIter = _aColumnNames.getConstArray();
|
|
|
|
const OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength();
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2013-02-27 06:47:14 +01:00
|
|
|
::comphelper::UStringMixEqual bCase(o_rColumnNames.key_comp().isCaseSensitive());
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XPropertySet> xQueryColumnProp(_rxQueryColumns->getByName(*pSelIter),UNO_QUERY_THROW);
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sRealName,sTableName;
|
2010-02-15 09:53:53 +01:00
|
|
|
OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
|
|
|
|
OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
for(;pTblColumnIter != pTblColumnEnd;++pTblColumnIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
if(bCase(sRealName,*pTblColumnIter) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(*pTblColumnIter) == o_rColumnNames.end())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nType = 0;
|
2010-02-15 09:53:53 +01:00
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
|
2008-01-30 07:28:36 +00:00
|
|
|
sal_Int32 nScale = 0;
|
2010-02-15 09:53:53 +01:00
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale;
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sColumnDefault;
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault;
|
2005-03-18 09:04:30 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
|
|
|
|
OSL_VERIFY( xQueryColumnProp->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable );
|
2009-04-23 10:42:05 +00:00
|
|
|
|
2013-02-27 06:53:34 +01:00
|
|
|
SelectColumnDescription aColDesc( nPos, nType, nScale, nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
|
|
|
|
OUString sName;
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( i_bAppendTableName )
|
|
|
|
{
|
2013-02-27 06:53:34 +01:00
|
|
|
sName = sTableName + "." + sRealName;
|
2010-02-15 09:53:53 +01:00
|
|
|
aColDesc.sRealName = sRealName;
|
|
|
|
aColDesc.sTableName = sTableName;
|
|
|
|
}
|
|
|
|
else
|
2013-02-27 06:53:34 +01:00
|
|
|
{
|
|
|
|
sName = sRealName;
|
|
|
|
}
|
|
|
|
o_rColumnNames[sName] = aColDesc;
|
2009-04-23 10:42:05 +00:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-15 09:53:53 +01:00
|
|
|
pTblColumnIter = _aColumnNames.getConstArray();
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-01-20 14:49:00 +01:00
|
|
|
void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData)
|
|
|
|
{
|
|
|
|
ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]);
|
|
|
|
switch(i_aMetaData.nType)
|
|
|
|
{
|
|
|
|
case DataType::DECIMAL:
|
|
|
|
case DataType::NUMERIC:
|
|
|
|
{
|
2013-01-05 19:12:07 -02:00
|
|
|
OUString sValue = aValue.getString();
|
2010-01-20 14:49:00 +01:00
|
|
|
sal_Int32 nIndex = sValue.indexOf('.');
|
|
|
|
if ( nIndex != -1 )
|
|
|
|
{
|
2010-08-24 15:00:36 +02:00
|
|
|
aValue = sValue.copy(0,::std::min(sValue.getLength(),nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0)));
|
2010-01-20 14:49:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|