2015-01-13 04:20:40 +08:00
|
|
|
from django.db.backends.base.features import BaseDatabaseFeatures
|
|
|
|
from django.db.utils import InterfaceError
|
2016-06-23 23:52:14 +08:00
|
|
|
from django.utils.functional import cached_property
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
2015-03-27 04:54:43 +08:00
|
|
|
allows_group_by_selected_pks = True
|
2015-01-13 04:20:40 +08:00
|
|
|
can_return_id_from_insert = True
|
2015-08-21 13:38:58 +08:00
|
|
|
can_return_ids_from_bulk_insert = True
|
2015-01-13 04:20:40 +08:00
|
|
|
has_real_datatype = True
|
2015-01-11 02:13:28 +08:00
|
|
|
has_native_uuid_field = True
|
2015-01-13 04:20:40 +08:00
|
|
|
has_native_duration_field = True
|
|
|
|
can_defer_constraint_checks = True
|
|
|
|
has_select_for_update = True
|
|
|
|
has_select_for_update_nowait = True
|
2017-06-30 04:00:15 +08:00
|
|
|
has_select_for_update_of = True
|
2015-01-13 04:20:40 +08:00
|
|
|
uses_savepoints = True
|
|
|
|
can_release_savepoints = True
|
|
|
|
supports_tablespaces = True
|
|
|
|
supports_transactions = True
|
|
|
|
can_introspect_autofield = True
|
|
|
|
can_introspect_ip_address_field = True
|
|
|
|
can_introspect_small_integer_field = True
|
|
|
|
can_distinct_on_fields = True
|
|
|
|
can_rollback_ddl = True
|
|
|
|
supports_combined_alters = True
|
|
|
|
nulls_order_largest = True
|
|
|
|
closed_cursor_error_class = InterfaceError
|
|
|
|
has_case_insensitive_like = False
|
|
|
|
requires_sqlparse_for_splitting = False
|
2015-05-09 19:55:03 +08:00
|
|
|
greatest_least_ignores_nulls = True
|
2015-09-06 17:12:08 +08:00
|
|
|
can_clone_databases = True
|
2016-01-20 09:43:41 +08:00
|
|
|
supports_temporal_subtraction = True
|
2017-01-14 21:32:07 +08:00
|
|
|
supports_slicing_ordering_in_compound = True
|
2017-08-09 04:13:02 +08:00
|
|
|
create_test_procedure_without_params_sql = """
|
|
|
|
CREATE FUNCTION test_procedure () RETURNS void AS $$
|
|
|
|
DECLARE
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := 1;
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE plpgsql;"""
|
|
|
|
create_test_procedure_with_int_param_sql = """
|
|
|
|
CREATE FUNCTION test_procedure (P_I INTEGER) RETURNS void AS $$
|
|
|
|
DECLARE
|
|
|
|
V_I INTEGER;
|
|
|
|
BEGIN
|
|
|
|
V_I := P_I;
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE plpgsql;"""
|
2017-09-18 21:42:29 +08:00
|
|
|
supports_over_clause = True
|
2017-09-06 22:26:45 +08:00
|
|
|
supports_aggregate_filter_clause = True
|
2017-09-10 22:34:18 +08:00
|
|
|
supported_explain_formats = {'JSON', 'TEXT', 'XML', 'YAML'}
|
|
|
|
validates_explain_options = False # A query will error on invalid options.
|
2017-04-22 23:44:51 +08:00
|
|
|
|
2016-06-23 23:52:14 +08:00
|
|
|
@cached_property
|
2018-01-10 03:07:17 +08:00
|
|
|
def is_postgresql_9_5(self):
|
2016-06-23 23:52:14 +08:00
|
|
|
return self.connection.pg_version >= 90500
|
2016-09-11 07:20:16 +08:00
|
|
|
|
2018-01-10 03:07:17 +08:00
|
|
|
has_select_for_update_skip_locked = is_postgresql_9_5
|
|
|
|
has_brin_index_support = is_postgresql_9_5
|
|
|
|
has_jsonb_agg = is_postgresql_9_5
|
|
|
|
has_gin_pending_list_limit = is_postgresql_9_5
|