Skip to content

Commit 7c5d0ae

Browse files
committed
Add contrib/file_fdw foreign-data wrapper for reading files via COPY.
This is both very useful in its own right, and an important test case for the core FDW support. This commit includes a small refactoring of copy.c to expose its option checking code as a separately callable function. The original patch submission duplicated hundreds of lines of that code, which seemed pretty unmaintainable. Shigeru Hanada, reviewed by Itagaki Takahiro and Tom Lane
1 parent bb74240 commit 7c5d0ae

File tree

19 files changed

+1171
-55
lines changed

19 files changed

+1171
-55
lines changed

contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SUBDIRS = \
1818
dict_xsyn \
1919
dummy_seclabel \
2020
earthdistance \
21+
file_fdw \
2122
fuzzystrmatch \
2223
hstore \
2324
intagg \

contrib/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ earthdistance -
7373
Functions for computing distances between two points on Earth
7474
by Bruno Wolff III <bruno@wolff.to> and Hal Snyder <hal@vailsys.com>
7575

76+
file_fdw
77+
Foreign-data wrapper for server-side CSV/TEXT files
78+
by Shigeru Hanada <hanada@metrosystems.co.jp>
79+
7680
fuzzystrmatch -
7781
Levenshtein, metaphone, and soundex fuzzy string matching
7882
by Joe Conway <mail@joeconway.com> and Joel Burton <jburton@scw.org>

contrib/file_fdw/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated subdirectories
2+
/results/

contrib/file_fdw/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# contrib/file_fdw/Makefile
2+
3+
MODULES = file_fdw
4+
5+
EXTENSION = file_fdw
6+
DATA = file_fdw--1.0.sql
7+
8+
REGRESS = file_fdw
9+
10+
EXTRA_CLEAN = sql/file_fdw.sql expected/file_fdw.out
11+
12+
ifdef USE_PGXS
13+
PG_CONFIG = pg_config
14+
PGXS := $(shell $(PG_CONFIG) --pgxs)
15+
include $(PGXS)
16+
else
17+
subdir = contrib/file_fdw
18+
top_builddir = ../..
19+
include $(top_builddir)/src/Makefile.global
20+
include $(top_srcdir)/contrib/contrib-global.mk
21+
endif

contrib/file_fdw/data/agg.bad

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
56;@7.8@
2+
100;@99.097@
3+
0;@aaa@
4+
42;@324.78@

contrib/file_fdw/data/agg.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
56;@7.8@
2+
100;@99.097@
3+
0;@0.09561@
4+
42;@324.78@

contrib/file_fdw/data/agg.data

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
56 7.8
2+
100 99.097
3+
0 0.09561
4+
42 324.78

contrib/file_fdw/expected/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/file_fdw.out

contrib/file_fdw/file_fdw--1.0.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* contrib/file_fdw/file_fdw--1.0.sql */
2+
3+
CREATE FUNCTION file_fdw_handler()
4+
RETURNS fdw_handler
5+
AS 'MODULE_PATHNAME'
6+
LANGUAGE C STRICT;
7+
8+
CREATE FUNCTION file_fdw_validator(text[], oid)
9+
RETURNS void
10+
AS 'MODULE_PATHNAME'
11+
LANGUAGE C STRICT;
12+
13+
CREATE FOREIGN DATA WRAPPER file_fdw
14+
HANDLER file_fdw_handler
15+
VALIDATOR file_fdw_validator;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy