Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4a926caf
Kaydet (Commit)
4a926caf
authored
Şub 26, 2017
tarafından
Berker Peksag
Kaydeden (comit)
GitHub
Şub 26, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-28518: Start a transaction implicitly before a DML statement (#245)
Patch by Aviv Palivoda.
üst
46ce7599
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
11 deletions
+24
-11
transactions.py
Lib/sqlite3/test/transactions.py
+9
-0
NEWS
Misc/NEWS
+3
-0
cursor.c
Modules/_sqlite/cursor.c
+4
-5
statement.c
Modules/_sqlite/statement.c
+7
-5
statement.h
Modules/_sqlite/statement.h
+1
-1
No files found.
Lib/sqlite3/test/transactions.py
Dosyayı görüntüle @
4a926caf
...
...
@@ -179,6 +179,15 @@ class TransactionalDDL(unittest.TestCase):
result
=
self
.
con
.
execute
(
"select * from test"
)
.
fetchall
()
self
.
assertEqual
(
result
,
[])
def
CheckImmediateTransactionalDDL
(
self
):
# You can achieve transactional DDL by issuing a BEGIN
# statement manually.
self
.
con
.
execute
(
"begin immediate"
)
self
.
con
.
execute
(
"create table test(i)"
)
self
.
con
.
rollback
()
with
self
.
assertRaises
(
sqlite
.
OperationalError
):
self
.
con
.
execute
(
"select * from test"
)
def
CheckTransactionalDDL
(
self
):
# You can achieve transactional DDL by issuing a BEGIN
# statement manually.
...
...
Misc/NEWS
Dosyayı görüntüle @
4a926caf
...
...
@@ -249,6 +249,9 @@ Extension Modules
Library
-------
- bpo-28518: Start a transaction implicitly before a DML statement.
Patch by Aviv Palivoda.
- Issue #16285: urrlib.parse.quote is now based on RFC 3986 and hence includes
'~' in the set of characters that is not quoted by default. Patch by
Christian Theune and Ratnadeep Debnath.
...
...
Modules/_sqlite/cursor.c
Dosyayı görüntüle @
4a926caf
...
...
@@ -511,10 +511,9 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
pysqlite_statement_reset
(
self
->
statement
);
pysqlite_statement_mark_dirty
(
self
->
statement
);
/* For backwards compatibility reasons, do not start a transaction if a
DDL statement is encountered. If anybody wants transactional DDL,
they can issue a BEGIN statement manually. */
if
(
self
->
connection
->
begin_statement
&&
!
sqlite3_stmt_readonly
(
self
->
statement
->
st
)
&&
!
self
->
statement
->
is_ddl
)
{
/* We start a transaction implicitly before a DML statement.
SELECT is the only exception. See #9924. */
if
(
self
->
connection
->
begin_statement
&&
self
->
statement
->
is_dml
)
{
if
(
sqlite3_get_autocommit
(
self
->
connection
->
db
))
{
result
=
_pysqlite_connection_begin
(
self
->
connection
);
if
(
!
result
)
{
...
...
@@ -609,7 +608,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
}
}
if
(
!
sqlite3_stmt_readonly
(
self
->
statement
->
st
)
)
{
if
(
self
->
statement
->
is_dml
)
{
self
->
rowcount
+=
(
long
)
sqlite3_changes
(
self
->
connection
->
db
);
}
else
{
self
->
rowcount
=
-
1L
;
...
...
Modules/_sqlite/statement.c
Dosyayı görüntüle @
4a926caf
...
...
@@ -73,8 +73,9 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
Py_INCREF
(
sql
);
self
->
sql
=
sql
;
/* determine if the statement is a DDL statement */
self
->
is_ddl
=
0
;
/* Determine if the statement is a DML statement.
SELECT is the only exception. See #9924. */
self
->
is_dml
=
0
;
for
(
p
=
sql_cstr
;
*
p
!=
0
;
p
++
)
{
switch
(
*
p
)
{
case
' '
:
...
...
@@ -84,9 +85,10 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
continue
;
}
self
->
is_ddl
=
(
PyOS_strnicmp
(
p
,
"create "
,
7
)
==
0
)
||
(
PyOS_strnicmp
(
p
,
"drop "
,
5
)
==
0
)
||
(
PyOS_strnicmp
(
p
,
"reindex "
,
8
)
==
0
);
self
->
is_dml
=
(
PyOS_strnicmp
(
p
,
"insert "
,
7
)
==
0
)
||
(
PyOS_strnicmp
(
p
,
"update "
,
7
)
==
0
)
||
(
PyOS_strnicmp
(
p
,
"delete "
,
7
)
==
0
)
||
(
PyOS_strnicmp
(
p
,
"replace "
,
8
)
==
0
);
break
;
}
...
...
Modules/_sqlite/statement.h
Dosyayı görüntüle @
4a926caf
...
...
@@ -38,7 +38,7 @@ typedef struct
sqlite3_stmt
*
st
;
PyObject
*
sql
;
int
in_use
;
int
is_d
d
l
;
int
is_d
m
l
;
PyObject
*
in_weakreflist
;
/* List of weak references */
}
pysqlite_Statement
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment