aboutsummaryrefslogtreecommitdiff
path: root/contrib/array
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/array')
-rw-r--r--contrib/array/Makefile35
-rw-r--r--contrib/array/array_iterator.c70
-rw-r--r--contrib/array/array_iterator.sql.in55
3 files changed, 48 insertions, 112 deletions
diff --git a/contrib/array/Makefile b/contrib/array/Makefile
index dd2ff66091d..9459f9c9bc3 100644
--- a/contrib/array/Makefile
+++ b/contrib/array/Makefile
@@ -15,36 +15,35 @@ INCLUDE_OPT = -I ./ \
-I $(SRCDIR)/include \
-I $(SRCDIR)/port/$(PORTNAME)
-CFLAGS += $(INCLUDE_OPT)
-
-ifeq ($(PORTNAME), linux)
- ifdef LINUX_ELF
- ifeq ($(CC), gcc)
- CFLAGS += -fPIC
- endif
- endif
-endif
-
-ifeq ($(PORTNAME), i386_solaris)
- CFLAGS+= -fPIC
-endif
+CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = array_iterator
MODULE = $(MODNAME)$(DLSUFFIX)
+MODDIR = $(LIBDIR)/modules
+
+SQLDIR = $(LIBDIR)/sql
+
all: module sql
module: $(MODULE)
sql: $(MODNAME).sql
-install: $(MODULE)
- cp -p $(MODULE) $(LIBDIR)/modules
- cd $(LIBDIR)/modules; strip $(MODULE)
+install: $(MODULE) $(MODDIR) $(SQLDIR)
+ cp -p $(MODULE) $(MODDIR)/
+ strip $(MODDIR)/$(MODULE)
+ cp -p $(MODNAME).sql $(SQLDIR)/
+
+$(MODDIR):
+ mkdir -p $@
+
+$(SQLDIR):
+ mkdir -p $@
%.sql: %.sql.in
- sed "s|MODULE_PATHNAME|$(LIBDIR)/modules/$(MODULE)|" < $< > $@
+ sed "s|MODULE_PATHNAME|$(MODDIR)/$(MODULE)|" < $< > $@
.SUFFIXES: $(DLSUFFIX)
@@ -55,7 +54,7 @@ depend dep:
$(CC) -MM $(INCLUDE_OPT) *.c >depend
clean:
- rm -f $(MODULE) $(MODNAME).sql
+ rm -f *~ $(MODULE) $(MODNAME).sql
ifeq (depend,$(wildcard depend))
include depend
diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c
index 9b6d9f8f4cf..06028ff4c6d 100644
--- a/contrib/array/array_iterator.c
+++ b/contrib/array/array_iterator.c
@@ -6,7 +6,10 @@
* elements of the array and the value and compute a result as
* the logical OR or AND of the iteration results.
*
- * Copyright (c) 1997, Massimo Dal Zotto <dz@cs.unitn.it>
+ * Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
+ *
+ * This file is distributed under the GNU General Public License
+ * either version 2, or (at your option) any later version.
*/
#include <ctype.h>
@@ -33,8 +36,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
TypeTupleForm typ_struct;
bool typbyval;
int typlen;
- func_ptr proc_fn;
- int pronargs;
+ FmgrInfo finfo;
int nitems,
i,
result;
@@ -70,9 +72,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
typbyval = typ_struct->typbyval;
/* Lookup the function entry point */
- proc_fn = (func_ptr) NULL;
- fmgr_info(proc, &pronargs); /* (proc, &proc_fn, &pronargs); */
- if ((proc_fn == NULL) || (pronargs != 2))
+ fmgr_info(proc, &finfo);
+ if ((finfo.fn_oid == 0) || (finfo.fn_nargs != 2))
{
elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc);
return (0);
@@ -88,21 +89,21 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
switch (typlen)
{
case 1:
- result = (int) (*proc_fn) (*p, value);
+ result = (int) (*(finfo.fn_addr)) (*p, value);
break;
case 2:
- result = (int) (*proc_fn) (*(int16 *) p, value);
+ result = (int) (*(finfo.fn_addr)) (*(int16 *) p, value);
break;
case 3:
case 4:
- result = (int) (*proc_fn) (*(int32 *) p, value);
+ result = (int) (*(finfo.fn_addr)) (*(int32 *) p, value);
break;
}
p += typlen;
}
else
{
- result = (int) (*proc_fn) (p, value);
+ result = (int) (*(finfo.fn_addr)) (p, value);
if (typlen > 0)
p += typlen;
else
@@ -167,47 +168,6 @@ array_all_textregexeq(ArrayType *array, char *value)
}
/*
- * Iterator functions for type _char16. Note that the regexp
- * operators take the second argument of type text.
- */
-
-int32
-array_char16eq(ArrayType *array, char *value)
-{
- return array_iterator((Oid) 20, /* char16 */
- (Oid) 1275, /* char16eq */
- 0, /* logical or */
- array, (Datum) value);
-}
-
-int32
-array_all_char16eq(ArrayType *array, char *value)
-{
- return array_iterator((Oid) 20, /* char16 */
- (Oid) 1275, /* char16eq */
- 1, /* logical and */
- array, (Datum) value);
-}
-
-int32
-array_char16regexeq(ArrayType *array, char *value)
-{
- return array_iterator((Oid) 20, /* char16 */
- (Oid) 1288, /* char16regexeq */
- 0, /* logical or */
- array, (Datum) value);
-}
-
-int32
-array_all_char16regexeq(ArrayType *array, char *value)
-{
- return array_iterator((Oid) 20, /* char16 */
- (Oid) 1288, /* char16regexeq */
- 1, /* logical and */
- array, (Datum) value);
-}
-
-/*
* Iterator functions for type _int4
*/
@@ -320,3 +280,11 @@ array_all_int4le(ArrayType *array, int4 value)
}
/* end of file */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/contrib/array/array_iterator.sql.in b/contrib/array/array_iterator.sql.in
index 6489545d97d..40deb7e0c60 100644
--- a/contrib/array/array_iterator.sql.in
+++ b/contrib/array/array_iterator.sql.in
@@ -1,6 +1,13 @@
--- SQL code to define the new array iterator functions and operators
+-- array_iterator.sql --
+--
+-- SQL code to define the array iterator functions and operators.
+--
+-- Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
+--
+-- This file is distributed under the GNU General Public License
+-- either version 2, or (at your option) any later version.
--- define the array operators *=, **=, *~ and **~ for type _text
+-- Define the array functions *=, **=, *~ and **~ for type _text
--
create function array_texteq(_text, text) returns bool
as 'MODULE_PATHNAME'
@@ -38,47 +45,7 @@ create operator **~ (
rightarg=text,
procedure=array_all_textregexeq);
-
--- define the array operators *=, **=, *~ and **~ for type _char16
---
-create function array_char16eq(_char16, char16) returns bool
- as 'MODULE_PATHNAME'
- language 'c';
-
-create function array_all_char16eq(_char16, char16) returns bool
- as 'MODULE_PATHNAME'
- language 'c';
-
-create function array_char16regexeq(_char16, text) returns bool
- as 'MODULE_PATHNAME'
- language 'c';
-
-create function array_all_char16regexeq(_char16, text) returns bool
- as 'MODULE_PATHNAME'
- language 'c';
-
-create operator *= (
- leftarg=_char16,
- rightarg=char16,
- procedure=array_char16eq);
-
-create operator **= (
- leftarg=_char16,
- rightarg=char16,
- procedure=array_all_char16eq);
-
-create operator *~ (
- leftarg=_char16,
- rightarg=text,
- procedure=array_char16regexeq);
-
-create operator **~ (
- leftarg=_char16,
- rightarg=text,
- procedure=array_all_char16regexeq);
-
-
--- define the array operators *=, **=, *> and **> for type _int4
+-- Define the array functions *=, **=, *> and **> for type _int4
--
create function array_int4eq(_int4, int4) returns bool
as 'MODULE_PATHNAME'
@@ -128,6 +95,8 @@ create function array_all_int4le(_int4, int4) returns bool
as 'MODULE_PATHNAME'
language 'c';
+-- Define the operators corresponding to the above functions
+--
create operator *= (
leftarg=_int4,
rightarg=int4,