Skip to content

Commit

Permalink
Integrate with PipelineDB
Browse files Browse the repository at this point in the history
  • Loading branch information
usmanm committed Jul 16, 2015
1 parent 27453e9 commit fb7e30a
Show file tree
Hide file tree
Showing 18 changed files with 1,079 additions and 47 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
*.la
.libs
*.lo
*~
gmon.out
install-sh
/install-sh
postgis_svn_revision.h
aclocal.m4
autom4te.cache/
Expand Down Expand Up @@ -86,6 +87,7 @@ postgis/legacy_gist.sql
postgis/legacy_minimal.sql
postgis/legacy.sql
postgis/postgis.sql
postgis/pipeline_gis.sql
postgis/postgis_upgrade.sql*
postgis/sfcgal_upgrade.sql*
postgis/sqldefines.h
Expand Down Expand Up @@ -128,11 +130,8 @@ topology/test/load_topology.sql
topology/test/topo_predicates.sql
topology/test/regress/topogeo_addlinestring_expected
topology/topology_drop_after.sql
topology/topology_drop_after.sql.in
topology/topology_drop_before.sql
topology/topology_drop_before.sql.in
topology/topology.sql
topology/topology.sql.in
topology/topology_upgrade.sql*
topology/uninstall_topology.sql
libpgcommon/Makefile
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#-----------------------------------------------------

# todo: add all subdirs
SUBDIRS = liblwgeom libpgcommon postgis regress @RASTER@ @TOPOLOGY@ loader utils doc @EXTENSIONS@
SUBDIRS = liblwgeom libpgcommon postgis regress @RASTER@ @TOPOLOGY@ loader utils @EXTENSIONS@

PERL = @PERL@

Expand All @@ -21,11 +21,11 @@ all install uninstall noop clean distclean check:

all: postgis_svn_revision.h

install: all comments-install
install: all # comments-install

uninstall: docs-uninstall comments-uninstall

clean: docs-clean clean-local
clean: clean-local

clean-local:
rm -f postgis.sql postgis_upgrade.sql
Expand Down
12 changes: 5 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dnl *
dnl * PostGIS - Spatial Types for PostgreSQL
dnl * http://postgis.net
dnl * Copyright 2008 Mark Cave-Ayland
dnl * Portions Copyright 2013-2015 PipelineDB
dnl *
dnl * This is free software; you can redistribute and/or modify it under
dnl * the terms of the GNU General Public Licence. See the COPYING file.
Expand Down Expand Up @@ -162,7 +163,7 @@ dnl
dnl Search for xsltproc which is required for building documentation
dnl

CAN_BUILD_COMMENTS=yes
CAN_BUILD_COMMENTS=no

AC_PATH_PROG([XSLTPROC], [xsltproc], [])
if test "x$XSLTPROC" = "x"; then
Expand Down Expand Up @@ -373,16 +374,16 @@ if test "x$PG_CONFIG" = "xno"; then

elif test "x$PG_CONFIG" = "x"; then
dnl PG_CONFIG was not specified, so search within the current path
AC_PATH_PROG([PG_CONFIG], [pg_config])
AC_PATH_PROG([PG_CONFIG], [pipeline-config])

dnl If we couldn't find pg_config, display an error
if test "x$PG_CONFIG" = "x"; then
AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pg_config parameter.])
AC_MSG_ERROR([could not find pipeline-config within the current path. You may need to try re-running configure with a --with-pg_config parameter.])
fi
else
dnl PG_CONFIG was specified; display a message to the user
if test "x$PG_CONFIG" = "xyes"; then
AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pipeline-config])
else
if test -f $PG_CONFIG; then
AC_MSG_RESULT([Using user-specified pg_config file: $PG_CONFIG])
Expand Down Expand Up @@ -1283,9 +1284,6 @@ AC_OUTPUT([GNUmakefile
topology/Makefile
topology/test/Makefile
regress/Makefile
doc/Makefile
doc/Makefile.comments
doc/html/image_src/Makefile
utils/Makefile
java/jdbc/Makefile
$RT_MAKEFILE_LIST])
Expand Down
1 change: 1 addition & 0 deletions extensions/address_standardizer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sql
19 changes: 11 additions & 8 deletions extensions/postgis/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ifeq ($(PG91),yes)

all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql sql/$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql sql_minor_upgrade

sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/mark_editable_objects.sql.in sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql
sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/mark_editable_objects.sql.in sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql sql_bits/pipeline_gis.sql
mkdir -p sql
echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@
cat $^ >> $@
Expand All @@ -46,9 +46,9 @@ sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
mkdir -p sql
cp $< $@

sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql ../../utils/create_unpackaged.pl
sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql ../../utils/create_unpackaged.pl ../../postgis/pipeline_gis.sql
mkdir -p sql
cat ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql | $(PERL) ../../utils/create_unpackaged.pl postgis > $@
cat ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql ../../postgis/pipeline_gis.sql | $(PERL) ../../utils/create_unpackaged.pl postgis > $@

#this is a cludge to allow upgrading from same SVN to same SVN
sql/$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql: sql_bits/postgis_raster_upgrade_minor.sql
Expand All @@ -64,11 +64,14 @@ sql_bits/spatial_ref_sys.sql: ../../spatial_ref_sys.sql
sql_bits/postgis.sql: ../../postgis/postgis.sql
sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' $< > $@

sql_bits/pipeline_gis.sql: ../../postgis/pipeline_gis.sql
sed -e 's/BEGIN;//g' -e 's/COMMIT;//g' $< > $@

../../doc/postgis_comments.sql:
$(MAKE) -C ../../doc comments

sql_bits/postgis_comments.sql: ../../doc/postgis_comments.sql
cp $< $@
sql_bits/postgis_comments.sql:
touch $@

#strip BEGIN/COMMIT since these are not allowed in extensions
sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql
Expand Down Expand Up @@ -98,13 +101,13 @@ sql_bits/postgis_upgrade.sql: ../../postgis/postgis_upgrade.sql
../../doc/raster_comments.sql:
$(MAKE) -C ../../doc comments

sql_bits/raster_comments.sql: ../../doc/raster_comments.sql
cp $< $@
sql_bits/raster_comments.sql:
touch $@

#postgis_raster_upgrade_minor.sql is the one that contains both postgis AND raster
#TODO: come up with a better name
#TODO: what about postgis_drop_after.sql ? where does it fit ??
sql_bits/postgis_raster_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/postgis_upgrade.sql sql_bits/rtpostgis_upgrade.sql ../../doc/raster_comments.sql ../../doc/postgis_comments.sql ../postgis_extension_helper_uninstall.sql
sql_bits/postgis_raster_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/postgis_upgrade.sql sql_bits/rtpostgis_upgrade.sql sql_bits/raster_comments.sql sql_bits/postgis_comments.sql ../postgis_extension_helper_uninstall.sql
echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@
cat $^ >> $@

Expand Down
4 changes: 2 additions & 2 deletions extensions/postgis_tiger_geocoder/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ sql_bits/add_search_path.sql: sql_bits/add_search_path.sql.in
../../doc/tiger_geocoder_comments.sql:
$(MAKE) -C ../../doc comments

sql_bits/tiger_geocoder_comments.sql: ../../doc/tiger_geocoder_comments.sql
cp $< $@
sql_bits/tiger_geocoder_comments.sql:
touch $@

#grep all lines that start with CREATE OR REPLACE FUNCTION, TRIGGER...
#then replace CREATE OR REPLACE .. with ALTER EXTENSION..;
Expand Down
4 changes: 2 additions & 2 deletions extensions/postgis_topology/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ sql_bits/topology.sql: ../../topology/topology.sql
../../doc/topology_comments.sql:
$(MAKE) -C ../../doc comments

