#include "postgres.h"#include "fmgr.h"#include "libpq/pqformat.h"
Go to the source code of this file.
Data Structures | |
| struct | Complex |
Defines | |
| #define | Mag(c) ((c)->x*(c)->x + (c)->y*(c)->y) |
Typedefs | |
| typedef struct Complex | Complex |
Functions | |
| Datum | complex_in (PG_FUNCTION_ARGS) |
| Datum | complex_out (PG_FUNCTION_ARGS) |
| Datum | complex_recv (PG_FUNCTION_ARGS) |
| Datum | complex_send (PG_FUNCTION_ARGS) |
| Datum | complex_add (PG_FUNCTION_ARGS) |
| Datum | complex_abs_lt (PG_FUNCTION_ARGS) |
| Datum | complex_abs_le (PG_FUNCTION_ARGS) |
| Datum | complex_abs_eq (PG_FUNCTION_ARGS) |
| Datum | complex_abs_ge (PG_FUNCTION_ARGS) |
| Datum | complex_abs_gt (PG_FUNCTION_ARGS) |
| Datum | complex_abs_cmp (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (complex_in) | |
| PG_FUNCTION_INFO_V1 (complex_out) | |
| PG_FUNCTION_INFO_V1 (complex_recv) | |
| PG_FUNCTION_INFO_V1 (complex_send) | |
| PG_FUNCTION_INFO_V1 (complex_add) | |
| static int | complex_abs_cmp_internal (Complex *a, Complex *b) |
| PG_FUNCTION_INFO_V1 (complex_abs_lt) | |
| PG_FUNCTION_INFO_V1 (complex_abs_le) | |
| PG_FUNCTION_INFO_V1 (complex_abs_eq) | |
| PG_FUNCTION_INFO_V1 (complex_abs_ge) | |
| PG_FUNCTION_INFO_V1 (complex_abs_gt) | |
| PG_FUNCTION_INFO_V1 (complex_abs_cmp) | |
Variables | |
| PG_MODULE_MAGIC | |
Definition at line 148 of file complex.c.
Referenced by complex_abs_cmp_internal().
| Datum complex_abs_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 222 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_INT32.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_INT32(complex_abs_cmp_internal(a, b));
}
Definition at line 151 of file complex.c.
References Mag.
Referenced by complex_abs_cmp(), complex_abs_eq(), complex_abs_ge(), complex_abs_gt(), complex_abs_le(), and complex_abs_lt().
| Datum complex_abs_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 189 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_BOOL.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(complex_abs_cmp_internal(a, b) == 0);
}
| Datum complex_abs_ge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 200 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_BOOL.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(complex_abs_cmp_internal(a, b) >= 0);
}
| Datum complex_abs_gt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 211 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_BOOL.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(complex_abs_cmp_internal(a, b) > 0);
}
| Datum complex_abs_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 178 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_BOOL.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(complex_abs_cmp_internal(a, b) <= 0);
}
| Datum complex_abs_lt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 167 of file complex.c.
References complex_abs_cmp_internal(), PG_GETARG_POINTER, and PG_RETURN_BOOL.
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(complex_abs_cmp_internal(a, b) < 0);
}
| Datum complex_add | ( | PG_FUNCTION_ARGS | ) |
Definition at line 124 of file complex.c.
References palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, Complex::x, and Complex::y.
| Datum complex_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 49 of file complex.c.
References ereport, errcode(), errmsg(), ERROR, palloc(), PG_GETARG_CSTRING, PG_RETURN_POINTER, Complex::x, and Complex::y.
{
char *str = PG_GETARG_CSTRING(0);
double x,
y;
Complex *result;
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for complex: \"%s\"",
str)));
result = (Complex *) palloc(sizeof(Complex));
result->x = x;
result->y = y;
PG_RETURN_POINTER(result);
}
| Datum complex_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 71 of file complex.c.
References palloc(), PG_GETARG_POINTER, PG_RETURN_CSTRING, snprintf(), Complex::x, and Complex::y.
{
Complex *complex = (Complex *) PG_GETARG_POINTER(0);
char *result;
result = (char *) palloc(100);
snprintf(result, 100, "(%g,%g)", complex->x, complex->y);
PG_RETURN_CSTRING(result);
}
| Datum complex_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 90 of file complex.c.
References buf, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, pq_getmsgfloat8(), Complex::x, and Complex::y.
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
Complex *result;
result = (Complex *) palloc(sizeof(Complex));
result->x = pq_getmsgfloat8(buf);
result->y = pq_getmsgfloat8(buf);
PG_RETURN_POINTER(result);
}
| Datum complex_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 104 of file complex.c.
References buf, PG_GETARG_POINTER, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendfloat8(), Complex::x, and Complex::y.
{
Complex *complex = (Complex *) PG_GETARG_POINTER(0);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendfloat8(&buf, complex->x);
pq_sendfloat8(&buf, complex->y);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
| PG_FUNCTION_INFO_V1 | ( | complex_in | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_gt | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_ge | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_eq | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_le | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_lt | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_abs_cmp | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_add | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_send | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_recv | ) |
| PG_FUNCTION_INFO_V1 | ( | complex_out | ) |
1.7.1