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

Commit043be9a

Browse files
committed
Make contrib/seg work with flex 2.5.31. Fix it up to have a real
btree operator class, too, since in PG 7.4 you can't GROUP without one.
1 parent03e4739 commit043be9a

File tree

9 files changed

+115
-190
lines changed

9 files changed

+115
-190
lines changed

‎contrib/seg/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.9 2003/05/1403:27:22 tgl Exp $
1+
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.10 2003/09/1402:18:49 tgl Exp $
22

33
subdir = contrib/seg
44
top_builddir = ../..
55
include$(top_builddir)/src/Makefile.global
66

77
MODULE_big = seg
8-
OBJS = seg.o segparse.o buffer.o
8+
OBJS = seg.o segparse.o
99
DATA_built = seg.sql
1010
DOCS = README.seg
1111
REGRESS = seg
@@ -27,7 +27,7 @@ endif
2727

2828
segscan.c: segscan.l
2929
ifdefFLEX
30-
$(FLEX) $(FLEXFLAGS) -Pseg_yy -o'$@' $<
30+
$(FLEX) $(FLEXFLAGS) -o'$@' $<
3131
else
3232
@$(missing) flex $< $@
3333
endif

‎contrib/seg/README.seg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ Makefilebuilding instructions for the shared library
5656

5757
README.segthe file you are now reading
5858

59-
buffer.cglobal variables and buffer access utilities
60-
shared between the parser (segparse.y) and the
61-
scanner (segscan.l)
62-
63-
buffer.hfunction prototypes for buffer.c
64-
6559
seg.cthe implementation of this data type in c
6660

6761
seg.sql.inSQL code needed to register this type with postgres

‎contrib/seg/buffer.c

Lines changed: 0 additions & 84 deletions
This file was deleted.

‎contrib/seg/buffer.h

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎contrib/seg/expected/seg.out

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -394,35 +394,29 @@ SELECT '100(+-)1'::seg AS seg;
394394

395395
-- invalid input
396396
SELECT ''::seg AS seg;
397-
ERROR: can't parse an empty string
397+
ERROR: bad seg representation
398+
DETAIL: syntax error at end of input
398399
SELECT 'ABC'::seg AS seg;
399-
ERROR: syntax error
400-
DETAIL: syntax error at or near position 1, character ('A', \101), input: 'ABC'
401-
400+
ERROR: bad seg representation
401+
DETAIL: syntax error at or near "A"
402402
SELECT '1ABC'::seg AS seg;
403-
ERROR: syntax error
404-
DETAIL: syntax error at or near position 2, character ('A', \101), input: '1ABC'
405-
403+
ERROR: bad seg representation
404+
DETAIL: syntax error at or near "A"
406405
SELECT '1.'::seg AS seg;
407-
ERROR: syntax error
408-
DETAIL: syntax error at or near position 2, character ('.', \056), input: '1.'
409-
406+
ERROR: bad seg representation
407+
DETAIL: syntax error at or near "."
410408
SELECT '1.....'::seg AS seg;
411-
ERROR: syntax error
412-
DETAIL: syntax error at or near position 6, character ('.', \056), input: '1.....'
413-
409+
ERROR: bad seg representation
410+
DETAIL: syntax error at or near ".."
414411
SELECT '.1'::seg AS seg;
415-
ERROR: syntax error
416-
DETAIL: syntax error at or near position 2, character ('1', \061), input: '.1'
417-
412+
ERROR: bad seg representation
413+
DETAIL: syntax error at or near "."
418414
SELECT '1..2.'::seg AS seg;
419-
ERROR: syntax error
420-
DETAIL: syntax error at or near position 5, character ('.', \056), input: '1..2.'
421-
415+
ERROR: bad seg representation
416+
DETAIL: syntax error at or near "."
422417
SELECT '1 e7'::seg AS seg;
423-
ERROR: syntax error
424-
DETAIL: syntax error at or near position 3, character ('e', \145), input: '1 e7'
425-
418+
ERROR: bad seg representation
419+
DETAIL: syntax error at or near "e"
426420
SELECT '1e700'::seg AS seg;
427421
ERROR: syntax error
428422
DETAIL: numeric value 1e700 unrepresentable

‎contrib/seg/seg.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#define GIST_QUERY_DEBUG
2424
*/
2525

26-
externvoidset_parse_buffer(char*str);
2726
externintseg_yyparse();
27+
externvoidseg_yyerror(constchar*message);
28+
externvoidseg_scanner_init(constchar*str);
29+
externvoidseg_scanner_finish(void);
2830

2931
/*
3032
extern int seg_yydebug;
@@ -99,16 +101,13 @@ seg_in(char *str)
99101
{
100102
SEG*result=palloc(sizeof(SEG));
101103

102-
set_parse_buffer(str);
104+
seg_scanner_init(str);
103105

104-
/*
105-
* seg_yydebug = 1;
106-
*/
107106
if (seg_yyparse(result)!=0)
108-
{
109-
pfree(result);
110-
returnNULL;
111-
}
107+
seg_yyerror("bogus input");
108+
109+
seg_scanner_finish();
110+
112111
return (result);
113112
}
114113

