-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathplphp_io.h
More file actions
77 lines (67 loc) · 2.61 KB
/
Copy pathplphp_io.h
File metadata and controls
77 lines (67 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* $Id$
*/
#ifndef PLPHP_IO_H
#define PLPHP_IO_H
/* PostgreSQL stuff */
#include "postgres.h"
#include "access/heapam.h"
#include "commands/trigger.h"
#include "funcapi.h"
#include "nodes/pg_list.h"
/*
* These are defined again in php.h, so undef them to avoid some
* cpp warnings.
*/
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
/* PHP stuff */
#include "php.h"
/*
* Memory-ownership convention (PHP 8):
*
* The functions that return a "zval *" (plphp_zval_from_tuple,
* plphp_convert_from_pg_array, plphp_build_tuple_argument) return a freshly
* emalloc'd zval container holding an owned value. The caller takes ownership
* and must dispose of it exactly once, either by handing the value off to a
* consumer that adopts it (add_assoc_zval / add_next_index_zval /
* ZVAL_COPY_VALUE into return_value) and then efree()'ing the container, or by
* calling zval_ptr_dtor() followed by efree() to discard it outright.
*
* plphp_array_get_elem returns a *borrowed* pointer into an existing array
* (or NULL); it must not be freed.
*/
/*
* Per-call transform context: the function's language and its declared
* TRANSFORM FOR TYPE types. Passed into the tuple builders so that a column
* whose type has a transform is converted through it (in trigger rows,
* composites and set-returning results), in both directions. A NULL context,
* or NIL trftypes, means "no transforms" -- e.g. rows read back from SPI.
*/
typedef struct plphp_trans_ctx
{
Oid lang_oid;
List *trftypes;
} plphp_trans_ctx;
/* Resolve a column type's From/To SQL transform under a context, or 0. */
Oid plphp_col_transform(plphp_trans_ctx *tctx, Oid typid, bool fromsql);
zval *plphp_zval_from_tuple(HeapTuple tuple, TupleDesc tupdesc);
HeapTuple plphp_htup_from_zval(zval *val, TupleDesc tupdesc,
plphp_trans_ctx *tctx);
HeapTuple plphp_srf_htup_from_zval(zval *val, AttInMetadata *attinmeta,
MemoryContext cxt, plphp_trans_ctx *tctx);
char *plphp_convert_to_pg_array(zval *array);
char *plphp_convert_to_pg_array_typed(zval *array, Oid elemtype);
zval *plphp_convert_from_pg_array(char *input, Oid elemtype);
zval *plphp_convert_from_pg_record(const char *input, TupleDesc tupdesc);
char *plphp_zval_get_typed_cstring(zval *val, Oid typid);
zval *plphp_array_get_elem(zval* array, char *key);
char *plphp_zval_get_cstring(zval *val, bool do_array, bool null_ok);
zval *plphp_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
plphp_trans_ctx *tctx);
HeapTuple plphp_modify_tuple(zval *outdata, TriggerData *tdata,
plphp_trans_ctx *tctx);
#endif /* PLPHP_IO_H */