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

Commitbe42eb9

Browse files
committed
Improve regression test coverage of regress.c.
It's a bit silly to have test functions that aren't tested, so testthem.In passing, rename int44in/int44out to city_budget_in/_out so that theymatch how the regression tests use them. Also, fix city_budget_outso that it emits the format city_budget_in expects to read; otherwisewe'd have dump/reload failures when testing pg_dump against theregression database. (We avoided that in the past only because nodata of type city_budget was actually stored anywhere.)Discussion:https://postgr.es/m/29322.1519701006@sss.pgh.pa.us
1 parentdb3af9f commitbe42eb9

File tree

9 files changed

+63
-27
lines changed

9 files changed

+63
-27
lines changed

‎src/test/regress/expected/create_misc.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking');
2424
INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking');
2525
INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball');
2626
INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking');
27+
INSERT INTO city VALUES
28+
('Podunk', '(1,2),(3,4)', '100,127,1000'),
29+
('Gotham', '(1000,34),(1100,334)', '123456,127,-1000,6789');
30+
TABLE city;
31+
name | location | budget
32+
--------+----------------------+-----------------------
33+
Podunk | (3,4),(1,2) | 100,127,1000,0
34+
Gotham | (1100,334),(1000,34) | 123456,127,-1000,6789
35+
(2 rows)
36+
2737
SELECT *
2838
INTO TABLE ramp
2939
FROM road

‎src/test/regress/expected/create_operator.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ CREATE OPERATOR #%# (
2626
leftarg = int8,-- right unary
2727
procedure = numeric_fac
2828
);
29+
-- Test operator created above
30+
SELECT point '(1,2)' <% widget '(0,0,3)' AS t,
31+
point '(1,2)' <% widget '(0,0,1)' AS f;
32+
t | f
33+
---+---
34+
t | f
35+
(1 row)
36+
2937
-- Test comments
3038
COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary';
3139
ERROR: operator does not exist: integer ######

‎src/test/regress/expected/create_type.out

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ CREATE TYPE widget (
1616
);
1717
CREATE TYPE city_budget (
1818
internallength = 16,
19-
input =int44in,
20-
output =int44out,
19+
input =city_budget_in,
20+
output =city_budget_out,
2121
element = int4,
2222
category = 'x', -- just to verify the system will take it
2323
preferred = true -- ditto
@@ -182,3 +182,12 @@ WHERE attrelid = 'mytab'::regclass AND attnum > 0;
182182
widget(42,13)
183183
(1 row)
184184

185+
-- might as well exercise the widget type while we're here
186+
INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)');
187+
TABLE mytab;
188+
foo
189+
--------------
190+
(1,2,3)
191+
(-44,5.5,12)
192+
(2 rows)
193+

‎src/test/regress/input/create_function_1.source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ CREATE FUNCTION widget_out(widget)
1212
AS '@libdir@/regress@DLSUFFIX@'
1313
LANGUAGE C STRICT IMMUTABLE;
1414

15-
CREATE FUNCTIONint44in(cstring)
15+
CREATE FUNCTIONcity_budget_in(cstring)
1616
RETURNS city_budget
1717
AS '@libdir@/regress@DLSUFFIX@'
1818
LANGUAGE C STRICT IMMUTABLE;
1919

20-
CREATE FUNCTIONint44out(city_budget)
20+
CREATE FUNCTIONcity_budget_out(city_budget)
2121
RETURNS cstring
2222
AS '@libdir@/regress@DLSUFFIX@'
2323
LANGUAGE C STRICT IMMUTABLE;

‎src/test/regress/output/create_function_1.source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ CREATE FUNCTION widget_out(widget)
1212
AS '@libdir@/regress@DLSUFFIX@'
1313
LANGUAGE C STRICT IMMUTABLE;
1414
NOTICE: argument type widget is only a shell
15-
CREATE FUNCTIONint44in(cstring)
15+
CREATE FUNCTIONcity_budget_in(cstring)
1616
RETURNS city_budget
1717
AS '@libdir@/regress@DLSUFFIX@'
1818
LANGUAGE C STRICT IMMUTABLE;
1919
NOTICE: type "city_budget" is not yet defined
2020
DETAIL: Creating a shell type definition.
21-
CREATE FUNCTIONint44out(city_budget)
21+
CREATE FUNCTIONcity_budget_out(city_budget)
2222
RETURNS cstring
2323
AS '@libdir@/regress@DLSUFFIX@'
2424
LANGUAGE C STRICT IMMUTABLE;

