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

Commitb1faf36

Browse files
committed
Allow -2147483648 to be treated as an INT4 rather than INT8 constant.
Per discussion with Paul Edwards.
1 parentd79eeef commitb1faf36

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

‎src/backend/parser/parse_node.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.87 2004/12/31 22:00:27 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.88 2005/04/23 18:35:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -276,9 +276,9 @@ transformArraySubscripts(ParseState *pstate,
276276
*Explicit "NULL" constants are also typed as UNKNOWN.
277277
*
278278
*For integers and floats we produce int4, int8, or numeric depending
279-
*on the value of the number. XXXThis shouldinclude int2 as well,
280-
*but additional cleanup is needed before we can do that;else cases
281-
*like "WHERE int4var = 42" willfailto be indexable.
279+
*on the value of the number. XXXWe shouldproduce int2 as well,
280+
*but additional cleanup is needed before we can do that;there are
281+
*too many examples thatfailif we try.
282282
*/
283283
Const*
284284
make_const(Value*value)
@@ -304,11 +304,28 @@ make_const(Value *value)
304304
/* could be an oversize integer as well as a float ... */
305305
if (scanint8(strVal(value), true,&val64))
306306
{
307-
val=Int64GetDatum(val64);
308-
309-
typeid=INT8OID;
310-
typelen=sizeof(int64);
311-
typebyval= false;/* XXX might change someday */
307+
/*
308+
* It might actually fit in int32. Probably only INT_MIN can
309+
* occur, but we'll code the test generally just to be sure.
310+
*/
311+
int32val32= (int32)val64;
312+
313+
if (val64== (int64)val32)
314+
{
315+
val=Int32GetDatum(val32);
316+
317+
typeid=INT4OID;
318+
typelen=sizeof(int32);
319+
typebyval= true;
320+
}
321+
else
322+
{
323+
val=Int64GetDatum(val64);
324+
325+
typeid=INT8OID;
326+
typelen=sizeof(int64);
327+
typebyval= false;/* XXX might change someday */
328+
}
312329
}
313330
else
314331
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp