6
6
* elements of the array and the value and compute a result as
7
7
* the logical OR or AND of the iteration results.
8
8
*
9
- * Copyright (c) 1997, Massimo Dal Zotto <dz@cs.unitn.it>
9
+ * Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
10
+ *
11
+ * This file is distributed under the GNU General Public License
12
+ * either version 2, or (at your option) any later version.
10
13
*/
11
14
12
15
#include <ctype.h>
@@ -33,8 +36,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
33
36
TypeTupleForm typ_struct ;
34
37
bool typbyval ;
35
38
int typlen ;
36
- func_ptr proc_fn ;
37
- int pronargs ;
39
+ FmgrInfo finfo ;
38
40
int nitems ,
39
41
i ,
40
42
result ;
@@ -70,9 +72,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
70
72
typbyval = typ_struct -> typbyval ;
71
73
72
74
/* Lookup the function entry point */
73
- proc_fn = (func_ptr ) NULL ;
74
- fmgr_info (proc , & pronargs ); /* (proc, &proc_fn, &pronargs); */
75
- if ((proc_fn == NULL ) || (pronargs != 2 ))
75
+ fmgr_info (proc , & finfo );
76
+ if ((finfo .fn_oid == 0 ) || (finfo .fn_nargs != 2 ))
76
77
{
77
78
elog (ERROR , "array_iterator: fmgr_info lookup failed for oid %d" , proc );
78
79
return (0 );
@@ -88,21 +89,21 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
88
89
switch (typlen )
89
90
{
90
91
case 1 :
91
- result = (int ) (* proc_fn ) (* p , value );
92
+ result = (int ) (* ( finfo . fn_addr ) ) (* p , value );
92
93
break ;
93
94
case 2 :
94
- result = (int ) (* proc_fn ) (* (int16 * ) p , value );
95
+ result = (int ) (* ( finfo . fn_addr ) ) (* (int16 * ) p , value );
95
96
break ;
96
97
case 3 :
97
98
case 4 :
98
- result = (int ) (* proc_fn ) (* (int32 * ) p , value );
99
+ result = (int ) (* ( finfo . fn_addr ) ) (* (int32 * ) p , value );
99
100
break ;
100
101
}
101
102
p += typlen ;
102
103
}
103
104
else
104
105
{
105
- result = (int ) (* proc_fn ) (p , value );
106
+ result = (int ) (* ( finfo . fn_addr ) ) (p , value );
106
107
if (typlen > 0 )
107
108
p += typlen ;
108
109
else
@@ -166,47 +167,6 @@ array_all_textregexeq(ArrayType *array, char *value)
166
167
array , (Datum ) value );
167
168
}
168
169
169
- /*
170
- * Iterator functions for type _char16. Note that the regexp
171
- * operators take the second argument of type text.
172
- */
173
-
174
- int32
175
- array_char16eq (ArrayType * array , char * value )
176
- {
177
- return array_iterator ((Oid ) 20 , /* char16 */
178
- (Oid ) 1275 , /* char16eq */
179
- 0 , /* logical or */
180
- array , (Datum ) value );
181
- }
182
-
183
- int32
184
- array_all_char16eq (ArrayType * array , char * value )
185
- {
186
- return array_iterator ((Oid ) 20 , /* char16 */
187
- (Oid ) 1275 , /* char16eq */
188
- 1 , /* logical and */
189
- array , (Datum ) value );
190
- }
191
-
192
- int32
193
- array_char16regexeq (ArrayType * array , char * value )
194
- {
195
- return array_iterator ((Oid ) 20 , /* char16 */
196
- (Oid ) 1288 , /* char16regexeq */
197
- 0 , /* logical or */
198
- array , (Datum ) value );
199
- }
200
-
201
- int32
202
- array_all_char16regexeq (ArrayType * array , char * value )
203
- {
204
- return array_iterator ((Oid ) 20 , /* char16 */
205
- (Oid ) 1288 , /* char16regexeq */
206
- 1 , /* logical and */
207
- array , (Datum ) value );
208
- }
209
-
210
170
/*
211
171
* Iterator functions for type _int4
212
172
*/
@@ -320,3 +280,11 @@ array_all_int4le(ArrayType *array, int4 value)
320
280
}
321
281
322
282
/* end of file */
283
+
284
+ /*
285
+ * Local variables:
286
+ * tab-width: 4
287
+ * c-indent-level: 4
288
+ * c-basic-offset: 4
289
+ * End:
290
+ */
0 commit comments