‎src/test/regress/regress.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,19 @@ set_ttdummy(PG_FUNCTION_ARGS)
427427

428428

429429
/*
430-
* Typeint44 has no real-world use, but the regression tests use it.
430+
* Typecity_budget has no real-world use, but the regression tests use it.
431431
* It's a four-element vector of int4's.
432432
*/
433433

434434
/*
435-
*int44in- converts "num num ..." to internal form
435+
*city_budget_in- converts "num, num, ..." to internal form
436436
*
437437
*Note: Fills any missing positions with zeroes.
438438
*/
439-
PG_FUNCTION_INFO_V1(int44in);
439+
PG_FUNCTION_INFO_V1(city_budget_in);
440440

441441
Datum
442-
int44in(PG_FUNCTION_ARGS)
442+
city_budget_in(PG_FUNCTION_ARGS)
443443
{
444444
char*input_string=PG_GETARG_CSTRING(0);
445445
int32*result= (int32*)palloc(4*sizeof(int32));
@@ -458,27 +458,22 @@ int44in(PG_FUNCTION_ARGS)
458458
}
459459

460460
/*
461-
*int44out- converts internal form to "num num ..."
461+
*city_budget_out- converts internal form to "num, num, ..."
462462
*/
463-
PG_FUNCTION_INFO_V1(int44out);
463+
PG_FUNCTION_INFO_V1(city_budget_out);
464464

465465
Datum
466-
int44out(PG_FUNCTION_ARGS)
466+
city_budget_out(PG_FUNCTION_ARGS)
467467
{
468468
int32*an_array= (int32*)PG_GETARG_POINTER(0);
469-
char*result= (char*)palloc(16*4);/* Allow 14 digits + sign */
470-
inti;
471-
char*walk;
469+
char*result= (char*)palloc(16*4);
470+
471+
snprintf(result,16*4,"%d,%d,%d,%d",
472+
an_array[0],
473+
an_array[1],
474+
an_array[2],
475+
an_array[3]);
472476

473-
walk=result;
474-
for (i=0;i<4;i++)
475-
{
476-
pg_ltoa(an_array[i],walk);
477-
while (*++walk!='\0')
478-
;
479-
*walk++=' ';
480-
}
481-
*--walk='\0';
482477
PG_RETURN_CSTRING(result);
483478
}
484479

@@ -861,5 +856,6 @@ PG_FUNCTION_INFO_V1(test_fdw_handler);
861856
Datum
862857
test_fdw_handler(PG_FUNCTION_ARGS)
863858
{
859+
elog(ERROR,"test_fdw_handler is not implemented");
864860
PG_RETURN_NULL();
865861
}

‎src/test/regress/sql/create_misc.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball');
3737

3838
INSERT INTO equipment_r (name, hobby)VALUES ('guts','skywalking');
3939

40+
INSERT INTO cityVALUES
41+
('Podunk','(1,2),(3,4)','100,127,1000'),
42+
('Gotham','(1000,34),(1100,334)','123456,127,-1000,6789');
43+
TABLE city;
44+
4045
SELECT*
4146
INTO TABLE ramp
4247
FROM road

‎src/test/regress/sql/create_operator.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ CREATE OPERATOR #%# (
3232
procedure= numeric_fac
3333
);
3434

35+
-- Test operator created above
36+
SELECTpoint'(1,2)'<% widget'(0,0,3)'AS t,
37+
point'(1,2)'<% widget'(0,0,1)'AS f;
38+
3539
-- Test comments
3640
COMMENT ON OPERATOR ###### (int4, NONE) IS'bad right unary';
3741

‎src/test/regress/sql/create_type.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ CREATE TYPE widget (
1818

1919
CREATETYPEcity_budget (
2020
internallength=16,
21-
input=int44in,
22-
output=int44out,
21+
input=city_budget_in,
22+
output=city_budget_out,
2323
element= int4,
2424
category='x',-- just to verify the system will take it
2525
preferred= true-- ditto
@@ -144,3 +144,7 @@ CREATE TEMP TABLE mytab (foo widget(42,13));
144144

145145
SELECT format_type(atttypid,atttypmod)FROM pg_attribute
146146
WHERE attrelid='mytab'::regclassAND attnum>0;
147+
148+
-- might as well exercise the widget type while we're here
149+
INSERT INTO mytabVALUES ('(1,2,3)'), ('(-44,5.5,12)');
150+
TABLE mytab;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp