Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdfa3290

Browse files
knizhnikpashkinelfe
authored andcommitted
Fix incompatibility with PG14
Due to vanilla change 8597a48d01b geo_decls.h can not be used withredefinition of EPSILON anymore. Private versions of macro are copiedfrom PG code.
1 parent7ff66ac commitdfa3290

File tree

5 files changed

+69
-14
lines changed

5 files changed

+69
-14
lines changed

‎gnomo.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include<postgres.h>
22
#include<fmgr.h>
33

4-
#include<utils/geo_decls.h>/* Point */
5-
6-
#include<point.h>/* SPoint */
74
#include<gnomo.h>
5+
#include<point.h>/* SPoint from pgsphere */
86

97
#include<math.h>
108

‎path.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,22 +506,26 @@ spherepath_in(PG_FUNCTION_ARGS)
506506
char*c=PG_GETARG_CSTRING(0);
507507
int32i,nelem;
508508
voidsphere_yyparse(void);
509-
SPoint*arr;
510509

511510
init_buffer(c);
512511
sphere_yyparse();
513512

514513
nelem=get_path_count();
515-
if (nelem>1)
514+
if (nelem>MAX_POINTS)
516515
{
517-
arr= (SPoint*)palloc(sizeof(SPoint)*nelem);
516+
reset_buffer();
517+
elog(ERROR,"spherepath_in: too much points");
518+
PG_RETURN_NULL();
519+
}
520+
elseif (nelem>1)
521+
{
522+
SPointarr[MAX_POINTS];
518523

519524
for (i=0;i<nelem;i++)
520525
{
521526
get_path_elem(i,&arr[i].lng,&arr[i].lat);
522527
}
523528
path=spherepath_from_array(&arr[0],nelem);
524-
pfree(arr);
525529
}
526530
else
527531
{

‎pg_sphere.h‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include"postgres.h"
3737
#include"fmgr.h"
38-
#include"utils/geo_decls.h"
3938
#include"utils/array.h"
4039
#include"utils/elog.h"
4140
#include"utils/builtins.h"
@@ -46,6 +45,56 @@
4645

4746
#include"pgs_util.h"
4847

48+
#defineEPSILON1.0E-09
49+
50+
#defineFPzero(A)(fabs(A) <= EPSILON)
51+
52+
staticinlinebool
53+
FPeq(doubleA,doubleB)
54+
{
55+
returnA==B||fabs(A-B) <=EPSILON;
56+
}
57+
58+
staticinlinebool
59+
FPne(doubleA,doubleB)
60+
{
61+
returnA!=B&&fabs(A-B)>EPSILON;
62+
}
63+
64+
staticinlinebool
65+
FPlt(doubleA,doubleB)
66+
{
67+
returnA+EPSILON<B;
68+
}
69+
70+
staticinlinebool
71+
FPle(doubleA,doubleB)
72+
{
73+
returnA <=B+EPSILON;
74+
}
75+
76+
staticinlinebool
77+
FPgt(doubleA,doubleB)
78+
{
79+
returnA>B+EPSILON;
80+
}
81+
82+
staticinlinebool
83+
FPge(doubleA,doubleB)
84+
{
85+
returnA+EPSILON >=B;
86+
}
87+
88+
/*---------------------------------------------------------------------
89+
* Point - (x,y)
90+
*-------------------------------------------------------------------*/
91+
typedefstruct
92+
{
93+
float8x,
94+
y;
95+
}Point;
96+
4997
voidsphere_yyparse(void);
5098

5199
#endif
100+

‎polygon.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,24 +815,29 @@ spherepoly_in(PG_FUNCTION_ARGS)
815815
char*c=PG_GETARG_CSTRING(0);
816816
int32i,
817817
nelem;
818-
SPoint*arr;
819818

820819
voidsphere_yyparse(void);
821820

822821
init_buffer(c);
823822
sphere_yyparse();
824823

825824
nelem=get_path_count();
825+
if (nelem>MAX_POINTS)
826+
{
827+
reset_buffer();
828+
elog(ERROR,"spherepoly_in: too much points");
829+
PG_RETURN_NULL();
830+
831+
}
826832
if (nelem>2)
827833
{
828-
arr= (SPoint*)palloc(sizeof(SPoint)*nelem);
834+
SPointarr[MAX_POINTS];
829835

830836
for (i=0;i<nelem;i++)
831837
{
832838
get_path_elem(i,&arr[i].lng,&arr[i].lat);
833839
}
834840
poly=spherepoly_from_array(&arr[0],nelem);
835-
pfree(arr);
836841
}
837842
else
838843
{
@@ -894,12 +899,11 @@ spherepoly_area(PG_FUNCTION_ARGS)
894899
{
895900
SPOLY*poly=PG_GETARG_SPOLY(0);
896901
int32i;
897-
SPoint*s;
902+
SPoints[MAX_POINTS+2];
898903
SPointstmp[2];
899904
SEulerse;
900905
float8sum=0.0;
901906

902-
s=(SPoint*)palloc(sizeof(SPoint)*(poly->npts+2));
903907
memcpy((void*)&s[1],
904908
(void*)&poly->p[0],
905909
poly->npts*sizeof(SPoint));
@@ -939,7 +943,6 @@ spherepoly_area(PG_FUNCTION_ARGS)
939943
sum=0.0;
940944
}
941945

942-
pfree(s);
943946
PG_RETURN_FLOAT8(sum);
944947
}
945948

‎polygon.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ typedef struct
1717
SPointp[1];/* variable length array of SPoints */
1818
}SPOLY;
1919

20+
#defineMAX_POINTS 1024
2021

2122
/* Polygon and ellipse */
2223
#definePGS_ELLIPSE_POLY_AVOID 0/* ellipse avoids polygon */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp