1
+ /******************************************************************************
2
+ This file contains routines that can be bound to a Postgres backend and
3
+ called by the backend in the process of processing queries. The calling
4
+ format for these routines is dictated by Postgres architecture.
5
+ ******************************************************************************/
6
+
1
7
#include <stdio.h>
2
8
/* do not include libpq-fe.h for backend-loaded functions*/
3
9
/* #include "libpq-fe.h" */
@@ -11,6 +17,20 @@ typedef struct Complex {
11
17
double y ;
12
18
} Complex ;
13
19
20
+ /* These prototypes declare the requirements that Postgres places on these
21
+ user written functions.
22
+ */
23
+ Complex * complex_in (char * str );
24
+ char * complex_out (Complex * complex );
25
+ Complex * complex_add (Complex * a , Complex * b );
26
+ bool complex_abs_lt (Complex * a , Complex * b );
27
+ bool complex_abs_le (Complex * a , Complex * b );
28
+ bool complex_abs_eq (Complex * a , Complex * b );
29
+ bool complex_abs_ge (Complex * a , Complex * b );
30
+ bool complex_abs_gt (Complex * a , Complex * b );
31
+ int4 complex_abs_cmp (Complex * a , Complex * b );
32
+
33
+
14
34
/*****************************************************************************
15
35
* Input/Output functions
16
36
*****************************************************************************/
@@ -48,7 +68,7 @@ complex_out(Complex *complex)
48
68
return (NULL );
49
69
50
70
result = (char * ) palloc (60 );
51
- sprintf (result , "(%lg,%lg )" , complex -> x , complex -> y );
71
+ sprintf (result , "(%g,%g )" , complex -> x , complex -> y );
52
72
return (result );
53
73
}
54
74
@@ -131,6 +151,7 @@ complex_abs_cmp(Complex *a, Complex *b)
131
151
* POSTGRES crashing, it is impossible to tell whether the bug is in your
132
152
* code or POSTGRES's.
133
153
*/
154
+ void test_main (void );
134
155
void
135
156
test_main ()
136
157
{
0 commit comments