1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

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.
This commit is contained in:
Marc G. Fournier
1998-08-30 19:37:51 +00:00
parent 3067ac8e77
commit eec4c7366f
25 changed files with 449 additions and 438 deletions

View File

@ -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

View File

@ -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 */

View File

@ -1,7 +0,0 @@
#ifndef ASSERT_TEST_H
#define ASSERT_TEST_H
int assert_enable(int val);
int assert_test(int val);
#endif

View File

@ -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:
*/

View File

@ -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>

View File

@ -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:
*/

View File

@ -1,4 +1,35 @@
-- 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.
-- Set the maximum number of tuples returned by a single query.
--
create function query_limit(int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Return the pid of the backend.
--
create function backend_pid() returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Unlisten from a relation.
--
create function "unlisten"(name) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Unlisten from all relations for this backend.
--
create function "unlisten"() returns int4
as 'select "unlisten"(''*'')'
language 'sql';
-- min(x,y)
--
@ -12,29 +43,16 @@ create function max(int4,int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Set the maximum number of tuples returned by a single query
-- Enable/disable Postgres assert checking.
--
create function query_limit(int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
create function assert_enable(int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Return the pid of the backend
-- Test Postgres assert checking.
--
create function backend_pid() returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Unlisten from a relation
--
create function unlisten(name) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Unlisten from all relations for this backend
--
create function unlisten() returns int4
as 'delete from pg_listener where listenerpid = backend_pid();
select 0'
language 'sql';
-- create function assert_test(int4) returns int4
-- as 'MODULE_PATHNAME'
-- language 'C';
-- end of file