PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
funcs.c File Reference
#include "postgres.h"
#include "executor/executor.h"
#include "utils/geo_decls.h"
Include dependency graph for funcs.c:

Go to the source code of this file.

Functions

int add_one (int arg)
 
float8add_one_float8 (float8 *arg)
 
Pointmakepoint (Point *pointx, Point *pointy)
 
textcopytext (text *t)
 
textconcat_text (text *arg1, text *arg2)
 
bool c_overpaid (HeapTupleHeader t, int32 limit)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

int add_one ( int  arg)

Definition at line 35 of file funcs.c.

36 {
37  return arg + 1;
38 }
void * arg
float8 * add_one_float8 ( float8 arg)

Definition at line 43 of file funcs.c.

References palloc().

44 {
45  float8 *result = (float8 *) palloc(sizeof(float8));
46 
47  *result = *arg + 1.0;
48 
49  return result;
50 }
double float8
Definition: c.h:375
void * palloc(Size size)
Definition: mcxt.c:848
void * arg
bool c_overpaid ( HeapTupleHeader  t,
int32  limit 
)

Definition at line 101 of file funcs.c.

References DatumGetInt32, and GetAttributeByName().

103 {
104  bool isnull;
105  int32 salary;
106 
107  salary = DatumGetInt32(GetAttributeByName(t, "salary", &isnull));
108  if (isnull)
109  return false;
110  return salary > limit;
111 }
#define DatumGetInt32(X)
Definition: postgres.h:478
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:890
signed int int32
Definition: c.h:246
text * concat_text ( text arg1,
text arg2 
)

Definition at line 85 of file funcs.c.

References palloc(), SET_VARSIZE, VARDATA, VARHDRSZ, and VARSIZE.

86 {
87  int32 arg1_size = VARSIZE(arg1) - VARHDRSZ;
88  int32 arg2_size = VARSIZE(arg2) - VARHDRSZ;
89  int32 new_text_size = arg1_size + arg2_size + VARHDRSZ;
90  text *new_text = (text *) palloc(new_text_size);
91 
92  SET_VARSIZE(new_text, new_text_size);
93  memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
94  memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
95  return new_text;
96 }
#define VARDATA(PTR)
Definition: postgres.h:303
#define VARSIZE(PTR)
Definition: postgres.h:304
#define VARHDRSZ
Definition: c.h:439
signed int int32
Definition: c.h:246
void * palloc(Size size)
Definition: mcxt.c:848
Definition: c.h:433
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:328
text * copytext ( text t)

Definition at line 66 of file funcs.c.

References palloc(), SET_VARSIZE, VARDATA, VARHDRSZ, and VARSIZE.

67 {
68  /*
69  * VARSIZE is the total size of the struct in bytes.
70  */
71  text *new_t = (text *) palloc(VARSIZE(t));
72 
73  SET_VARSIZE(new_t, VARSIZE(t));
74 
75  /*
76  * VARDATA is a pointer to the data region of the struct.
77  */
78  memcpy((void *) VARDATA(new_t), /* destination */
79  (void *) VARDATA(t), /* source */
80  VARSIZE(t) - VARHDRSZ); /* how many bytes */
81  return new_t;
82 }
#define VARDATA(PTR)
Definition: postgres.h:303
#define VARSIZE(PTR)
Definition: postgres.h:304
#define VARHDRSZ
Definition: c.h:439
void * palloc(Size size)
Definition: mcxt.c:848
Definition: c.h:433
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:328
Point * makepoint ( Point pointx,
Point pointy 
)

Definition at line 53 of file funcs.c.

References palloc(), Point::x, and Point::y.

54 {
55  Point *new_point = (Point *) palloc(sizeof(Point));
56 
57  new_point->x = pointx->x;
58  new_point->y = pointy->y;
59 
60  return new_point;
61 }
double y
Definition: geo_decls.h:60
double x
Definition: geo_decls.h:60
void * palloc(Size size)
Definition: mcxt.c:848

Variable Documentation

PG_MODULE_MAGIC

Definition at line 19 of file funcs.c.