Commit 27b81439 authored by Bruce Momjian's avatar Bruce Momjian

Hi,

I have updated my contrib code for version 6.5. In the attachment you will
find the directories array, datetime, miscutil, string, tools and userlocks
which replace the corresponding directories under contrib.

In contrib/tools you will find some developement scripts which I use while
hacking the sources. I hope they will be useful for some other people.

I have also added a contrib/Makefile which tries to compile and install all
the contribs. Unfortunately many of them don't have a Makefile or don't
compile cleanly.

--
Massimo Dal Zotto
parent 977108e8
# Makefile for contrib code
#
# The following subdirs don't have a Makefile:
#
# apache_logging
# linux
# mSQL-interface
# noupdate
# unixdate
#
# The following subdirs give make errors:
#
# earthdistance
# findoidjoins
# isbn_issn
# os2client
# pginterface
all:
for dir in *; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir; \
fi; \
done
install:
for dir in *; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir $@ ; \
fi; \
done
clean:
for dir in *; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir $@ ; \
fi; \
done || exit 0
distclean:
for dir in *; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir $@ ; \
fi; \
done || exit 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile-- # Makefile --
# Makefile for array iterator functions. #
# Makefile for array iterator module.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) ...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = array_iterator MODNAME = array_iterator
SQLDEFS = $(MODNAME).sql
MODULE = $(MODNAME)$(DLSUFFIX) MODULE = $(MODNAME)$(DLSUFFIX)
MODDIR = $(LIBDIR)/modules MODDIR = $(LIBDIR)/modules
...@@ -29,12 +32,12 @@ all: module sql ...@@ -29,12 +32,12 @@ all: module sql
module: $(MODULE) module: $(MODULE)
sql: $(MODNAME).sql sql: $(SQLDEFS)
install: $(MODULE) $(MODDIR) $(SQLDIR) install: $(MODULE) $(SQLDEFS) $(MODDIR) $(SQLDIR)
cp -p $(MODULE) $(MODDIR)/ cp -p $(MODULE) $(MODDIR)/
strip $(MODDIR)/$(MODULE) strip $(MODDIR)/$(MODULE)
cp -p $(MODNAME).sql $(SQLDIR)/ cp -p $(SQLDEFS) $(SQLDIR)/
$(MODDIR): $(MODDIR):
mkdir -p $@ mkdir -p $@
......
...@@ -173,42 +173,83 @@ array_all_textregexeq(ArrayType *array, char *value) ...@@ -173,42 +173,83 @@ array_all_textregexeq(ArrayType *array, char *value)
} }
/* /*
* Iterator functions for type _char16. Note that the regexp * Iterator functions for type _varchar. Note that the regexp
* operators take the second argument of type text. * operators take the second argument of type text.
*/ */
int32 int32
array_char16eq(ArrayType *array, char *value) array_varchareq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* varchar */
(Oid) 1275, /* char16eq */ (Oid) 1070, /* varchareq */
0, /* logical or */ 0, /* logical or */
array, (Datum) value); array, (Datum) value);
} }
int32 int32
array_all_char16eq(ArrayType *array, char *value) array_all_varchareq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* varchar */
(Oid) 1275, /* char16eq */ (Oid) 1070, /* varchareq */
1, /* logical and */ 1, /* logical and */
array, (Datum) value); array, (Datum) value);
} }
int32 int32
array_char16regexeq(ArrayType *array, char *value) array_varcharregexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* varchar */
(Oid) 1288, /* char16regexeq */ (Oid) 1254, /* textregexeq */
0, /* logical or */
array, (Datum) value);
}
int32
array_all_varcharregexeq(ArrayType *array, char *value)
{
return array_iterator((Oid) 20, /* varchar */
(Oid) 1254, /* textregexeq */
1, /* logical and */
array, (Datum) value);
}
/*
* Iterator functions for type _bpchar. Note that the regexp
* operators take the second argument of type text.
*/
int32
array_bpchareq(ArrayType *array, char *value)
{
return array_iterator((Oid) 20, /* bpchar */
(Oid) 1048, /* bpchareq */
0, /* logical or */
array, (Datum) value);
}
int32
array_all_bpchareq(ArrayType *array, char *value)
{
return array_iterator((Oid) 20, /* bpchar */
(Oid) 1048, /* bpchareq */
1, /* logical and */
array, (Datum) value);
}
int32
array_bpcharregexeq(ArrayType *array, char *value)
{
return array_iterator((Oid) 20, /* bpchar */
(Oid) 1254, /* textregexeq */
0, /* logical or */ 0, /* logical or */
array, (Datum) value); array, (Datum) value);
} }
int32 int32
array_all_char16regexeq(ArrayType *array, char *value) array_all_bpcharregexeq(ArrayType *array, char *value)
{ {
return array_iterator((Oid) 20, /* char16 */ return array_iterator((Oid) 20, /* bpchar */
(Oid) 1288, /* char16regexeq */ (Oid) 1254, /* textregexeq */
1, /* logical and */ 1, /* logical and */
array, (Datum) value); array, (Datum) value);
} }
...@@ -327,7 +368,6 @@ array_all_int4le(ArrayType *array, int4 value) ...@@ -327,7 +368,6 @@ array_all_int4le(ArrayType *array, int4 value)
/* new tobias gabele 1999 */ /* new tobias gabele 1999 */
int32 int32
array_oideq(ArrayType *array, Oid value) array_oideq(ArrayType *array, Oid value)
{ {
...@@ -346,10 +386,12 @@ array_all_oidne(ArrayType *array, Oid value) ...@@ -346,10 +386,12 @@ array_all_oidne(ArrayType *array, Oid value)
array, (Datum) value); array, (Datum) value);
} }
/* end of file */ /* end of file */
/*
* Local Variables:
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/
...@@ -3,14 +3,22 @@ ...@@ -3,14 +3,22 @@
static int32 array_iterator(Oid elemtype, Oid proc, int and, static int32 array_iterator(Oid elemtype, Oid proc, int and,
ArrayType *array, Datum value); ArrayType *array, Datum value);
int32 array_texteq(ArrayType *array, char *value); int32 array_texteq(ArrayType *array, char *value);
int32 array_all_texteq(ArrayType *array, char *value); int32 array_all_texteq(ArrayType *array, char *value);
int32 array_textregexeq(ArrayType *array, char *value); int32 array_textregexeq(ArrayType *array, char *value);
int32 array_all_textregexeq(ArrayType *array, char *value); int32 array_all_textregexeq(ArrayType *array, char *value);
int32 array_char16eq(ArrayType *array, char *value);
int32 array_all_char16eq(ArrayType *array, char *value); int32 array_varchareq(ArrayType *array, char *value);
int32 array_char16regexeq(ArrayType *array, char *value); int32 array_all_varchareq(ArrayType *array, char *value);
int32 array_all_char16regexeq(ArrayType *array, char *value); int32 array_varcharregexeq(ArrayType *array, char *value);
int32 array_all_varcharregexeq(ArrayType *array, char *value);
int32 array_bpchareq(ArrayType *array, char *value);
int32 array_all_bpchareq(ArrayType *array, char *value);
int32 array_bpcharregexeq(ArrayType *array, char *value);
int32 array_all_bpcharregexeq(ArrayType *array, char *value);
int32 array_int4eq(ArrayType *array, int4 value); int32 array_int4eq(ArrayType *array, int4 value);
int32 array_all_int4eq(ArrayType *array, int4 value); int32 array_all_int4eq(ArrayType *array, int4 value);
int32 array_int4ne(ArrayType *array, int4 value); int32 array_int4ne(ArrayType *array, int4 value);
...@@ -23,7 +31,15 @@ int32 array_int4lt(ArrayType *array, int4 value); ...@@ -23,7 +31,15 @@ int32 array_int4lt(ArrayType *array, int4 value);
int32 array_all_int4lt(ArrayType *array, int4 value); int32 array_all_int4lt(ArrayType *array, int4 value);
int32 array_int4le(ArrayType *array, int4 value); int32 array_int4le(ArrayType *array, int4 value);
int32 array_all_int4le(ArrayType *array, int4 value); int32 array_all_int4le(ArrayType *array, int4 value);
int32 array_oideq(ArrayType *array, Oid value); int32 array_oideq(ArrayType *array, Oid value);
int32 array_all_oidne(ArrayType *array, Oid value); int32 array_all_oidne(ArrayType *array, Oid value);
#endif #endif
/*
* Local Variables:
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/
...@@ -39,43 +39,84 @@ create operator **~ ( ...@@ -39,43 +39,84 @@ create operator **~ (
procedure=array_all_textregexeq); procedure=array_all_textregexeq);
-- define the array operators *=, **=, *~ and **~ for type _char16 -- define the array operators *=, **=, *~ and **~ for type _varchar
-- --
create function array_char16eq(_char16, char16) returns bool -- NOTE: "varchar" is also a reserved word and must be quoted.
--
create function array_varchareq(_varchar, varchar) returns bool
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function array_all_char16eq(_char16, char16) returns bool create function array_all_varchareq(_varchar, varchar) returns bool
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function array_char16regexeq(_char16, text) returns bool create function array_varcharregexeq(_varchar, varchar) returns bool
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create function array_all_char16regexeq(_char16, text) returns bool create function array_all_varcharregexeq(_varchar, varchar) returns bool
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'c'; language 'c';
create operator *= ( create operator *= (
leftarg=_char16, leftarg=_varchar,
rightarg=char16, rightarg="varchar",
procedure=array_char16eq); procedure=array_varchareq);
create operator **= ( create operator **= (
leftarg=_char16, leftarg=_varchar,
rightarg=char16, rightarg="varchar",
procedure=array_all_char16eq); procedure=array_all_varchareq);
create operator *~ ( create operator *~ (
leftarg=_char16, leftarg=_varchar,
rightarg=text, rightarg="varchar",
procedure=array_char16regexeq); procedure=array_varcharregexeq);
create operator **~ ( create operator **~ (
leftarg=_char16, leftarg=_varchar,
rightarg=text, rightarg="varchar",
procedure=array_all_char16regexeq); procedure=array_all_varcharregexeq);
-- define the array operators *=, **=, *~ and **~ for type _bpchar
--
create function array_bpchareq(_bpchar, bpchar) returns bool
as 'MODULE_PATHNAME'
language 'c';
create function array_all_bpchareq(_bpchar, bpchar) returns bool
as 'MODULE_PATHNAME'
language 'c';
create function array_bpcharregexeq(_bpchar, bpchar) returns bool
as 'MODULE_PATHNAME'
language 'c';
create function array_all_bpcharregexeq(_bpchar, bpchar) returns bool
as 'MODULE_PATHNAME'
language 'c';
create operator *= (
leftarg=_bpchar,
rightarg=bpchar,
procedure=array_bpchareq);
create operator **= (
leftarg=_bpchar,
rightarg=bpchar,
procedure=array_all_bpchareq);
create operator *~ (
leftarg=_bpchar,
rightarg=bpchar,
procedure=array_bpcharregexeq);
create operator **~ (
leftarg=_bpchar,
rightarg=bpchar,
procedure=array_all_bpcharregexeq);
-- define the array operators *=, **=, *> and **> for type _int4 -- define the array operators *=, **=, *> and **> for type _int4
...@@ -209,5 +250,4 @@ create operator **<> ( ...@@ -209,5 +250,4 @@ create operator **<> (
procedure=array_all_oidne); procedure=array_all_oidne);
-- end of file -- end of file
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile-- # Makefile --
# Makefile for new date/time functions. #
# Makefile for new datetime module.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) ...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = datetime_functions MODNAME = datetime_functions
SQLDEFS = $(MODNAME).sql
MODULE = $(MODNAME)$(DLSUFFIX) MODULE = $(MODNAME)$(DLSUFFIX)
MODDIR = $(LIBDIR)/modules MODDIR = $(LIBDIR)/modules
...@@ -29,12 +32,12 @@ all: module sql ...@@ -29,12 +32,12 @@ all: module sql
module: $(MODULE) module: $(MODULE)
sql: $(MODNAME).sql sql: $(SQLDEFS)
install: $(MODULE) $(MODDIR) $(SQLDIR) install: $(MODULE) $(SQLDEFS) $(MODDIR) $(SQLDIR)
cp -p $(MODULE) $(MODDIR)/ cp -p $(MODULE) $(MODDIR)/
strip $(MODDIR)/$(MODULE) strip $(MODDIR)/$(MODULE)
cp -p $(MODNAME).sql $(SQLDIR)/ cp -p $(SQLDEFS) $(SQLDIR)/
$(MODDIR): $(MODDIR):
mkdir -p $@ mkdir -p $@
......
...@@ -28,10 +28,61 @@ ...@@ -28,10 +28,61 @@
/* Constant to replace calls to date2j(2000,1,1) */ /* Constant to replace calls to date2j(2000,1,1) */
#define JDATE_2000 2451545 #define JDATE_2000 2451545
/*
* decode_24h_time()
*
* Decode time string 00:00:00 through 24:00:00.
*/
static int
decode_24h_time(char *str, struct tm *tm, double *fsec)
{
char *cp;
tm->tm_hour = strtol(str, &cp, 10);
if (*cp != ':')
return -1;
str = cp + 1;
tm->tm_min = strtol(str, &cp, 10);
if (*cp == '\0')
{
tm->tm_sec = 0;
*fsec = 0;
}
else if (*cp != ':')
{
return -1;
}
else
{
str = cp + 1;
tm->tm_sec = strtol(str, &cp, 10);
if (*cp == '\0')
*fsec = 0;
else if (*cp == '.')
{
str = cp;
*fsec = strtod(str, &cp);
if (cp == str)
return -1;
}
else
return -1;
}
/* do a sanity check */
if ( (tm->tm_hour < 0) || (tm->tm_hour > 24)
|| (tm->tm_min < 0) || (tm->tm_min > 59)
|| (tm->tm_sec < 0) || (tm->tm_sec > 59)
|| (fsec < 0) )
return -1;
return 0;
}
/* /*
* A modified version of time_in which allows the value 24:00:00 for * A modified version of time_in which allows the value 24:00:00 for
* time and converts it to TimeADT data type forcing seconds to 0. * time and converts it to TimeADT data type forcing seconds to 0.
* This can be Useful if you need to handle TimeADT values limited * This can be useful if you need to handle TimeADT values limited
* to hh:mm like in timetables. * to hh:mm like in timetables.
*/ */
...@@ -44,35 +95,23 @@ hhmm_in(char *str) ...@@ -44,35 +95,23 @@ hhmm_in(char *str)
struct tm tt, struct tm tt,
*tm = &tt; *tm = &tt;
int nf;
char lowstr[MAXDATELEN + 1];
char *field[MAXDATEFIELDS];
int dtype;
int ftype[MAXDATEFIELDS];
if (!PointerIsValid(str)) if (!PointerIsValid(str))
elog(ERROR, "Bad (null) time external representation", NULL); elog(ERROR, "Bad (null) time external representation", NULL);
if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0) if (decode_24h_time(str, tm, &fsec) != 0)
|| (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec) != 0))
elog(ERROR, "Bad time external representation '%s'", str); elog(ERROR, "Bad time external representation '%s'", str);
if (tm->tm_hour < 0 || tm->tm_hour > 24 || if ((tm->tm_hour < 0) || (tm->tm_hour > 24)
(tm->tm_hour == 24 && (tm->tm_min != 0 || tm->tm_sec != 0 || fsec != 0))) || ((tm->tm_hour == 24)
&& ((tm->tm_min != 0) || (tm->tm_sec != 0) || (fsec != 0.0))))
{ {
elog(ERROR, elog(ERROR,
"time_in: hour must be limited to values 0 through 24:00 " "Time must be limited to values 00:00:00 through 24:00:00 "
"in \"%s\"", "in \"%s\"",
str); str);
} }
if ((tm->tm_min < 0) || (tm->tm_min > 59))
elog(ERROR, "Minute must be limited to values 0 through 59 in '%s'", str);
if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60))
elog(ERROR, "Second must be limited to values 0 through < 60 in '%s'",
str);
time = palloc(sizeof(TimeADT)); time = palloc(sizeof(TimeADT));
*time = ((((tm->tm_hour * 60) + tm->tm_min) * 60)); *time = ((((tm->tm_hour * 60) + tm->tm_min) * 60));
return (time); return (time);
...@@ -224,7 +263,7 @@ currentdate() ...@@ -224,7 +263,7 @@ currentdate()
/* end of file */ /* end of file */
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -17,3 +17,11 @@ TimeADT *currenttime(void); ...@@ -17,3 +17,11 @@ TimeADT *currenttime(void);
DateADT currentdate(void); DateADT currentdate(void);
#endif #endif
/*
* Local Variables:
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/
...@@ -79,14 +79,14 @@ create operator - ( ...@@ -79,14 +79,14 @@ create operator - (
-- --
create function hhmm_mode() returns text create function hhmm_mode() returns text
as 'update pg_type set typinput =''hhmm_in'' where typname=''time''; as 'update pg_type set typinput =''hhmm_in'' where typname=''time'';
update pg_type set typoutput=''hhmm_out'' where typname=''time'' update pg_type set typoutput=''hhmm_out'' where typname=''time'';
select ''hhmm_mode''::text' select ''hhmm_mode''::text;'
language 'sql'; language 'sql';
create function time_mode() returns text create function time_mode() returns text
as 'update pg_type set typinput =''time_in'' where typname=''time''; as 'update pg_type set typinput =''time_in'' where typname=''time'';
update pg_type set typoutput=''time_out'' where typname=''time'' update pg_type set typoutput=''time_out'' where typname=''time'';
select ''time_mode''::text' select ''time_mode''::text;'
language 'sql'; language 'sql';
-- Use these to do the updates manually -- Use these to do the updates manually
......
...@@ -20,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) ...@@ -20,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = misc_utils MODNAME = misc_utils
SQLDEFS = $(MODNAME).sql
MODULE = $(MODNAME)$(DLSUFFIX) MODULE = $(MODNAME)$(DLSUFFIX)
MODDIR = $(LIBDIR)/modules MODDIR = $(LIBDIR)/modules
...@@ -30,12 +32,12 @@ all: module sql ...@@ -30,12 +32,12 @@ all: module sql
module: $(MODULE) module: $(MODULE)
sql: $(MODNAME).sql sql: $(SQLDEFS)
install: $(MODULE) $(MODDIR) $(SQLDIR) install: $(MODULE) $(SQLDEFS) $(MODDIR) $(SQLDIR)
cp -p $(MODULE) $(MODDIR)/ cp -p $(MODULE) $(MODDIR)/
strip $(MODDIR)/$(MODULE) strip $(MODDIR)/$(MODULE)
cp -p $(MODNAME).sql $(SQLDIR)/ cp -p $(SQLDEFS) $(SQLDIR)/
$(MODDIR): $(MODDIR):
mkdir -p $@ mkdir -p $@
......
...@@ -10,12 +10,27 @@ ...@@ -10,12 +10,27 @@
*/ */
#include <unistd.h> #include <unistd.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include "postgres.h" #include "postgres.h"
#include "access/heapam.h"
#include "access/htup.h"
#include "access/relscan.h"
#include "access/skey.h"
#include "access/tupdesc.h"
#include "catalog/catname.h"
#include "catalog/pg_listener.h"
#include "storage/lmgr.h"
#include "utils/fmgr.h"
#include "utils/palloc.h" #include "utils/palloc.h"
#include "utils/rel.h"
#include "utils/tqual.h"
#include "misc_utils.h" #include "misc_utils.h"
#include "assert_test.h"
#define MIN(x,y) ((x)<=(y) ? (x) : (y))
extern int ExecutorLimit(int limit); extern int ExecutorLimit(int limit);
extern void Async_Unlisten(char *relname, int pid); extern void Async_Unlisten(char *relname, int pid);
...@@ -23,7 +38,6 @@ extern int assertTest(int val); ...@@ -23,7 +38,6 @@ extern int assertTest(int val);
#ifdef ASSERT_CHECKING_TEST #ifdef ASSERT_CHECKING_TEST
extern int assertEnable(int val); extern int assertEnable(int val);
#endif #endif
int int
...@@ -57,6 +71,62 @@ min(int x, int y) ...@@ -57,6 +71,62 @@ min(int x, int y)
return ((x < y) ? x : y); return ((x < y) ? x : y);
} }
/*
* Return the number of active listeners on a relation name.
*/
int
active_listeners(text *relname)
{
HeapTuple lTuple;
Relation lRel;
HeapScanDesc sRel;
TupleDesc tdesc;
ScanKeyData key;
Datum d;
bool isnull;
int len, pid;
int count = 0;
int ourpid = getpid();
char listen_name[NAMEDATALEN];
lRel = heap_openr(ListenerRelationName);
tdesc = RelationGetDescr(lRel);
LockRelation(lRel, AccessShareLock);
if (relname && (VARSIZE(relname) > VARHDRSZ)) {
len = MIN(VARSIZE(relname)-VARHDRSZ, NAMEDATALEN-1);
strncpy(listen_name, VARDATA(relname), len);
listen_name[len] = '\0';
ScanKeyEntryInitialize(&key, 0,
Anum_pg_listener_relname,
F_NAMEEQ,
PointerGetDatum(listen_name));
sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key);
} else {
sRel = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey)NULL);
}
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
{
d = heap_getattr(lTuple, Anum_pg_listener_pid, tdesc, &isnull);
pid = DatumGetInt32(d);
#ifdef HAVE_KILL
if ((pid == ourpid) || (kill(pid, SIGTSTP) == 0)) {
/* elog(NOTICE, "%d ok", pid); */
count++;
}
#else
count++;
#endif
}
heap_endscan(sRel);
UnlockRelation(lRel, AccessShareLock);
heap_close(lRel);
return count;
}
int int
assert_enable(int val) assert_enable(int val)
{ {
...@@ -69,13 +139,12 @@ assert_test(int val) ...@@ -69,13 +139,12 @@ assert_test(int val)
{ {
return assertTest(val); return assertTest(val);
} }
#endif #endif
/* end of file */ /* end of file */
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -10,13 +10,13 @@ int assert_enable(int val); ...@@ -10,13 +10,13 @@ int assert_enable(int val);
#ifdef ASSERT_CHECKING_TEST #ifdef ASSERT_CHECKING_TEST
int assert_test(int val); int assert_test(int val);
#endif #endif
int active_listeners(text *relname);
#endif #endif
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -43,6 +43,12 @@ create function max(int4,int4) returns int4 ...@@ -43,6 +43,12 @@ create function max(int4,int4) returns int4
as 'MODULE_PATHNAME' as 'MODULE_PATHNAME'
language 'C'; language 'C';
-- Return the number of active listeners on a relation
--
create function active_listeners(text) returns int4
as 'MODULE_PATHNAME'
language 'C';
-- Enable/disable Postgres assert checking. -- Enable/disable Postgres assert checking.
-- --
create function assert_enable(int4) returns int4 create function assert_enable(int4) returns int4
......
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile -- # Makefile --
#
# Makefile for string I/O module. # Makefile for string I/O module.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) ...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = string_io MODNAME = string_io
SQLDEFS = $(MODNAME).sql
MODULE = $(MODNAME)$(DLSUFFIX) MODULE = $(MODNAME)$(DLSUFFIX)
MODDIR = $(LIBDIR)/modules MODDIR = $(LIBDIR)/modules
...@@ -29,12 +32,12 @@ all: module sql ...@@ -29,12 +32,12 @@ all: module sql
module: $(MODULE) module: $(MODULE)
sql: $(MODNAME).sql sql: $(SQLDEFS)
install: $(MODULE) $(MODDIR) $(SQLDIR) install: $(MODULE) $(SQLDEFS) $(MODDIR) $(SQLDIR)
cp -p $(MODULE) $(MODDIR)/ cp -p $(MODULE) $(MODDIR)/
strip $(MODDIR)/$(MODULE) strip $(MODDIR)/$(MODULE)
cp -p $(MODNAME).sql $(SQLDIR)/ cp -p $(SQLDEFS) $(SQLDIR)/
$(MODDIR): $(MODDIR):
mkdir -p $@ mkdir -p $@
......
...@@ -352,13 +352,12 @@ c_charin(char *str) ...@@ -352,13 +352,12 @@ c_charin(char *str)
{ {
return (string_input(str, 1, 0, NULL)); return (string_input(str, 1, 0, NULL));
} }
#endif #endif
/* end of file */ /* end of file */
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -14,13 +14,12 @@ char *c_varcharout(char *s); ...@@ -14,13 +14,12 @@ char *c_varcharout(char *s);
#if 0 #if 0
struct varlena *c_textin(char *str); struct varlena *c_textin(char *str);
char *c_char16in(char *str); char *c_char16in(char *str);
#endif #endif
#endif #endif
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -40,7 +40,7 @@ create function c_mode() returns text ...@@ -40,7 +40,7 @@ create function c_mode() returns text
update pg_type set typoutput=''c_textout'' where typname=''text''; update pg_type set typoutput=''c_textout'' where typname=''text'';
update pg_type set typoutput=''c_textout'' where typname=''unknown''; update pg_type set typoutput=''c_textout'' where typname=''unknown'';
update pg_type set typoutput=''c_varcharout'' where typname=''varchar''; update pg_type set typoutput=''c_varcharout'' where typname=''varchar'';
select ''c_mode''::text' select ''c_mode''::text;'
language 'sql'; language 'sql';
-- Define a function which restores the standard routines for char types. -- Define a function which restores the standard routines for char types.
...@@ -55,7 +55,7 @@ create function pg_mode() returns text ...@@ -55,7 +55,7 @@ create function pg_mode() returns text
update pg_type set typoutput=''textout'' where typname=''text''; update pg_type set typoutput=''textout'' where typname=''text'';
update pg_type set typoutput=''textout'' where typname=''unknown''; update pg_type set typoutput=''textout'' where typname=''unknown'';
update pg_type set typoutput=''varcharout'' where typname=''varchar''; update pg_type set typoutput=''varcharout'' where typname=''varchar'';
select ''pg_mode''::text' select ''pg_mode''::text;'
language 'sql'; language 'sql';
-- Use these to do the changes manually. -- Use these to do the changes manually.
......
#-------------------------------------------------------------------------
#
# Makefile --
#
# Makefile for contrib tools.
#
#-------------------------------------------------------------------------
PGDIR = ../..
SRCDIR = $(PGDIR)/src
include $(SRCDIR)/Makefile.global
all:
install:
clean:
rm -f *~
distclean: clean
#!/bin/bash
#
# Add local variables to C sources files to set emacs C style to 4-space tabs.
#
# Usage: cd $PG_HOME && add-emacs-variables `find . -name \*.[chy] -print`
for f in $*; do
if [ -L $f ] || grep -q '^ \* Local Variables:' $f; then
continue
fi
echo $f
touch -r $f /tmp/.add-local-variables.$$
cat <<- ' EOF' >> $f
/*
* Local Variables:
* tab-width: 4
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/
EOF
touch -r /tmp/.add-local-variables.$$ $f
done
rm -f /tmp/.add-local-variables.$$
# end of file
#!/bin/echo Usage: source
#
# Set the shell variables files, cfiles, hfiles, yfiles and sfiles with
# the names of all .c, .h, .y, and .S files in current directory tree.
# Define also some shell functions to grep the files. Typical usage is:
#
# $ cd src/
# $ source ../contrib/tools/find-sources
# $ gh BLCKSZ # grep BLCKSZ in .h files
# $ gcl MAXTUPLEN # list all .c files containing MAXTUPLEN
#
# THIS SCRIPT MUST BE SOURCED FROM BASH.
#
# Copyright (C) 1999 Massimo Dal Zotto <dz@cs.unitn.it>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# Build the file lists
dir=${1-`pwd`}/
cfiles=`find $dir -name \*.c | sort`
hfiles=`find $dir -name \*.h | sort`
yfiles=`find $dir -name \*.y | sort`
sfiles=`find $dir -name \*.S | sort`
files="$hfiles $cfiles $yfiles $sfiles"
# Define some functions to grep the files in the lists
function g() { grep -- "$*" $files /dev/null; }
function gc() { grep -- "$*" $cfiles /dev/null; }
function gh() { grep -- "$*" $hfiles /dev/null; }
function gy() { grep -- "$*" $yfiles /dev/null; }
function gS() { grep -- "$*" $sfiles /dev/null; }
function gl() { grep -l -- "$*" $files /dev/null; }
function gcl() { grep -l -- "$*" $cfiles /dev/null; }
function ghl() { grep -l -- "$*" $hfiles /dev/null; }
function gyl() { grep -l -- "$*" $yfiles /dev/null; }
function gSl() { grep -l -- "$*" $sfiles /dev/null; }
# end of file
#!/bin/bash
#
# Makes an emacs tagfile for all .[chS] and .el files in the current
# directory tree.
etags $(find . -name \*.h) 2>/dev/null || true
etags -a $(find . -name \*.c) 2>/dev/null || true
etags -a $(find . -name \*.S) 2>/dev/null || true
etags -a $(find . -name \*.el) 2>/dev/null || true
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile -- # Makefile --
#
# Makefile for the user_locks module. # Makefile for the user_locks module.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL) ...@@ -19,6 +20,8 @@ CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
MODNAME = user_locks MODNAME = user_locks
SQLDEFS = $(MODNAME).sql
MODULE = $(MODNAME)$(DLSUFFIX) MODULE = $(MODNAME)$(DLSUFFIX)
MODDIR = $(LIBDIR)/modules MODDIR = $(LIBDIR)/modules
...@@ -29,12 +32,12 @@ all: module sql ...@@ -29,12 +32,12 @@ all: module sql
module: $(MODULE) module: $(MODULE)
sql: $(MODNAME).sql sql: $(SQLDEFS)
install: $(MODULE) $(MODDIR) $(SQLDIR) install: $(MODULE) $(SQLDEFS) $(MODDIR) $(SQLDIR)
cp -p $(MODULE) $(MODDIR)/ cp -p $(MODULE) $(MODDIR)/
strip $(MODDIR)/$(MODULE) strip $(MODDIR)/$(MODULE)
cp -p $(MODNAME).sql $(SQLDIR)/ cp -p $(SQLDEFS) $(SQLDIR)/
$(MODDIR): $(MODDIR):
mkdir -p $@ mkdir -p $@
......
...@@ -95,7 +95,7 @@ user_unlock_all() ...@@ -95,7 +95,7 @@ user_unlock_all()
/* end of file */ /* end of file */
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
...@@ -33,8 +33,8 @@ a long period because other transactions would block completely. ...@@ -33,8 +33,8 @@ a long period because other transactions would block completely.
The generic user locks use two values, group and id, to identify a lock, The generic user locks use two values, group and id, to identify a lock,
which correspond to ip_posid and ip_blkid of an ItemPointerData. which correspond to ip_posid and ip_blkid of an ItemPointerData.
Group is a 16 bit value while id is a 32 bit integer which can also Group is a 16 bit value while id is a 32 bit integer which could also be
contain an oid. The oid user lock function, which take an oid as argument, an oid. The oid user lock functions, which take only an oid as argument,
use a group equal to 0. use a group equal to 0.
The meaning of group and id is defined by the application. The user The meaning of group and id is defined by the application. The user
......
...@@ -12,7 +12,7 @@ int user_unlock_all(void); ...@@ -12,7 +12,7 @@ int user_unlock_all(void);
#endif #endif
/* /*
* Local variables: * Local Variables:
* tab-width: 4 * tab-width: 4
* c-indent-level: 4 * c-indent-level: 4
* c-basic-offset: 4 * c-basic-offset: 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment