42#include <com/sun/star/sdbc/FetchDirection.hpp>
43#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
44#include <com/sun/star/sdbc/ResultSetType.hpp>
45#include <com/sun/star/sdbc/DataType.hpp>
46#include <com/sun/star/sdbc/SQLException.hpp>
52using com::sun::star::uno::Any;
54using com::sun::star::uno::XInterface;
56using com::sun::star::sdbc::SQLException;
57using com::sun::star::sdbc::XResultSetMetaData;
67 throw SQLException(
"pq_resultset: already closed",
68 *
this, OUString(), 1,
Any() );
73 throw SQLException(
"pq_resultset: statement has been closed already",
74 *
this, OUString(), 1,
Any() );
86 refMutex, owner, PQntuples(
result ),
87 PQnfields(
result ),(*ppSettings)->tc ),
89 m_schema(
std::move( schema )),
91 m_ppSettings( ppSettings )
133 MutexGuard guard(
m_xMutex->GetMutex() );
147 MutexGuard guard(
m_xMutex->GetMutex() );
155 MutexGuard guard(
m_xMutex->GetMutex() );
157 sal_Int32 res = PQfnumber(
m_result,
173static bool isNumber(
const char * data, sal_Int32 len )
179 for(
int i = 0 ;
i < len ;
i ++ )
181 if( ( data[
i] >=
'0' && data[
i] <=
'9' ) ||
182 data[
i] ==
'-' || data[
i] ==
'+' || data[
i] ==
'.' || data[
i] ==
',' )
184 if( data[
i] ==
'-' &&
i != 0 &&
i != len-1 )
201static bool isInteger(
const char * data, sal_Int32 len )
207 for(
int i = 0 ;
i < len ;
i ++ )
209 if( ( data[
i] >=
'0' && data[
i] <=
'9' ) ||
210 data[
i] ==
'-' || data[
i] ==
'+' )
212 if( data[
i] ==
'-' &&
i != 0 &&
i != len-1 )
229static bool isDate(
const char * data, sal_Int32 len )
239static bool isTime(
const char * data, sal_Int32 len )
252 return len == 19 &&
isDate( data, 10) &&
isTime( &(data[11]),8 );
258 sal_Int32 ret = css::sdbc::DataType::INTEGER;
260 int maxRows = std::min<sal_Int32>(
m_rowCount, 100 );
261 for(
int i = 0 ;
i < maxRows ;
i ++ )
263 if( ! PQgetisnull(
m_result,
i , column-1 ) )
265 const char *
p = PQgetvalue(
m_result,
i , column -1 );
266 int len = PQgetlength(
m_result,
i , column -1 );
268 if( css::sdbc::DataType::INTEGER == ret )
271 ret = css::sdbc::DataType::NUMERIC;
273 if( css::sdbc::DataType::NUMERIC == ret )
277 ret = css::sdbc::DataType::DATE;
280 if( css::sdbc::DataType::DATE == ret )
284 ret = css::sdbc::DataType::TIME;
287 if( css::sdbc::DataType::TIME == ret )
291 ret = css::sdbc::DataType::TIMESTAMP;
294 if( css::sdbc::DataType::TIMESTAMP == ret )
298 ret = css::sdbc::DataType::LONGVARCHAR;
css::uno::Reference< css::uno::XInterface > m_owner
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
css::uno::Any m_props[BASERESULTSET_SIZE]
virtual css::uno::Any getValue(sal_Int32 columnIndex) override
unchecked, acquire mutex before calling
ResultSet(const ::rtl::Reference< comphelper::RefCountedMutex > &mutex, const css::uno::Reference< css::uno::XInterface > &owner, ConnectionSettings **pSettings, PGresult *result, OUString schema, OUString table)
virtual ~ResultSet() override
virtual void SAL_CALL close() override
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
ConnectionSettings ** m_ppSettings
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
sal_Int32 guessDataType(sal_Int32 column)
virtual void checkClosed() override
mutex should be locked before called
const sal_Int32 BASERESULTSET_RESULT_SET_CONCURRENCY
const sal_Int32 BASERESULTSET_FETCH_DIRECTION
static bool isTimestamp(const char *data, sal_Int32 len)
const sal_Int32 BASERESULTSET_IS_BOOKMARKABLE
static bool isDate(const char *data, sal_Int32 len)
const sal_Int32 BASERESULTSET_RESULT_SET_TYPE
static bool isInteger(const char *data, sal_Int32 len)
static bool isNumber(const char *data, sal_Int32 len)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const sal_Int32 BASERESULTSET_ESCAPE_PROCESSING
static bool isTime(const char *data, sal_Int32 len)
static const rtl_TextEncoding encoding