Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bfb924

Browse files
author
Bryan Henderson
committed
Silence compiler warnings, fix error in complex compare function.
1 parent227015b commit7bfb924

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

‎src/tutorial/C-code/complex.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
17
#include<stdio.h>
28
/* do not include libpq-fe.h for backend-loaded functions*/
39
/* #include "libpq-fe.h" */
@@ -11,6 +17,20 @@ typedef struct Complex {
1117
doubley;
1218
}Complex;
1319

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+
boolcomplex_abs_lt(Complex*a,Complex*b);
27+
boolcomplex_abs_le(Complex*a,Complex*b);
28+
boolcomplex_abs_eq(Complex*a,Complex*b);
29+
boolcomplex_abs_ge(Complex*a,Complex*b);
30+
boolcomplex_abs_gt(Complex*a,Complex*b);
31+
int4complex_abs_cmp(Complex*a,Complex*b);
32+
33+
1434
/*****************************************************************************
1535
* Input/Output functions
1636
*****************************************************************************/
@@ -48,7 +68,7 @@ complex_out(Complex *complex)
4868
return(NULL);
4969

5070
result= (char*)palloc(60);
51-
sprintf(result,"(%lg,%lg)",complex->x,complex->y);
71+
sprintf(result,"(%g,%g)",complex->x,complex->y);
5272
return(result);
5373
}
5474

@@ -131,6 +151,7 @@ complex_abs_cmp(Complex *a, Complex *b)
131151
* POSTGRES crashing, it is impossible to tell whether the bug is in your
132152
* code or POSTGRES's.
133153
*/
154+
voidtest_main(void);
134155
void
135156
test_main()
136157
{

‎src/tutorial/C-code/funcs.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1+
/******************************************************************************
2+
These are user-defined functions that can be bound to a Postgres backend
3+
and called by Postgres to execute SQL functions of the same name.
4+
5+
The calling format for these functions is defined by the CREATE FUNCTION
6+
SQL statement that binds them to the backend.
7+
*****************************************************************************/
8+
19
#include<string.h>
210
#include<stdio.h>
311
#include"postgres.h"/* for char16, etc. */
412
#include"utils/palloc.h"/* for palloc */
513
#include"libpq-fe.h"/* for TUPLE */
14+
#include"executor/executor.h"/* for GetAttributeByName() */
15+
16+
/* The following prototypes declare what we assume the user declares to
17+
Postgres in his CREATE FUNCTION statement.
18+
*/
19+
20+
intadd_one(intarg);
21+
char16*concat16(char16*arg1,char16*arg2);
22+
text*copytext(text*t);
23+
boolc_overpaid(TUPLEt,/* the current instance of EMP */
24+
int4limit);
25+
26+
627

728
int
829
add_one(intarg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp