Repository navigation
Expand file tree
/
Copy pathage--1.8.0--y.y.y.sql
More file actions
113 lines (96 loc) · 4.5 KB
/
Copy pathage--1.8.0--y.y.y.sql
File metadata and controls
113 lines (96 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-- This will only work within a major version of PostgreSQL, not across
-- major versions.
--* This is a TEMPLATE for upgrading from the previous version of Apache AGE
--* Please adjust the below ALTER EXTENSION to reflect the -- correct version it
-- is upgrading to.
-- This will only work within a major version of PostgreSQL, not across
-- major versions.
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "ALTER EXTENSION age UPDATE TO '1.X.0'" to load this file. \quit
--* Please add all additions, deletions, and modifications to the end of this
--* file. We need to keep the order of these changes.
--* REMOVE ALL LINES ABOVE, and this one, that start with --*
--
-- Add delimiter parameter to load_labels_from_file and load_edges_from_file
--
-- Issue #2449: Both load_labels_from_file and load_edges_from_file now accept
-- an optional delimiter parameter (default ',') to support non-CSV delimiters
-- such as pipe-delimited files.
-- Drop and recreate load_labels_from_file with new delimiter parameter
DROP FUNCTION IF EXISTS ag_catalog.load_labels_from_file(name, name, text, bool, bool);
CREATE FUNCTION ag_catalog.load_labels_from_file(graph_name name,
label_name name,
file_path text,
id_field_exists bool default true,
load_as_agtype bool default false,
delimiter text default ',')
RETURNS void
LANGUAGE c
AS 'MODULE_PATHNAME';
-- Drop and recreate load_edges_from_file with new delimiter parameter
DROP FUNCTION IF EXISTS ag_catalog.load_edges_from_file(name, name, text, bool);
CREATE FUNCTION ag_catalog.load_edges_from_file(graph_name name,
label_name name,
file_path text,
load_as_agtype bool default false,
delimiter text default ',')
RETURNS void
LANGUAGE c
AS 'MODULE_PATHNAME';
DO $$
DECLARE
btree_family oid;
BEGIN
SELECT opcfamily INTO STRICT btree_family
FROM pg_catalog.pg_opclass
WHERE opcnamespace = 'ag_catalog'::regnamespace
AND opcname = 'agtype_ops_btree'
AND opcmethod = (SELECT oid FROM pg_catalog.pg_am WHERE amname = 'btree');
UPDATE pg_catalog.pg_amop
SET amopstrategy = amopstrategy + 10
WHERE amopfamily = btree_family
AND amoplefttype = 'ag_catalog.agtype'::regtype
AND amoprighttype = 'ag_catalog.agtype'::regtype
AND amopstrategy IN (4, 5);
UPDATE pg_catalog.pg_amop
SET amopstrategy = CASE amopopr
WHEN 'ag_catalog.>=(ag_catalog.agtype,ag_catalog.agtype)'::regoperator THEN 4
WHEN 'ag_catalog.>(ag_catalog.agtype,ag_catalog.agtype)'::regoperator THEN 5
END
WHERE amopfamily = btree_family
AND amoplefttype = 'ag_catalog.agtype'::regtype
AND amoprighttype = 'ag_catalog.agtype'::regtype
AND amopstrategy IN (14, 15);
UPDATE pg_catalog.pg_opclass
SET opcfamily = btree_family
WHERE opcnamespace = 'ag_catalog'::regnamespace
AND opcname = 'agtype_ops_btree'
AND opcfamily = btree_family;
END
$$;
--
-- Mark agtype_string_match_starts_with/_ends_with IMMUTABLE
--
-- Issue #2576: same inputs always produce the same output with no catalog
-- lookups or session state, matching agtype_string_match_contains which is
-- already IMMUTABLE.
ALTER FUNCTION ag_catalog.agtype_string_match_starts_with(agtype, agtype) IMMUTABLE;
ALTER FUNCTION ag_catalog.agtype_string_match_ends_with(agtype, agtype) IMMUTABLE;