summaryrefslogtreecommitdiff
path: root/contrib/miscutil
diff options
context:
space:
mode:
authorMarc G. Fournier1998-08-30 19:37:51 +0000
committerMarc G. Fournier1998-08-30 19:37:51 +0000
commiteec4c7366f04aa258bb8b7fcd2bbc90eda1cc271 (patch)
treedfb6b70845221063cc0515177b993713595ff69c /contrib/miscutil
parent3067ac8e77369c1b41195b4d90e2ff2c0b23bc7f (diff)
From: Massimo Dal Zotto <dz@cs.unitn.it>
Here is a tar file the new directories, which substitute the old ones in contrib. Please remove the old directories array, datetime, miscutil, string and userlock before unpacking the tar file in contrib. Note that as the modules are now installed in lib/modules I install all my sql code in lib/sql. In my opinion also the other contributors should follow these rules.
Diffstat (limited to 'contrib/miscutil')
-rw-r--r--contrib/miscutil/Makefile40
-rw-r--r--contrib/miscutil/assert_test.c43
-rw-r--r--contrib/miscutil/assert_test.h7
-rw-r--r--contrib/miscutil/misc_utils.c37
-rw-r--r--contrib/miscutil/misc_utils.doc39
-rw-r--r--contrib/miscutil/misc_utils.h12
-rw-r--r--contrib/miscutil/misc_utils.sql.in50
7 files changed, 139 insertions, 89 deletions
diff --git a/contrib/miscutil/Makefile b/contrib/miscutil/Makefile
index 33ba1e09370..ecb855e5600 100644
--- a/contrib/miscutil/Makefile
+++ b/contrib/miscutil/Makefile
@@ -1,7 +1,8 @@
#-------------------------------------------------------------------------
#
-# Makefile--
-# Makefile for array iterator functions.
+# Makefile --
+#
+# Makefile for the misc_util module.
#
#-------------------------------------------------------------------------
@@ -15,36 +16,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 = misc_utils
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 +55,7 @@ depend dep:
$(CC) -MM $(INCLUDE_OPT) *.c >depend
clean:
- rm -f $(MODULE) $(MODNAME).sql assert_test.so
+ rm -f *~ $(MODULE) $(MODNAME).sql
ifeq (depend,$(wildcard depend))
include depend
diff --git a/contrib/miscutil/assert_test.c b/contrib/miscutil/assert_test.c
deleted file mode 100644
index 793f585e510..00000000000
--- a/contrib/miscutil/assert_test.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * assert_test.c --
- *
- * This file tests Postgres assert checking.
- *
- * Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
- */
-
-#include "postgres.h"
-#include "assert_test.h"
-
-extern int assertTest(int val);
-extern int assertEnable(int val);
-
-int
-assert_enable(int val)
-{
- return assertEnable(val);
-}
-
-int
-assert_test(int val)
-{
- return assertTest(val);
-}
-
-/*
-
--- Enable/disable Postgres assert checking.
---
-create function assert_enable(int4) returns int4
- as '/usr/local/pgsql/lib/assert_test.so'
- language 'C';
-
--- Test Postgres assert checking.
---
-create function assert_test(int4) returns int4
- as '/usr/local/pgsql/lib/assert_test.so'
- language 'C';
-
-*/
-
-/* end of file */
diff --git a/contrib/miscutil/assert_test.h b/contrib/miscutil/assert_test.h
deleted file mode 100644
index 73b3938e065..00000000000
--- a/contrib/miscutil/assert_test.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef ASSERT_TEST_H
-#define ASSERT_TEST_H
-
-int assert_enable(int val);
-int assert_test(int val);
-
-#endif
diff --git a/contrib/miscutil/misc_utils.c b/contrib/miscutil/misc_utils.c
index b787457e3f9..ee2f3ec2b28 100644
--- a/contrib/miscutil/misc_utils.c
+++ b/contrib/miscutil/misc_utils.c
@@ -1,9 +1,12 @@
/*
- * utils.c --
+ * misc_utils.c --
*
- * This file defines various Postgres utility functions.
+ * This file defines miscellaneous PostgreSQL utility functions.
*
- * Copyright (c) 1996, 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 <unistd.h>
@@ -12,9 +15,15 @@
#include "utils/palloc.h"
#include "misc_utils.h"
+#include "assert_test.h"
extern int ExecutorLimit(int limit);
extern void Async_Unlisten(char *relname, int pid);
+extern int assertTest(int val);
+
+#ifdef ASSERT_CHECKING_TEST
+extern int assertEnable(int val);
+#endif
int
query_limit(int limit)
@@ -47,4 +56,26 @@ min(int x, int y)
return ((x < y) ? x : y);
}
+int
+assert_enable(int val)
+{
+ return assertEnable(val);
+}
+
+#ifdef ASSERT_CHECKING_TEST
+int
+assert_test(int val)
+{
+ return assertTest(val);
+}
+#endif
+
/* end of file */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/contrib/miscutil/misc_utils.doc b/contrib/miscutil/misc_utils.doc
new file mode 100644
index 00000000000..d1e3ac29ab8
--- /dev/null
+++ b/contrib/miscutil/misc_utils.doc
@@ -0,0 +1,39 @@
+Miscellaneous utility functions for PostgreSQL.
+
+query_limit(n)
+
+ sets a limit on the maximum numbers of query returned from
+ a backend. It can be used to limit the result size retrieved
+ by the application for poor input data or to avoid accidental
+ table product while playying with sql.
+
+backend_pid()
+
+ return the pid of our corresponding backend.
+
+unlisten(relname)
+
+ unlisten from a relation or from all relations if the argument
+ is null, empty or '*'.
+ It is now obsoleted by the new unlisten command but still useful
+ if you want unlisten a name computed by the query.
+ Note that a listen/notify relname can be any ascii string, not
+ just valid relation names.
+
+min(x,y)
+max(x,y)
+
+ return the min or max bteween two integers.
+
+assert_enable(bool)
+
+ enable/disable assert checkings in the backend, if it has been
+ compiled with USE_ASSERT_CHECKING.
+
+assert_test(bool)
+
+ test the assert enable/disable code, if the backend has been
+ compiled with ASSERT_CHECKING_TEST.
+
+--
+Massimo Dal Zotto <dz@cs.unitn.it>
diff --git a/contrib/miscutil/misc_utils.h b/contrib/miscutil/misc_utils.h
index a87c71b244b..cc7f9234432 100644
--- a/contrib/miscutil/misc_utils.h
+++ b/contrib/miscutil/misc_utils.h
@@ -6,5 +6,17 @@ int backend_pid(void);
int unlisten(char *relname);
int max(int x, int y);
int min(int x, int y);
+int assert_enable(int val);
+#ifdef ASSERT_CHECKING_TEST
+int assert_test(int val);
+#endif
#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/contrib/miscutil/misc_utils.sql.in b/contrib/miscutil/misc_utils.sql.in
index 0c90ba52eb9..1185d743e69 100644
--- a/contrib/miscutil/misc_utils.sql.in
+++ b/contrib/miscutil/misc_utils.sql.in
@@ -1,40 +1,58 @@
--- SQL code to define the new array iterator functions and operators
+-- misc_utils.sql --
+--
+-- SQL code to define misc functions.
+--
+-- 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.
--- min(x,y)
+-- Set the maximum number of tuples returned by a single query.
--
-create function min(int4,int4) returns int4
+create function query_limit(int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
--- max(x,y)
+-- Return the pid of the backend.
--
-create function max(int4,int4) returns int4
+create function backend_pid() returns int4
as 'MODULE_PATHNAME'
language 'C';
--- Set the maximum number of tuples returned by a single query
+-- Unlisten from a relation.
--
-create function query_limit(int4) returns int4
+create function "unlisten"(name) returns int4
as 'MODULE_PATHNAME'
language 'C';
--- Return the pid of the backend
+-- Unlisten from all relations for this backend.
--
-create function backend_pid() returns int4
+create function "unlisten"() returns int4
+ as 'select "unlisten"(''*'')'
+ language 'sql';
+
+-- min(x,y)
+--
+create function min(int4,int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
--- Unlisten from a relation
+-- max(x,y)
--
-create function unlisten(name) returns int4
+create function max(int4,int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
--- Unlisten from all relations for this backend
+-- Enable/disable Postgres assert checking.
--
-create function unlisten() returns int4
- as 'delete from pg_listener where listenerpid = backend_pid();
- select 0'
- language 'sql';
+create function assert_enable(int4) returns int4
+ as 'MODULE_PATHNAME'
+ language 'C';
+
+-- Test Postgres assert checking.
+--
+-- create function assert_test(int4) returns int4
+-- as 'MODULE_PATHNAME'
+-- language 'C';
-- end of file