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

Commitd70d46f

Browse files
committed
PATH and POLYGON datatypes are now TOASTable. Associated functions
updated to new fmgr style. Deleted hoary old functions for compatibilitywith pre-6.1 representations of these datatypes.
1 parent1ebe1da commitd70d46f

File tree

10 files changed

+505
-796
lines changed

10 files changed

+505
-796
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.31 2000/07/14 15:26:21 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.32 2000/07/29 18:45:51 tgl Exp $
33
-->
44

55
<chapter id="datatype">
@@ -1641,13 +1641,6 @@ January 8 04:05:06 1999 PST
16411641

16421642
<para>
16431643
Paths are output using the first syntax.
1644-
Note that <productname>Postgres</productname> versions prior to
1645-
v6.1 used a format for paths which had a single leading parenthesis,
1646-
a "closed" flag,
1647-
an integer count of the number of points, then the list of points followed by a
1648-
closing parenthesis.
1649-
The built-in function <function>upgradepath</function> is supplied to convert
1650-
paths dumped and reloaded from pre-v6.1 databases.
16511644
</para>
16521645
</sect2>
16531646

@@ -1687,12 +1680,6 @@ January 8 04:05:06 1999 PST
16871680

16881681
<para>
16891682
Polygons are output using the first syntax.
1690-
Note that <productname>Postgres</productname> versions prior to
1691-
v6.1 used a format for polygons which had a single leading parenthesis, the list
1692-
of x-axis coordinates, the list of y-axis coordinates,
1693-
followed by a closing parenthesis.
1694-
The built-in function <function>upgradepoly</function> is supplied to convert
1695-
polygons dumped and reloaded from pre-v6.1 databases.
16961683
</para>
16971684
</sect2>
16981685

‎doc/src/sgml/func.sgml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,48 +1423,6 @@ Not defined by this name. Implements the intersection operator '#'
14231423
</tgroup>
14241424
</table>
14251425
</para>
1426-
1427-
<para>
1428-
<table tocentry="1">
1429-
<title>Geometric Upgrade Functions</title>
1430-
<tgroup cols="4">
1431-
<thead>
1432-
<row>
1433-
<entry>Function</entry>
1434-
<entry>Returns</entry>
1435-
<entry>Description</entry>
1436-
<entry>Example</entry>
1437-
</row>
1438-
</thead>
1439-
<tbody>
1440-
<row>
1441-
<entry>isoldpath(path)</entry>
1442-
<entry>path</entry>
1443-
<entry>test path for pre-v6.1 form</entry>
1444-
<entry>isoldpath('(1,3,0,0,1,1,2,0)'::path)</entry>
1445-
</row>
1446-
<row>
1447-
<entry>revertpoly(polygon)</entry>
1448-
<entry>polygon</entry>
1449-
<entry>to pre-v6.1</entry>
1450-
<entry>revertpoly('((0,0),(1,1),(2,0))'::polygon)</entry>
1451-
</row>
1452-
<row>
1453-
<entry>upgradepath(path)</entry>
1454-
<entry>path</entry>
1455-
<entry>to pre-v6.1</entry>
1456-
<entry>upgradepath('(1,3,0,0,1,1,2,0)'::path)</entry>
1457-
</row>
1458-
<row>
1459-
<entry>upgradepoly(polygon)</entry>
1460-
<entry>polygon</entry>
1461-
<entry>to pre-v6.1</entry>
1462-
<entry>upgradepoly('(0,1,2,0,1,0)'::polygon)</entry>
1463-
</row>
1464-
</tbody>
1465-
</tgroup>
1466-
</table>
1467-
</para>
14681426
</sect1>
14691427

14701428
<sect1>

‎src/backend/access/rtree/rtproc.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.27 2000/06/14 05:24:43 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.28 2000/07/29 18:45:52 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

1616
#include"postgres.h"
1717

18-
#include"utils/builtins.h"
18+
#include"utils/geo_decls.h"
1919

2020

2121
BOX*
@@ -81,24 +81,28 @@ rt_bigbox_size(BOX *a, float *size)
8181
rt_box_size(a,size);
8282
}
8383

84-
POLYGON*
85-
rt_poly_union(POLYGON*a,POLYGON*b)
84+
Datum
85+
rt_poly_union(PG_FUNCTION_ARGS)
8686
{
87+
POLYGON*a=PG_GETARG_POLYGON_P(0);
88+
POLYGON*b=PG_GETARG_POLYGON_P(1);
8789
POLYGON*p;
8890

8991
p= (POLYGON*)palloc(sizeof(POLYGON));
9092

91-
if (!PointerIsValid(p))
92-
elog(ERROR,"Cannot allocate polygon for union");
93-
9493
MemSet((char*)p,0,sizeof(POLYGON));/* zero any holes */
9594
p->size=sizeof(POLYGON);
9695
p->npts=0;
9796
p->boundbox.high.x=Max(a->boundbox.high.x,b->boundbox.high.x);
9897
p->boundbox.high.y=Max(a->boundbox.high.y,b->boundbox.high.y);
9998
p->boundbox.low.x=Min(a->boundbox.low.x,b->boundbox.low.x);
10099
p->boundbox.low.y=Min(a->boundbox.low.y,b->boundbox.low.y);
101-
returnp;
100+
101+
/* Avoid leaking memory when handed toasted input. */
102+
PG_FREE_IF_COPY(a,0);
103+
PG_FREE_IF_COPY(b,1);
104+
105+
PG_RETURN_POLYGON_P(p);
102106
}
103107

104108
Datum
@@ -125,16 +129,15 @@ rt_poly_size(PG_FUNCTION_ARGS)
125129
PG_RETURN_VOID();
126130
}
127131

128-
POLYGON*
129-
rt_poly_inter(POLYGON*a,POLYGON*b)
132+
Datum
133+
rt_poly_inter(PG_FUNCTION_ARGS)
130134
{
135+
POLYGON*a=PG_GETARG_POLYGON_P(0);
136+
POLYGON*b=PG_GETARG_POLYGON_P(1);
131137
POLYGON*p;
132138

133139
p= (POLYGON*)palloc(sizeof(POLYGON));
134140

135-
if (!PointerIsValid(p))
136-
elog(ERROR,"Cannot allocate polygon for intersection");
137-
138141
MemSet((char*)p,0,sizeof(POLYGON));/* zero any holes */
139142
p->size=sizeof(POLYGON);
140143
p->npts=0;
@@ -143,11 +146,16 @@ rt_poly_inter(POLYGON *a, POLYGON *b)
143146
p->boundbox.low.x=Max(a->boundbox.low.x,b->boundbox.low.x);
144147
p->boundbox.low.y=Max(a->boundbox.low.y,b->boundbox.low.y);
145148

146-
if (p->boundbox.high.x<p->boundbox.low.x||p->boundbox.high.y<p->boundbox.low.y)
149+
/* Avoid leaking memory when handed toasted input. */
150+
PG_FREE_IF_COPY(a,0);
151+
PG_FREE_IF_COPY(b,1);
152+
153+
if (p->boundbox.high.x<p->boundbox.low.x||
154+
p->boundbox.high.y<p->boundbox.low.y)
147155
{
148156
pfree(p);
149-
return (POLYGON*)NULL;
157+
PG_RETURN_NULL();
150158
}
151159

152-
returnp;
160+
PG_RETURN_POLYGON_P(p);
153161
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp