Remove support for PostgrSQL server < 8.2

This commit is contained in:
Jon Dufresne 2020-02-09 07:15:56 -08:00
parent 9bcca1a7b0
commit 0654cf5a8e
27 changed files with 35 additions and 188 deletions

5
NEWS
View File

@ -1,6 +1,11 @@
Current release
---------------
UNRELEASED
^^^^^^^^^^
- Removed support for PostgreSQL server < 8.2.
What's new in psycopg 2.8.5
^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -36,7 +36,7 @@ The current `!psycopg2` implementation supports:
- Python version 2.7
- Python 3 versions from 3.4 to 3.8
- PostgreSQL server versions from 7.4 to 12
- PostgreSQL server versions from 8.2 to 12
- PostgreSQL client library version from 9.1

View File

@ -199,15 +199,6 @@ HIDDEN void conn_set_error(connectionObject *self, const char *msg);
return NULL; \
}
#define EXC_IF_TPC_NOT_SUPPORTED(self) \
if ((self)->server_version < 80100) { \
PyErr_Format(NotSupportedError, \
"server version %d: " \
"two-phase transactions not supported", \
(self)->server_version); \
return NULL; \
}
#define EXC_IF_TPC_BEGIN(self, cmd) if ((self)->tpc_xid) { \
PyErr_Format(ProgrammingError, "%s cannot be used " \
"during a two-phase transaction", #cmd); \

View File

@ -1279,16 +1279,6 @@ conn_set_session(connectionObject *self, int autocommit,
goto exit;
}
/* Promote an isolation level to one of the levels supported by the server */
if (self->server_version < 80000) {
if (isolevel == ISOLATION_LEVEL_READ_UNCOMMITTED) {
isolevel = ISOLATION_LEVEL_READ_COMMITTED;
}
else if (isolevel == ISOLATION_LEVEL_REPEATABLE_READ) {
isolevel = ISOLATION_LEVEL_SERIALIZABLE;
}
}
Py_BEGIN_ALLOW_THREADS;
pthread_mutex_lock(&self->lock);

View File

@ -193,7 +193,6 @@ static PyObject *
psyco_conn_xid(connectionObject *self, PyObject *args, PyObject *kwargs)
{
EXC_IF_CONN_CLOSED(self);
EXC_IF_TPC_NOT_SUPPORTED(self);
return PyObject_Call((PyObject *)&xidType, args, kwargs);
}
@ -211,7 +210,6 @@ psyco_conn_tpc_begin(connectionObject *self, PyObject *args)
EXC_IF_CONN_CLOSED(self);
EXC_IF_CONN_ASYNC(self, tpc_begin);
EXC_IF_TPC_NOT_SUPPORTED(self);
EXC_IF_IN_TRANSACTION(self, tpc_begin);
if (!PyArg_ParseTuple(args, "O", &oxid)) {
@ -365,7 +363,6 @@ psyco_conn_tpc_commit(connectionObject *self, PyObject *args)
{
EXC_IF_CONN_CLOSED(self);
EXC_IF_CONN_ASYNC(self, tpc_commit);
EXC_IF_TPC_NOT_SUPPORTED(self);
return _psyco_conn_tpc_finish(self, args,
conn_commit, "COMMIT PREPARED");
@ -379,7 +376,6 @@ psyco_conn_tpc_rollback(connectionObject *self, PyObject *args)
{
EXC_IF_CONN_CLOSED(self);
EXC_IF_CONN_ASYNC(self, tpc_rollback);
EXC_IF_TPC_NOT_SUPPORTED(self);
return _psyco_conn_tpc_finish(self, args,
conn_rollback, "ROLLBACK PREPARED");
@ -394,7 +390,6 @@ psyco_conn_tpc_recover(connectionObject *self, PyObject *dummy)
EXC_IF_CONN_CLOSED(self);
EXC_IF_CONN_ASYNC(self, tpc_recover);
EXC_IF_TPC_PREPARED(self, tpc_recover);
EXC_IF_TPC_NOT_SUPPORTED(self);
return conn_tpc_recover(self);
}

View File

@ -84,9 +84,9 @@ curs_close(cursorObject *self, PyObject *dummy)
* closed (#746).
*
* So if we didn't execute() check for the cursor existence before
* closing it (the view exists since PG 8.2 according to docs).
* closing it.
*/
if (!self->query && self->conn->server_version >= 80200) {
if (!self->query) {
if (!(lname = psyco_escape_string(
self->conn, self->name, -1, NULL, NULL))) {
goto exit;

View File

@ -360,8 +360,7 @@ pq_begin_locked(connectionObject *conn, PyThreadState **tstate)
}
else {
snprintf(buf, bufsize,
conn->server_version >= 80000 ?
"BEGIN%s%s%s%s" : "BEGIN;SET TRANSACTION%s%s%s%s",
"BEGIN%s%s%s%s",
(conn->isolevel >= 1 && conn->isolevel <= 4)
? " ISOLATION LEVEL " : "",
(conn->isolevel >= 1 && conn->isolevel <= 4)

View File

@ -128,9 +128,6 @@ fi
# Unsupported postgres versions that we still support
# Images built by https://github.com/psycopg/psycopg2-wheels/tree/build-dinosaurs
if (( "$TEST_PAST" )); then
create 7.4
create 8.0
create 8.1
create 8.2
create 8.3
create 8.4

View File

@ -64,9 +64,6 @@ if (( "$TEST_PAST" )); then
run_test 8.4
run_test 8.3
run_test 8.2
run_test 8.1
run_test 8.0
run_test 7.4
fi
# Postgres built from master

View File

@ -101,7 +101,6 @@ class AsyncTests(ConnectingTestCase):
self.assertEquals(cur.fetchone()[0], "a")
@slow
@skip_before_postgres(8, 2)
def test_async_callproc(self):
cur = self.conn.cursor()
cur.callproc("pg_sleep", (0.1, ))
@ -460,7 +459,6 @@ class AsyncTests(ConnectingTestCase):
else:
self.fail("no exception raised")
@skip_before_postgres(8, 2)
def test_copy_no_hang(self):
cur = self.conn.cursor()
cur.execute("copy (select 1) to stdout")

View File

@ -103,7 +103,6 @@ class CancelTests(ConnectingTestCase):
self.conn.commit()
@slow
@skip_before_postgres(8, 2)
def test_async_cancel(self):
async_conn = psycopg2.connect(dsn, async=True)
self.assertRaises(psycopg2.OperationalError, async_conn.cancel)

View File

@ -33,7 +33,7 @@ from psycopg2 import extras
from .testconfig import dsn
import unittest
from .testutils import ConnectingTestCase, skip_before_postgres, slow
from .testutils import ConnectingTestCase, slow
class CancelTests(ConnectingTestCase):
@ -52,7 +52,6 @@ class CancelTests(ConnectingTestCase):
self.conn.cancel()
@slow
@skip_before_postgres(8, 2)
def test_cancel(self):
errors = []
@ -90,7 +89,6 @@ class CancelTests(ConnectingTestCase):
self.assertEqual(errors, [])
@slow
@skip_before_postgres(8, 2)
def test_async_cancel(self):
async_conn = psycopg2.connect(dsn, async_=True)
self.assertRaises(psycopg2.OperationalError, async_conn.cancel)

View File

@ -202,16 +202,7 @@ class ConnectionTests(ConnectingTestCase):
self.assert_(self.conn.protocol_version in (2, 3),
self.conn.protocol_version)
def test_tpc_unsupported(self):
cnn = self.conn
if cnn.info.server_version >= 80100:
return self.skipTest("tpc is supported")
self.assertRaises(psycopg2.NotSupportedError,
cnn.xid, 42, "foo", "bar")
@slow
@skip_before_postgres(8, 2)
def test_concurrent_execution(self):
def slave():
cnn = self.connect()
@ -595,13 +586,6 @@ class IsolationLevelsTestCase(ConnectingTestCase):
for name, level in levels:
conn.set_isolation_level(level)
# the only values available on prehistoric PG versions
if conn.info.server_version < 80000:
if level in (
ext.ISOLATION_LEVEL_READ_UNCOMMITTED,
ext.ISOLATION_LEVEL_REPEATABLE_READ):
name, level = levels[levels.index((name, level)) + 1]
self.assertEqual(conn.isolation_level, level)
curs.execute('show transaction_isolation;')
@ -776,14 +760,9 @@ class IsolationLevelsTestCase(ConnectingTestCase):
self.conn.isolation_level = ext.ISOLATION_LEVEL_REPEATABLE_READ
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_REPEATABLE_READ)
self.assertEqual(cur.fetchone()[0], 'repeatable read')
else:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_SERIALIZABLE)
self.assertEqual(cur.fetchone()[0], 'serializable')
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_REPEATABLE_READ)
self.assertEqual(cur.fetchone()[0], 'repeatable read')
self.conn.rollback()
self.conn.isolation_level = ext.ISOLATION_LEVEL_READ_COMMITTED
@ -795,14 +774,9 @@ class IsolationLevelsTestCase(ConnectingTestCase):
self.conn.isolation_level = ext.ISOLATION_LEVEL_READ_UNCOMMITTED
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_UNCOMMITTED)
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
else:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_COMMITTED)
self.assertEqual(cur.fetchone()[0], 'read committed')
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_UNCOMMITTED)
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
self.conn.rollback()
self.assertEqual(ext.ISOLATION_LEVEL_DEFAULT, None)
@ -824,14 +798,9 @@ class IsolationLevelsTestCase(ConnectingTestCase):
self.conn.isolation_level = "repeatable read"
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_REPEATABLE_READ)
self.assertEqual(cur.fetchone()[0], 'repeatable read')
else:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_SERIALIZABLE)
self.assertEqual(cur.fetchone()[0], 'serializable')
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_REPEATABLE_READ)
self.assertEqual(cur.fetchone()[0], 'repeatable read')
self.conn.rollback()
self.conn.isolation_level = "read committed"
@ -843,14 +812,9 @@ class IsolationLevelsTestCase(ConnectingTestCase):
self.conn.isolation_level = "read uncommitted"
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_UNCOMMITTED)
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
else:
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_COMMITTED)
self.assertEqual(cur.fetchone()[0], 'read committed')
self.assertEqual(self.conn.isolation_level,
ext.ISOLATION_LEVEL_READ_UNCOMMITTED)
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
self.conn.rollback()
self.conn.isolation_level = "default"
@ -1265,10 +1229,7 @@ class TransactionControlTests(ConnectingTestCase):
self.conn.set_session(
ext.ISOLATION_LEVEL_REPEATABLE_READ)
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(cur.fetchone()[0], 'repeatable read')
else:
self.assertEqual(cur.fetchone()[0], 'serializable')
self.assertEqual(cur.fetchone()[0], 'repeatable read')
self.conn.rollback()
self.conn.set_session(
@ -1280,10 +1241,7 @@ class TransactionControlTests(ConnectingTestCase):
self.conn.set_session(
isolation_level=ext.ISOLATION_LEVEL_READ_UNCOMMITTED)
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
else:
self.assertEqual(cur.fetchone()[0], 'read committed')
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
self.conn.rollback()
def test_set_isolation_level_str(self):
@ -1295,10 +1253,7 @@ class TransactionControlTests(ConnectingTestCase):
self.conn.set_session("repeatable read")
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(cur.fetchone()[0], 'repeatable read')
else:
self.assertEqual(cur.fetchone()[0], 'serializable')
self.assertEqual(cur.fetchone()[0], 'repeatable read')
self.conn.rollback()
self.conn.set_session("read committed")
@ -1308,10 +1263,7 @@ class TransactionControlTests(ConnectingTestCase):
self.conn.set_session("read uncommitted")
cur.execute("SHOW transaction_isolation;")
if self.conn.info.server_version > 80000:
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
else:
self.assertEqual(cur.fetchone()[0], 'read committed')
self.assertEqual(cur.fetchone()[0], 'read uncommitted')
self.conn.rollback()
def test_bad_isolation_level(self):
@ -1685,7 +1637,6 @@ class PasswordLeakTestCase(ConnectingTestCase):
class SignalTestCase(ConnectingTestCase):
@slow
@skip_before_postgres(8, 2)
def test_bug_551_returning(self):
# Raise an exception trying to decode 'id'
self._test_bug_551(query="""

View File

@ -27,7 +27,7 @@ import io
import sys
import string
import unittest
from .testutils import (ConnectingTestCase, skip_before_postgres, slow, StringIO)
from .testutils import ConnectingTestCase, slow, StringIO
from itertools import cycle
from subprocess import Popen, PIPE
@ -276,7 +276,6 @@ class CopyTests(ConnectingTestCase):
curs.execute("select count(*) from manycols;")
self.assertEqual(curs.fetchone()[0], 2)
@skip_before_postgres(8, 2) # they don't send the count
def test_copy_rowcount(self):
curs = self.conn.cursor()

View File

@ -335,7 +335,6 @@ class CursorTests(ConnectingTestCase):
self.assertRaises(psycopg2.OperationalError, curs.scroll, -1)
@slow
@skip_before_postgres(8, 2)
def test_iter_named_cursor_efficient(self):
curs = self.conn.cursor('tmp')
# if these records are fetched in the same roundtrip their
@ -349,7 +348,6 @@ class CursorTests(ConnectingTestCase):
"named cursor records fetched in 2 roundtrips (delta: %s)"
% (t2 - t1))
@skip_before_postgres(8, 0)
def test_iter_named_cursor_default_itersize(self):
curs = self.conn.cursor('tmp')
curs.execute('select generate_series(1,50)')
@ -357,7 +355,6 @@ class CursorTests(ConnectingTestCase):
# everything swallowed in one gulp
self.assertEqual(rv, [(i, i) for i in range(1, 51)])
@skip_before_postgres(8, 0)
def test_iter_named_cursor_itersize(self):
curs = self.conn.cursor('tmp')
curs.itersize = 30
@ -366,7 +363,6 @@ class CursorTests(ConnectingTestCase):
# everything swallowed in two gulps
self.assertEqual(rv, [(i, ((i - 1) % 30) + 1) for i in range(1, 51)])
@skip_before_postgres(8, 0)
def test_iter_named_cursor_rownumber(self):
curs = self.conn.cursor('tmp')
# note: this fails if itersize < dataset: internally we check
@ -443,7 +439,6 @@ class CursorTests(ConnectingTestCase):
self.assertEqual(description, unpickled)
@skip_before_postgres(8, 0)
def test_named_cursor_stealing(self):
# you can use a named cursor to iterate on a refcursor created
# somewhere else
@ -457,12 +452,10 @@ class CursorTests(ConnectingTestCase):
self.assertEqual([(2,), (3,), (4,)], cur2.fetchmany(3))
self.assertEqual([(5,), (6,), (7,)], cur2.fetchall())
@skip_before_postgres(8, 2)
def test_named_noop_close(self):
cur = self.conn.cursor('test')
cur.close()
@skip_before_postgres(8, 2)
def test_stolen_named_cursor_close(self):
cur1 = self.conn.cursor()
cur1.execute("DECLARE test CURSOR WITHOUT HOLD "
@ -475,7 +468,6 @@ class CursorTests(ConnectingTestCase):
cur2 = self.conn.cursor('test')
cur2.close()
@skip_before_postgres(8, 0)
def test_scroll(self):
cur = self.conn.cursor()
cur.execute("select generate_series(0,9)")
@ -509,7 +501,6 @@ class CursorTests(ConnectingTestCase):
self.assertRaises((IndexError, psycopg2.ProgrammingError),
cur.scroll, 1)
@skip_before_postgres(8, 0)
def test_scroll_named(self):
cur = self.conn.cursor('tmp', scrollable=True)
cur.execute("select generate_series(0,9)")
@ -636,7 +627,6 @@ class CursorTests(ConnectingTestCase):
self.assertEqual(victim_conn.closed, 2)
@skip_before_postgres(8, 2)
def test_rowcount_on_executemany_returning(self):
cur = self.conn.cursor()
cur.execute("create table execmany(id serial primary key, data int)")

View File

@ -321,7 +321,6 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin):
def test_type_roundtrip_interval_array(self):
self._test_type_roundtrip_array(timedelta(seconds=30))
@skip_before_postgres(8, 1)
def test_time_24(self):
t = self.execute("select '24:00'::time;")
self.assertEqual(t, time(0, 0))
@ -332,7 +331,6 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin):
t = self.execute("select '24:00+05:30'::timetz;")
self.assertEqual(t, time(0, 0, tzinfo=FixedOffsetTimezone(330)))
@skip_before_postgres(8, 1)
def test_large_interval(self):
t = self.execute("select '999999:00:00'::interval")
self.assertEqual(total_seconds(t), 999999 * 60 * 60)

View File

@ -25,8 +25,7 @@ from psycopg2.compat import lru_cache
import psycopg2.extras
from psycopg2.extras import NamedTupleConnection, NamedTupleCursor
from .testutils import ConnectingTestCase, skip_before_postgres, \
skip_before_python, skip_from_python
from .testutils import ConnectingTestCase, skip_before_python, skip_from_python
class _DictCursorBase(ConnectingTestCase):
@ -97,7 +96,6 @@ class ExtrasDictCursorTests(_DictCursorBase):
self.failUnless(row['foo'] == 'qux')
self.failUnless(row[0] == 'qux')
@skip_before_postgres(8, 0)
def testDictCursorWithPlainCursorIterRowNumber(self):
curs = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
self._testIterRowNumber(curs)
@ -128,12 +126,10 @@ class ExtrasDictCursorTests(_DictCursorBase):
return row
self._testWithNamedCursor(getter)
@skip_before_postgres(8, 2)
def testDictCursorWithNamedCursorNotGreedy(self):
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor)
self._testNamedCursorNotGreedy(curs)
@skip_before_postgres(8, 0)
def testDictCursorWithNamedCursorIterRowNumber(self):
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor)
self._testIterRowNumber(curs)
@ -246,7 +242,6 @@ class ExtrasDictCursorRealTests(_DictCursorBase):
return row
self._testWithPlainCursorReal(getter)
@skip_before_postgres(8, 0)
def testDictCursorWithPlainCursorRealIterRowNumber(self):
curs = self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
self._testIterRowNumber(curs)
@ -285,12 +280,10 @@ class ExtrasDictCursorRealTests(_DictCursorBase):
return row
self._testWithNamedCursorReal(getter)
@skip_before_postgres(8, 2)
def testDictCursorRealWithNamedCursorNotGreedy(self):
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor)
self._testNamedCursorNotGreedy(curs)
@skip_before_postgres(8, 0)
def testDictCursorRealWithNamedCursorIterRowNumber(self):
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor)
self._testIterRowNumber(curs)
@ -524,7 +517,6 @@ class NamedTupleCursorTest(ConnectingTestCase):
self.assertEqual(rv.f3, 3)
@skip_before_python(3)
@skip_before_postgres(8)
def test_nonascii_name(self):
curs = self.conn.cursor()
curs.execute('select 1 as \xe5h\xe9')
@ -563,7 +555,6 @@ class NamedTupleCursorTest(ConnectingTestCase):
finally:
NamedTupleCursor._make_nt = f_orig
@skip_before_postgres(8, 0)
def test_named(self):
curs = self.conn.cursor('tmp')
curs.execute("""select i from generate_series(0,9) i""")
@ -591,7 +582,6 @@ class NamedTupleCursorTest(ConnectingTestCase):
recs = curs.fetchall()
self.assertEqual(recs[0].i, 42)
@skip_before_postgres(8, 2)
def test_not_greedy(self):
curs = self.conn.cursor('tmp')
curs.itersize = 2
@ -605,7 +595,6 @@ class NamedTupleCursorTest(ConnectingTestCase):
self.assert_(recs[1].ts - recs[0].ts < timedelta(seconds=0.005))
self.assert_(recs[2].ts - recs[1].ts > timedelta(seconds=0.0099))
@skip_before_postgres(8, 0)
def test_named_rownumber(self):
curs = self.conn.cursor('tmp')
# Only checking for dataset < itersize:

View File

@ -107,7 +107,6 @@ class TestExecuteBatch(FastExecuteTestMixin, testutils.ConnectingTestCase):
cur.execute("select id, val from testfast order by id")
self.assertEqual(cur.fetchall(), [(i, i * 10) for i in range(25)])
@testutils.skip_before_postgres(8, 0)
def test_unicode(self):
cur = self.conn.cursor()
ext.register_type(ext.UNICODE, cur)
@ -135,7 +134,6 @@ class TestExecuteBatch(FastExecuteTestMixin, testutils.ConnectingTestCase):
self.assertEqual(cur.fetchone(), (3, snowman))
@testutils.skip_before_postgres(8, 2)
class TestExecuteValues(FastExecuteTestMixin, testutils.ConnectingTestCase):
def test_empty(self):
cur = self.conn.cursor()

View File

@ -115,7 +115,6 @@ class GreenTestCase(ConnectingTestCase):
curs.execute("select 1")
self.assertEqual(curs.fetchone()[0], 1)
@skip_before_postgres(8, 2)
def test_copy_no_hang(self):
cur = self.conn.cursor()
self.assertRaises(psycopg2.ProgrammingError,

View File

@ -49,7 +49,6 @@ class NetworkingTestCase(testutils.ConnectingTestCase):
self.assert_(isinstance(obj, ip.IPv6Interface), repr(obj))
self.assertEquals(obj, ip.ip_interface('::ffff:102:300/128'))
@testutils.skip_before_postgres(8, 2)
def test_inet_array_cast(self):
cur = self.conn.cursor()
psycopg2.extras.register_ipaddress(cur)
@ -88,7 +87,6 @@ class NetworkingTestCase(testutils.ConnectingTestCase):
self.assert_(isinstance(obj, ip.IPv6Network), repr(obj))
self.assertEquals(obj, ip.ip_network('::ffff:102:300/128'))
@testutils.skip_before_postgres(8, 2)
def test_cidr_array_cast(self):
cur = self.conn.cursor()
psycopg2.extras.register_ipaddress(cur)

View File

@ -32,12 +32,9 @@ import psycopg2
import psycopg2.extensions
import unittest
from .testutils import (decorate_all_tests, skip_if_tpc_disabled,
skip_before_postgres, ConnectingTestCase, skip_if_green, slow)
ConnectingTestCase, skip_if_green, slow)
skip_if_no_lo = skip_before_postgres(8, 1,
"large objects only supported from PG 8.1")
skip_lo_if_green = skip_if_green("libpq doesn't support LO in async mode")
@ -66,7 +63,6 @@ class LargeObjectTestCase(ConnectingTestCase):
ConnectingTestCase.tearDown(self)
@skip_if_no_lo
@skip_lo_if_green
class LargeObjectTests(LargeObjectTestCase):
def test_create(self):
@ -412,7 +408,6 @@ def skip_if_no_truncate(f):
return skip_if_no_truncate_
@skip_if_no_lo
@skip_lo_if_green
@skip_if_no_truncate
class LargeObjectTruncateTests(LargeObjectTestCase):
@ -477,7 +472,6 @@ def skip_if_no_lo64(f):
return skip_if_no_lo64_
@skip_if_no_lo
@skip_lo_if_green
@skip_if_no_truncate
@skip_if_no_lo64
@ -505,7 +499,6 @@ def skip_if_lo64(f):
return skip_if_lo64_
@skip_if_no_lo
@skip_lo_if_green
@skip_if_no_truncate
@skip_if_lo64

View File

@ -42,10 +42,9 @@ class QuotingTestCase(ConnectingTestCase):
This test case checks that the E'' quotes are used whenever they are
needed. The tests are expected to pass with all PostgreSQL server versions
(currently tested with 7.4 <= PG <= 8.3beta) and with any
'standard_conforming_strings' server parameter value.
The tests also check that no warning is raised ('escape_string_warning'
should be on).
and with any 'standard_conforming_strings' server parameter value. The
tests also check that no warning is raised ('escape_string_warning' should
be on).
https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
https://www.postgresql.org/docs/current/static/runtime-config-compatible.html
@ -198,7 +197,6 @@ class TestQuotedIdentifier(ConnectingTestCase):
self.assertEqual(quote_ident('blah-blah', self.conn), '"blah-blah"')
self.assertEqual(quote_ident('quote"inside', self.conn), '"quote""inside"')
@testutils.skip_before_postgres(8, 0)
def test_unicode_ident(self):
snowman = u"\u2603"
quoted = '"' + snowman + '"'

View File

@ -25,8 +25,7 @@
import datetime as dt
import unittest
from .testutils import (
ConnectingTestCase, skip_before_postgres, skip_copy_if_green, StringIO)
from .testutils import ConnectingTestCase, skip_copy_if_green, StringIO
import psycopg2
from psycopg2 import sql
@ -152,7 +151,6 @@ class SqlFormatTests(ConnectingTestCase):
[(10, 'a', 'b', 'c'), (20, 'd', 'e', 'f')])
@skip_copy_if_green
@skip_before_postgres(8, 2)
def test_copy(self):
cur = self.conn.cursor()
cur.execute("""

View File

@ -25,7 +25,7 @@
import threading
import unittest
from .testutils import ConnectingTestCase, skip_before_postgres, slow
from .testutils import ConnectingTestCase, slow
import psycopg2
from psycopg2.extensions import (
@ -238,7 +238,6 @@ class QueryCancellationTests(ConnectingTestCase):
ConnectingTestCase.setUp(self)
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
@skip_before_postgres(8, 2)
def test_statement_timeout(self):
curs = self.conn.cursor()
# Set a low statement timeout, then sleep for a longer period.

View File

@ -235,7 +235,6 @@ class TypesBasicTests(ConnectingTestCase):
self.assert_(isinstance(x[0], bytes))
self.assertEqual(x, [b'a', b'b', b'c'])
@testutils.skip_before_postgres(8, 2)
def testArrayOfNulls(self):
curs = self.conn.cursor()
curs.execute("""
@ -271,7 +270,6 @@ class TypesBasicTests(ConnectingTestCase):
curs.execute("insert into na (boolaa) values (%s)", ([[True, None]],))
curs.execute("insert into na (boolaa) values (%s)", ([[None, None]],))
@testutils.skip_before_postgres(8, 2)
def testNestedArrays(self):
curs = self.conn.cursor()
for a in [
@ -385,7 +383,6 @@ class TypesBasicTests(ConnectingTestCase):
a = self.execute("select array['a', 'b', '''']::text[]")
self.assertEqual(a, ['a', 'b', "'"])
@testutils.skip_before_postgres(8, 2)
def testGenericArrayNull(self):
def caster(s, cur):
if s is None:
@ -400,7 +397,6 @@ class TypesBasicTests(ConnectingTestCase):
a = self.execute("select '{1, 2, NULL}'::int4[]")
self.assertEqual(a, [2, 4, 'nada'])
@testutils.skip_before_postgres(8, 2)
def testNetworkArray(self):
# we don't know these types, but we know their arrays
a = self.execute("select '{192.168.0.1/24}'::inet[]")

View File

@ -415,21 +415,7 @@ class HstoreTestCase(ConnectingTestCase):
conn.close()
def skip_if_no_composite(f):
@wraps(f)
def skip_if_no_composite_(self):
if self.conn.info.server_version < 80000:
return self.skipTest(
"server version %s doesn't support composite types"
% self.conn.info.server_version)
return f(self)
return skip_if_no_composite_
class AdaptTypeTestCase(ConnectingTestCase):
@skip_if_no_composite
def test_none_in_record(self):
curs = self.conn.cursor()
s = curs.mogrify("SELECT %s;", [(42, None)])
@ -489,7 +475,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
'^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f")',
[None, ''.join(map(chr, range(1, 128)))])
@skip_if_no_composite
def test_cast_composite(self):
oid = self._create_type("type_isd",
[('anint', 'integer'), ('astring', 'text'), ('adate', 'date')])
@ -515,7 +500,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
self.assertEqual(v.astring, "hello")
self.assertEqual(v.adate, date(2011, 1, 2))
@skip_if_no_composite
def test_empty_string(self):
# issue #141
self._create_type("type_ss", [('s1', 'text'), ('s2', 'text')])
@ -535,7 +519,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
ok(('', ''))
ok((None, None))
@skip_if_no_composite
def test_cast_nested(self):
self._create_type("type_is",
[("anint", "integer"), ("astring", "text")])
@ -556,7 +539,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
self.assertEqual(r, v)
self.assertEqual(v.anotherpair.apair.astring, "hello")
@skip_if_no_composite
def test_register_on_cursor(self):
self._create_type("type_ii", [("a", "integer"), ("b", "integer")])
@ -568,7 +550,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
curs2.execute("select (1,2)::type_ii")
self.assertEqual(curs2.fetchone()[0], "(1,2)")
@skip_if_no_composite
def test_register_on_connection(self):
self._create_type("type_ii", [("a", "integer"), ("b", "integer")])
@ -586,7 +567,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
conn1.close()
conn2.close()
@skip_if_no_composite
@restore_types
def test_register_globally(self):
self._create_type("type_ii", [("a", "integer"), ("b", "integer")])
@ -606,7 +586,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
conn1.close()
conn2.close()
@skip_if_no_composite
def test_composite_namespace(self):
curs = self.conn.cursor()
curs.execute("""
@ -625,7 +604,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
curs.execute("select (4,8)::typens.typens_ii")
self.assertEqual(curs.fetchone()[0], (4, 8))
@skip_if_no_composite
@skip_before_postgres(8, 4)
def test_composite_array(self):
self._create_type("type_isd",
@ -648,7 +626,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
self.assertEqual(v[1][1], "world")
self.assertEqual(v[1][2], date(2011, 1, 3))
@skip_if_no_composite
def test_wrong_schema(self):
oid = self._create_type("type_ii", [("a", "integer"), ("b", "integer")])
c = CompositeCaster('type_ii', oid, [('a', 23), ('b', 23), ('c', 23)])
@ -658,7 +635,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
self.assertRaises(psycopg2.DataError, curs.fetchone)
@slow
@skip_if_no_composite
@skip_before_postgres(8, 4)
def test_from_tables(self):
curs = self.conn.cursor()
@ -703,7 +679,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
self.assertEqual(r[0], (2, 'test2'))
self.assertEqual(r[1], [(3, 'testc', 2), (4, 'testd', 2)])
@skip_if_no_composite
def test_non_dbapi_connection(self):
self._create_type("type_ii", [("a", "integer"), ("b", "integer")])
@ -725,7 +700,6 @@ class AdaptTypeTestCase(ConnectingTestCase):
finally:
conn.close()
@skip_if_no_composite
def test_subclass(self):
oid = self._create_type("type_isd",
[('anint', 'integer'), ('astring', 'text'), ('adate', 'date')])
@ -953,7 +927,6 @@ class JsonTestCase(ConnectingTestCase):
self.assert_(s.startswith("'"))
self.assert_(s.endswith("'"))
@skip_before_postgres(8, 2)
def test_scs(self):
cnn_on = self.connect(options="-c standard_conforming_strings=on")
cur_on = cnn_on.cursor()

View File

@ -27,7 +27,7 @@ import psycopg2
import psycopg2.extensions as ext
import unittest
from .testutils import ConnectingTestCase, skip_before_postgres
from .testutils import ConnectingTestCase
class WithTestCase(ConnectingTestCase):
@ -216,7 +216,6 @@ class WithCursorTestCase(WithTestCase):
else:
self.fail("where is my exception?")
@skip_before_postgres(8, 2)
def test_named_with_noop(self):
with self.conn.cursor('named'):
pass