Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Matched PGXN directory layout

  • Loading branch information...
commit 7aafc0897fbed7007bdfbc4b6b6355ee6a58a31c 1 parent 6afafb6
theirix authored
View
5 .gitignore
@@ -1,4 +1 @@
-# Generated subdirectories
-/log/
-/results/
-/tmp_check/
+expected
View
7 COPYING
@@ -0,0 +1,7 @@
+Copyright (c) 2012, Con Certeza LLC
+
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL Con Certeza LLC BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF Con Certeza LLC HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Con Certeza LLC SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND Con Certeza LLC HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
View
16 Changes
@@ -0,0 +1,16 @@
+Revision history for PostgreSQL extension.
+
+1.2.0 2012-12-31T235959
+ - UNRELEASED
+ - Matched PGXN directory layout.
+ - Allow to have CDRs with empty fields. They are read as NULL values.
+ - Added row length restrictions (rowminlen and rowmaxlen foreign table options) to filter out non-valid rows.
+
+1.1 2012-08-07T001248
+ - Documentation changes.
+ - Date restrictions added
+
+1.0 2012-05-08T030000
+ - Initial version
+ - Extracting CDRs in a specified directory
+ - Fully customizable CDR format specification
View
27 Makefile
@@ -1,12 +1,27 @@
-MODULES = multicdr_fdw
+EXTENSION = multicdr_fdw
+EXTVERSION = 1.2.0
+MODULE_big = multicdr_fdw
+OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
+DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
+#DOCS = $(wildcard doc/*.md)
+TESTS = $(wildcard test/input/*.source)
+TESTSCLEAN = $(patsubst test/input/%.source,test/sql/%.sql,$(TESTS)) \
+ $(patsubst test/input/%.source,expected/%.out,$(TESTS))
+REGRESS = $(patsubst test/input/%.source,%,$(TESTS))
+REGRESS_OPTS = --inputdir=test
+PG_CONFIG := pg_config
+#PG_CPPFLAGS =
+EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql $(TESTSCLEAN)
-EXTENSION = multicdr_fdw
-DATA = multicdr_fdw--1.1.sql
+foo:
+ echo $(TESTS)
+ echo $(TESTSPARSED)
+ echo $(REGRESS)
-REGRESS = multicdr_fdw
+all: sql/$(EXTENSION)--$(EXTVERSION).sql
-EXTRA_CLEAN = sql/multicdr_fdw.sql expected/multicdr_fdw.out
+sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
+ cp $< $@
-#PG_CPPFLAGS += -Wno-format -g -O0
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
View
120 README
@@ -5,8 +5,10 @@ Foreign Data Wrapper for dealing with multiple CDR files.
CDR files from a directory can be read into a table with a
specified field-to-column mapping.
+Works with PostgreSQL 9.1.
+
Usage
---------------------------------------------------
+-----
Please refer to a PostgreSQL Foreign Data Wrapper documentation.
In a few words extension, foreign data server and foreign table
@@ -25,113 +27,127 @@ Minimum and maximum dates can be specified in a query so extension
could early skip a file if it does not match predefined date pattern.
Options
---------------------------------------------------
+-------
-* directory. Text, mandatory.
+### directory
+Text, mandatory.
A directory where FDW should look for files. Scan is not recursive.
-* pattern. Text, mandatory.
+### pattern
+Text, mandatory.
Posix Extended regex for selecting a file path.
If dateformat is used, specify a date portion as a regex group.
-* dateformat. Text, optional.
+### dateformat
+Text, optional.
Specifies how date is stored in a filename. Uses a following format:
$filename_pattern_group_no=date_regex
Pattern must have a 'filename_pattern_group_no' group which contains a date
portion which must be parsed with a 'date_regex' regex.
-* dateminfield, datemaxfield. Timestamp, optional.
+### dateminfield, datemaxfield
+Timestamp, optional.
Must be specified if a dateformat is specified.
Contains column names with a minimum or maximum date restriction.
For using date restrictions one should provide values for these fields
using a WHERE clause. Only '=' operator for timestamps is recognized.
-* filefield. Text, optional.
+### filefield
+Text, optional.
Name of the column that should contain a row's file path.
-* mapfields. Text array with a comma-separated integers, optional.
+### mapfields
+Text array with a comma-separated integers, optional.
Specifies a mapping from table columns to a CDR fields. For example, "4,5,6"
says that fourth, fifth and sixth fields from each CDR row will be read to a
table. An array and a table must have equal dimensions.
Fields are mapped sequentially if mapfields is not specified.
Default mapping is a one-to-one.
-* posfields. Text array with a comma-separated integers, mandatory.
+### posfields
+Text array with a comma-separated integers, mandatory.
Specified positions in chars where each CDR field is started. Fields are
always left-aligned so a position should point to the non-space.
-* rowminlen, rowmaxlen. Integers (specified as text), optional.
+### rowminlen, rowmaxlen
+Integers (specified as text), optional.
Minimum and maximum lengths of valid CDR row.
Row must satisfy to specified length restriction to be fetched into database.
-Building and installing from source
---------------------------------------------------
+Installing extension
+--------------------
+
+### Building and installing from source
Assume you are a current postgres user.
-1. Install a postgres 9.1 or newer
-2. Build an extension
- gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config clean all install
-3. Restart a server
-4. Create extension, foreign server and table
-5. Optionally, run tests
- gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config installcheck
+1. Build an extension
+
+ gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config clean all install
+
+2. Restart a server
+3. Create extension, foreign server and table
+4. Optionally, run tests
+
+ gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config PGUSER=postgres installcheck
-Installing from prebuilt version (easy way, automatic)
---------------------------------------------------
+### Installing from prebuilt version
+
+It is the easiest automatic way.
1. Invoke a command in a distributon directory:
- gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config install
+
+ gmake PG_CONFIG=$POSTGRES_DIR/bin/pg_config install
+
2. Restart a server
3. Create extension, foreign server and table
-Installing from prebuilt version (hard way, manual)
---------------------------------------------------
+### Installing from prebuilt version
-1. Copy multicdr_fdw.so to the pkglibdir dir. Consult with `$POSTGRES_DIR/bin/pg_config --pkglibdir`
-2. Copy multicdr_fdw.control and multicdr_fdw--1.1.sql to extension dir. Consult with `$POSTGRES_DIR/bin/pg_config --sharedir`/extension
+Manual way.
+
+1. Copy `multicdr_fdw.so` to the pkglibdir dir. Consult with `$POSTGRES_DIR/bin/pg_config --pkglibdir`
+2. Copy `multicdr_fdw.control` and `multicdr_fdw--<version>.sql` to extension dir. Consult with `$POSTGRES_DIR/bin/pg_config --sharedir`/extension
3. Restart a server
4. Create extension, foreign server and table
-
-Platform notes
---------------------------------------------------
+### Platform notes
Please note that path to the pg_config could be $POSTGRES_DIR/bin/64/pg_config for 64-bit solaris systems.
Example initialization sql script
---------------------------------------------------
+---------------------------------
--- Should be run by a superuser
+ -- Should be run by a superuser
-CREATE EXTENSION multicdr_fdw;
+ CREATE EXTENSION multicdr_fdw;
-DROP FOREIGN TABLE IF EXISTS multicdr_test_table;
-DROP SERVER IF EXISTS multicdr_fdw_server;
+ DROP FOREIGN TABLE IF EXISTS multicdr_test_table;
+ DROP SERVER IF EXISTS multicdr_fdw_server;
-CREATE SERVER multicdr_fdw_server FOREIGN DATA WRAPPER multicdr_fdw;
+ CREATE SERVER multicdr_fdw_server FOREIGN DATA WRAPPER multicdr_fdw;
-CREATE FOREIGN TABLE multicdr_test_table (
- field1 text,
- field2 text,
- field3 text,
- field4 text,
- field5 text
-) SERVER multicdr_fdw_server OPTIONS (
- directory '/opt/pool',
- pattern '.*\.cdr',
- posfields '0,6,15,40,50,71,92');
+ CREATE FOREIGN TABLE multicdr_test_table (
+ field1 text,
+ field2 text,
+ field3 text,
+ field4 text,
+ field5 text
+ ) SERVER multicdr_fdw_server OPTIONS (
+ directory '/opt/pool',
+ pattern '.*\.cdr',
+ posfields '0,6,15,40,50,71,92');
Version history
---------------------------------------------------
+---------------
+
+Please consult with the Changes for version history information
-Version 1.1
-* Date restrictions added
+License information
+-------------------
-Version 1.0
-* Initial version
-* Extracting CDRs in a specified directory
-* Fully customizable CDR format specification
+You can use any code from this project under the terms of [PostgreSQL License](http://www.postgresql.org/about/licence/).
+Please consult with the COPYING for license information.
View
0  expected/.gitignore
No changes.
View
4 multicdr_fdw.control
@@ -1,5 +1,5 @@
# multicdr_fdw extension
-comment = 'foreign-data wrapper for CDR multiple file access'
-default_version = '1.1'
+comment = 'FDW wrapper for CDR multiple file access'
+default_version = '1.2.0'
module_pathname = '$libdir/multicdr_fdw'
relocatable = true
View
0  multicdr_fdw--1.1.sql → sql/multicdr_fdw.sql
File renamed without changes
View
0  multicdr_fdw.c → src/multicdr_fdw.c
File renamed without changes
View
0  data/regression1/data1.cdr → test/data/regression1/data1.cdr
File renamed without changes
View
0  data/regression2/data1.cdr → test/data/regression2/data1.cdr
File renamed without changes
View
0  data/regression2/data2.cdr → test/data/regression2/data2.cdr
File renamed without changes
View
0  data/regression2/data3.cdr → test/data/regression2/data3.cdr
File renamed without changes
View
0  data/regression2/data4.cdr → test/data/regression2/data4.cdr
File renamed without changes
View
0  data/regression3/MSC_20121201074000-1.cdr → ...data/regression3/MSC_20121201074000-1.cdr
File renamed without changes
View
0  data/regression3/MSC_20121209074000-2.cdr → ...data/regression3/MSC_20121209074000-2.cdr
File renamed without changes
View
0  data/regression3/MSC_20130102074000-3.cdr → ...data/regression3/MSC_20130102074000-3.cdr
File renamed without changes
View
0  data/regression3/MSC_20130102084000-4.cdr → ...data/regression3/MSC_20130102084000-4.cdr
File renamed without changes
View
0  data/regression4/data1.cdr → test/data/regression4/data1.cdr
File renamed without changes
View
0  input/multicdr_fdw.source → test/input/regress.source
File renamed without changes
View
2  output/multicdr_fdw.source → test/output/regress.source
@@ -428,7 +428,7 @@ CREATE FOREIGN TABLE tbl_emptyspaces (
f4 int4,
f5 text
) SERVER file_server
-OPTIONS (directory '/projects/concerteza/postgres/multicdr_fdw/data/regression4', pattern '.*\.cdr$', posfields '0,6,15,40,50,71,92,113,175,212,217,227,232,319,329', mapfields '4,3,2,1,0');
+OPTIONS (directory '@abs_srcdir@/data/regression4', pattern '.*\.cdr$', posfields '0,6,15,40,50,71,92,113,175,212,217,227,232,319,329', mapfields '4,3,2,1,0');
\t on
SELECT count(*) FROM tbl_emptyspaces; -- 19
19
View
0  sql/test.sql → test/sql/test.sql
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.