Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "postgres.h"
00015
00016 #include "executor/executor.h"
00017 #include "utils/geo_decls.h"
00018
00019 PG_MODULE_MAGIC;
00020
00021
00022
00023
00024 int add_one(int arg);
00025 float8 *add_one_float8(float8 *arg);
00026 Point *makepoint(Point *pointx, Point *pointy);
00027 text *copytext(text *t);
00028 text *concat_text(text *arg1, text *arg2);
00029 bool c_overpaid(HeapTupleHeader t,
00030 int32 limit);
00031
00032
00033
00034
00035 int
00036 add_one(int arg)
00037 {
00038 return arg + 1;
00039 }
00040
00041
00042
00043 float8 *
00044 add_one_float8(float8 *arg)
00045 {
00046 float8 *result = (float8 *) palloc(sizeof(float8));
00047
00048 *result = *arg + 1.0;
00049
00050 return result;
00051 }
00052
00053 Point *
00054 makepoint(Point *pointx, Point *pointy)
00055 {
00056 Point *new_point = (Point *) palloc(sizeof(Point));
00057
00058 new_point->x = pointx->x;
00059 new_point->y = pointy->y;
00060
00061 return new_point;
00062 }
00063
00064
00065
00066 text *
00067 copytext(text *t)
00068 {
00069
00070
00071
00072 text *new_t = (text *) palloc(VARSIZE(t));
00073
00074 SET_VARSIZE(new_t, VARSIZE(t));
00075
00076
00077
00078
00079 memcpy((void *) VARDATA(new_t),
00080 (void *) VARDATA(t),
00081 VARSIZE(t) - VARHDRSZ);
00082 return new_t;
00083 }
00084
00085 text *
00086 concat_text(text *arg1, text *arg2)
00087 {
00088 int32 arg1_size = VARSIZE(arg1) - VARHDRSZ;
00089 int32 arg2_size = VARSIZE(arg2) - VARHDRSZ;
00090 int32 new_text_size = arg1_size + arg2_size + VARHDRSZ;
00091 text *new_text = (text *) palloc(new_text_size);
00092
00093 SET_VARSIZE(new_text, new_text_size);
00094 memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
00095 memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
00096 return new_text;
00097 }
00098
00099
00100
00101 bool
00102 c_overpaid(HeapTupleHeader t,
00103 int32 limit)
00104 {
00105 bool isnull;
00106 int32 salary;
00107
00108 salary = DatumGetInt32(GetAttributeByName(t, "salary", &isnull));
00109 if (isnull)
00110 return false;
00111 return salary > limit;
00112 }