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

Commita0cd991

Browse files
committed
Add int2-to-int8 and int8-to-int2 conversion routines. Needed to avoid
breaking existing pg_dump scripts, which try to assign the result ofcount(*) to an int2 variable. catversion bumped.
1 parent92e8282 commita0cd991

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

‎src/backend/utils/adt/int8.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.34 2001/10/2505:49:44 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.35 2001/10/2514:10:06 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -697,6 +697,29 @@ int84(PG_FUNCTION_ARGS)
697697
PG_RETURN_INT32(result);
698698
}
699699

700+
Datum
701+
int28(PG_FUNCTION_ARGS)
702+
{
703+
int16val=PG_GETARG_INT16(0);
704+
705+
PG_RETURN_INT64((int64)val);
706+
}
707+
708+
Datum
709+
int82(PG_FUNCTION_ARGS)
710+
{
711+
int64val=PG_GETARG_INT64(0);
712+
int16result;
713+
714+
result= (int16)val;
715+
716+
/* Test for overflow by reverse-conversion. */
717+
if ((int64)result!=val)
718+
elog(ERROR,"int8 conversion to int2 is out of range");
719+
720+
PG_RETURN_INT16(result);
721+
}
722+
700723
Datum
701724
i8tod(PG_FUNCTION_ARGS)
702725
{

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $Id: catversion.h,v 1.100 2001/10/2505:49:56 momjian Exp $
40+
* $Id: catversion.h,v 1.101 2001/10/2514:10:06 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,5 +53,5 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200110181
56+
#defineCATALOG_VERSION_NO200110251
5757
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_proc.h,v 1.218 2001/10/2505:49:57 momjian Exp $
10+
* $Id: pg_proc.h,v 1.219 2001/10/2514:10:06 tgl Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -885,6 +885,11 @@ DESCR("convert int8 to float8");
885885
DATA(insertOID=483 (int8PGUID12fttt1f20"701"10000100dtoi8- ));
886886
DESCR("convert float8 to int8");
887887

888+
DATA(insertOID=714 (int2PGUID12fttt1f21"20"10000100int82- ));
889+
DESCR("convert int8 to int2");
890+
DATA(insertOID=754 (int8PGUID12fttt1f20"21"10000100int28- ));
891+
DESCR("convert int2 to int8");
892+
888893
/* OIDS 500 - 599 */
889894

890895
/* OIDS 600 - 699 */

‎src/include/utils/int8.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: int8.h,v 1.28 2001/10/2505:50:10 momjian Exp $
10+
* $Id: int8.h,v 1.29 2001/10/2514:10:07 tgl Exp $
1111
*
1212
* NOTES
1313
* These data types are supported on all 64-bit architectures, and may
@@ -98,6 +98,9 @@ extern Datum int48div(PG_FUNCTION_ARGS);
9898
externDatumint48(PG_FUNCTION_ARGS);
9999
externDatumint84(PG_FUNCTION_ARGS);
100100

101+
externDatumint28(PG_FUNCTION_ARGS);
102+
externDatumint82(PG_FUNCTION_ARGS);
103+
101104
externDatumi8tod(PG_FUNCTION_ARGS);
102105
externDatumdtoi8(PG_FUNCTION_ARGS);
103106

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp