summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAndres Freund2017-03-29 20:16:49 +0000
committerAndres Freund2017-03-30 13:25:46 +0000
commit5ded4bd21403e143dd3eb66b92d52732fdac1945 (patch)
treee0ec55a8afd221282172fd36783ada06840c0134 /src/test
parent389bb2818f404d5b967f21e1ac4f987f894e94bb (diff)
Remove support for version-0 calling conventions.
The V0 convention is failure prone because we've so far assumed that a function is V0 if PG_FUNCTION_INFO_V1 is missing, leading to crashes if a function was coded against the V1 interface. V0 doesn't allow proper NULL, SRF and toast handling. V0 doesn't offer features that V1 doesn't. Thus remove V0 support and obsolete fmgr README contents relating to it. Author: Andres Freund, with contributions by Peter Eisentraut & Craig Ringer Reviewed-By: Peter Eisentraut, Craig Ringer Discussion: https://postgr.es/m/20161208213441.k3mbno4twhg2qf7g@alap3.anarazel.de
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/input/create_function_2.source5
-rw-r--r--src/test/regress/input/misc.source13
-rw-r--r--src/test/regress/output/create_function_2.source4
-rw-r--r--src/test/regress/output/misc.source18
-rw-r--r--src/test/regress/regress.c47
5 files changed, 18 insertions, 69 deletions
diff --git a/src/test/regress/input/create_function_2.source b/src/test/regress/input/create_function_2.source
index 3c26b2fec6a..b167c8ac6d8 100644
--- a/src/test/regress/input/create_function_2.source
+++ b/src/test/regress/input/create_function_2.source
@@ -87,11 +87,6 @@ CREATE FUNCTION reverse_name(name)
AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT;
-CREATE FUNCTION oldstyle_length(int4, text)
- RETURNS int4
- AS '@libdir@/regress@DLSUFFIX@'
- LANGUAGE C; -- intentionally not strict
-
--
-- Function dynamic loading
--
diff --git a/src/test/regress/input/misc.source b/src/test/regress/input/misc.source
index dd2d1b20337..b1dbc573c9b 100644
--- a/src/test/regress/input/misc.source
+++ b/src/test/regress/input/misc.source
@@ -250,19 +250,6 @@ SELECT *, name(equipment(h.*)) FROM hobbies_r h;
SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h;
--
--- check that old-style C functions work properly with TOASTed values
---
-create table oldstyle_test(i int4, t text);
-insert into oldstyle_test values(null,null);
-insert into oldstyle_test values(0,'12');
-insert into oldstyle_test values(1000,'12');
-insert into oldstyle_test values(0, repeat('x', 50000));
-
-select i, length(t), octet_length(t), oldstyle_length(i,t) from oldstyle_test;
-
-drop table oldstyle_test;
-
---
-- functional joins
--
diff --git a/src/test/regress/output/create_function_2.source b/src/test/regress/output/create_function_2.source
index bdd1b1bec56..8f28bff298a 100644
--- a/src/test/regress/output/create_function_2.source
+++ b/src/test/regress/output/create_function_2.source
@@ -67,10 +67,6 @@ CREATE FUNCTION reverse_name(name)
RETURNS name
AS '@libdir@/regress@DLSUFFIX@'
LANGUAGE C STRICT;
-CREATE FUNCTION oldstyle_length(int4, text)
- RETURNS int4
- AS '@libdir@/regress@DLSUFFIX@'
- LANGUAGE C; -- intentionally not strict
--
-- Function dynamic loading
--
diff --git a/src/test/regress/output/misc.source b/src/test/regress/output/misc.source
index 574ef0d2e34..b9595cc2391 100644
--- a/src/test/regress/output/misc.source
+++ b/src/test/regress/output/misc.source
@@ -682,24 +682,6 @@ SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h;
(7 rows)
--
--- check that old-style C functions work properly with TOASTed values
---
-create table oldstyle_test(i int4, t text);
-insert into oldstyle_test values(null,null);
-insert into oldstyle_test values(0,'12');
-insert into oldstyle_test values(1000,'12');
-insert into oldstyle_test values(0, repeat('x', 50000));
-select i, length(t), octet_length(t), oldstyle_length(i,t) from oldstyle_test;
- i | length | octet_length | oldstyle_length
-------+--------+--------------+-----------------
- | | |
- 0 | 2 | 2 | 2
- 1000 | 2 | 2 | 1002
- 0 | 50000 | 50000 | 50000
-(4 rows)
-
-drop table oldstyle_test;
---
-- functional joins
--
--
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 986d54ce2fa..d7fb8498d86 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -45,8 +45,6 @@
extern PATH *poly2path(POLYGON *poly);
extern void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
-extern char *reverse_name(char *string);
-extern int oldstyle_length(int n, text *t);
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
@@ -240,14 +238,15 @@ typedef struct
double radius;
} WIDGET;
-WIDGET *widget_in(char *str);
-char *widget_out(WIDGET *widget);
+PG_FUNCTION_INFO_V1(widget_in);
+PG_FUNCTION_INFO_V1(widget_out);
#define NARGS 3
-WIDGET *
-widget_in(char *str)
+Datum
+widget_in(PG_FUNCTION_ARGS)
{
+ char *str = PG_GETARG_CSTRING(0);
char *p,
*coord[NARGS];
int i;
@@ -270,14 +269,16 @@ widget_in(char *str)
result->center.y = atof(coord[1]);
result->radius = atof(coord[2]);
- return result;
+ PG_RETURN_POINTER(result);
}
-char *
-widget_out(WIDGET *widget)
+Datum
+widget_out(PG_FUNCTION_ARGS)
{
- return psprintf("(%g,%g,%g)",
- widget->center.x, widget->center.y, widget->radius);
+ WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
+ char *str = psprintf("(%g,%g,%g)",
+ widget->center.x, widget->center.y, widget->radius);
+ PG_RETURN_CSTRING(str);
}
PG_FUNCTION_INFO_V1(pt_in_widget);
@@ -305,9 +306,12 @@ boxarea(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(width * height);
}
-char *
-reverse_name(char *string)
+PG_FUNCTION_INFO_V1(reverse_name);
+
+Datum
+reverse_name(PG_FUNCTION_ARGS)
{
+ char *string = PG_GETARG_CSTRING(0);
int i;
int len;
char *new_string;
@@ -320,22 +324,7 @@ reverse_name(char *string)
len = i;
for (; i >= 0; --i)
new_string[len - i] = string[i];
- return new_string;
-}
-
-/*
- * This rather silly function is just to test that oldstyle functions
- * work correctly on toast-able inputs.
- */
-int
-oldstyle_length(int n, text *t)
-{
- int len = 0;
-
- if (t)
- len = VARSIZE(t) - VARHDRSZ;
-
- return n + len;
+ PG_RETURN_CSTRING(new_string);
}