File: pg13

package info (click to toggle)
postgresql-multicorn 1.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,244 kB
  • sloc: ansic: 3,324; python: 2,258; sql: 751; makefile: 259; sh: 81
file content (237 lines) | stat: -rw-r--r-- 6,424 bytes parent folder | download
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
--- a/src/utils.c
+++ b/src/utils.c
@@ -89,7 +89,11 @@ log_to_postgres(PyObject *self, PyObject
 	}
 	hint = PyDict_GetItemString(kwargs, "hint");
 	detail = PyDict_GetItemString(kwargs, "detail");
+#if PG_VERSION_NUM >= 130000
+	if (errstart(severity, TEXTDOMAIN))
+#else
 	if (errstart(severity, __FILE__, __LINE__, PG_FUNCNAME_MACRO, TEXTDOMAIN))
+#endif
 	{
 		errmsg("%s", message);
 		if (hint != NULL && hint != Py_None)
@@ -104,7 +108,11 @@ log_to_postgres(PyObject *self, PyObject
 		}
 		Py_DECREF(args);
 		Py_DECREF(kwargs);
+#if PG_VERSION_NUM >= 130000
+		errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO);
+#else
 		errfinish(0);
+#endif
 	}
 	else
 	{
--- a/src/errors.c
+++ b/src/errors.c
@@ -68,9 +68,17 @@ reportException(PyObject *pErrType, PyOb
 	{
 		severity = ERROR;
 	}
+#if PG_VERSION_NUM >= 130000
+	if (errstart(severity, TEXTDOMAIN))
+#else
 	if (errstart(severity, __FILE__, __LINE__, PG_FUNCNAME_MACRO, TEXTDOMAIN))
+#endif
 	{
+#if PG_VERSION_NUM >= 130000
+		if (errstart(severity, TEXTDOMAIN))
+#else
 		if (errstart(severity, __FILE__, __LINE__, PG_FUNCNAME_MACRO, TEXTDOMAIN))
+#endif
 			errmsg("Error in python: %s", errName);
 		errdetail("%s", errValue);
 		errdetail_log("%s", errTraceback);
@@ -81,5 +89,9 @@ reportException(PyObject *pErrType, PyOb
 	Py_DECREF(tracebackModule);
 	Py_DECREF(newline);
 	Py_DECREF(pTemp);
-	errfinish(0);
+#if PG_VERSION_NUM >= 130000
+		errfinish(__FILE__, __LINE__, PG_FUNCNAME_MACRO);
+#else
+		errfinish(0);
+#endif
 }
--- a/src/python.c
+++ b/src/python.c
@@ -524,22 +524,37 @@ compareColumns(List *columns1, List *col
 		{
 			return false;
 		}
+#if PG_VERSION_NUM >= 130000
+		cell1 = lnext(coldef1, cell1);
+		cell2 = lnext(coldef2, cell2);
+#else
 		cell1 = lnext(cell1);
 		cell2 = lnext(cell2);
+#endif
 		/* Compare typoid */
 		if (((Const *) (lfirst(cell1)))->constvalue != ((Const *) lfirst(cell2))->constvalue)
 		{
 			return false;
 		}
+#if PG_VERSION_NUM >= 130000
+		cell1 = lnext(coldef1, cell1);
+		cell2 = lnext(coldef2, cell2);
+#else
 		cell1 = lnext(cell1);
 		cell2 = lnext(cell2);
+#endif
 		/* Compare typmod */
 		if (((Const *) (lfirst(cell1)))->constvalue != ((Const *) lfirst(cell2))->constvalue)
 		{
 			return false;
 		}
+#if PG_VERSION_NUM >= 130000
+		cell1 = lnext(coldef1, cell1);
+		cell2 = lnext(coldef2, cell2);
+#else
 		cell1 = lnext(cell1);
 		cell2 = lnext(cell2);
+#endif
 		/* Compare column options */
 		if (!compareOptions(lfirst(cell1), lfirst(cell2)))
 		{
--- a/src/multicorn.c
+++ b/src/multicorn.c
@@ -27,6 +27,9 @@
 #include "utils/rel.h"
 #include "parser/parsetree.h"
 #include "fmgr.h"
+#if PG_VERSION_NUM >= 130000
+#include "common/hashfn.h" /* oid_hash */
+#endif
 
 
 PG_MODULE_MAGIC;
--- a/src/query.c
+++ b/src/query.c
@@ -837,26 +837,49 @@ deserializeDeparsedSortGroup(List *items
 		ListCell *lc;
 		MulticornDeparsedSortGroup *key =
 			palloc0(sizeof(MulticornDeparsedSortGroup));
+#if PG_VERSION_NUM >= 130000
+		List *list = lfirst(k);
+#endif
 
 		lc = list_head(lfirst(k));
 		key->attname = (Name) strdup(strVal(lfirst(lc)));
 
+#if PG_VERSION_NUM >= 130000
+		lc = lnext(list, lc);
+#else
 		lc = lnext(lc);
+#endif
 		key->attnum = (int) intVal(lfirst(lc));
 
+#if PG_VERSION_NUM >= 130000
+		lc = lnext(list, lc);
+#else
 		lc = lnext(lc);
+#endif
 		key->reversed = (bool) intVal(lfirst(lc));
 
+#if PG_VERSION_NUM >= 130000
+		lc = lnext(list, lc);
+#else
 		lc = lnext(lc);
+#endif
 		key->nulls_first = (bool) intVal(lfirst(lc));
 
+#if PG_VERSION_NUM >= 130000
+		lc = lnext(list, lc);
+#else
 		lc = lnext(lc);
+#endif
 		if(lfirst(lc) != NULL)
 			key->collate = (Name) strdup(strVal(lfirst(lc)));
 		else
 			key->collate = NULL;
 
+#if PG_VERSION_NUM >= 130000
+		lc = lnext(list, lc);
+#else
 		lc = lnext(lc);
+#endif
 		key->key = (PathKey *) lfirst(lc);
 
 		result = lappend(result, key);
--- a/Makefile
+++ b/Makefile
@@ -124,6 +124,6 @@ ifeq (${SUPPORTS_IMPORT}, 1)
 endif
 
 REGRESS      = $(patsubst test-$(PYTHON_TEST_VERSION)/sql/%.sql,%,$(TESTS))
-REGRESS_OPTS = --inputdir=test-$(PYTHON_TEST_VERSION) --load-language=plpgsql
+REGRESS_OPTS = --inputdir=test-$(PYTHON_TEST_VERSION)
 
 $(info Python version is $(python_version))
--- a/test-2.7/expected/write_filesystem.out
+++ b/test-2.7/expected/write_filesystem.out
@@ -3,7 +3,7 @@ CREATE EXTENSION multicorn;
 CREATE server multicorn_srv foreign data wrapper multicorn options (
     wrapper 'multicorn.fsfdw.FilesystemFdw'
 );
-CREATE language plpythonu;
+CREATE EXTENSION plpythonu;
 CREATE TABLE temp_dir (dirname varchar);
 -- Create a table with the filesystem fdw in a temporary directory,
 -- and store the dirname in the temp_dir table.
@@ -598,4 +598,4 @@ DROP EXTENSION multicorn cascade;
 NOTICE:  drop cascades to 2 other objects
 DETAIL:  drop cascades to server multicorn_srv
 drop cascades to foreign table testmulticorn
-DROP LANGUAGE plpythonu;
+DROP EXTENSION plpythonu;
--- a/test-2.7/sql/write_filesystem.sql
+++ b/test-2.7/sql/write_filesystem.sql
@@ -6,7 +6,7 @@ CREATE server multicorn_srv foreign data
 );
 
 
-CREATE language plpythonu;
+CREATE EXTENSION plpythonu;
 CREATE TABLE temp_dir (dirname varchar);
 
 -- Create a table with the filesystem fdw in a temporary directory,
@@ -63,4 +63,4 @@ DROP FUNCTION cleanup_dir();
 DROP TABLE temp_dir;
 DROP FUNCTION create_table();
 DROP EXTENSION multicorn cascade;
-DROP LANGUAGE plpythonu;
+DROP EXTENSION plpythonu;
--- a/test-3.3/expected/write_filesystem.out
+++ b/test-3.3/expected/write_filesystem.out
@@ -1,6 +1,6 @@
 -- Setup the test
 CREATE EXTENSION multicorn;
-CREATE language plpython3u;
+CREATE EXTENSION plpython3u;
 \i test-common/disable_jit.include
 DO $$
 BEGIN
@@ -606,4 +606,4 @@ DROP EXTENSION multicorn cascade;
 NOTICE:  drop cascades to 2 other objects
 DETAIL:  drop cascades to server multicorn_srv
 drop cascades to foreign table testmulticorn
-DROP LANGUAGE plpython3u;
+DROP EXTENSION plpython3u;
--- a/test-3.3/sql/write_filesystem.sql
+++ b/test-3.3/sql/write_filesystem.sql
@@ -1,6 +1,6 @@
 -- Setup the test
 CREATE EXTENSION multicorn;
-CREATE language plpython3u;
+CREATE EXTENSION plpython3u;
 \i test-common/disable_jit.include
 
 CREATE OR REPLACE FUNCTION create_table() RETURNS VOID AS $$
@@ -65,4 +65,4 @@ DROP FUNCTION cleanup_dir();
 DROP TABLE temp_dir;
 DROP FUNCTION create_table();
 DROP EXTENSION multicorn cascade;
-DROP LANGUAGE plpython3u;
+DROP EXTENSION plpython3u;