Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
e264f671
Kaydet (Commit)
e264f671
authored
Mar 01, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactored implementation of savepoints.
Prepared for using savepoints within transactions in autocommit mode.
üst
918f44e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
+24
-19
__init__.py
django/db/backends/__init__.py
+24
-19
No files found.
django/db/backends/__init__.py
Dosyayı görüntüle @
e264f671
...
...
@@ -176,54 +176,59 @@ class BaseDatabaseWrapper(object):
##### Backend-specific savepoint management methods #####
def
_savepoint
(
self
,
sid
):
if
not
self
.
features
.
uses_savepoints
or
self
.
autocommit
:
return
self
.
cursor
()
.
execute
(
self
.
ops
.
savepoint_create_sql
(
sid
))
def
_savepoint_rollback
(
self
,
sid
):
if
not
self
.
features
.
uses_savepoints
or
self
.
autocommit
:
return
self
.
cursor
()
.
execute
(
self
.
ops
.
savepoint_rollback_sql
(
sid
))
def
_savepoint_commit
(
self
,
sid
):
if
not
self
.
features
.
uses_savepoints
or
self
.
autocommit
:
return
self
.
cursor
()
.
execute
(
self
.
ops
.
savepoint_commit_sql
(
sid
))
def
_savepoint_allowed
(
self
):
# Savepoints cannot be created outside a transaction
return
self
.
features
.
uses_savepoints
and
not
self
.
autocommit
##### Generic savepoint management methods #####
def
savepoint
(
self
):
"""
Creates a savepoint
(if supported and required by the backend) inside the
current transaction. Returns an identifier for the savepoint that will be
used for the subsequent rollback or commit
.
Creates a savepoint
inside the current transaction. Returns an
identifier for the savepoint that will be used for the subsequent
rollback or commit. Does nothing if savepoints are not supported
.
"""
if
not
self
.
_savepoint_allowed
():
return
thread_ident
=
thread
.
get_ident
()
tid
=
str
(
thread_ident
)
.
replace
(
'-'
,
''
)
self
.
savepoint_state
+=
1
tid
=
str
(
thread_ident
)
.
replace
(
'-'
,
''
)
sid
=
"s
%
s_x
%
d"
%
(
tid
,
self
.
savepoint_state
)
self
.
validate_thread_sharing
()
self
.
_savepoint
(
sid
)
return
sid
def
savepoint_rollback
(
self
,
sid
):
"""
Rolls back the most recent savepoint (if one exists). Does nothing if
savepoints are not supported.
Rolls back to a savepoint. Does nothing if savepoints are not supported.
"""
if
not
self
.
_savepoint_allowed
():
return
self
.
validate_thread_sharing
()
if
self
.
savepoint_state
:
self
.
_savepoint_rollback
(
sid
)
self
.
_savepoint_rollback
(
sid
)
def
savepoint_commit
(
self
,
sid
):
"""
Commits the most recent savepoint (if one exists). Does nothing if
savepoints are not supported.
Releases a savepoint. Does nothing if savepoints are not supported.
"""
if
not
self
.
_savepoint_allowed
():
return
self
.
validate_thread_sharing
()
if
self
.
savepoint_state
:
self
.
_savepoint_commit
(
sid
)
self
.
_savepoint_commit
(
sid
)
def
clean_savepoints
(
self
):
"""
...
...
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