diff options
author | Bryan Henderson <bryanh@giraffe.netgate.net> | 1997-01-05 21:20:34 +0000 |
---|---|---|
committer | Bryan Henderson <bryanh@giraffe.netgate.net> | 1997-01-05 21:20:34 +0000 |
commit | 7bfb924aea0a459540a58db002f5a6b00842ff08 (patch) | |
tree | 9834cf0a1a26b052e43f223444b4c46c625ecb08 /src/tutorial/C-code/complex.c | |
parent | 227015b08ec10e8422b33bc988951fdd1d0ce5d0 (diff) | |
download | postgresql-7bfb924aea0a459540a58db002f5a6b00842ff08.tar.gz postgresql-7bfb924aea0a459540a58db002f5a6b00842ff08.zip |
Silence compiler warnings, fix error in complex compare function.
Diffstat (limited to 'src/tutorial/C-code/complex.c')
-rw-r--r-- | src/tutorial/C-code/complex.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/tutorial/C-code/complex.c b/src/tutorial/C-code/complex.c index e554b7fcfb7..8c83665c803 100644 --- a/src/tutorial/C-code/complex.c +++ b/src/tutorial/C-code/complex.c @@ -1,3 +1,9 @@ +/****************************************************************************** + This file contains routines that can be bound to a Postgres backend and + called by the backend in the process of processing queries. The calling + format for these routines is dictated by Postgres architecture. +******************************************************************************/ + #include <stdio.h> /* do not include libpq-fe.h for backend-loaded functions*/ /* #include "libpq-fe.h" */ @@ -11,6 +17,20 @@ typedef struct Complex { double y; } Complex; +/* These prototypes declare the requirements that Postgres places on these + user written functions. +*/ +Complex * complex_in(char *str); +char * complex_out(Complex *complex); +Complex * complex_add(Complex *a, Complex *b); +bool complex_abs_lt(Complex *a, Complex *b); +bool complex_abs_le(Complex *a, Complex *b); +bool complex_abs_eq(Complex *a, Complex *b); +bool complex_abs_ge(Complex *a, Complex *b); +bool complex_abs_gt(Complex *a, Complex *b); +int4 complex_abs_cmp(Complex *a, Complex *b); + + /***************************************************************************** * Input/Output functions *****************************************************************************/ @@ -48,7 +68,7 @@ complex_out(Complex *complex) return(NULL); result = (char *) palloc(60); - sprintf(result, "(%lg,%lg)", complex->x, complex->y); + sprintf(result, "(%g,%g)", complex->x, complex->y); return(result); } @@ -131,6 +151,7 @@ complex_abs_cmp(Complex *a, Complex *b) * POSTGRES crashing, it is impossible to tell whether the bug is in your * code or POSTGRES's. */ +void test_main(void); void test_main() { |