Tag: oo_pqsdbc_01
User: jbu     
Date: 06/01/22 07:14:46

Modified:
 /dba/connectivity/source/drivers/postgresql/
  DataAccess.xcu, makefile.mk, pq_databasemetadata.cxx, 
pq_preparedstatement.cxx,
  pq_preparedstatement.hxx, pq_resultsetmetadata.cxx, pq_sequenceresultset.cxx,
  pq_sequenceresultset.hxx, pq_statement.cxx, pq_statement.hxx, pq_statics.cxx,
  pq_statics.hxx, pq_tools.cxx, pq_tools.hxx, pq_xcontainer.cxx, pq_xtable.cxx,
  pq_xuser.cxx, pq_xusers.cxx

Log:
 changes towards 0.7.0, fixed some bugs, that led to crashes in OOo2.0, now 
insertion support for no oid tables

File Changes:

Directory: /dba/connectivity/source/drivers/postgresql/
=======================================================

File [changed]: DataAccess.xcu
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/DataAccess.xcu?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +1 -1
-------------------
--- DataAccess.xcu      9 May 2004 19:47:12 -0000       1.1.2.2
+++ DataAccess.xcu      22 Jan 2006 15:14:25 -0000      1.1.2.3
@@ -3,7 +3,7 @@
  <node oor:name="UserDefinedDriverSettings">
        <node oor:name="Postgresql Driver" oor:op="replace">
             <prop oor:name="DriverPageDisplayName">
-                  <value>Postgresql-SDBC Driver V 0.6</value>
+                  <value>Postgresql-SDBC Driver V 0.7.0</value>
             </prop>
             <prop oor:name="DriverTypeDisplayName">
                   <value>postgresql</value>

File [changed]: makefile.mk
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/makefile.mk?r1=1.1.2.6&r2=1.1.2.7
Delta lines:  +6 -5
-------------------
--- makefile.mk 29 Aug 2004 08:33:27 -0000      1.1.2.6
+++ makefile.mk 22 Jan 2006 15:14:26 -0000      1.1.2.7
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: makefile.mk,v $
 #
-#   $Revision: 1.1.2.6 $
+#   $Revision: 1.1.2.7 $
 #
-#   last change: $Author: jbu $ $Date: 2004/08/29 08:33:27 $
+#   last change: $Author: jbu $ $Date: 2006/01/22 15:14:26 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -78,8 +78,8 @@
 DLLPRE= 
 
 PQ_SDBC_MAJOR=0
-PQ_SDBC_MINOR=6
-PQ_SDBC_MICRO=2
+PQ_SDBC_MINOR=7
+PQ_SDBC_MICRO=0
 
 CFLAGS+=-I$(SOLARINCDIR)$/postgresql \
        -DPOSTGRESQL_MAJOR=$(POSTGRESQL_MAJOR) \
@@ -143,7 +143,8 @@
                $(SLO)$/pq_xindexcolumns.obj \
                $(SLO)$/pq_updateableresultset.obj \
                $(SLO)$/pq_fakedupdateableresultset.obj \
-               $(SLO)$/pq_array.obj
+               $(SLO)$/pq_array.obj    \
+               $(SLO)$/pq_sequenceresultsetmetadata.obj
 
 
 SHL2STDLIBS= \

File [changed]: pq_databasemetadata.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx?r1=1.1.2.7&r2=1.1.2.8
Delta lines:  +4 -3
-------------------
--- pq_databasemetadata.cxx     29 Aug 2004 08:33:28 -0000      1.1.2.7
+++ pq_databasemetadata.cxx     22 Jan 2006 15:14:27 -0000      1.1.2.8
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_databasemetadata.cxx,v $
  *
- *  $Revision: 1.1.2.7 $
+ *  $Revision: 1.1.2.8 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:28 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:27 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -1783,7 +1783,8 @@
         *this,
         getStatics().typeinfoColumnNames,
         Sequence< Sequence< Any > > ( &vec[0] , vec.size() ),
-        m_pSettings->tc );
+        m_pSettings->tc,
+        &( getStatics().typeInfoMetaData ));
 }
 
 

File [changed]: pq_preparedstatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx?r1=1.1.2.6&r2=1.1.2.7
Delta lines:  +14 -14
---------------------
--- pq_preparedstatement.cxx    29 Aug 2004 08:33:28 -0000      1.1.2.6
+++ pq_preparedstatement.cxx    22 Jan 2006 15:14:28 -0000      1.1.2.7
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_preparedstatement.cxx,v $
  *
- *  $Revision: 1.1.2.6 $
+ *  $Revision: 1.1.2.7 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:28 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:28 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -270,6 +270,7 @@
         ret = ::cppu::queryInterface( reqType,
                                     static_cast< XWarningsSupplier * > ( this  
),
                                     static_cast< XPreparedStatement * > ( this 
),
+                                    static_cast< 
com::sun::star::sdbc::XResultSetMetaDataSupplier * > ( this ),
                                     static_cast< XParameters * > ( this ),
                                     static_cast< XCloseable * > ( this ),
                                     static_cast< XGeneratedResultSet * > ( 
this ),
@@ -291,6 +292,7 @@
             static cppu::OTypeCollection collection(
                 getCppuType( (Reference< XWarningsSupplier> *) 0 ),
                 getCppuType( (Reference< XPreparedStatement> *) 0 ),
+                getCppuType( (Reference< 
com::sun::star::sdbc::XResultSetMetaDataSupplier> *) 0 ),
                 getCppuType( (Reference< XParameters> *) 0 ),
                 getCppuType( (Reference< XCloseable> *) 0 ),
                 getCppuType( (Reference< XGeneratedResultSet> *) 0 ),
@@ -444,6 +446,7 @@
     data.refMutex = m_refMutex;
     data.ppSettings = &m_pSettings;
     data.pLastOidInserted = &m_lastOidInserted;
+    data.pLastQuery = &m_lastQuery;
     data.pMultipleResultUpdateCount = &m_multipleResultUpdateCount;
     data.pMultipleResultAvailable = &m_multipleResultAvailable;
     data.pLastTableInserted = &m_lastTableInserted;
@@ -731,6 +734,12 @@
 {
 }
 
+Reference< ::com::sun::star::sdbc::XResultSetMetaData > 
PreparedStatement::getMetaData()
+            throw (SQLException,RuntimeException)
+{
+    return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ( 
m_lastResultset, UNO_QUERY );
+}
+
 ::cppu::IPropertyArrayHelper & PreparedStatement::getInfoHelper()
 {
     return getPreparedStatementPropertyArrayHelper(); 
@@ -827,18 +836,9 @@
 Reference< XResultSet > PreparedStatement::getGeneratedValues(  )
         throw (SQLException, RuntimeException)
 {
-    Reference< XResultSet > ret;
-    if( m_lastOidInserted && m_lastTableInserted.getLength() )
-    {
-        OUStringBuffer buf( 128 );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
-        buf.append( m_lastTableInserted );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE oid = " ) );
-        buf.append( m_lastOidInserted , 10 );
-        Reference< com::sun::star::sdbc::XStatement > stmt = 
getConnection()->createStatement();
-        ret = stmt->executeQuery( buf.makeStringAndClear() );
-    }
-    return ret;
+    osl::MutexGuard guard( m_refMutex->mutex );
+    return getGeneratedValuesFromLastInsert(
+        m_pSettings, m_connection, m_lastOidInserted, m_lastTableInserted, 
m_lastQuery );
 }
 
 

File [changed]: pq_preparedstatement.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_preparedstatement.hxx?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +11 -3
--------------------
--- pq_preparedstatement.hxx    11 Jul 2004 10:03:07 -0000      1.1.2.4
+++ pq_preparedstatement.hxx    22 Jan 2006 15:14:29 -0000      1.1.2.5
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_preparedstatement.hxx,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: jbu $ $Date: 2004/07/11 10:03:07 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:29 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -71,6 +71,7 @@
 #include <com/sun/star/sdbc/XParameters.hpp>
 #include <com/sun/star/sdbc/XMultipleResults.hpp>
 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
 
 #include "pq_connection.hxx"
 namespace rtl { class OString; } 
@@ -97,7 +98,8 @@
                           public com::sun::star::sdbc::XCloseable,
                           public com::sun::star::sdbc::XWarningsSupplier,
                           public com::sun::star::sdbc::XMultipleResults,
-                          public com::sun::star::sdbc::XGeneratedResultSet
+                          public com::sun::star::sdbc::XGeneratedResultSet,
+                          public 
com::sun::star::sdbc::XResultSetMetaDataSupplier
 {
 private:
     com::sun::star::uno::Any m_props[PREPARED_STATEMENT_SIZE];
@@ -113,6 +115,7 @@
     sal_Int32 m_multipleResultUpdateCount;
     sal_Int32 m_lastOidInserted;
     rtl::OUString m_lastTableInserted;
+    rtl::OString m_lastQuery;
     
 public:
     /**
@@ -259,6 +262,11 @@
     virtual sal_Int32 SAL_CALL getUpdateCount(  )
         throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getMoreResults(  )
+        throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
+
+public: // XResultSetMetaDataSupplier (is required by framework (see
+        // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
         throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
 
 public: // OComponentHelper

File [changed]: pq_resultsetmetadata.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +2 -3
-------------------
--- pq_resultsetmetadata.cxx    29 Aug 2004 16:35:16 -0000      1.1.2.4
+++ pq_resultsetmetadata.cxx    22 Jan 2006 15:14:30 -0000      1.1.2.5
@@ -2,9 +2,9 @@
  *

  *  $RCSfile: pq_resultsetmetadata.cxx,v $

  *

- *  $Revision: 1.1.2.4 $

+ *  $Revision: 1.1.2.5 $

  *

- *  last change: $Author: jbu $ $Date: 2004/08/29 16:35:16 $

+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:30 $

  *

  *  The Contents of this file are made available subject to the terms of

  *  either of the following licenses

@@ -138,7 +138,6 @@
         }

     }

 }

-

 

 ResultSetMetaData::ResultSetMetaData(

     const ::rtl::Reference< RefCountedMutex > & refMutex,


File [changed]: pq_sequenceresultset.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +17 -7
--------------------
--- pq_sequenceresultset.cxx    9 May 2004 19:47:15 -0000       1.1.2.2
+++ pq_sequenceresultset.cxx    22 Jan 2006 15:14:31 -0000      1.1.2.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_sequenceresultset.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: jbu $ $Date: 2004/05/09 19:47:15 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:31 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -60,6 +60,7 @@
  ************************************************************************/
 
 #include "pq_sequenceresultset.hxx"
+#include "pq_sequenceresultsetmetadata.hxx"
 
 
 using rtl::OUString;
@@ -93,11 +94,16 @@
     const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 
&owner,
     const Sequence< OUString > &colNames,
     const Sequence< Sequence< Any > > &data,
-    const Reference< com::sun::star::script::XTypeConverter > & tc) :
+    const Reference< com::sun::star::script::XTypeConverter > & tc,
+    const ColumnMetaDataVector *pVec) :
     BaseResultSet( mutex, owner, data.getLength(), colNames.getLength(),tc ),
     m_data(data ),
     m_columnNames( colNames )
 {
+    if( pVec )
+    {
+        m_meta = new SequenceResultSetMetaData( mutex, *pVec, 
m_columnNames.getLength() );
+    }
 }
 
 SequenceResultSet::~SequenceResultSet()
@@ -114,10 +120,14 @@
 Reference< XResultSetMetaData > SAL_CALL SequenceResultSet::getMetaData(  )
     throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException)
 {
+    if( ! m_meta.is() )
+    {
     // Oh no, not again
     throw ::com::sun::star::sdbc::SQLException(
         ASCII_STR( "pq_sequenceresultset: no meta supported " ), *this,
         OUString(), 1, Any() );
+    }
+    return m_meta;
 }
 
 

File [changed]: pq_sequenceresultset.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +6 -3
-------------------
--- pq_sequenceresultset.hxx    9 May 2004 19:47:16 -0000       1.1.2.2
+++ pq_sequenceresultset.hxx    22 Jan 2006 15:14:32 -0000      1.1.2.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_sequenceresultset.hxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: jbu $ $Date: 2004/05/09 19:47:16 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:32 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -70,6 +70,7 @@
 #include <com/sun/star/sdbc/XColumnLocate.hpp>
 #include "pq_connection.hxx"
 #include "pq_baseresultset.hxx"
+#include "pq_statics.hxx"
 
 namespace pq_sdbc_driver
 {
@@ -90,6 +91,7 @@
     ::com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< 
::com::sun::star::uno::Any > > m_data;
 
     ::com::sun::star::uno::Sequence< ::rtl::OUString > m_columnNames;
+    ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData 
> m_meta;
 
 protected:
     /** mutex should be locked before called
@@ -107,7 +109,8 @@
         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface 
> &owner,
         const com::sun::star::uno::Sequence< rtl::OUString > &colNames,
         const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< 
com::sun::star::uno::Any > > &data,
-        const com::sun::star::uno::Reference< 
com::sun::star::script::XTypeConverter > &tc);
+        const com::sun::star::uno::Reference< 
com::sun::star::script::XTypeConverter > &tc,
+        const ColumnMetaDataVector *pVec = 0);
     ~SequenceResultSet();
     
 public: // XCloseable

File [changed]: pq_statement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_statement.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +218 -19
----------------------
--- pq_statement.cxx    9 May 2004 19:47:16 -0000       1.1.2.2
+++ pq_statement.cxx    22 Jan 2006 15:14:33 -0000      1.1.2.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_statement.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: jbu $ $Date: 2004/05/09 19:47:16 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:33 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -77,6 +77,7 @@
 
 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
 #include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
 
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
 #include <com/sun/star/sdbcx/KeyType.hpp>
@@ -110,6 +111,9 @@
 using com::sun::star::sdbc::XWarningsSupplier;
 using com::sun::star::sdbc::XCloseable;
 using com::sun::star::sdbc::XStatement;
+using com::sun::star::sdbc::XPreparedStatement;
+using com::sun::star::sdbc::XParameters;
+using com::sun::star::sdbc::XRow;
 using com::sun::star::sdbc::XResultSet;
 using com::sun::star::sdbc::XGeneratedResultSet;
 using com::sun::star::sdbc::XConnection;
@@ -219,6 +223,7 @@
         ret = ::cppu::queryInterface( reqType,
                                     static_cast< XWarningsSupplier * > ( this  
),
                                     static_cast< XStatement * > ( this ),
+                                    static_cast< 
com::sun::star::sdbc::XResultSetMetaDataSupplier * > ( this ),
                                     static_cast< XCloseable * > ( this ),
                                     static_cast< XPropertySet * > ( this ),
                                     static_cast< XMultiPropertySet * > ( this 
),
@@ -239,6 +244,7 @@
             static cppu::OTypeCollection collection(
                 getCppuType( (Reference< XWarningsSupplier> *) 0 ),
                 getCppuType( (Reference< XStatement> *) 0 ),
+                getCppuType( (Reference< 
com::sun::star::sdbc::XResultSetMetaDataSupplier> *) 0 ),
                 getCppuType( (Reference< XCloseable> *) 0 ),
                 getCppuType( (Reference< XPropertySet >*) 0 ),
                 getCppuType( (Reference< XFastPropertySet > *) 0 ),
@@ -496,6 +502,7 @@
     ExecStatusType state = PQresultStatus( result );
     *(data->pLastOidInserted) = 0;
     *(data->pLastTableInserted) = rtl::OUString();
+    *(data->pLastQuery) = cmd;
 
     sal_Bool ret = sal_False;
     switch( state )
@@ -504,13 +511,14 @@
     {
         *(data->pMultipleResultUpdateCount) = atoi( PQcmdTuples( result ) );
         *(data->pMultipleResultAvailable) = sal_False;
+
+        // in case an oid value is available, we retrieve it
         *(data->pLastOidInserted) = PQoidValue( result );
-        if( *(data->pLastOidInserted) )
-        {
-            // it was a single insert !
+        
+        // in case it was a single insert, extract the name of the table,
+        // otherwise the table name is empty
             *(data->pLastTableInserted) =
                 extractTableFromInsert( OStringToOUString( cmd, 
pSettings->encoding ) );
-        }
         if( isLog( pSettings, LogLevel::SQL ) )
         {
             rtl::OStringBuffer buf( 128 );
@@ -690,6 +698,197 @@
 
 }
 
+static Sequence< OUString > getPrimaryKeyColumnNames(
+    const Reference< XConnection > & connection, const OUString &schemaName, 
const OUString &tableName )
+{
+    Sequence< OUString > ret; 
+
+    Int2StringMap mapIndex2Name;
+    fillAttnum2attnameMap( mapIndex2Name, connection, schemaName, tableName );
+
+    // retrieve the primary key ...
+    Reference< XPreparedStatement > stmt = connection->prepareStatement(
+        ASCII_STR(
+            "SELECT conkey "              // 7
+            "FROM pg_constraint INNER JOIN pg_class ON conrelid = pg_class.oid 
"
+                      "INNER JOIN pg_namespace ON pg_class.relnamespace = 
pg_namespace.oid "
+                      "LEFT JOIN pg_class AS class2 ON confrelid = class2.oid "
+                      "LEFT JOIN pg_namespace AS nmsp2 ON 
class2.relnamespace=nmsp2.oid "
+            "WHERE pg_class.relname = ? AND pg_namespace.nspname = ? AND 
pg_constraint.contype='p'" ) );
+    DisposeGuard guard( stmt );
+    Reference< XParameters > paras( stmt, UNO_QUERY );
+    paras->setString( 1 , tableName );
+    paras->setString( 2 , schemaName );
+    Reference< XResultSet > rs = stmt->executeQuery();
+    Reference< XRow > xRow( rs , UNO_QUERY );
+
+    if( rs->next() )
+    {
+        ret = convertMappedIntArray2StringArray( mapIndex2Name, 
string2intarray(xRow->getString( 1 ) ) );
+    }
+    return ret;
+}
+
+static void getAutoValues(
+    String2StringMap & result,
+    const Reference< XConnection > & connection,
+    const OUString &schemaName,
+    const OUString & tableName )
+{
+    Reference< XPreparedStatement > stmt = connection->prepareStatement(
+        ASCII_STR("SELECT   pg_attribute.attname, pg_attrdef.adsrc "
+                  "FROM pg_class, pg_namespace, pg_attribute "
+                  "LEFT JOIN pg_attrdef ON pg_attribute.attrelid = 
pg_attrdef.adrelid AND "
+                                        "pg_attribute.attnum = 
pg_attrdef.adnum "
+                  "WHERE pg_attribute.attrelid = pg_class.oid AND "
+                        "pg_class.relnamespace = pg_namespace.oid AND "
+                        "pg_namespace.nspname = ? AND "
+                        "pg_class.relname LIKE ? AND "
+                        "pg_attrdef.adsrc != ''"
+            ) );
+    DisposeGuard guard( stmt );
+    Reference< XParameters > paras( stmt, UNO_QUERY );
+    paras->setString( 1 , schemaName );
+    paras->setString( 2 , tableName );
+    Reference< XResultSet > rs = stmt->executeQuery();
+    Reference< XRow > xRow( rs , UNO_QUERY );
+
+    while( rs->next() )
+    {
+        result[ OUStringToOString( xRow->getString( 1 ), 
RTL_TEXTENCODING_ASCII_US) ] =
+            OUStringToOString( xRow->getString(2), RTL_TEXTENCODING_ASCII_US );
+    }
+}
+
+Reference< XResultSet > getGeneratedValuesFromLastInsert(
+    ConnectionSettings *pConnectionSettings,
+    const Reference< XConnection > &connection,
+    sal_Int32 nLastOid,
+    const rtl::OUString & lastTableInserted,
+    const rtl::OString & lastQuery )
+{
+    Reference< XResultSet > ret;
+    OUString query;
+    if( nLastOid && lastTableInserted.getLength() )
+    {
+        OUStringBuffer buf( 128 );
+        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
+        buf.append( lastTableInserted );
+        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE oid = " ) );
+        buf.append( nLastOid , 10 );
+        query = buf.makeStringAndClear();
+    }
+    else if ( lastTableInserted.getLength() && lastQuery.getLength() )
+    {
+        // extract nameValue Pairs
+        String2StringMap namedValues;
+        extractNameValuePairsFromInsert( namedValues, lastQuery );
+
+        // debug ...
+//         rtl::OStringBuffer buf( 128);
+//         buf.append( "extracting name/value from '" );
+//         buf.append( lastQuery.getStr() );
+//         buf.append( "' to [" );
+//         for( String2StringMap::iterator ii = namedValues.begin() ; ii != 
namedValues.end() ; ++ii )
+//         {
+//             buf.append( ii->first.getStr() );
+//             buf.append( "=" );
+//             buf.append( ii->second.getStr() );
+//             buf.append( "," );
+//         }
+//         buf.append( "]\n" );
+//         printf( buf.makeStringAndClear() );
+
+        // TODO: make also unqualified tables names work here. Have a look at 
2.8.3. The Schema Search Path
+        //       in postgresql doc
+        OUString schemaName, tableName;
+        splitConcatenatedIdentifier(
+            lastTableInserted, &schemaName, &tableName );
+        
+        Sequence< OUString > keyColumnNames = getPrimaryKeyColumnNames( 
connection, schemaName, tableName );
+        if( keyColumnNames.getLength() )
+        {
+            OUStringBuffer buf( 128 );
+            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
+            buf.append( lastTableInserted );
+            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE " ) );
+            bool additionalCondition = false;
+            String2StringMap autoValues;
+            for( int i = 0 ; i < keyColumnNames.getLength() ; i ++ )
+            {
+                OUString value;
+                OString columnName = OUStringToOString( keyColumnNames[i], 
pConnectionSettings->encoding );
+                String2StringMap::iterator ii = namedValues.begin();
+                for( ; ii != namedValues.end() ; ++ii )
+                {
+                    if( columnName.equalsIgnoreAsciiCase( ii->first ) )
+                    {
+                        value = OStringToOUString( ii->second , 
pConnectionSettings->encoding );
+                        break;
+                    }
+                }
+                
+                // check, if a column of the primary key was not inserted 
explicitly,
+                if( ii == namedValues.end() )
+                {
+                    
+                    if( autoValues.begin() == autoValues.end() )
+                    {
+                        getAutoValues( autoValues, connection, schemaName, 
tableName );
+                    }
+                    // this could mean, that the column is a default or auto 
value, check this ...
+                    String2StringMap::iterator ii = autoValues.begin();
+                    for( ; ii != autoValues.end() ; ++ii )
+                    {
+                        if( columnName.equalsIgnoreAsciiCase( ii->first ) )
+                        {
+                            // it is indeed an auto value.
+                            value = OStringToOUString(ii->second, 
RTL_TEXTENCODING_ASCII_US );
+                            // check, whether it is a sequence
+                            
+                            if( rtl_str_shortenedCompare_WithLength(
+                                    ii->second.getStr(), 
ii->second.getLength(),
+                                    RTL_CONSTASCII_STRINGPARAM( "nextval(" ), 
8 ) == 0 )
+                            {
+                                // retrieve current sequence value:
+                                OUStringBuffer myBuf(128 );
+                                myBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( 
"SELECT currval(" ) );
+                                myBuf.appendAscii( &(ii->second.getStr()[8]));
+                                value = querySingleValue( connection, 
myBuf.makeStringAndClear() );
+                            }
+                            break;
+                        }
+                    }
+                    if( ii == autoValues.end() )
+                    {
+                        // it even was no autovalue, no sense to continue as 
we can't query the
+                        // inserted row
+                        buf = OUStringBuffer();
+                        break;
+                    }
+                }
+                
+                if( additionalCondition )
+                    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AND " ) );
+                buf.append( keyColumnNames[i] );
+                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
+                buf.append( value );
+                additionalCondition = true;
+            }
+            query = buf.makeStringAndClear();
+        }
+    }
+
+    if( query.getLength() )
+    {
+        Reference< com::sun::star::sdbc::XStatement > stmt = 
connection->createStatement();
+        ret = stmt->executeQuery( query );
+    }
+
+    return ret;
+
+}
+
 sal_Bool Statement::execute( const OUString& sql )
         throw (SQLException, RuntimeException)
 {
@@ -704,6 +903,7 @@
     data.refMutex = m_refMutex;
     data.ppSettings = &m_pSettings;
     data.pLastOidInserted = &m_lastOidInserted;
+    data.pLastQuery = &m_lastQuery;
     data.pMultipleResultUpdateCount = &m_multipleResultUpdateCount;
     data.pMultipleResultAvailable = &m_multipleResultAvailable;
     data.pLastTableInserted = &m_lastTableInserted;
@@ -739,6 +939,13 @@
 {
 }
 
+Reference< ::com::sun::star::sdbc::XResultSetMetaData > 
Statement::getMetaData()
+            throw (SQLException,RuntimeException)
+{
+    return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ( 
m_lastResultset, UNO_QUERY );
+}
+
+
 ::cppu::IPropertyArrayHelper & Statement::getInfoHelper()
 {
     return getStatementPropertyArrayHelper(); 
@@ -839,17 +1046,9 @@
 Reference< XResultSet > Statement::getGeneratedValues(  )
         throw (SQLException, RuntimeException)
 {
-    Reference< XResultSet > ret;
-    if( m_lastOidInserted && m_lastTableInserted.getLength() )
-    {
-        OUStringBuffer buf( 128 );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT * FROM " ) );
-        buf.append( m_lastTableInserted );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE oid = " ) );
-        buf.append( m_lastOidInserted , 10 );
-        ret = executeQuery( buf.makeStringAndClear() );
-    }
-    return ret;
+    osl::MutexGuard guard( m_refMutex->mutex );
+    return getGeneratedValuesFromLastInsert(
+        m_pSettings, m_connection, m_lastOidInserted, m_lastTableInserted, 
m_lastQuery );
 }
 
 }

File [changed]: pq_statement.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_statement.hxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +19 -3
--------------------
--- pq_statement.hxx    9 May 2004 19:47:16 -0000       1.1.2.2
+++ pq_statement.hxx    22 Jan 2006 15:14:34 -0000      1.1.2.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_statement.hxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: jbu $ $Date: 2004/05/09 19:47:16 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:34 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -68,6 +68,7 @@
 #include "pq_connection.hxx"
 #include <com/sun/star/sdbc/XMultipleResults.hpp>
 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
 
 namespace pq_sdbc_driver
 {
@@ -91,7 +92,8 @@
                   public com::sun::star::sdbc::XCloseable,
                   public com::sun::star::sdbc::XWarningsSupplier,
                   public com::sun::star::sdbc::XMultipleResults,
-                  public com::sun::star::sdbc::XGeneratedResultSet
+                  public com::sun::star::sdbc::XGeneratedResultSet,
+                  public com::sun::star::sdbc::XResultSetMetaDataSupplier
 {
 private:
     com::sun::star::uno::Any m_props[STATEMENT_SIZE];
@@ -103,6 +105,7 @@
     sal_Int32 m_multipleResultUpdateCount;
     sal_Int32 m_lastOidInserted;
     rtl::OUString m_lastTableInserted;
+    rtl::OString m_lastQuery;
     
 public:
     /**
@@ -186,6 +189,11 @@
 public: // OComponentHelper
     virtual void SAL_CALL disposing();
     
+public: // XResultSetMetaDataSupplier (is required by framework (see
+        // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
+    virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
+        throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
+    
 private:
     void checkClosed() throw (com::sun::star::sdbc::SQLException, 
com::sun::star::uno::RuntimeException);
     void raiseSQLException( const ::rtl::OUString & sql, const char * 
errorMsg, const char *errorType = 0 )
@@ -201,6 +209,7 @@
     sal_Bool *pMultipleResultAvailable;
     ::rtl::OUString *pLastTableInserted;
     ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > 
*pLastResultset;
+    ::rtl::OString *pLastQuery;
     ::rtl::Reference< RefCountedMutex > refMutex;
     ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > owner;
     ::com::sun::star::uno::Reference< com::sun::star::sdbcx::XTablesSupplier > 
tableSupplier;
@@ -208,6 +217,13 @@
 };
 
 bool executePostgresCommand( const rtl::OString & cmd, struct CommandData 
*data );
+com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > 
getGeneratedValuesFromLastInsert(
+    ConnectionSettings *pConnectionSettings,
+    const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > 
&connection,
+    sal_Int32 nLastOid,
+    const rtl::OUString & lastTableInserted,
+    const rtl::OString & lastQuery );
+
 
 }
 #endif

File [changed]: pq_statics.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_statics.cxx?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +60 -2
--------------------
--- pq_statics.cxx      29 Aug 2004 08:33:29 -0000      1.1.2.4
+++ pq_statics.cxx      22 Jan 2006 15:14:35 -0000      1.1.2.5
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_statics.cxx,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:29 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:35 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -76,6 +76,22 @@
 namespace pq_sdbc_driver
 {
 
+struct DefColumnMetaData
+{
+    sal_Char * columnName;
+    sal_Char * tableName;
+    sal_Char * schemaTableName;
+    sal_Char * typeName;
+    sal_Int32 type;
+    sal_Int32 precision;
+    sal_Int32 scale;
+    sal_Bool isCurrency;
+    sal_Bool isNullable;
+    sal_Bool isAutoIncrement;
+    sal_Bool isReadOnly;
+    sal_Bool isSigned;
+};
+
 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 struct BaseTypeDef { const char * typeName; sal_Int32 value; };
 
@@ -689,6 +705,48 @@
                     OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
                            baseTypeDefs[i].value;
             }
+
+            DefColumnMetaData defTypeInfoMetaData[] =
+                {
+                    { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 },  // 0
+                    { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 1
+                    { "PRECISION", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 2
+                    { "foo1", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 3
+                    { "foo2", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 4
+                    { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 },  // 5
+                    { "NULLABLE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 6
+                    { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 },  // 7
+                    { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0 },  // 8
+                    { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 },  // 9
+                    { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 },  // 10
+                    { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 },  // 11
+                    { "foo3", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 12
+                    { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 13
+                    { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 14
+                    { "foo4", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 15
+                    { "foo5", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 16
+                    { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", 
com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 },  // 17
+                    {0,0,0,0,0,0,0,0,0,0,0}
+                };
+            
+            for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
+            {
+                statics.typeInfoMetaData.push_back(
+                    ColumnMetaData(
+                        rtl::OUString::createFromAscii( 
defTypeInfoMetaData[i].columnName ),
+                        rtl::OUString::createFromAscii( 
defTypeInfoMetaData[i].tableName ),
+                        rtl::OUString::createFromAscii( 
defTypeInfoMetaData[i].schemaTableName ),
+                        rtl::OUString::createFromAscii( 
defTypeInfoMetaData[i].typeName ),
+                        defTypeInfoMetaData[i].type,
+                        defTypeInfoMetaData[i].precision,
+                        defTypeInfoMetaData[i].scale,
+                        defTypeInfoMetaData[i].isCurrency,
+                        defTypeInfoMetaData[i].isNullable,
+                        defTypeInfoMetaData[i].isAutoIncrement,
+                        defTypeInfoMetaData[i].isReadOnly,
+                        defTypeInfoMetaData[i].isSigned ) );
+            }
+            
             p = &statics;
         }
     }

File [changed]: pq_statics.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_statics.hxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +48 -2
--------------------
--- pq_statics.hxx      29 Aug 2004 08:33:29 -0000      1.1.2.3
+++ pq_statics.hxx      22 Jan 2006 15:14:36 -0000      1.1.2.4
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_statics.hxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:29 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:36 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -68,6 +68,7 @@
 
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
 
 #include <cppuhelper/propshlp.hxx>
 
@@ -76,6 +77,50 @@
 namespace pq_sdbc_driver
 {
 
+struct ColumnMetaData
+{
+    ColumnMetaData(
+        const rtl::OUString &_columnName,  
+        const rtl::OUString &_tableName,  
+        const rtl::OUString &_schemaTableName,  
+        const rtl::OUString &_typeName,
+        sal_Int32 _type,
+        sal_Int32 _precision,
+        sal_Int32 _scale,
+        sal_Bool _isCurrency,
+        sal_Bool _isNullable,
+        sal_Bool _isAutoIncrement,
+        sal_Bool _isReadOnly,
+        sal_Bool _isSigned ) :
+        columnName( _columnName ),
+        tableName( _tableName ),
+        schemaTableName( _schemaTableName ),
+        typeName( _typeName ),
+        type( _type ),
+        precision( _precision ),
+        scale( _scale ),
+        isCurrency( _isCurrency ),
+        isNullable( _isNullable ),
+        isAutoIncrement( _isAutoIncrement ),
+        isReadOnly( _isReadOnly ),
+        isSigned( _isSigned )
+    {}
+
+    rtl::OUString columnName;
+    rtl::OUString tableName;
+    rtl::OUString schemaTableName;
+    rtl::OUString typeName;
+    sal_Int32 type;
+    sal_Int32 precision;
+    sal_Int32 scale;
+    sal_Bool isCurrency;
+    sal_Bool isNullable;
+    sal_Bool isAutoIncrement;
+    sal_Bool isReadOnly;
+    sal_Bool isSigned;
+};
+
+typedef std::vector< ColumnMetaData, Allocator< ColumnMetaData > > 
ColumnMetaDataVector;
 
 struct TypeDetails
 {
@@ -237,6 +282,7 @@
     com::sun::star::uno::Sequence< ::rtl::OUString > resultSetArrayColumnNames;
     com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< 
com::sun::star::uno::Any > > tableTypeData;
     
+    ColumnMetaDataVector typeInfoMetaData;
     BaseTypeMap baseTypeMap;
     Statics(){}
 private:

File [changed]: pq_tools.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_tools.cxx?r1=1.1.2.5&r2=1.1.2.6
Delta lines:  +87 -0
--------------------
--- pq_tools.cxx        29 Aug 2004 08:33:29 -0000      1.1.2.5
+++ pq_tools.cxx        22 Jan 2006 15:14:37 -0000      1.1.2.6
@@ -1045,4 +1045,91 @@
 
 }
 
+static bool equalsIgnoreCase( const rtl::OString & str, const char *str2, int 
length2 )
+{
+    return 0 == rtl_str_compareIgnoreAsciiCase_WithLength(
+        str.pData->buffer, str.pData->length, str2, length2 );
+}
+
+void extractNameValuePairsFromInsert( String2StringMap & map, const 
rtl::OString & lastQuery )
+{
+    OStringVector vec;
+    tokenizeSQL( lastQuery, vec  );
+
+    int nSize = vec.size();
+//     printf( "1 %d\n", nSize );
+    if( nSize > 6  &&
+        equalsIgnoreCase( vec[0] , RTL_CONSTASCII_STRINGPARAM( "insert" ) ) &&
+        equalsIgnoreCase( vec[1] , RTL_CONSTASCII_STRINGPARAM( "into" ) ) )
+    {
+        int n = 2;
+
+//         printf( "1a\n" );
+        // extract table name
+        rtl::OString tableName;
+        if( equalsIgnoreCase( vec[n+1], RTL_CONSTASCII_STRINGPARAM( "." ) ) )
+        {
+            tableName = vec[n];
+            tableName += vec[n+1];
+            tableName += vec[n+2];
+            n +=2;
+        }
+        else
+        {
+            tableName = vec[n];
+        }
+
+        OStringVector names;
+        n ++;
+        if( equalsIgnoreCase( vec[n], RTL_CONSTASCII_STRINGPARAM( "(" ) ) )
+        {
+//             printf( "2\n" );
+            // extract names 
+            n++;
+            while( nSize > n && ! equalsIgnoreCase(vec[n] , 
RTL_CONSTASCII_STRINGPARAM( ")" ) ) )
+            {
+                names.push_back( vec[n] );
+                if( nSize > n+1 && equalsIgnoreCase( vec[n+1] , 
RTL_CONSTASCII_STRINGPARAM( "," ) ) )
+                {
+                    n ++;
+                }
+                n++;
+            }
+            n++;
+
+            // now read the values
+            if( nSize > n +1 && equalsIgnoreCase( vec[n], 
RTL_CONSTASCII_STRINGPARAM("VALUES") ) &&
+                equalsIgnoreCase(vec[n+1], RTL_CONSTASCII_STRINGPARAM( "(" ) ) 
)
+            {
+                n +=2;
+//                 printf( "3\n" );
+                for ( int i = 0 ; i < names.size() && nSize > n ; i ++ )
+                {
+                    map[names[i]] = vec[n];
+                    if( nSize > n+1 && equalsIgnoreCase( vec[n+1] , 
RTL_CONSTASCII_STRINGPARAM(",") ) )
+                    {
+                        n ++;
+                    }
+                    n++;
+                }
+            }
+        }
+    }
+}
+
+rtl::OUString querySingleValue(
+    const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > 
&connection,
+    const rtl::OUString &query )
+{
+    OUString ret;
+    Reference< XStatement > stmt = connection->createStatement();
+    DisposeGuard guard( stmt );
+    Reference< XResultSet > rs = stmt->executeQuery( query );
+    Reference< XRow > xRow( rs, UNO_QUERY );
+    if( rs->next() )
+        ret = xRow->getString( 1 );
+    return ret;
+}
+
+
 }

File [changed]: pq_tools.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_tools.hxx?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +17 -2
--------------------
--- pq_tools.hxx        29 Aug 2004 08:33:30 -0000      1.1.2.4
+++ pq_tools.hxx        22 Jan 2006 15:14:37 -0000      1.1.2.5
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_tools.hxx,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:30 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:37 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -152,6 +152,21 @@
 
 com::sun::star::uno::Sequence< rtl::OUString > 
convertMappedIntArray2StringArray(
     const Int2StringMap &map, const com::sun::star::uno::Sequence< sal_Int32> 
&source );
+
+typedef std::hash_map
+<
+    ::rtl::OString,
+    ::rtl::OString,
+    ::rtl::OStringHash,
+    ::std::equal_to< rtl::OString >,
+    Allocator< ::std::pair< rtl::OString, ::rtl::OString > >
+> String2StringMap;
+
+rtl::OUString querySingleValue(
+    const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > 
&connection,
+    const rtl::OUString &query );
+
+void extractNameValuePairsFromInsert( String2StringMap & map, const 
rtl::OString & lastQuery );
 
 class DisposeGuard
 {

File [changed]: pq_xcontainer.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_xcontainer.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +2 -3
-------------------
--- pq_xcontainer.cxx   29 Aug 2004 08:33:30 -0000      1.1.2.3
+++ pq_xcontainer.cxx   22 Jan 2006 15:14:38 -0000      1.1.2.4
@@ -2,9 +2,9 @@
  *

  *  $RCSfile: pq_xcontainer.cxx,v $

  *

- *  $Revision: 1.1.2.3 $

+ *  $Revision: 1.1.2.4 $

  *

- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:30 $

+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:38 $

  *

  *  The Contents of this file are made available subject to the terms of

  *  either of the following licenses

@@ -124,7 +124,6 @@
 

     virtual void fire( XEventListener * listener ) const

     {

-        printf( "elementReplaced got called\n" );

         ((XContainerListener*)listener)->elementReplaced( m_event );

     }

     virtual Type getType() const


File [changed]: pq_xtable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_xtable.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +13 -5
--------------------
--- pq_xtable.cxx       29 Aug 2004 08:33:32 -0000      1.1.2.3
+++ pq_xtable.cxx       22 Jan 2006 15:14:39 -0000      1.1.2.4
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_xtable.cxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:32 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:39 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -195,19 +195,27 @@
     ::rtl::OUString oldName = extractStringProperty(this,st.NAME );
     ::rtl::OUString schema = extractStringProperty(this,st.SCHEMA_NAME );
 
+    OUString realNewName = newName;
+    // OOo2.0 passes schema + dot + new-table-name while
+    // OO1.1.x passes new Name without schema
+    if( newName.match( schema ) && newName[schema.getLength() == '.'] )
+    {
+        realNewName = newName.copy( schema.getLength() +1);
+    }
+
     OUStringBuffer buf(128);
     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
     bufferQuoteQualifiedIdentifier(buf, schema, oldName );
     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("RENAME TO" ) );
-    bufferQuoteIdentifier( buf, newName );
+    bufferQuoteIdentifier( buf, realNewName );
     Reference< XStatement > statement = m_conn->createStatement();
     statement->executeUpdate( buf.makeStringAndClear() );
-    setPropertyValue_NoBroadcast_public( st.NAME, makeAny(newName) );
+    setPropertyValue_NoBroadcast_public( st.NAME, makeAny(realNewName) );
 
         // inform the container of the name change !
     if( m_pSettings->tables.is() )
     {
-        m_pSettings->pTablesImpl->rename( schema, oldName, newName );
+        m_pSettings->pTablesImpl->rename( schema, oldName, realNewName );
     }
 }
     

File [changed]: pq_xuser.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_xuser.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +10 -5
--------------------
--- pq_xuser.cxx        10 Jun 2004 15:27:12 -0000      1.1.2.2
+++ pq_xuser.cxx        22 Jan 2006 15:14:40 -0000      1.1.2.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_xuser.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: jbu $ $Date: 2004/06/10 15:27:12 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:40 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -175,9 +175,14 @@
     const ::rtl::OUString& oldPassword, const ::rtl::OUString& newPassword )
     throw (::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException)
 {
-    throw com::sun::star::sdbc::SQLException(
-        ASCII_STR( "pq_driver: passwort change not implemented yet" ),
-        *this, OUString(), 1, Any() );
+    rtl::OUStringBuffer buf(128);
+    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER USER " ) );
+    bufferQuoteIdentifier( buf, extractStringProperty( this, getStatics().NAME 
) );
+    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
+    bufferQuoteConstant( buf, newPassword, m_pSettings->encoding );
+    Reference< XStatement > stmt = m_conn->createStatement();
+    DisposeGuard guard( stmt );
+    stmt->executeUpdate( buf.makeStringAndClear() );
 }
 
 sal_Int32 User::getPrivileges( const ::rtl::OUString& objName, sal_Int32 
objType )

File [changed]: pq_xusers.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/postgresql/pq_xusers.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +39 -80
---------------------
--- pq_xusers.cxx       29 Aug 2004 08:33:32 -0000      1.1.2.3
+++ pq_xusers.cxx       22 Jan 2006 15:14:41 -0000      1.1.2.4
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pq_xusers.cxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: jbu $ $Date: 2004/08/29 08:33:32 $
+ *  last change: $Author: jbu $ $Date: 2006/01/22 15:14:41 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -164,57 +164,18 @@
            ::com::sun::star::container::ElementExistException,
            ::com::sun::star::uno::RuntimeException)
 {
-    throw com::sun::star::sdbc::SQLException(
-        ASCII_STR( "pq_driver: adding users not implemented yet" ),
-        *this, OUString(), 1, Any() );
-
-//     osl::MutexGuard guard( m_refMutex->mutex );
-//     Reference< XStatement > stmt =
-//         m_origin->createStatement();
-
-//     Statics &st = getStatics();
-//     OUString name,schema;
-//     descriptor->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
-//     descriptor->getPropertyValue( st.NAME ) >>= name;
-
-//     try
-//     {
-//         stmt->executeUpdate( st.BEGIN );
-        
-//         OUStringBuffer buf( 128 );
-//         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CREATE TABLE" ) );
-//         bufferQuoteQualifiedIdentifier( buf, schema, name );
-//         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "()" ) );
-//         stmt->executeUpdate( buf.makeStringAndClear() );
-
-//         buf = OUStringBuffer( 128 );
-//         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON TABLE" ) );
-//         bufferQuoteQualifiedIdentifier( buf, schema, name );
-//         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
-//         bufferQuoteConstant( buf, extractStringProperty( 
descriptor,st.DESCRIPTION ), m_pSettings->encoding );
-//         stmt->executeUpdate( buf.makeStringAndClear() );
-
-//         stmt->executeUpdate( st.COMMIT );
-//         disposeNoThrow( stmt );
-//     }
-//     catch( com::sun::star::sdbc::SQLException & e )
-//     {
-//         rollbackNoThrow( m_origin );
-//         throw;
-//     }
-    
-    // increase the vector
-//     sal_Int32 index = m_values.getLength();
-//     m_values.realloc( index + 1 );
-
-//     Table * pTable = 
-//         new Table( m_refMutex, m_origin, m_pSettings, false /*modifiable*/ 
);
-//     Reference< com::sun::star::beans::XPropertySet > prop = pTable;
-//     copyProperties( pTable, descriptor );
-//     m_values[index] = makeAny( prop );
-//     OUStringBuffer buf( name.getLength() + 1 + schema.getLength() );
-//     buf.append( schema ).appendAscii( "." ).append( name );
-//     m_name2index[ buf.makeStringAndClear() ] = index;
+    osl::MutexGuard guard( m_refMutex->mutex );
+    Statics &st = getStatics();
+
+    OUStringBuffer update( 128 );
+    update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE USER " ) );
+    bufferQuoteIdentifier( update, extractStringProperty( descriptor, 
getStatics().NAME ) );
+    update.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
+    bufferQuoteConstant( update, extractStringProperty( descriptor, 
getStatics().PASSWORD ), m_pSettings->encoding );
+    
+    Reference< XStatement > stmt = m_origin->createStatement( );
+    DisposeGuard disposeGuard( stmt );
+    stmt->executeUpdate( update.makeStringAndClear() );
 }
 
 void Users::dropByName( const ::rtl::OUString& elementName )
@@ -240,35 +201,33 @@
            ::com::sun::star::lang::IndexOutOfBoundsException,
            ::com::sun::star::uno::RuntimeException)
 {
-    throw com::sun::star::sdbc::SQLException(
-        ASCII_STR( "pq_driver: dropping users not implemented yet" ),
-        *this, OUString(), 1, Any() );
-//     osl::MutexGuard guard( m_refMutex->mutex );
-//     if( index < 0 ||  index >= m_values.getLength() )
-//     {
-//         OUStringBuffer buf( 128 );
-//         buf.appendAscii( "TABLES: Index out of range (allowed 0 to " );
-//         buf.append( (sal_Int32) (m_values.getLength() -1) );
-//         buf.appendAscii( ", got " );
-//         buf.append( index );
-//         buf.appendAscii( ")" );
-//         throw com::sun::star::lang::IndexOutOfBoundsException(
-//             buf.makeStringAndClear(), *this );
-//     }
-
-//     Reference< XPropertySet > set;
-//     m_values[index] >>= set;
-//     Statics &st = getStatics();
-//     OUString name,schema;
-//     set->getPropertyValue( st.SCHEMA_NAME ) >>= schema;
-//     set->getPropertyValue( st.NAME ) >>= name;
-
-//     OUStringBuffer update( 128 );
-//     update.appendAscii( "DROP TABLE \"" ).append( schema ).appendAscii( 
"\".\"" );
-//     update.append( name ).appendAscii( "\"" );
-//     Reference< XStatement > stmt = m_origin->createStatement( );
 
-//     stmt->executeUpdate( update.makeStringAndClear() );
+    osl::MutexGuard guard( m_refMutex->mutex );
+    if( index < 0 ||  index >= m_values.getLength() )
+    {
+        OUStringBuffer buf( 128 );
+        buf.appendAscii( "USERS: Index out of range (allowed 0 to " );
+        buf.append( (sal_Int32) (m_values.getLength() -1) );
+        buf.appendAscii( ", got " );
+        buf.append( index );
+        buf.appendAscii( ")" );
+        throw com::sun::star::lang::IndexOutOfBoundsException(
+            buf.makeStringAndClear(), *this );
+    }
+
+    Reference< XPropertySet > set;
+    m_values[index] >>= set;
+    Statics &st = getStatics();
+    OUString name;
+    set->getPropertyValue( getStatics().NAME ) >>= name;
+
+    OUStringBuffer update( 128 );
+    update.appendAscii( "DROP USER " );
+    bufferQuoteIdentifier( update, name );
+
+    Reference< XStatement > stmt = m_origin->createStatement( );
+    DisposeGuard disposeGuard( stmt );
+    stmt->executeUpdate( update.makeStringAndClear() );
 }
 
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to