Also reorganize the source tree per pgxn recommendations.
--- /dev/null
+{
+ "name": "pg_proctab",
+ "abstract": "Access operating system process tables from PostgreSQL",
+ "description": "pg_proctab is a collection of stored functions that can access the operating systems process table so that system statitics can be queried through the database.",
+ "version": "0.0.4",
+ "maintainer": "Mark Wong",
+ "license": {
+ "PostgreSQL": "http://www.postgresql.org/about/licence"
+ },
+ "provides": {
+ "pg_cputime": {
+ "abstract": "Processor statitics",
+ "file": "sql/pg_proctab.sql",
+ "version": "0.0.1"
+ },
+ "pg_loadavg": {
+ "abstract": "System load averages",
+ "file": "sql/pg_loadavg.sql",
+ "version": "0.0.1"
+ },
+ "pg_memusage": {
+ "abstract": "Memory usage",
+ "file": "sql/pg_memusage.sql",
+ "version": "0.0.1"
+ },
+ "pg_proctab": {
+ "abstract": "Operating system process table",
+ "file": "sql/pg_proctab.sql",
+ "version": "0.0.2"
+ }
+ },
+ "resources": {
+ "repository": {
+ "url": "git://git.postgresql.org/git/pg_proctab.git",
+ "type": "git"
+ }
+ },
+ "release_status": "testing",
+ "generated_by": "Mark Wong",
+ "meta-spec": {
+ "version": "1.0.0",
+ "url": "http://pgxn.org/meta/spec.txt"
+ }
+}
-MODULES = pg_cputime pg_loadavg pg_memusage pg_proctab
-DATA_built = pg_cputime.sql pg_loadavg.sql pg_memusage.sql pg_proctab.sql
+EXTENSION = pg_proctab
+EXTVERSION := $(shell grep default_version $(EXTENSION).control | \
+ sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
+DATA := $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
+DOCS := $(wildcard doc/*)
+MODULES := $(patsubst %.c,%,$(wildcard src/*.c))
PG_CONFIG = pg_config
+PG91 := $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo no || echo yes)
+
+ifeq ($(PG91),yes)
+all: sql/$(EXTENSION)--$(EXTVERSION).sql
+
+sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
+ cp $< $@
+
+DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
+EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
+endif
+
+# Determine the database version in order to build with the right queries.
+
+PG_VERSION := $(shell $(PG_CONFIG) --version | sed -n 's/PostgreSQL \([0-9]*\.[0-9]*\).*/\1/p')
+PG_VERSION_LT92 := $(shell expr $PG_VERSION '<' 9.2)
+
+ifeq ($(PG_VERSION_LT92),1)
+PG_CPPFLAGS = -DPG91=1
+endif
+
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
--- /dev/null
+# pg_proctab extension
+comment = 'Access operating system process table'
+default_version = '0.0.4'
+module_pathname = '$libdir/pg_proctab'
+relocatable = true
#define FULLCOMM_LEN 1024
+#ifdef PG91
#define GET_PIDS \
"SELECT procpid " \
"FROM pg_stat_activity"
+#else
+#define GET_PIDS \
+ "SELECT pid " \
+ "FROM pg_stat_activity"
+#endif /* PG91 */
#ifdef __linux__
#define GET_VALUE(value) \