Issue 90531 - release database connexion obase ott odt merging
Summary: release database connexion obase ott odt merging
Status: CLOSED FIXED
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: OOo 2.4.0
Hardware: PC Windows XP
: P3 Trivial (vote)
Target Milestone: OOo 3.1
Assignee: joerg.skottke
QA Contact: issues@dba
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2008-06-09 16:53 UTC by coufan
Modified: 2009-04-23 13:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
ott file exemple (20.98 KB, text/plain)
2008-06-17 11:02 UTC, coufan
no flags Details
csv file (1.28 KB, text/plain)
2008-06-17 12:57 UTC, coufan
no flags Details
file odt (11.97 KB, text/plain)
2008-06-17 12:58 UTC, coufan
no flags Details
file .ott (22.00 KB, text/plain)
2008-06-17 12:58 UTC, coufan
no flags Details
suggested patch (929 bytes, patch)
2008-07-16 13:06 UTC, Frank Schönheit
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description coufan 2008-06-09 16:53:26 UTC
i have a macro to merging a.ott with a.odt located in a.odt 
when i open a.odt, the first fusion work, when i reopen, the merging does not work
in fact, the macro get a csv file, create a ods file and odb file to connect
a.ott and a.odt with a temporary datasource.
the odb file is locked thus macro do not kill this file.
what prevents the macro from killing the .odb file.

to kill .odb file, i have to kill quickstart.exe and all desktops open.

the code of merging is that :

Sub Publipostage()
   
  Dim sDocumentModele As String, sRepertoireCible As String
  Dim sNomTable As String, sNomSource As String
  Dim oMonPublipostage As Object
  Dim oMyProps() 


  sNomSource = csNomSource
  sDocumentModele = csFichierLettreType
  sRepertoireCible = csRepertoireResultat
  sNomTable = csNomTableDonnees

oMonPublipostage = createUnoService("com.sun.star.text.MailMerge")
 
oMonPublipostage.DataSourceName = sNomSource
oMonPublipostage.CommandType = com.sun.star.sdb.CommandType.TABLE
oMonPublipostage.Command = sNomTable

oMonPublipostage.OutputType = com.sun.star.text.MailMergeType.FILE
oMonPublipostage..FileNameFromColumn = false

oMonPublipostage.DocumentURL = ConvertToURL(sDocumentModele)
oMonPublipostage.OutputURL = ConvertToURL(sRepertoireCible)

oMonPublipostage.SaveAsSingleFile = True

oMonPublipostage.execute(oMyProps())

oMonPublipostage.dispose()

end sub

i tested with ooo 240 and 30 beta dev m_17 unsuccessfully
Comment 1 marc.neumann 2008-06-10 07:49:41 UTC
According to http://www.openoffice.org/scdocs/ddIssues_EnterModify.html#priority
I reduce the prio to 2
Comment 2 Frank Schönheit 2008-06-16 22:45:33 UTC
Could you please attach
- a database document (.odb) with sample data
- a text document (.odt) which can be used to do a mail merge based on the
  database
?

This would tremendously ease reproducing the bug case.
Comment 3 coufan 2008-06-17 11:02:24 UTC
Created attachment 54531 [details]
ott file exemple
Comment 4 coufan 2008-06-17 12:57:46 UTC
Created attachment 54534 [details]
csv file
Comment 5 coufan 2008-06-17 12:58:17 UTC
Created attachment 54535 [details]
file odt
Comment 6 coufan 2008-06-17 12:58:47 UTC
Created attachment 54536 [details]
file .ott
Comment 7 coufan 2008-06-17 13:15:31 UTC
i confirm that my macro script works for oOo221 but not 240/241 and 30 beta ..

you'll find macro in odt 
courrier.txt

tree of located files is :
f:\sources\courrier.txt
f:\sources\modelesOO\2200-lr.odt
f:\sources\modelesOO\2200-lr.ott

the first macro function is  "main".

with data located in courrier.txt, i create a file .ods to populate a file .odb
and to over, merge between odb and ott to create a new odt stocked in the folder
f:\sources\modelesOO\resultat

Thank you very much

Comment 8 Frank Schönheit 2008-07-02 14:49:46 UTC
will have a deeper look, seems your files allow me to reproduce this, thanks

(one note: monDBContext.dispose() is definitely wrong, disposing the
DatabaseContext is a bad idea, as all database functionality will cease to
function then. Just spare this line in your macro)
Comment 9 Frank Schönheit 2008-07-16 12:49:56 UTC
fs->os: during running the macro, two connections are opened: One from within
the RowSet, which is employed by SwXMailMerge::execute. This connection is freed
when the RowSet dies, which is fine.
A second connection is created from within SwNewDBMgr::GetConnection, which is
called indirectly via SwNewDBMgr::MergeNew, which is called within
SwXMailMerge::execute.

The second connection is never freed, thus the database document is kept locked.

Adding "regression" keyword (since it in fact worked in OOo 2.2.1) and target.
Comment 10 Frank Schönheit 2008-07-16 12:54:19 UTC
fs->os: In general, I think the SwNewDBMgr's habit of caching connections is
broken by design. Keeping a connection longer than you need it is a waste of
resources, without giving the user a chance to control the behavior.

I would say that every operation at the DB manager should dispose the connection
it just created, at least on a high level. That is, some kind of guard
  {
    DBClient aGuard( ... );
    SwNewDBMgr::doSomething();
    SwNewDBMgr::doSomethingElse();
  }
 - where the connection would be freed when the (last) guard dies. This would
probably help to get rid of a lot more similar issues (though it's also a bigger
change, of course).
Comment 11 Frank Schönheit 2008-07-16 12:59:37 UTC
Note that another option to fix (only) this particular issue is the following:
SwNewDBMgr::MergeNew, called from SwXMailMerge::execute, is given an
SwMergeDescriptor, which is allowed to contain an XConnection object. However,
this is not used currently.
Currently, the connection in the descriptor is set to the value of the
ActiveConnection of the MailMerge object. In case this is NULL, it should simply
be set to the ActiveConnection of the RowSet (after executing it), and
everything should be fine.
Comment 12 Oliver Specht 2008-07-16 13:05:47 UTC
I can't see how Prio 2 fits to this
http://www.openoffice.org/scdocs/ddIssues_EnterModify.html#priority
Adjusted to P3
Comment 13 Frank Schönheit 2008-07-16 13:06:49 UTC
Created attachment 55151 [details]
suggested patch
Comment 14 Oliver Specht 2008-09-10 13:36:16 UTC
Intergrated in cws os120
Comment 15 Oliver Specht 2008-10-21 08:53:27 UTC
Reassigned for verification
Comment 16 h.ilter 2008-10-27 12:19:51 UTC
HI->JSK: Please take over, Thanks.
Comment 17 joerg.skottke 2008-10-27 13:56:22 UTC
Verified issue on Windows. I had to modify the paths in the macros and to create
the file structure.
Now the macro runs and ends with a messagebox "Fin de l'operation".
I cannot run the macro twice without running into an exception, but it's not the
general I/O error that was found in 2.4.1 and 3.0
Comment 18 joerg.skottke 2009-03-20 09:18:17 UTC
@coufan, 

could you please verify your issue in a OOO310m6?
Comment 19 joerg.skottke 2009-04-23 13:14:23 UTC
Assuming fixed (appears to work, a stakeholder verificateion would have been
better though)