diff options
author | Marc G. Fournier <scrappy@hub.org> | 1998-03-01 04:51:16 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1998-03-01 04:51:16 +0000 |
commit | f3f7712675abf9310859e4a1ccf6407dc3a3770e (patch) | |
tree | 1e6e5a87d4ff8cf7c14a3f1fc4019fa8d0c978d1 /src/tutorial/C-code/funcs.c | |
parent | 56b3182241347aacb7b4c47519f009ffa2b57aa8 (diff) | |
download | postgresql-f3f7712675abf9310859e4a1ccf6407dc3a3770e.tar.gz postgresql-f3f7712675abf9310859e4a1ccf6407dc3a3770e.zip |
Move around files before applying Darren's second patch
Diffstat (limited to 'src/tutorial/C-code/funcs.c')
-rw-r--r-- | src/tutorial/C-code/funcs.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/tutorial/C-code/funcs.c b/src/tutorial/C-code/funcs.c deleted file mode 100644 index 71371f51609..00000000000 --- a/src/tutorial/C-code/funcs.c +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - These are user-defined functions that can be bound to a Postgres backend - and called by Postgres to execute SQL functions of the same name. - - The calling format for these functions is defined by the CREATE FUNCTION - SQL statement that binds them to the backend. -*****************************************************************************/ - -#include <string.h> -#include <stdio.h> -#include "postgres.h" /* for char16, etc. */ -#include "utils/palloc.h" /* for palloc */ -#include "libpq-fe.h" /* for TUPLE */ -#include "executor/executor.h" /* for GetAttributeByName() */ - -/* 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); -text *copytext(text *t); - -bool -c_overpaid(TUPLE t, /* the current instance of EMP */ - int4 limit); - - - -int -add_one(int arg) -{ - return (arg + 1); -} - -char16 * -concat16(char16 *arg1, char16 *arg2) -{ - char16 *new_c16 = (char16 *) palloc(sizeof(char16)); - - MemSet(new_c16, 0, sizeof(char16)); - strncpy((char *) new_c16, (char *) arg1, 16); - return (char16 *) (strncat((char *) new_c16, (char *) arg2, 16)); -} - -text * -copytext(text *t) -{ - - /* - * VARSIZE is the total size of the struct in bytes. - */ - text *new_t = (text *) palloc(VARSIZE(t)); - - MemSet(new_t, 0, VARSIZE(t)); - - VARSIZE(new_t) = VARSIZE(t); - - /* - * VARDATA is a pointer to the data region of the struct. - */ - memcpy((void *) VARDATA(new_t), /* destination */ - (void *) VARDATA(t), /* source */ - VARSIZE(t) - VARHDRSZ); /* how many bytes */ - - return (new_t); -} - -bool -c_overpaid(TUPLE t, /* the current instance of EMP */ - int4 limit) -{ - bool isnull = false; - int4 salary; - - salary = (int4) GetAttributeByName(t, "salary", &isnull); - - if (isnull) - return (false); - return (salary > limit); -} |