sql_bits/topology_comments.sql: ../../doc/topology_comments.sql
cp $< $@
sql_bits/topology_comments.sql:
touch $@

sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../topology/topology.sql ../../utils/create_unpackaged.pl
mkdir -p sql
Expand Down
8 changes: 6 additions & 2 deletions liblwgeom/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# * PostGIS - Spatial Types for PostgreSQL
# * http://postgis.net
# * Copyright 2008 Mark Cave-Ayland
# * Portions Copyright 2013-2015 PipelineDB
# *
# * This is free software; you can redistribute and/or modify it under
# * the terms of the GNU General Public Licence. See the COPYING file.
Expand All @@ -24,6 +25,9 @@ LIBTOOL = @LIBTOOL@

SOVER = @POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@.@POSTGIS_MICRO_VERSION@

PG_CONFIG = @PG_CONFIG@
LIB_INSTALL_PATH = $(shell $(PG_CONFIG) --libdir)
LIB_INCLUDE_PATH = $(shell $(PG_CONFIG) --includedir)

YACC=@YACC@
LEX=@LEX@
Expand Down Expand Up @@ -120,8 +124,8 @@ install: install-liblwgeom
uninstall: uninstall-liblwgeom

install-liblwgeom: liblwgeom.la
$(LIBTOOL) --mode=install $(INSTALL) liblwgeom.la "$(DESTDIR)$(libdir)/liblwgeom.la"
$(INSTALL) liblwgeom.h "$(DESTDIR)$(includedir)/liblwgeom.h"
$(LIBTOOL) --mode=install $(INSTALL) liblwgeom.la "$(LIB_INSTALL_PATH)/liblwgeom.la"
$(INSTALL) -m 0644 liblwgeom.h "$(LIB_INCLUDE_PATH)/liblwgeom.h"

uninstall-liblwgeom:
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/liblwgeom.la"
Expand Down
5 changes: 3 additions & 2 deletions postgis/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# * PostGIS - Spatial Types for PostgreSQL
# * http://postgis.net
# * Copyright 2008 Mark Cave-Ayland
# * Portions Copyright 2013-2015 PipelineDB
# *
# * This is free software; you can redistribute and/or modify it under
# * the terms of the GNU General Public Licence. See the COPYING file.
Expand All @@ -14,11 +15,11 @@ MODULE_big=postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
MODULEDIR=contrib/$(MODULE_big)

# Files to be copied to the contrib/ directory
SQL_built=postgis.sql uninstall_postgis.sql postgis_upgrade.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql
SQL_built=postgis.sql uninstall_postgis.sql postgis_upgrade.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql pipeline_gis.sql
DATA=../spatial_ref_sys.sql

# SQL objects (files requiring pre-processing)
SQL_objs=postgis.sql legacy.sql legacy_minimal.sql
SQL_objs=postgis.sql legacy.sql legacy_minimal.sql pipeline_gis.sql

GEOM_BACKEND_OBJ = lwgeom_geos.o
SFCGAL_BACKEND_OBJ = lwgeom_sfcgal.o
Expand Down
78 changes: 77 additions & 1 deletion postgis/lwgeom_accum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.net
* Copyright 2009 Paul Ramsey <[email protected]>
* Portions Copyright 2009 Paul Ramsey <[email protected]>
* Portions Copyright 2013-2015 PipelineDB
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
Expand All @@ -13,6 +14,8 @@
#include "fmgr.h"
#include "funcapi.h"
#include "access/tupmacs.h"
#include "lib/stringinfo.h"
#include "libpq/pqformat.h"
#include "utils/array.h"
#include "utils/lsyscache.h"

Expand Down Expand Up @@ -87,6 +90,79 @@ pgis_abs_out(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(NULL);
}

/*
* Serializes as pgis_abs
*/
PG_FUNCTION_INFO_V1(pgis_abs_send);
Datum
pgis_abs_send(PG_FUNCTION_ARGS)
{
pgis_abs *p = (pgis_abs *) PG_GETARG_POINTER(0);
ArrayType *arr = DirectFunctionCall1(arrayaggstatesend, (Datum) p->a);

PG_RETURN_ARRAYTYPE_P(arr);
}

/*
* Deserializes a pgis_abs
*/
PG_FUNCTION_INFO_V1(pgis_abs_recv);
Datum
pgis_abs_recv(PG_FUNCTION_ARGS)
{
MemoryContext context;
MemoryContext old;
pgis_abs *result;
ArrayType *arr;

if (!AggCheckCallContext(fcinfo, &context))
context = fcinfo->flinfo->fn_mcxt;

old = MemoryContextSwitchTo(context);

arr = (ArrayType *) PG_GETARG_ARRAYTYPE_P_COPY(0);
fcinfo->arg[0] = (Datum) arr;
result = palloc0(sizeof(pgis_abs));
result->a = (ArrayBuildState *) arrayaggstaterecv(fcinfo);

MemoryContextSwitchTo(old);

PG_RETURN_POINTER(result);
}

/*
* Combines two pgis_abs transition states into one
*/
PG_FUNCTION_INFO_V1(pgis_geometry_accum_combinefn);
Datum
pgis_geometry_accum_combinefn(PG_FUNCTION_ARGS)
{
MemoryContext old;
MemoryContext aggcontext;
pgis_abs *state = PG_ARGISNULL(0) ? NULL : (pgis_abs *) PG_GETARG_POINTER(0);
pgis_abs *incoming = (pgis_abs *) PG_GETARG_POINTER(1);
int i;

if (!AggCheckCallContext(fcinfo, &aggcontext))
elog(ERROR, "pgis_geometry_accum_combinefn called in non-aggregate context");

if (state == NULL)
PG_RETURN_POINTER(incoming);

old = MemoryContextSwitchTo(aggcontext);

for (i=0; i<incoming->a->nelems; i++)
{
state->a = accumArrayResult(state->a,
incoming->a->dvalues[i], incoming->a->dnulls[i],
incoming->a->element_type, aggcontext);
}

MemoryContextSwitchTo(old);

PG_RETURN_POINTER(state);
}

/**
** The transfer function hooks into the PostgreSQL accumArrayResult()
** function (present since 8.0) to build an array in a side memory
Expand Down
27 changes: 27 additions & 0 deletions postgis/lwgeom_box3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*
* BOX3D IO and conversions
*
* Portions Copyright 2013-2015 PipelineDB
*
**********************************************************************/

#include "postgres.h"
Expand Down Expand Up @@ -340,6 +342,31 @@ Datum BOX3D_zmax(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(Max(box->zmin, box->zmax));
}

PG_FUNCTION_INFO_V1(BOX3D_combine_3d);
Datum BOX3D_combine_3d(PG_FUNCTION_ARGS)
{
BOX3D *state;
BOX3D *incoming = (BOX3D *) PG_GETARG_POINTER(1);

if (PG_ARGISNULL(0))
{
if (PG_ARGISNULL(1))
PG_RETURN_NULL();
PG_RETURN_POINTER(incoming);
}

state = (BOX3D *) PG_GETARG_POINTER(0);

state->xmax = Max(state->xmax, incoming->xmax);
state->ymax = Max(state->ymax, incoming->ymax);
state->zmax = Max(state->zmax, incoming->zmax);
state->xmin = Min(state->xmin, incoming->xmin);
state->ymin = Min(state->ymin, incoming->ymin);
state->zmin = Min(state->zmin, incoming->zmin);

PG_RETURN_POINTER(state);
}

/**
* Used in the ST_Extent and ST_Extent3D aggregates, does not read the
* serialized cached bounding box (since that is floating point)
Expand Down
Loading

0 comments on commit fb7e30a

Please sign in to comment.