Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » SQL refactored, adding per-thread option, added second SQLR
SQL refactored, adding per-thread option, added second SQLR [message #34760] Sat, 10 December 2011 17:10 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
SQL, 'global SQL session/cursor', is now refactored so that each thread is allowed to assign its own SqlSession to SQL.

Unless this is assigned, SQL defaults to 'global SQL', the first one that was assigned.

This way, it is possible to support both "single DB session per whole program" (only main thread assigns SQL) - in that case using SQL has to be serialized (mutexes). And it is also possible to have per-thread SQL (if thread assigns it).

I have also noticed that there is quite common pattern to use two SQL sessions - one for read/write master DB, second for read-only slaves. Read operations are then performed on slaves, which unloads master DB.

So support this, I have introduced secondary 'global cursor/session', SQLR. If not assigned, it defaults to session defined for SQL. Of course, global/per-thread behaviour is the same.
Re: SQL refactored, adding per-thread option, added second SQLR [message #35541 is a reply to message #34760] Tue, 28 February 2012 10:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
After gaining some experience, I have changed the semantics to be more explicit: You have to call Sql::PerThread or SqlSession::PerThread (or SQL.PerThread) to enable per-thread global sessions, otherwise there is just one global.

[Updated on: Tue, 28 February 2012 11:05]

Report message to a moderator

Re: SQL refactored, adding per-thread option, added second SQLR [message #35543 is a reply to message #35541] Tue, 28 February 2012 11:14 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Mirek,

Are these changes implemented in the next release? I mean after the #4428.

Does it mean that we will use the following syntax ?

SQL = MySession;
SQL.PerThread();


Thank you for continously improving U++

Biobytes
Re: SQL refactored, adding per-thread option, added second SQLR [message #35545 is a reply to message #35543] Tue, 28 February 2012 12:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
BioBytes wrote on Tue, 28 February 2012 05:14

Hi Mirek,

Are these changes implemented in the next release? I mean after the #4428.



They are commited, so they will be in next nightly, and in next release.

Quote:


SQL = MySession;
SQL.PerThread();




The syntax is valid, but it might not do what you expect. You need to create and assign a session in each thread again.
Re: SQL refactored, adding per-thread option, added second SQLR [message #38319 is a reply to message #35545] Mon, 10 December 2012 00:10 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
mirek wrote on Tue, 28 February 2012 08:09


SQL = MySession;
SQL.PerThread();


The syntax is valid, but it might not do what you expect. You need to create and assign a session in each thread again.



Is there an example on how to use it? If not, could you please briefly provide us with a few code lines on how to do it?

thanks!
Re: SQL refactored, adding per-thread option, added second SQLR [message #38322 is a reply to message #38319] Mon, 10 December 2012 05:24 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kropniczki wrote on Sun, 09 December 2012 18:10

mirek wrote on Tue, 28 February 2012 08:09


SQL = MySession;
SQL.PerThread();


The syntax is valid, but it might not do what you expect. You need to create and assign a session in each thread again.



Is there an example on how to use it? If not, could you please briefly provide us with a few code lines on how to do it?

thanks!



It is used in e.g. Skylark. See examples/AddressBookWeb.

Mirek
Previous Topic: Testers wanted for new .deb packages
Next Topic: U++ logging refactored
Goto Forum:
  


Current Time: Fri Mar 29 16:07:23 CET 2024

Total time taken to generate the page: 0.01748 seconds