Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
7bfb924a
Commit
7bfb924a
authored
28 years ago
by
Bryan Henderson
Browse files
Options
Downloads
Patches
Plain Diff
Silence compiler warnings, fix error in complex compare function.
parent
227015b0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tutorial/C-code/complex.c
+22
-1
22 additions, 1 deletion
src/tutorial/C-code/complex.c
src/tutorial/C-code/funcs.c
+21
-0
21 additions, 0 deletions
src/tutorial/C-code/funcs.c
with
43 additions
and
1 deletion
src/tutorial/C-code/complex.c
+
22
−
1
View file @
7bfb924a
/******************************************************************************
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
,
"(%
l
g,%
l
g)"
,
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
()
{
...
...
This diff is collapsed.
Click to expand it.
src/tutorial/C-code/funcs.c
+
21
−
0
View file @
7bfb924a
/******************************************************************************
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment