driver ODBC-PostreSQL, cursor and transaction isolation level
am 02.04.2009 17:53:51 von olivier dorieThis is a multi-part message in MIME format.
style=3D'font-size:10.0pt;
style=3D'font-size:10.0pt;
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
style=3D'font-size:
------=_NextPart_000_010A_01C9B3BB.FB293D90
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
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=
RowVersioning=0;ShowSystemTables=0;ConnSettings=;Fetch=10000 ;Socket=4096;Unk
nownSizes=0;MaxVarcharSize=255;MaxLongVarcharSize=5400000;De bug=0;CommLog=0;
Optimizer=1;Ksqo=1;UseDeclareFetch=1;TextAsLongVarchar=1;Unk nownsAsLongVarch
ar=1;BoolsAsChar=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTableP refixes=dd_;;LFC
onversion=0;UpdatableCursors=1;DisallowPremature=0;TrueIsMin us1=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
------=_NextPart_000_010A_01C9B3BB.FB293D90
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
xmlns=3D"http://www.w3.org/TR/REC-html40">
charset=3Dus-ascii">
font-family:Tahoma'>Hello,
font-family:Tahoma'>
10.0pt;font-family:Tahoma'>I have some problems to have a transaction =
isolation
level serializable with postgresql-ODBC driver for windows by using the =
ODBC
cursor (UseDeclareFetch=3D1).
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>My database is on PostgreSQL 8.3.7/ =
Linux.
10.0pt;font-family:Tahoma'>I use the
face=3DTahoma>
lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Tahoma'>postgresql-ODB C version =
8.03.04
for windows.
10.0pt;font-family:Tahoma'>I make this test with the =
default_transaction_isolation
=3D 'read committed' and after with the default_transaction_isolation =
=3D 'serializable'
on the server. The results are the same.
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>I do the followings operations in a c++ =
programm:
connections on my database with the ODBC drivers: =
“connexion1”
and “connexion2”
face=3D"Times New Roman">
style=3D'font-size:10.0pt;font-style:italic'>CDatabase
* db1 =3D
style=3D'color:blue'>new
CDatabase ;
=
style=3D'font-size:10.0pt;font-style:italic'>
face=3D"Times New Roman">
style=3D'font-size:10.0pt;font-style:italic'>CDatabase
* db2 =3D
style=3D'color:blue'>new =
CDatabase
size=3D2>
style=3D'font-size:10.0pt;font-style:italic'>
face=3D"Times New Roman">
style=3D'font-size:10.0pt;
font-style:italic'>db1->OpenEx (chaine_connection_mydatabase,
CDatabase::noOdbcDialog);
lang=3DEN-GB =
style=3D'font-size:10.0pt;font-style:italic'>
face=3D"Times New Roman">
style=3D'font-size:10.0pt;font-style:italic'>db2->OpenEx
(chaine_connection_mydatabase, =
CDatabase::noOdbcDialog)
size=3D2>
style=3D'font-size:10.0pt;font-style:italic'>
for the
number of tuples of table “table1”
size=3D2
face=3DWingdings>
style=3D'font-size:10.0pt;font-family:Wingdings'>à
size=3D2 face=3DTahoma>
style=3D'font-size:10.0pt;font-family:
Tahoma'> n tuples:
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>CRecordset crs (
size=3D2
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>db1)
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>crs.Open (CRecordset::snapshot, "SELECT =
count (*)
FROM table1;")
face=3DTahoma>
lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Tahoma;font-style:ital ic'>
the “connexion1”
serializable :
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>db1->ExecuteSQL (“BEGIN =
TRANSACTION;”)
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>db1->ExecuteSQL (“SET TRANSACTION =
ISOLATION
LEVEL SERIALIZABLE;”)
connexion1, I
add a tuple in the table “table1” =
:
style=3D'font-size:10.0pt;font-family:Tahoma'>db1->ExecuteSQL
("INSERT INTO table1 ….;”)
size=3D2
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma'>
li>
connexion1, I
ask for the number of tuples of table “table1” =
size=3D2 face=3DWingdings>
style=3D'font-size:10.0pt;font-family:
Wingdings'>à
lang=3DEN-GB style=3D'font-size:10.0pt;font-family:Tahoma'> n+1 =
tuples
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>CRecordset crs (
size=3D2
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>db1)
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>crs.Open (CRecordset::snapshot, "SELECT =
count (*)
FROM table1;")
face=3DTahoma>
lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Tahoma;font-style:ital ic'>
connexion2, I
ask for the number of tuples of table “table1” =
size=3D2 face=3DWingdings>
style=3D'font-size:10.0pt;font-family:
Wingdings'>à
lang=3DEN-GB style=3D'font-size:10.0pt;font-family:Tahoma'> n+1 =
tuples;
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>CRecordset crs (
size=3D2
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>db1)
face=3DTahoma>
style=3D'font-size:10.0pt;font-family:Tahoma;
font-style:italic'>crs.Open (CRecordset::snapshot, "SELECT =
count (*)
FROM table2;")
face=3DTahoma>
lang=3DEN-GB =
style=3D'font-size:10.0pt;font-family:Tahoma;font-style:ital ic'>
10.0pt;font-family:Tahoma'>I don’t understand why the number is =
not n
tuples in the “connexion2” because the connexion1 is =
serializable ?
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>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 ?
10.0pt;font-family:Tahoma'>My parameters are the =
followings:
10.0pt;font-family:Tahoma'>“DRIVER=3D{PostgreSQL =
ANSI};DATABASE=3D<mabase>;SERVER=3D<monserver>;PORT=3D5438;UI=
D=3D<user>;PWD=3D<password>;SSLmode=3Ddisable;ReadOnly=3D0;Pr=
otocol=3D7.4-1;FakeOidIndex=3D0;ShowOidColumn=3D0;RowVersion ing=3D0;ShowS=
ystemTables=3D0;ConnSettings=3D;Fetch=3D10000;Socket=3D4096; UnknownSizes=3D=
0;MaxVarcharSize=3D255;MaxLongVarcharSize=3D5400000;Debug=3D 0;CommLog=3D0=
;Optimizer=3D1;Ksqo=3D1;UseDeclareFetch=3D1;TextAsLongVarcha r=3D1;Unknown=
sAsLongVarchar=3D1;BoolsAsChar=3D1;Parse=3D0;CancelAsFreeStm t=3D0;ExtraSy=
sTablePrefixes=3Ddd_;;LFConversion=3D0;UpdatableCursors=3D1; DisallowPrema=
ture=3D0;TrueIsMinus1=3D0;BI=3D0;ByteaAsLongVarBinary=3D0;Us eServerSidePr=
epare=3D1;LowerCaseIdentifier=3D0;XaOpt=3D1”
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>If I use the option =
“UseDeclareFetch=3D0”,
the transaction isolation level serializable is =
respected.
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>Thank’s =
all
10.0pt;font-family:Tahoma'>
10.0pt;font-family:Tahoma'>Olivier
10.0pt;font-family:Arial'>
10.0pt;font-family:Arial'>
10.0pt;font-family:Arial'>
------=_NextPart_000_010A_01C9B3BB.FB293D90--