1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Update of contrib stuff from massimo.

This commit is contained in:
Bruce Momjian
1997-11-05 21:38:25 +00:00
parent 5aaf00f3f3
commit 951986c550
33 changed files with 2547 additions and 578 deletions

62
contrib/miscutil/Makefile Normal file
View File

@ -0,0 +1,62 @@
#-------------------------------------------------------------------------
#
# Makefile--
# Makefile for array iterator functions.
#
#-------------------------------------------------------------------------
PGDIR = ../..
SRCDIR = $(PGDIR)/src
include $(SRCDIR)/Makefile.global
INCLUDE_OPT = -I ./ \
-I $(SRCDIR)/ \
-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
MODNAME = misc_utils
MODULE = $(MODNAME)$(DLSUFFIX)
all: module sql
module: $(MODULE)
sql: $(MODNAME).sql
install: $(MODULE)
cp -p $(MODULE) $(LIBDIR)
cd $(LIBDIR); strip $(MODULE)
%.sql: %.sql.in
sed "s|MODULE_PATHNAME|$(LIBDIR)/$(MODULE)|" < $< > $@
.SUFFIXES: $(DLSUFFIX)
%$(DLSUFFIX): %.c
cc $(CFLAGS) -shared -o $@ $<
depend dep:
$(CC) -MM $(INCLUDE_OPT) *.c >depend
clean:
rm -f $(MODULE) $(MODNAME).sql assert_test.so
ifeq (depend,$(wildcard depend))
include depend
endif

View File

@ -0,0 +1,43 @@
/*
* 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

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

View File

@ -0,0 +1,50 @@
/*
* utils.c --
*
* This file defines various Postgres utility functions.
*
* Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
*/
#include <unistd.h>
#include "postgres.h"
#include "utils/palloc.h"
#include "misc_utils.h"
extern int ExecutorLimit(int limit);
extern void Async_Unlisten(char *relname, int pid);
int
query_limit(int limit)
{
return ExecutorLimit(limit);
}
int
backend_pid()
{
return getpid();
}
int
unlisten(char *relname)
{
Async_Unlisten(relname, getpid());
return 0;
}
int
max(int x, int y)
{
return ((x > y) ? x : y);
}
int
min(int x, int y)
{
return ((x < y) ? x : y);
}
/* end of file */

View File

@ -0,0 +1,10 @@
#ifndef MISC_UTILS_H
#define MISC_UTILS_H
int query_limit(int limit);
int backend_pid(void);
int unlisten(char *relname);
int max(int x, int y);
int min(int x, int y);
#endif

View File

@ -0,0 +1,40 @@
-- SQL code to define the new array iterator functions and operators
-- min(x,y)
--
create function min(int4,int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- max(x,y)
--
create function max(int4,int4) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- 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 'delete from pg_listener where listenerpid = backend_pid();
select 0'
language 'sql';
-- end of file