@@ -880,7 +879,6 @@ seg_gt(SEG * a, SEG * b)
880879
returnseg_cmp(a,b)>0;
881880
}
882881

883-
884882
bool
885883
seg_ge(SEG*a,SEG*b)
886884
{

‎contrib/seg/seg.sql.in

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ SET search_path = public;
77
CREATE FUNCTION seg_in(cstring)
88
RETURNS seg
99
AS 'MODULE_PATHNAME'
10-
LANGUAGE 'C';
10+
LANGUAGE 'C' IMMUTABLE STRICT;
1111

1212
CREATE FUNCTION seg_out(seg)
1313
RETURNS cstring
1414
AS 'MODULE_PATHNAME'
15-
LANGUAGE 'C';
15+
LANGUAGE 'C' IMMUTABLE STRICT;
1616

1717
CREATE TYPE seg (
1818
INTERNALLENGTH = 12,
@@ -138,6 +138,13 @@ COMMENT ON FUNCTION seg_different(seg, seg) IS
138138

139139
-- support routines for indexing
140140

141+
CREATE OR REPLACE FUNCTION seg_cmp(seg, seg)
142+
RETURNS int4
143+
AS 'MODULE_PATHNAME'
144+
LANGUAGE 'C' STRICT;
145+
146+
COMMENT ON FUNCTION seg_cmp(seg, seg) IS 'btree comparison function';
147+
141148
CREATE FUNCTION seg_union(seg, seg)
142149
RETURNS seg
143150
AS 'MODULE_PATHNAME'
@@ -263,8 +270,7 @@ CREATE OPERATOR = (
263270
NEGATOR = '<>',
264271
RESTRICT = eqsel,
265272
JOIN = eqjoinsel,
266-
SORT1 = '<',
267-
SORT2 = '<'
273+
MERGES
268274
);
269275

270276
CREATE OPERATOR <> (
@@ -333,7 +339,16 @@ AS 'MODULE_PATHNAME'
333339
LANGUAGE 'C';
334340

335341

336-
-- Create the operator class for indexing
342+
-- Create the operator classes for indexing
343+
344+
CREATE OPERATOR CLASS seg_ops
345+
DEFAULT FOR TYPE seg USING btree AS
346+
OPERATOR 1 < ,
347+
OPERATOR 2 <= ,
348+
OPERATOR 3 = ,
349+
OPERATOR 4 >= ,
350+
OPERATOR 5 > ,
351+
FUNCTION 1 seg_cmp(seg, seg);
337352

338353
CREATE OPERATOR CLASS gist_seg_ops
339354
DEFAULT FOR TYPE seg USING gist

‎contrib/seg/segparse.y

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include<math.h>
77

88
#include"segdata.h"
9-
#include"buffer.h"
109

1110
#ifdef __CYGWIN__
1211
#defineHUGE HUGE_VAL
@@ -19,7 +18,7 @@
1918
externintyylex();/* defined as seg_yylex in segscan.c*/
2019
externintsignificant_digits(char *str );/* defined in seg.c*/
2120

22-
intseg_yyerror(char *msg);
21+
voidseg_yyerror(constchar *message);
2322
intseg_yyparse(void *result );
2423

2524
floatseg_atof(char *value );
@@ -72,7 +71,6 @@ range:
7271
((SEG *)result)->lower =$1.val;
7372
((SEG *)result)->upper =$3.val;
7473
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
75-
reset_parse_buffer();
7674
ereport(ERROR,
7775
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
7876
errmsg("swapped boundaries: %g is greater than %g",
@@ -145,7 +143,6 @@ float seg_atof ( char *value ) {
145143

146144
if ( errno ) {
147145
snprintf(buf,256,"numeric value %s unrepresentable", value);
148-
reset_parse_buffer();
149146
ereport(ERROR,
150147
(errcode(ERRCODE_SYNTAX_ERROR),
151148
errmsg("syntax error"),
@@ -156,35 +153,4 @@ float seg_atof ( char *value ) {
156153
}
157154

158155

159-
intseg_yyerror (char *msg ) {
160-
char *buf = (char *)palloc(256);
161-
int position;
162-
163-
yyclearin;
164-
165-
if ( !strcmp(msg,"parse error, expecting `$'") ) {
166-
msg ="expecting end of input";
167-
}
168-
169-
position =parse_buffer_pos() >parse_buffer_size() ?parse_buffer_pos() -1 :parse_buffer_pos();
170-
171-
snprintf(
172-
buf,
173-
256,
174-
"%s at or near position %d, character ('%c',\\%03o), input: '%s'\n",
175-
msg,
176-
position,
177-
parse_buffer()[position -1],
178-
parse_buffer()[position -1],
179-
parse_buffer()
180-
);
181-
182-
reset_parse_buffer();
183-
ereport(ERROR,
184-
(errcode(ERRCODE_SYNTAX_ERROR),
185-
errmsg("syntax error"),
186-
errdetail("%s", buf)));
187-
return0;
188-
}
189-
190156
#include"segscan.c"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp