forked from postgis/postgis
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,079 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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" | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.