summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
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);
}