forked from tada/pljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathType_priv.h
More file actions
216 lines (184 loc) · 5.64 KB
/
Copy pathType_priv.h
File metadata and controls
216 lines (184 loc) · 5.64 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Copyright (c) 2004, 2005, 2006 TADA AB - Taby Sweden
* Distributed under the terms shown in the file COPYRIGHT
* found in the root folder of this project or at
* http://eng.tada.se/osprojects/COPYRIGHT.html
*
* @author Thomas Hallgren
*/
#ifndef __pljava_type_Type_priv_h
#define __pljava_type_Type_priv_h
#include "pljava/PgObject_priv.h"
#include "pljava/HashMap.h"
#include "pljava/type/Type.h"
#ifdef __cplusplus
extern "C" {
#endif
/* This is the "abstract" Type class. The Type is responsible for
* value coercsions between Java types and PostGreSQL types.
*
* @author Thomas Hallgren
*/
struct TypeClass_
{
struct PgObjectClass_ extendedClass;
/*
* Contains the JNI compliant signature for the type.
*/
const char* JNISignature;
/*
* Contains the Java type name.
*/
const char* javaTypeName;
/*
* The Java class that represents this type. Will be NULL for
* primitive types.
*/
jclass javaClass;
/*
* Set to true if this type represents a dynamic type (anyelement or
* collection/iterator of anyelement)
*/
bool dynamic;
/*
* Set to true if the invocation will create an out parameter (ResultSet typically)
* to collect the return value. If so, the real return value will be a bool.
*/
bool outParameter;
/*
* Creates the array type for this type.
*/
Type (*createArrayType)(Type self, Oid arrayType);
/*
* Returns the real type for a dynamic type. A non dynamic type will
* return itself.
*/
Type (*getRealType)(Type self, Oid realTypeID, jobject typeMap);
/*
* Returns true if this type uses the same postgres type the other type.
* This is used when explicit java signatures are declared functions to
* verify that the declared Java type is compatible with the SQL type.
*
* At present, the type argument must be either equal to self, or if
* self is a Boolean, Character, or any Number, the primitive that
* corresponds to that number (i.e. java.lang.Short == short).
*/
bool (*canReplaceType)(Type self, Type type);
/*
* Translate a given Datum into a jvalue accorging to the type represented
* by this instance.
*/
DatumCoercer coerceDatum;
/*
* Translate a given Object into a Datum accorging to the type represented
* by this instance.
*/
ObjectCoercer coerceObject;
/*
* Calls a java method using one of the Call<type>MethodA routines where
* <type> corresponds to the type represented by this instance and
* coerces the returned value into a Datum.
*
* The method will set the value pointed to by the wasNull parameter
* to true if the Java method returned null. The method expects that
* the wasNull parameter is set to false by the caller prior to the
* call.
*/
Datum (*invoke)(Type self, jclass clazz, jmethodID method, jvalue* args, PG_FUNCTION_ARGS);
jobject (*getSRFProducer)(Type self, jclass clazz, jmethodID method, jvalue* args);
jobject (*getSRFCollector)(Type self, PG_FUNCTION_ARGS);
bool (*hasNextSRF)(Type self, jobject producer, jobject collector, jint counter);
Datum (*nextSRF)(Type self, jobject producer, jobject collector);
void (*closeSRF)(Type self, jobject producer);
const char* (*getJNISignature)(Type self);
const char* (*getJNIReturnSignature)(Type self, bool forMultiCall, bool useAltRepr);
/*
* Returns the TupleDesc that corresponds to this type.
*/
TupleDesc (*getTupleDesc)(Type self, PG_FUNCTION_ARGS);
};
struct Type_
{
TypeClass typeClass;
/*
* The Oid that identifies this type.
*/
Oid typeId;
/*
* Points to the array type where this type is the element type.
* If the type has no corresponding array type, this type will be NULL.
*/
Type arrayType;
/*
* If the type is an array type, this is the element type.
*/
Type elementType;
/*
* Points to the object type that corresponds to this type
* if this type is a primitive. For non primitives, this attribute
* will be NULL.
*/
Type objectType;
/*
* Oid keyed hash map of coercion routines that can front this type when doing
* parameter input coercion.
*/
HashMap inCoercions;
/*
* Oid keyed hash map of coercion routines that can front this type when doing
* coercion of output results.
*/
HashMap outCoercions;
int16 length;
bool byValue;
char align;
};
/*
* Default version of canReplaceType. Returns true when
* self and other are equal.
*/
extern bool _Type_canReplaceType(Type self, Type other);
/*
* Default version of invoke. Will make a JNI CallObjectMethod call and then
* a call to self->coerceObject to create the Datum.
*/
extern Datum _Type_invoke(Type self, jclass cls, jmethodID method, jvalue* args, PG_FUNCTION_ARGS);
/*
* Return the m_oid member of the Type. This is the default version of
* Type_getTupleDesc.
*/
extern TupleDesc _Type_getTupleDesc(Type self, PG_FUNCTION_ARGS);
/*
* Store a Type keyed by its Oid in the cache.
*/
extern void Type_cacheByOid(Oid typeId, Type type);
/*
* Create a TypeClass with default sizes for TypeClass and Type.
*/
extern TypeClass TypeClass_alloc(const char* className);
/*
* Create a TypeClass for a specific TypeClass size and a specific Type size.
*/
extern TypeClass TypeClass_alloc2(const char* className, Size classSize, Size instanceSize);
/*
* Types are always allocated in global context.
*/
extern Type TypeClass_allocInstance(TypeClass cls, Oid typeId);
extern Type TypeClass_allocInstance2(TypeClass cls, Oid typeId, Form_pg_type pgType);
#ifdef __cplusplus
}
#endif
#endif
/*
Yet to implement
LOG: Type name = 'abstime'
LOG: Type name = 'box'
LOG: Type name = 'cid'
LOG: Type name = 'lseg'
LOG: Type name = 'path'
LOG: Type name = 'point'
LOG: Type name = 'reltime'
LOG: Type name = 'tid'
LOG: Type name = 'tinterval'
LOG: Type name = 'xid'
*/