Skip to content

Commit 655fc89

Browse files
author
James William Pye
committed
Merge branch 'v1.1' into v1.0
Conflicts: postgresql/test/test_driver.py postgresql/test/test_string.py
2 parents fddb5c2 + 06b6a7a commit 655fc89

13 files changed

Lines changed: 356 additions & 333 deletions

File tree

postgresql/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ def __call__(self, *args, **kw) -> (object, Cursor, collections.Iterable):
598598
"""
599599

600600
##
601-
# Arguably, it would be wiser to isolate blocks, prepared transactions, and
602-
# savepoints, but the utility of the separation is not significant. It's really
601+
# Arguably, it would be wiser to isolate blocks, and savepoints, but the utility
602+
# of the separation is not significant. It's really
603603
# more interesting as a formality that the user may explicitly state the
604604
# type of the transaction. However, this capability is not completely absent
605605
# from the current interface as the configuration parameters, or lack thereof,

postgresql/documentation/copyman.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Copy Management
55
***************
66

7-
.. warning:: `postgresql.copyman` is a new feature in v1.0.
8-
97
The `postgresql.copyman` module provides a way to quickly move COPY data coming
108
from one connection to many connections. Alternatively, it can be sourced
119
by arbitrary iterators and target arbitrary callables.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* sidebar.js
3+
* ~~~~~~~~~~
4+
*
5+
* This script makes the Sphinx sidebar collapsible.
6+
*
7+
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
8+
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
9+
* used to collapse and expand the sidebar.
10+
*
11+
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
12+
* and the width of the sidebar and the margin-left of the document
13+
* are decreased. When the sidebar is expanded the opposite happens.
14+
* This script saves a per-browser/per-session cookie used to
15+
* remember the position of the sidebar among the pages.
16+
* Once the browser is closed the cookie is deleted and the position
17+
* reset to the default (expanded).
18+
*
19+
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
20+
* :license: BSD, see LICENSE for details.
21+
*
22+
*/
23+
24+
$(function() {
25+
// global elements used by the functions.
26+
// the 'sidebarbutton' element is defined as global after its
27+
// creation, in the add_sidebar_button function
28+
var bodywrapper = $('.bodywrapper');
29+
var sidebar = $('.sphinxsidebar');
30+
var sidebarwrapper = $('.sphinxsidebarwrapper');
31+
32+
// original margin-left of the bodywrapper and width of the sidebar
33+
// with the sidebar expanded
34+
var bw_margin_expanded = bodywrapper.css('margin-left');
35+
var ssb_width_expanded = sidebar.width();
36+
37+
// margin-left of the bodywrapper and width of the sidebar
38+
// with the sidebar collapsed
39+
var bw_margin_collapsed = '.8em';
40+
var ssb_width_collapsed = '.8em';
41+
42+
// colors used by the current theme
43+
var dark_color = $('.related').css('background-color');
44+
var light_color = $('.document').css('background-color');
45+
46+
function sidebar_is_collapsed() {
47+
return sidebarwrapper.is(':not(:visible)');
48+
}
49+
50+
function toggle_sidebar() {
51+
if (sidebar_is_collapsed())
52+
expand_sidebar();
53+
else
54+
collapse_sidebar();
55+
}
56+
57+
function collapse_sidebar() {
58+
sidebarwrapper.hide();
59+
sidebar.css('width', ssb_width_collapsed);
60+
bodywrapper.css('margin-left', bw_margin_collapsed);
61+
sidebarbutton.css({
62+
'margin-left': '0',
63+
'height': bodywrapper.height()
64+
});
65+
sidebarbutton.find('span').text('»');
66+
sidebarbutton.attr('title', _('Expand sidebar'));
67+
document.cookie = 'sidebar=collapsed';
68+
}
69+
70+
function expand_sidebar() {
71+
bodywrapper.css('margin-left', bw_margin_expanded);
72+
sidebar.css('width', ssb_width_expanded);
73+
sidebarwrapper.show();
74+
sidebarbutton.css({
75+
'margin-left': ssb_width_expanded-12,
76+
'height': bodywrapper.height()
77+
});
78+
sidebarbutton.find('span').text('«');
79+
sidebarbutton.attr('title', _('Collapse sidebar'));
80+
document.cookie = 'sidebar=expanded';
81+
}
82+
83+
function add_sidebar_button() {
84+
sidebarwrapper.css({
85+
'float': 'left',
86+
'margin-right': '0',
87+
'width': ssb_width_expanded - 28
88+
});
89+
// create the button
90+
sidebar.append(
91+
'<div id="sidebarbutton"><span>&laquo;</span></div>'
92+
);
93+
var sidebarbutton = $('#sidebarbutton');
94+
// find the height of the viewport to center the '<<' in the page
95+
var viewport_height;
96+
if (window.innerHeight)
97+
viewport_height = window.innerHeight;
98+
else
99+
viewport_height = $(window).height();
100+
sidebarbutton.find('span').css({
101+
'display': 'block',
102+
'margin-top': (viewport_height - sidebar.position().top - 20) / 2
103+
});
104+
105+
sidebarbutton.click(toggle_sidebar);
106+
sidebarbutton.attr('title', _('Collapse sidebar'));
107+
sidebarbutton.css({
108+
'color': '#FFFFFF',
109+
'border-left': '1px solid ' + dark_color,
110+
'font-size': '1.2em',
111+
'cursor': 'pointer',
112+
'height': bodywrapper.height(),
113+
'padding-top': '1px',
114+
'margin-left': ssb_width_expanded - 12
115+
});
116+
117+
sidebarbutton.hover(
118+
function () {
119+
$(this).css('background-color', dark_color);
120+
},
121+
function () {
122+
$(this).css('background-color', light_color);
123+
}
124+
);
125+
}
126+
127+
function set_position_from_cookie() {
128+
if (!document.cookie)
129+
return;
130+
var items = document.cookie.split(';');
131+
for(var k=0; k<items.length; k++) {
132+
var key_val = items[k].split('=');
133+
var key = key_val[0];
134+
if (key == 'sidebar') {
135+
var value = key_val[1];
136+
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
137+
collapse_sidebar();
138+
else if ((value == 'expanded') && (sidebar_is_collapsed()))
139+
expand_sidebar();
140+
}
141+
}
142+
}
143+
144+
add_sidebar_button();
145+
var sidebarbutton = $('#sidebarbutton');
146+
set_position_from_cookie();
147+
});

postgresql/documentation/html/_static/underscore.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postgresql/documentation/notifyman.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Notification Management
55
***********************
66

7-
.. warning:: `postgresql.notifyman` is a new feature in v1.0.
8-
97
Relevant SQL commands: `NOTIFY <http://postgresql.org/docs/current/static/sql-notify.html>`_,
108
`LISTEN <http://postgresql.org/docs/current/static/sql-listen.html>`_,
119
`UNLISTEN <http://postgresql.org/docs/current/static/sql-unlisten.html>`_.

postgresql/driver/pq3.py

Lines changed: 14 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def sql_type_from_oid(self, oid, qi = quote_ident):
207207
if oid in self.typinfo:
208208
nsp, name, *_ = self.typinfo[oid]
209209
return qi(nsp) + '.' + qi(name)
210-
return 'pg_catalog.' + pg_types.oid_to_name.get(oid)
210+
name = pg_types.oid_to_name.get(oid)
211+
if name:
212+
return 'pg_catalog.%s' % name
213+
else:
214+
return None
211215

212216
def type_from_oid(self, oid):
213217
if oid in self._cache:
@@ -2038,19 +2042,14 @@ class Transaction(pg_api.Transaction):
20382042

20392043
mode = None
20402044
isolation = None
2041-
gid = None
20422045

2043-
_e_factors = ('database', 'gid', 'isolation', 'mode')
2046+
_e_factors = ('database', 'isolation', 'mode')
20442047

20452048
def _e_metas(self):
20462049
yield (None, self.state)
20472050

2048-
def __init__(self, database, isolation = None, mode = None, gid = None):
2051+
def __init__(self, database, isolation = None, mode = None):
20492052
self.database = database
2050-
self.gid = gid
2051-
if gid is not None:
2052-
# XXX: remove in 1.1
2053-
warnings.warn("two phase interfaces will not exist in 1.1; do not use the 'gid' parameter", DeprecationWarning, stacklevel=3)
20542053
self.isolation = isolation
20552054
self.mode = mode
20562055
self.state = 'initialized'
@@ -2081,26 +2080,10 @@ def __exit__(self, typ, value, tb):
20812080
# If an error occurs, clean up the transaction state
20822081
# and raise as needed.
20832082
except pg_exc.ActiveTransactionError as err:
2084-
##
2085-
# Failed COMMIT PREPARED <gid>?
2086-
# Likely cases:
2087-
# - User exited block without preparing the transaction.
2088-
##
2089-
if not self.database.closed and self.gid is not None:
2083+
if not self.database.closed:
20902084
# adjust the state so rollback will do the right thing and abort.
20912085
self.state = 'open'
20922086
self.rollback()
2093-
##
2094-
# The other exception that *can* occur is
2095-
# UndefinedObjectError in which:
2096-
# - User issued C/RB P <gid> before exit, but not via xact methods.
2097-
# - User adjusted gid after prepare().
2098-
#
2099-
# But the occurrence of this exception means it's not in an active
2100-
# transaction, which means no cleanup other than raise is necessary.
2101-
err.details['cause'] = \
2102-
"The prepared transaction was not " \
2103-
"prepared prior to the block's exit."
21042087
raise
21052088
elif issubclass(typ, Exception):
21062089
# There's an exception, so only rollback if the connection
@@ -2146,7 +2129,7 @@ def start(self):
21462129
)
21472130
else:
21482131
self.type = 'savepoint'
2149-
if (self.gid, self.isolation, self.mode) != (None,None,None):
2132+
if (self.isolation, self.mode) != (None,None):
21502133
em = element.ClientError((
21512134
(b'S', 'ERROR'),
21522135
(b'C', '--OPE'),
@@ -2159,60 +2142,15 @@ def start(self):
21592142
self.state = 'open'
21602143
begin = start
21612144

2162-
@staticmethod
2163-
def _prepare_string(id):
2164-
"2pc prepared transaction 'gid'"
2165-
return "PREPARE TRANSACTION '" + id.replace("'", "''") + "';"
2166-
21672145
@staticmethod
21682146
def _release_string(id):
21692147
'release "";'
21702148
return 'RELEASE "xact(' + id.replace('"', '""') + ')";'
21712149

2172-
def prepare(self):
2173-
if self.state == 'prepared':
2174-
return
2175-
if self.state != 'open':
2176-
em = element.ClientError((
2177-
(b'S', 'ERROR'),
2178-
(b'C', '--OPE'),
2179-
(b'M', "transaction state must be 'open' in order to prepare"),
2180-
))
2181-
self.database.typio.raise_client_error(em, creator = self)
2182-
if self.type != 'block':
2183-
em = element.ClientError((
2184-
(b'S', 'ERROR'),
2185-
(b'C', '--OPE'),
2186-
(b'M', "improper transaction type to prepare"),
2187-
))
2188-
self.database.typio.raise_client_error(em, creator = self)
2189-
q = self._prepare_string(self.gid)
2190-
self.database.execute(q)
2191-
self.state = 'prepared'
2192-
2193-
def recover(self):
2194-
if self.state != 'initialized':
2195-
em = element.ClientError((
2196-
(b'S', 'ERROR'),
2197-
(b'C', '--OPE'),
2198-
(b'M', "improper state for prepared transaction recovery"),
2199-
))
2200-
self.database.typio.raise_client_error(em, creator = self)
2201-
if self.database.sys.xact_is_prepared(self.gid):
2202-
self.state = 'prepared'
2203-
self.type = 'block'
2204-
else:
2205-
em = element.ClientError((
2206-
(b'S', 'ERROR'),
2207-
(b'C', '42704'), # UndefinedObjectError
2208-
(b'M', "prepared transaction does not exist"),
2209-
))
2210-
self.database.typio.raise_client_error(em, creator = self)
2211-
22122150
def commit(self):
22132151
if self.state == 'committed':
22142152
return
2215-
if self.state not in ('prepared', 'open'):
2153+
if self.state != 'open':
22162154
em = element.ClientError((
22172155
(b'S', 'ERROR'),
22182156
(b'C', '--OPE'),
@@ -2221,19 +2159,8 @@ def commit(self):
22212159
self.database.typio.raise_client_error(em, creator = self)
22222160

22232161
if self.type == 'block':
2224-
if self.gid is not None:
2225-
# User better have prepared it.
2226-
q = "COMMIT PREPARED '" + self.gid.replace("'", "''") + "';"
2227-
else:
2228-
q = 'COMMIT'
2162+
q = 'COMMIT'
22292163
else:
2230-
if self.gid is not None:
2231-
em = element.ClientError((
2232-
(b'S', 'ERROR'),
2233-
(b'C', '--OPE'),
2234-
(b'M', "savepoint configured with global identifier"),
2235-
))
2236-
self.database.typio.raise_client_error(em, creator = self)
22372164
q = self._release_string(hex(id(self)))
22382165
self.database.execute(q)
22392166
self.state = 'committed'
@@ -2254,10 +2181,7 @@ def rollback(self):
22542181
self.database.typio.raise_client_error(em, creator = self)
22552182

22562183
if self.type == 'block':
2257-
if self.state == 'prepared':
2258-
q = "ROLLBACK PREPARED '" + self.gid.replace("'", "''") + "'"
2259-
else:
2260-
q = 'ABORT;'
2184+
q = 'ABORT;'
22612185
elif self.type == 'savepoint':
22622186
q = self._rollback_to_string(hex(id(self)))
22632187
else:
@@ -2339,8 +2263,8 @@ def do(self, language : str, source : str,
23392263
sql = "DO " + qlit(source) + " LANGUAGE " + qid(language) + ";"
23402264
self.execute(sql)
23412265

2342-
def xact(self, gid = None, isolation = None, mode = None):
2343-
x = Transaction(self, gid = gid, isolation = isolation, mode = mode)
2266+
def xact(self, isolation = None, mode = None):
2267+
x = Transaction(self, isolation = isolation, mode = mode)
23442268
return x
23452269

23462270
def prepare(self,

postgresql/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# Set this to the target date when approaching a release.
1313
date = None
1414
tags = set(())
15-
version_info = (1, 0, 3)
15+
version_info = (1, 1, 0)
1616
version = '.'.join(map(str, version_info)) + (date is None and 'dev' or '')

0 commit comments

Comments
 (0)