diff --git a/META.json b/META.json new file mode 100644 index 0000000..ae01457 --- /dev/null +++ b/META.json @@ -0,0 +1,34 @@ +{ + "name": "pg_check", + "abstract": "Performs basic integrity checks of data files (page structure, tuple structure).", + "description": "When the database fails with a strange error and you suspect that might be caused by a data corruption, this tool might help you a it performs basic integrity checks - verifies page structure (lower/upper), placement of tuples on the page, etc.", + "version": "0.1.0", + "maintainer": "Tomas Vondra ", + "license": "bsd", + "prereqs": { + "runtime": { + "requires": { + "PostgreSQL": "9.0.0" + } + } + }, + "provides": { + "pg_check": { + "file": "sql/pg_check--0.1.0.sql", + "version": "0.1.0" + }, + }, + "resources": { + "repository": { + "url": "https://tvondra@github.com/tvondra/pg_check.git", + "web": "http://github.com/tvondra/pg_check", + "type": "git" + } + }, + "tags" : ["check", "integrity", "structure", "data", "corruption"], + "meta-spec": { + "version": "1.0.0", + "url": "http://pgxn.org/meta/spec.txt" + }, + "release_status" : "testing" +} diff --git a/Makefile b/Makefile index 98c5cf7..da80fe1 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,14 @@ -#------------------------------------------------------------------------- -# -# pg_check Makefile -# -#------------------------------------------------------------------------- +MODULE_big = pg_check +OBJS = src/pg_check.o src/common.o src/heap.o src/index.o -MODULE_big = pg_check -OBJS = pg_check.o index.o heap.o common.o -DATA_built = pg_check.sql -DATA = uninstall_pg_check.sql +EXTENSION = pg_check +DATA = sql/pg_check--0.1.0.sql +MODULES = pg_check + +CFLAGS=`pg_config --includedir-server` -ifdef USE_PGXS PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) -else -subdir = contrib/pg_check -top_builddir = ../.. -include $(top_builddir)/src/Makefile.global -include $(top_srcdir)/contrib/contrib-global.mk -endif +pg_check.so: $(OBJS) diff --git a/README b/README index bad2a88..40fd23a 100644 --- a/README +++ b/README @@ -2,11 +2,18 @@ INSTALL ------- -1. copy the directory to "contrib/" directory of the PostgreSQL (9.0) tree +This is a regular extension (9.1) or a contrib module (9.0), so it may be +installed rather easily - do either this -2. modify the "contrib/Makefile" - add the "pg_check" to SUBDIRS + $ make install + $ psql dbname -c "CREATE EXTENSION pg_check" -3. build/install just as the other contrib modules +or this (on 9.0) + + $ make install + $ psql dbname < `pg_config --sharedir`/contrib/pg_check--0.1.0.sql + +and the extension should be installed. FUNCTIONS diff --git a/pg_check.control b/pg_check.control new file mode 100644 index 0000000..b6dd6fe --- /dev/null +++ b/pg_check.control @@ -0,0 +1,4 @@ +# pg_check +comment = 'Provides basic integrity checks for data files.' +default_version = '0.1.0' +relocatable = true diff --git a/pg_check.sql.in b/sql/pg_check--0.1.0.sql similarity index 75% rename from pg_check.sql.in rename to sql/pg_check--0.1.0.sql index 911a31a..b4c45bb 100644 --- a/pg_check.sql.in +++ b/sql/pg_check--0.1.0.sql @@ -7,12 +7,12 @@ SET search_path = public; CREATE OR REPLACE FUNCTION pg_check_table(regclass, bool) RETURNS int4 -AS 'MODULE_PATHNAME', 'pg_check_table' +AS '$libdir/pg_check', 'pg_check_table' LANGUAGE C STRICT; CREATE OR REPLACE FUNCTION pg_check_table(regclass, bigint, bigint) RETURNS int4 -AS 'MODULE_PATHNAME', 'pg_check_table_pages' +AS '$libdir/pg_check', 'pg_check_table_pages' LANGUAGE C STRICT; -- @@ -21,10 +21,10 @@ LANGUAGE C STRICT; CREATE OR REPLACE FUNCTION pg_check_index(regclass) RETURNS int4 -AS 'MODULE_PATHNAME', 'pg_check_index' +AS '$libdir/pg_check', 'pg_check_index' LANGUAGE C STRICT; CREATE OR REPLACE FUNCTION pg_check_index(regclass, bigint, bigint) RETURNS int4 -AS 'MODULE_PATHNAME', 'pg_check_index_pages' +AS '$libdir/pg_check', 'pg_check_index_pages' LANGUAGE C STRICT; diff --git a/common.c b/src/common.c similarity index 100% rename from common.c rename to src/common.c diff --git a/common.h b/src/common.h similarity index 100% rename from common.h rename to src/common.h diff --git a/heap.c b/src/heap.c similarity index 100% rename from heap.c rename to src/heap.c diff --git a/heap.h b/src/heap.h similarity index 100% rename from heap.h rename to src/heap.h diff --git a/index.c b/src/index.c similarity index 100% rename from index.c rename to src/index.c diff --git a/index.h b/src/index.h similarity index 100% rename from index.h rename to src/index.h diff --git a/pg_check.c b/src/pg_check.c similarity index 100% rename from pg_check.c rename to src/pg_check.c diff --git a/uninstall_pg_check.sql b/uninstall_pg_check.sql deleted file mode 100644 index a3b8b11..0000000 --- a/uninstall_pg_check.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Adjust this setting to control where the objects get dropped. -SET search_path = public; - -DROP FUNCTION pg_check_table(regclass, bool); -DROP FUNCTION pg_check_table(regclass, bigint, bigint); -DROP FUNCTION pg_check_index(regclass); -DROP FUNCTION pg_check_index(regclass, bigint, bigint);