提交 8055f920 编写于 作者: H Heikki Linnakangas

Merge commit 'eddbf397' from PostgreSQL 8.3.

Most of the commits included in this merge we had backported already.
One ForgetDatabaseFsyncRequests() call was missing from dropdb(), and an
error check was added to width_bucket_numeric. Also, add pg_proc entry
for width_bucket_float8; the code was backported already. Update 'numeric'
regression test, per the merged commit.

Since we changed the catalogs, bump catversion, and recreate 4.3.json file.

Conflicts:
	doc/TODO
	doc/src/FAQ/TODO.html
	doc/src/sgml/func.sgml
	src/backend/catalog/information_schema.sql
	src/backend/commands/dbcommands.c
	src/backend/postmaster/bgwriter.c
	src/backend/storage/smgr/md.c
	src/backend/utils/adt/float.c
	src/backend/utils/adt/numeric.c
	src/include/catalog/catversion.h
	src/include/storage/smgr.h
	src/include/utils/builtins.h
	src/test/regress/expected/numeric.out
	src/test/regress/sql/numeric.sql
	src/tools/msvc/Project.pm
	src/tools/msvc/README
	src/tools/msvc/Solution.pm
	src/tools/msvc/build.bat
	src/tools/msvc/mkvcbuild.pl
	src/tools/msvc/pgbison.bat
	src/tools/msvc/pgflex.bat
{
"__comment" : "Generated by tidycat.pl version 34 on Mon Dec 7 13:31:04 2015 CATALOG_VERSION_NO=300701081",
"__comment" : "Generated by tidycat.pl version 34 on Wed Dec 9 00:07:28 2015 CATALOG_VERSION_NO=300701161",
"__info" : {
"CATALOG_VERSION_NO" : "300701081"
"CATALOG_VERSION_NO" : "300701161"
},
"gp_configuration" : {
"CamelCaseRelationId" : "GpConfigurationRelationId",
......
......@@ -4,7 +4,7 @@
*
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.38.2.1 2007/01/16 18:32:32 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.40 2007/01/16 18:32:26 tgl Exp $
*/
/*
......
......@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.187.2.4 2010/03/25 14:45:21 alvherre Exp $
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.190 2007/01/17 16:25:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1475,6 +1475,12 @@ dropdb(const char *dbname, bool missing_ok)
*/
FreeSpaceMapForgetDatabase(InvalidOid, db_id);
/*
* Tell bgwriter to forget any pending fsync requests for files in the
* database; else it'll fail at next checkpoint.
*/
ForgetDatabaseFsyncRequests(InvalidOid, db_id);
/*
* Force a checkpoint to make sure the bgwriter to push all pages to disk.
*/
......
......@@ -33,7 +33,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.33.2.2 2007/09/11 17:15:40 tgl Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.36 2007/01/17 16:25:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.142 2007/01/05 22:19:40 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.147 2007/01/16 21:41:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......
......@@ -14,7 +14,7 @@
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.98 2007/01/05 22:19:41 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.99 2007/01/16 21:41:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -905,16 +905,17 @@ numeric_floor(PG_FUNCTION_ARGS)
}
/*
* width_bucket_numeric() -
* Implements the numeric version of the width_bucket() function
* defined by SQL2003. See also width_bucket_float8().
*
* 'bound1' and 'bound2' are the lower and upper bounds of the
* histogram's range, respectively. 'count' is the number of buckets
* in the histogram. width_bucket() returns an integer indicating the
* bucket number that 'operand' belongs in for an equiwidth histogram
* bucket number that 'operand' belongs to in an equiwidth histogram
* with the specified characteristics. An operand smaller than the
* lower bound is assigned to bucket 0. An operand greater than the
* upper bound is assigned to an additional bucket (with number
* count+1).
* count+1). We don't allow "NaN" for any of the numeric arguments.
*/
Datum
width_bucket_numeric(PG_FUNCTION_ARGS)
......@@ -932,6 +933,13 @@ width_bucket_numeric(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION),
errmsg("count must be greater than zero")));
if (NUMERIC_IS_NAN(operand) ||
NUMERIC_IS_NAN(bound1) ||
NUMERIC_IS_NAN(bound2))
ereport(ERROR,
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION),
errmsg("operand, lower bound and upper bound cannot be NaN")));
quick_init_var(&result_var);
quick_init_var(&count_var);
......@@ -968,16 +976,16 @@ width_bucket_numeric(PG_FUNCTION_ARGS)
break;
}
free_var(&count_var);
/* if result exceeds the range of a legal int4, we ereport here */
result = numericvar_to_int4(&result_var);
free_var(&count_var);
free_var(&result_var);
PG_RETURN_INT32(result);
}
/*
* compute_bucket() -
*
* If 'operand' is not outside the bucket range, determine the correct
* bucket for it to go. The calculations performed by this function
* are derived directly from the SQL2003 spec.
......
......@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.371 2007/01/09 02:14:15 tgl Exp $
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.372 2007/01/16 21:41:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -56,6 +56,6 @@
*/
/* 3yyymmddN */
#define CATALOG_VERSION_NO 300701081
#define CATALOG_VERSION_NO 300701161
#endif
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.436 2007/01/05 22:19:53 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.437 2007/01/16 21:41:13 neilc Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
......@@ -685,6 +685,8 @@ DATA(insert OID = 309 ( float84gt PGNSP PGUID 12 f f t f i 2 16 "701 700" _
DESCR("greater-than");
DATA(insert OID = 310 ( float84ge PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84ge - _null_ ));
DESCR("greater-than-or-equal");
DATA(insert OID = 320 ( width_bucket PGNSP PGUID 12 f f t f i 4 23 "701 701 701 23" _null_ _null_ _null_ width_bucket_float8 - _null_ ));
DESCR("bucket number of operand in equidepth histogram");
DATA(insert OID = 311 ( float8 PGNSP PGUID 12 f f t f i 1 701 "700" _null_ _null_ _null_ ftod - _null_ ));
DESCR("convert float4 to float8");
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.57 2007/01/05 22:19:58 momjian Exp $
* $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.58 2007/01/17 16:25:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.285 2007/01/05 22:19:58 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.286 2007/01/16 21:41:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
......
......@@ -730,55 +730,77 @@ SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round ;
(7 rows)
DROP TABLE ceil_floor_round;
-- Testing for width_bucket()
-- NULL result
SELECT width_bucket(NULL, NULL, NULL, NULL);
width_bucket
--------------
(1 row)
-- Testing for width_bucket(). For convenience, we test both the
-- numeric and float8 versions of the function in this file.
-- errors
SELECT width_bucket(5.0, 3.0, 4.0, 0);
ERROR: count must be greater than zero
SELECT width_bucket(5.0, 3.0, 4.0, -5);
ERROR: count must be greater than zero
SELECT width_bucket(3.0, 3.0, 3.0, 888);
SELECT width_bucket(3.5, 3.0, 3.0, 888);
ERROR: lower bound cannot equal upper bound
SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0);
ERROR: count must be greater than zero
SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5);
ERROR: count must be greater than zero
SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888);
ERROR: lower bound cannot equal upper bound
SELECT width_bucket('NaN', 3.0, 4.0, 888);
ERROR: operand, lower bound and upper bound cannot be NaN
SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888);
ERROR: operand, lower bound and upper bound cannot be NaN
-- normal operation
CREATE TABLE width_bucket_test (operand numeric);
COPY width_bucket_test FROM stdin;
CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8);
COPY width_bucket_test (operand_num) FROM stdin;
UPDATE width_bucket_test SET operand_f8 = operand_num::float8;
SELECT
operand,
width_bucket(operand, 0, 10, 5) AS wb_1,
width_bucket(operand, 10, 0, 5) AS wb_2,
width_bucket(operand, 2, 8, 4) AS wb_3,
width_bucket(operand, 5.0, 5.5, 20) AS wb_4,
width_bucket(operand, -25, 25, 10) AS wb_5
FROM width_bucket_test ;
operand | wb_1 | wb_2 | wb_3 | wb_4 | wb_5
------------------+------+------+------+------+------
-5.2 | 0 | 6 | 0 | 0 | 4
-0.0000000000001 | 0 | 6 | 0 | 0 | 5
0.0000000000001 | 1 | 5 | 0 | 0 | 6
1 | 1 | 5 | 0 | 0 | 6
1.99999999999999 | 1 | 5 | 0 | 0 | 6
2 | 2 | 5 | 1 | 0 | 6
2.00000000000001 | 2 | 4 | 1 | 0 | 6
3 | 2 | 4 | 1 | 0 | 6
4 | 3 | 4 | 2 | 0 | 6
4.5 | 3 | 3 | 2 | 0 | 6
5 | 3 | 3 | 3 | 1 | 7
5.5 | 3 | 3 | 3 | 21 | 7
6 | 4 | 3 | 3 | 21 | 7
7 | 4 | 2 | 4 | 21 | 7
8 | 5 | 2 | 5 | 21 | 7
9 | 5 | 1 | 5 | 21 | 7
9.99999999999999 | 5 | 1 | 5 | 21 | 7
10 | 6 | 1 | 5 | 21 | 8
10.0000000000001 | 6 | 0 | 5 | 21 | 8
NaN | 6 | 0 | 5 | 21 | 11
(20 rows)
operand_num,
width_bucket(operand_num, 0, 10, 5) AS wb_1,
width_bucket(operand_f8, 0, 10, 5) AS wb_1f,
width_bucket(operand_num, 10, 0, 5) AS wb_2,
width_bucket(operand_f8, 10, 0, 5) AS wb_2f,
width_bucket(operand_num, 2, 8, 4) AS wb_3,
width_bucket(operand_f8, 2, 8, 4) AS wb_3f,
width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4,
width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f,
width_bucket(operand_num, -25, 25, 10) AS wb_5,
width_bucket(operand_f8, -25, 25, 10) AS wb_5f
FROM width_bucket_test;
operand_num | wb_1 | wb_1f | wb_2 | wb_2f | wb_3 | wb_3f | wb_4 | wb_4f | wb_5 | wb_5f
------------------+------+-------+------+-------+------+-------+------+-------+------+-------
-5.2 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 4 | 4
-0.0000000001 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 5 | 5
0.000000000001 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6
1 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6
1.99999999999999 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6
2 | 2 | 2 | 5 | 5 | 1 | 1 | 0 | 0 | 6 | 6
2.00000000000001 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6
3 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6
4 | 3 | 3 | 4 | 4 | 2 | 2 | 0 | 0 | 6 | 6
4.5 | 3 | 3 | 3 | 3 | 2 | 2 | 0 | 0 | 6 | 6
5 | 3 | 3 | 3 | 3 | 3 | 3 | 1 | 1 | 7 | 7
5.5 | 3 | 3 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7
6 | 4 | 4 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7
7 | 4 | 4 | 2 | 2 | 4 | 4 | 21 | 21 | 7 | 7
8 | 5 | 5 | 2 | 2 | 5 | 5 | 21 | 21 | 7 | 7
9 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7
9.99999999999999 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7
10 | 6 | 6 | 1 | 1 | 5 | 5 | 21 | 21 | 8 | 8
10.0000000000001 | 6 | 6 | 0 | 0 | 5 | 5 | 21 | 21 | 8 | 8
(19 rows)
-- for float8 only, check positive and negative infinity: we require
-- finite bucket bounds, but allow an infinite operand
SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10); -- error
ERROR: lower and upper bounds must be finite
SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20); -- error
ERROR: lower and upper bounds must be finite
SELECT width_bucket('Infinity'::float8, 1, 10, 10),
width_bucket('-Infinity'::float8, 1, 10, 10);
width_bucket | width_bucket
--------------+--------------
11 | 0
(1 row)
DROP TABLE width_bucket_test;
-- TO_CHAR()
......@@ -800,7 +822,7 @@ SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999')
(10 rows)
SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999')
FROM num_data ;
FROM num_data;
to_char_2 | to_char
-----------+--------------------------------------------
| .000,000,000,000,000
......
......@@ -667,22 +667,26 @@ INSERT INTO ceil_floor_round VALUES ('-0.000001');
SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round ;
DROP TABLE ceil_floor_round;
-- Testing for width_bucket()
-- NULL result
SELECT width_bucket(NULL, NULL, NULL, NULL);
-- Testing for width_bucket(). For convenience, we test both the
-- numeric and float8 versions of the function in this file.
-- errors
SELECT width_bucket(5.0, 3.0, 4.0, 0);
SELECT width_bucket(5.0, 3.0, 4.0, -5);
SELECT width_bucket(3.0, 3.0, 3.0, 888);
SELECT width_bucket(3.5, 3.0, 3.0, 888);
SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0);
SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5);
SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888);
SELECT width_bucket('NaN', 3.0, 4.0, 888);
SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888);
-- normal operation
CREATE TABLE width_bucket_test (operand numeric);
CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8);
COPY width_bucket_test FROM stdin;
COPY width_bucket_test (operand_num) FROM stdin;
-5.2
-0.0000000000001
0.0000000000001
-0.0000000001
0.000000000001
1
1.99999999999999
2
......@@ -699,17 +703,30 @@ COPY width_bucket_test FROM stdin;
9.99999999999999
10
10.0000000000001
NaN
\.
UPDATE width_bucket_test SET operand_f8 = operand_num::float8;
SELECT
operand,
width_bucket(operand, 0, 10, 5) AS wb_1,
width_bucket(operand, 10, 0, 5) AS wb_2,
width_bucket(operand, 2, 8, 4) AS wb_3,
width_bucket(operand, 5.0, 5.5, 20) AS wb_4,
width_bucket(operand, -25, 25, 10) AS wb_5
FROM width_bucket_test ;
operand_num,
width_bucket(operand_num, 0, 10, 5) AS wb_1,
width_bucket(operand_f8, 0, 10, 5) AS wb_1f,
width_bucket(operand_num, 10, 0, 5) AS wb_2,
width_bucket(operand_f8, 10, 0, 5) AS wb_2f,
width_bucket(operand_num, 2, 8, 4) AS wb_3,
width_bucket(operand_f8, 2, 8, 4) AS wb_3f,
width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4,
width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f,
width_bucket(operand_num, -25, 25, 10) AS wb_5,
width_bucket(operand_f8, -25, 25, 10) AS wb_5f
FROM width_bucket_test;
-- for float8 only, check positive and negative infinity: we require
-- finite bucket bounds, but allow an infinite operand
SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10); -- error
SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20); -- error
SELECT width_bucket('Infinity'::float8, 1, 10, 10),
width_bucket('-Infinity'::float8, 1, 10, 10);
DROP TABLE width_bucket_test;
......@@ -719,7 +736,7 @@ SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999')
FROM num_data ;
SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999')
FROM num_data ;
FROM num_data;
SELECT '' AS to_char_3, to_char(val, '9999999999999999.999999999999999PR')
FROM num_data ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册