Skip to content

Commit 2326153

Browse files
committed
Add PostgreSQL 12 support
PostgreSQL has a couple of incompatible configuration changes so adjust to that. Also, the new JIT is messing up with test timings, so disable it explicitly for the testsuite on 11+.
1 parent 32fccaa commit 2326153

File tree

6 files changed

+173
-67
lines changed

6 files changed

+173
-67
lines changed

.travis.yml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,87 +40,89 @@ matrix:
4040
# Do quick test runs for each supported version of PostgreSQL
4141
# minus the latest.
4242
- os: linux
43-
dist: trusty
44-
sudo: false
43+
dist: xenial
4544
language: python
4645
python: "3.6"
4746
env: BUILD=quicktests PGVERSION=9.2
4847
addons:
49-
apt: {packages: [postgresql-9.2]}
48+
apt: {packages: [postgresql-9.2, postgresql-contrib-9.2]}
5049

5150
- os: linux
52-
dist: trusty
53-
sudo: false
51+
dist: xenial
5452
language: python
5553
python: "3.6"
5654
env: BUILD=quicktests PGVERSION=9.3
5755
addons:
58-
apt: {packages: [postgresql-9.3]}
56+
apt: {packages: [postgresql-9.3, postgresql-contrib-9.3]}
5957

6058
- os: linux
61-
dist: trusty
62-
sudo: false
59+
dist: xenial
6360
language: python
6461
python: "3.6"
6562
env: BUILD=quicktests PGVERSION=9.4
6663
addons:
67-
apt: {packages: [postgresql-9.4]}
64+
apt: {packages: [postgresql-9.4, postgresql-contrib-9.4]}
6865

6966
- os: linux
70-
dist: trusty
71-
sudo: false
67+
dist: xenial
7268
language: python
7369
python: "3.6"
7470
env: BUILD=quicktests PGVERSION=9.5
7571
addons:
76-
apt: {packages: [postgresql-9.5]}
72+
apt: {packages: [postgresql-9.5, postgresql-contrib-9.5]}
7773

7874
- os: linux
79-
dist: trusty
80-
sudo: false
75+
dist: xenial
8176
language: python
8277
python: "3.6"
8378
env: BUILD=quicktests PGVERSION=9.6
8479
addons:
85-
apt: {packages: [postgresql-9.6]}
80+
apt: {packages: [postgresql-9.6, postgresql-contrib-9.6]}
8681

8782
- os: linux
88-
dist: trusty
89-
sudo: false
83+
dist: xenial
9084
language: python
9185
python: "3.6"
9286
env: BUILD=quicktests PGVERSION=10
9387
addons:
9488
apt: {packages: [postgresql-10]}
9589

90+
- os: linux
91+
dist: xenial
92+
language: python
93+
python: "3.6"
94+
env: BUILD=quicktests PGVERSION=11
95+
addons:
96+
apt: {packages: [postgresql-11]}
97+
9698
# Do a full test run on the latest supported version of PostgreSQL
9799
# on each supported version of Python.
98100
- os: linux
99101
dist: xenial
100102
sudo: required
101103
language: python
102104
python: "3.5"
103-
env: BUILD=tests PGVERSION=11
105+
env: BUILD=tests PGVERSION=12
104106
addons:
105-
apt: {packages: [postgresql-11]}
107+
apt: {packages: [postgresql-12]}
106108

107109
- os: linux
108110
dist: xenial
109111
sudo: required
110112
language: python
111113
python: "3.6"
112-
env: BUILD=tests PGVERSION=11
114+
env: BUILD=tests PGVERSION=12
113115
addons:
114-
apt: {packages: [postgresql-11]}
116+
apt: {packages: [postgresql-12]}
115117

116118
- os: linux
117119
dist: xenial
118120
sudo: true
119121
language: python
120122
python: "3.7"
121-
env: BUILD=tests PGVERSION=11
123+
env: BUILD=tests PGVERSION=12
122124
addons:
123-
apt: {packages: [postgresql-11]}
125+
apt: {packages: [postgresql-12]}
124126

125127
# Build manylinux wheels. Each wheel will be tested,
126128
# so there is no need for BUILD=tests here.
@@ -131,19 +133,19 @@ matrix:
131133
sudo: required
132134
language: python
133135
python: "3.6"
134-
env: BUILD=wheels,docs,release PGVERSION=11
136+
env: BUILD=wheels,docs,release PGVERSION=12
135137
services: [docker]
136138
addons:
137-
apt: {packages: [postgresql-11]}
139+
apt: {packages: [postgresql-12]}
138140

139141
- os: osx
140-
env: BUILD=tests,wheels PYTHON_VERSION=3.5.5 PGVERSION=10
142+
env: BUILD=tests,wheels PYTHON_VERSION=3.5.7 PGVERSION=10
141143

142144
- os: osx
143-
env: BUILD=tests,wheels PYTHON_VERSION=3.6.5 PGVERSION=10
145+
env: BUILD=tests,wheels PYTHON_VERSION=3.6.9 PGVERSION=10
144146

145147
- os: osx
146-
env: BUILD=tests,wheels PYTHON_VERSION=3.7.0 PGVERSION=10
148+
env: BUILD=tests,wheels PYTHON_VERSION=3.7.4 PGVERSION=10
147149

148150
cache:
149151
pip

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ framework. You can read more about asyncpg in an introductory
1717
`blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
1818

1919
asyncpg requires Python 3.5 or later and is supported for PostgreSQL
20-
versions 9.2 to 11.
20+
versions 9.2 to 12.
2121

2222

2323
Documentation

asyncpg/_testbase/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,17 @@ def create_pool(dsn=None, *,
279279
class ClusterTestCase(TestCase):
280280
@classmethod
281281
def get_server_settings(cls):
282-
return {
282+
settings = {
283283
'log_connections': 'on'
284284
}
285285

286+
if cls.cluster.get_pg_version() >= (11, 0):
287+
# JITting messes up timing tests, and
288+
# is not essential for testing.
289+
settings['jit'] = 'off'
290+
291+
return settings
292+
286293
@classmethod
287294
def new_cluster(cls, ClusterCls, *, cluster_kwargs={}, initdb_options={}):
288295
cluster = _init_cluster(ClusterCls, cluster_kwargs,

asyncpg/cluster.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __init__(self, data_dir, *, pg_config_path=None):
7676
self._connection_addr = None
7777
self._connection_spec_override = None
7878

79+
def get_pg_version(self):
80+
return self._pg_version
81+
7982
def is_managed(self):
8083
return True
8184

@@ -620,17 +623,34 @@ def init(self, **settings):
620623
'pg_basebackup init exited with status {:d}:\n{}'.format(
621624
process.returncode, output.decode()))
622625

623-
with open(os.path.join(self._data_dir, 'recovery.conf'), 'w') as f:
624-
f.write(textwrap.dedent("""\
625-
standby_mode = 'on'
626-
primary_conninfo = 'host={host} port={port} user={user}'
627-
""".format(
628-
host=self._master['host'],
629-
port=self._master['port'],
630-
user=self._repl_user)))
626+
if self._pg_version <= (11, 0):
627+
with open(os.path.join(self._data_dir, 'recovery.conf'), 'w') as f:
628+
f.write(textwrap.dedent("""\
629+
standby_mode = 'on'
630+
primary_conninfo = 'host={host} port={port} user={user}'
631+
""".format(
632+
host=self._master['host'],
633+
port=self._master['port'],
634+
user=self._repl_user)))
635+
else:
636+
f = open(os.path.join(self._data_dir, 'standby.signal'), 'w')
637+
f.close()
631638

632639
return output.decode()
633640

641+
def start(self, wait=60, *, server_settings={}, **opts):
642+
if self._pg_version >= (12, 0):
643+
server_settings = server_settings.copy()
644+
server_settings['primary_conninfo'] = (
645+
'host={host} port={port} user={user}'.format(
646+
host=self._master['host'],
647+
port=self._master['port'],
648+
user=self._repl_user,
649+
)
650+
)
651+
652+
super().start(wait=wait, server_settings=server_settings, **opts)
653+
634654

635655
class RunningCluster(Cluster):
636656
def __init__(self, **kwargs):

0 commit comments

Comments
 (0)