pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feeddriver ODBC-PostreSQL, cursor and transaction isolation level
7+ messages / 4 participants
[nested] [flat]
* driver ODBC-PostreSQL, cursor and transaction isolation level
@ 2009-04-02 15:53 olivier dorie <olivier.dorie@ign.fr>
2009-04-03 06:41 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Albe Laurenz <laurenz.albe@wien.gv.at>
2009-04-04 07:01 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Hiroshi Inoue <inoue@tpf.co.jp>
0 siblings, 2 replies; 7+ messages in thread
From: olivier dorie @ 2009-04-02 15:53 UTC (permalink / raw)
To: pgsql-odbc
Hello,
I have some problems to have a transaction isolation level serializable with
postgresql-ODBC driver for windows by using the ODBC cursor
(UseDeclareFetch=1).
My database is on PostgreSQL 8.3.7/ Linux.
I use the postgresql-ODBC version 8.03.04 for windows.
I make this test with the default_transaction_isolation = 'read committed'
and after with the default_transaction_isolation = 'serializable' on the
server. The results are the same.
I do the followings operations in a c++ programm:
* I open 2 connections on my database with the ODBC drivers:
"connexion1" and "connexion2"
* CDatabase * db1 = new CDatabase ;
* CDatabase * db2 = new CDatabase
* db1->OpenEx (chaine_connection_mydatabase, CDatabase::noOdbcDialog);
* db2->OpenEx (chaine_connection_mydatabase, CDatabase::noOdbcDialog)
* I ask for the number of tuples of table "table1" --> n tuples:
* CRecordset crs (db1)
* crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table1;")
* I make the "connexion1" serializable :
* db1->ExecuteSQL ("BEGIN TRANSACTION;")
* db1->ExecuteSQL ("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;")
* In the connexion1, I add a tuple in the table "table1" :
* db1->ExecuteSQL ("INSERT INTO table1 ..;")
* In the connexion1, I ask for the number of tuples of table "table1"
--> n+1 tuples
* CRecordset crs (db1)
* crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table1;")
* In the connexion2, I ask for the number of tuples of table "table1"
--> n+1 tuples;
* CRecordset crs (db1)
* crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table2;")
I don't understand why the number is not n tuples in the "connexion2"
because the connexion1 is serializable ?
Do I use the good parameters for ODBC? Are there some restrictions for the
use of the cursors with ODBC-PostgreSQL and the transaction isolation level
?
My parameters are the followings:
"DRIVER={PostgreSQL
ANSI};DATABASE=<mabase>;SERVER=<monserver>;PORT=5438;UID=<user>;PWD=<passwor
d>;SSLmode=disable;ReadOnly=0;Protocol=7.4-1;FakeOidIndex=0;ShowOidColumn=0;
RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=10000;Socket=4096;Unk
nownSizes=0;MaxVarcharSize=255;MaxLongVarcharSize=5400000;Debug=0;CommLog=0;
Optimizer=1;Ksqo=1;UseDeclareFetch=1;TextAsLongVarchar=1;UnknownsAsLongVarch
ar=1;BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTablePrefixes=dd_;;LFC
onversion=0;UpdatableCursors=1;DisallowPremature=0;TrueIsMinus1=0;BI=0;Bytea
AsLongVarBinary=0;UseServerSidePrepare=1;LowerCaseIdentifier=0;XaOpt=1"
If I use the option "UseDeclareFetch=0", the transaction isolation level
serializable is respected.
Thank's all
Olivier
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
2009-04-02 15:53 driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
@ 2009-04-03 06:41 ` Albe Laurenz <laurenz.albe@wien.gv.at>
1 sibling, 0 replies; 7+ messages in thread
From: Albe Laurenz @ 2009-04-03 06:41 UTC (permalink / raw)
To: olivier dorie *EXTERN* <olivier.dorie@ign.fr>; pgsql-odbc
olivier dorie wrote:
> I have some problems to have a transaction isolation level
> serializable with postgresql-ODBC driver for windows by using
> the ODBC cursor (UseDeclareFetch=1).
>
> My database is on PostgreSQL 8.3.7/ Linux.
>
> I use the postgresql-ODBC version 8.03.04 for windows.
>
> I make this test with the default_transaction_isolation = 'read committed' and after with the
> default_transaction_isolation = 'serializable' on the server.
> The results are the same.
>
>
>
> I do the followings operations in a c++ programm:
>
> * I open 2 connections on my database with the ODBC drivers: "connexion1" and "connexion2"
>
> * CDatabase * db1 = new CDatabase ;
> * CDatabase * db2 = new CDatabase
> * db1->OpenEx (chaine_connection_mydatabase, CDatabase::noOdbcDialog);
> * db2->OpenEx (chaine_connection_mydatabase, CDatabase::noOdbcDialog)
>
> * I ask for the number of tuples of table "table1" --> n tuples:
>
> * CRecordset crs (db1)
> * crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table1;")
>
> * I make the "connexion1" serializable :
>
> * db1->ExecuteSQL ("BEGIN TRANSACTION;")
> * db1->ExecuteSQL ("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;")
>
> * In the connexion1, I add a tuple in the table "table1" :
>
> * db1->ExecuteSQL ("INSERT INTO table1 ....;")
>
> * In the connexion1, I ask for the number of tuples of table "table1" --> n+1 tuples
>
> * CRecordset crs (db1)
> * crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table1;")
>
> * In the connexion2, I ask for the number of tuples of table "table1" --> n+1 tuples;
>
> * CRecordset crs (db1)
> * crs.Open (CRecordset::snapshot, "SELECT count (*) FROM table2;")
Wait a minute:
I would say that in connection 1, you ask for the number of tuples in table2
and not what you claim. Is this a typo?
> I don't understand why the number is not n tuples in the
> "connexion2" because the connexion1 is serializable ?
The isolation level of a transaction does not influence other transactions.
It only changes the world-view of the transaction itself.
It is the fact that there is a transaction in progress (irrespective of
its isolation level) that will keep others from seeing the inserted record.
But yes, you are right, a second connection should only see committed records.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
2009-04-02 15:53 driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
@ 2009-04-04 07:01 ` Hiroshi Inoue <inoue@tpf.co.jp>
2009-04-08 12:38 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
1 sibling, 1 reply; 7+ messages in thread
From: Hiroshi Inoue @ 2009-04-04 07:01 UTC (permalink / raw)
To: olivier dorie <olivier.dorie@ign.fr>; +Cc: pgsql-odbc
olivier dorie wrote:
> Hello,
>
>
> I have some problems to have a transaction isolation level serializable
> with postgresql-ODBC driver for windows by using the ODBC cursor
> (UseDeclareFetch=1).
>
>
> My database is on PostgreSQL 8.3.7/ Linux.
>
> I use the postgresql-ODBC version 8.03.04 for windows.
>
> I make this test with the default_transaction_isolation = 'read
> committed' and after with the default_transaction_isolation =
> 'serializable' on the server. The results are the same.
>
>
> I do the followings operations in a c++ programm:
>
> * I open 2 connections on my database with the ODBC drivers:
> “connexion1” and “connexion2”
> o /CDatabase * db1 = new CDatabase ;///
> o /CDatabase * db2 = new CDatabase///
> o /db1->OpenEx (chaine_connection_mydatabase,
> CDatabase::noOdbcDialog);///
> o /db2->OpenEx (chaine_connection_mydatabase,
> CDatabase::noOdbcDialog)///
> * I ask for the number of tuples of table “table1” à n tuples:
> o /CRecordset crs (//db1)/
> o /crs.Open (CRecordset::snapshot, "SELECT count (*) FROM
> table1;")///
> * I make the “connexion1” serializable :
> o /db1->ExecuteSQL (“BEGIN TRANSACTION;”) /
> o /db1->ExecuteSQL (“SET TRANSACTION ISOLATION LEVEL
> SERIALIZABLE;”)/
ODBC doesn't recommend to call dbms specific commands to control
transaction. Please use BeginTrans/CommitTrans/Rollback instead.
Anyway I improved the handling of transaction under useDeclareFetch
mode a little. Please try the drivers on testing for 8.4.0100 at
http://www.geocities.jp/inocchichichi/psqlodbc/index.html
.
regards,
Hiroshi Inoue
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
2009-04-02 15:53 driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
2009-04-04 07:01 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Hiroshi Inoue <inoue@tpf.co.jp>
@ 2009-04-08 12:38 ` olivier dorie <olivier.dorie@ign.fr>
2009-04-08 14:27 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Hiroshi Inoue <inoue@tpf.co.jp>
0 siblings, 1 reply; 7+ messages in thread
From: olivier dorie @ 2009-04-08 12:38 UTC (permalink / raw)
To: 'Hiroshi Inoue' <inoue@tpf.co.jp>; +Cc: pgsql-odbc
Hiroshi,
Thank you for your answer.
I try the 2 solutions (BeginTrans and the driver 8.4.0100) and the two of
them work: in the small test, I describe in the last mail, the transaction
is serializable.
I have a last question: with BeginTrans or with the driver 8.4.0100, the
transaction isolation level is every time serializable ? Is it possible to
have a read committed level?
Regards
Olivier
-----Message d'origine-----
De : pgsql-odbc-owner@postgresql.org
[mailto:pgsql-odbc-owner@postgresql.org] De la part de Hiroshi Inoue
Envoyé : samedi 4 avril 2009 09:01
À : olivier dorie
Cc : pgsql-odbc@postgresql.org
Objet : Re: [ODBC] driver ODBC-PostreSQL, cursor and transaction isolation
level
olivier dorie wrote:
> Hello,
>
>
> I have some problems to have a transaction isolation level serializable
> with postgresql-ODBC driver for windows by using the ODBC cursor
> (UseDeclareFetch=1).
>
>
> My database is on PostgreSQL 8.3.7/ Linux.
>
> I use the postgresql-ODBC version 8.03.04 for windows.
>
> I make this test with the default_transaction_isolation = 'read
> committed' and after with the default_transaction_isolation =
> 'serializable' on the server. The results are the same.
>
>
> I do the followings operations in a c++ programm:
>
> * I open 2 connections on my database with the ODBC drivers:
> “connexion1” and “connexion2”
> o /CDatabase * db1 = new CDatabase ;///
> o /CDatabase * db2 = new CDatabase///
> o /db1->OpenEx (chaine_connection_mydatabase,
> CDatabase::noOdbcDialog);///
> o /db2->OpenEx (chaine_connection_mydatabase,
> CDatabase::noOdbcDialog)///
> * I ask for the number of tuples of table “table1” à n tuples:
> o /CRecordset crs (//db1)/
> o /crs.Open (CRecordset::snapshot, "SELECT count (*) FROM
> table1;")///
> * I make the “connexion1” serializable :
> o /db1->ExecuteSQL (“BEGIN TRANSACTION;”) /
> o /db1->ExecuteSQL (“SET TRANSACTION ISOLATION LEVEL
> SERIALIZABLE;”)/
ODBC doesn't recommend to call dbms specific commands to control
transaction. Please use BeginTrans/CommitTrans/Rollback instead.
Anyway I improved the handling of transaction under useDeclareFetch
mode a little. Please try the drivers on testing for 8.4.0100 at
http://www.geocities.jp/inocchichichi/psqlodbc/index.html
.
regards,
Hiroshi Inoue
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
2009-04-02 15:53 driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
2009-04-04 07:01 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Hiroshi Inoue <inoue@tpf.co.jp>
2009-04-08 12:38 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
@ 2009-04-08 14:27 ` Hiroshi Inoue <inoue@tpf.co.jp>
0 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Inoue @ 2009-04-08 14:27 UTC (permalink / raw)
To: olivier dorie <olivier.dorie@ign.fr>; +Cc: pgsql-odbc
Hi Olivier,
olivier dorie wrote:
> Hiroshi,
>
> Thank you for your answer.
>
> I try the 2 solutions (BeginTrans and the driver 8.4.0100) and the two of
> them work: in the small test, I describe in the last mail, the transaction
> is serializable.
>
> I have a last question: with BeginTrans or with the driver 8.4.0100, the
> transaction isolation level is every time serializable ?
Why do you think so?
Your example doesn't seem to show us the difference.
> Is it possible to
> have a read committed level?
It's determined by the server setting. The default is read committed.
regards,
Hiroshi Inoue
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
@ 2009-04-09 10:05 olivier dorie <olivier.dorie@ign.fr>
2009-04-09 14:14 ` Re: driver ODBC-PostreSQL, cursor and transaction isolation level Richard Broersma <richard.broersma@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: olivier dorie @ 2009-04-09 10:05 UTC (permalink / raw)
To: 'Hiroshi Inoue' <inoue@tpf.co.jp>; +Cc: pgsql-odbc
Hi Hiroshi,
Sorry for my last message, I made some mistakes in my tests.
Since, I have made others tests with begintrans with (the driver 8.4.0100
and the driver 8.3.4):
* No dirty read
* Read committed
* Serializable
I use the server settings or ExecuteSQL("SET ISOLATION LEVEL ..")
All tests give good results.
Regards
Olivier
Hi Olivier,
olivier dorie wrote:
> Hiroshi,
>
> Thank you for your answer.
>
> I try the 2 solutions (BeginTrans and the driver 8.4.0100) and the two
> of them work: in the small test, I describe in the last mail, the
> transaction is serializable.
>
> I have a last question: with BeginTrans or with the driver 8.4.0100,
> the transaction isolation level is every time serializable ?
Why do you think so?
Your example doesn't seem to show us the difference.
> Is it possible to
> have a read committed level?
It's determined by the server setting. The default is read committed.
regards,
Hiroshi Inoue
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: driver ODBC-PostreSQL, cursor and transaction isolation level
2009-04-09 10:05 Re: driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
@ 2009-04-09 14:14 ` Richard Broersma <richard.broersma@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Richard Broersma @ 2009-04-09 14:14 UTC (permalink / raw)
To: olivier dorie <olivier.dorie@ign.fr>; +Cc: pgsql-odbc
On Thu, Apr 9, 2009 at 3:05 AM, olivier dorie <olivier.dorie@ign.fr> wrote:
> Since, I have made others tests with begintrans with (the driver 8.4.0100
> and the driver 8.3.4):
>
> · No dirty read
> · Read committed
> · Serializable
>
> I use the server settings or ExecuteSQL(“SET ISOLATION LEVEL ….”)
> All tests give good results.
Only Read Committed and Serializable are implemented in PostgreSQL all
other isolation levels default to one of these two:
http://www.postgresql.org/docs/8.3/interactive/sql-set-transaction.html
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2009-04-09 14:14 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-04-02 15:53 driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
2009-04-03 06:41 ` Albe Laurenz <laurenz.albe@wien.gv.at>
2009-04-04 07:01 ` Hiroshi Inoue <inoue@tpf.co.jp>
2009-04-08 12:38 ` olivier dorie <olivier.dorie@ign.fr>
2009-04-08 14:27 ` Hiroshi Inoue <inoue@tpf.co.jp>
2009-04-09 10:05 Re: driver ODBC-PostreSQL, cursor and transaction isolation level olivier dorie <olivier.dorie@ign.fr>
2009-04-09 14:14 ` Richard Broersma <richard.broersma@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox