From 344190b7efea9ba2d9e7dcf85f7f40368edca58e Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 14 Mar 1999 15:22:15 +0000 Subject: Fixup for src/tutorial/func.c and src/tutorial/func.source Removed char16 and replaced with an example using Point as suggested by Tom Lane. The dept field was changed to the cubicle field denoting the row(x) and column(y) of the employee's cube in the corporate jungle. The C function builds a 'compromise' cubicle from two suggested ones. I'll try and patchup the documentation next. Clark --- src/tutorial/funcs.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/tutorial/funcs.c') diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c index 77eec35b729..cda3ef112a9 100644 --- a/src/tutorial/funcs.c +++ b/src/tutorial/funcs.c @@ -8,21 +8,21 @@ #include #include -#include "postgres.h" /* for char16, etc. */ +#include "postgres.h" /* for variable length type */ #include "utils/palloc.h" /* for palloc */ -#include "libpq-fe.h" /* for TUPLE */ #include "executor/executor.h" /* for GetAttributeByName() */ +#include "utils/geo_decls.h" /* for point type */ /* The following prototypes declare what we assume the user declares to Postgres in his CREATE FUNCTION statement. */ int add_one(int arg); -char16 *concat16(char16 * arg1, char16 * arg2); +Point *makepoint(Point *pointx, Point *pointy ); text *copytext(text *t); -bool c_overpaid(TUPLE t, /* the current instance of EMP */ - int4 limit); +bool c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ + int4 limit); @@ -32,14 +32,15 @@ add_one(int arg) return arg + 1; } -char16 * -concat16(char16 * arg1, char16 * arg2) +Point * +makepoint(Point *pointx, Point *pointy ) { - char16 *new_c16 = (char16 *) palloc(sizeof(char16)); + Point *new_point = (Point *) palloc(sizeof(Point)); - MemSet(new_c16, 0, sizeof(char16)); - strncpy((char *) new_c16, (char *) arg1, 16); - return (char16 *) (strncat((char *) new_c16, (char *) arg2, 16)); + new_point->x = pointx->x; + new_point->y = pointy->y; + + return new_point; } text * @@ -66,7 +67,7 @@ copytext(text *t) } bool -c_overpaid(TUPLE t, /* the current instance of EMP */ +c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ int4 limit) { bool isnull = false; -- cgit v1.2.3