14
14
* Copyright (c) 1998-2003, PostgreSQL Global Development Group
15
15
*
16
16
* IDENTIFICATION
17
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.63 2003/07/27 04:53:07 tgl Exp $
17
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.64 2003/07/30 19:48:41 tgl Exp $
18
18
*
19
19
*-------------------------------------------------------------------------
20
20
*/
@@ -316,7 +316,7 @@ numeric_in(PG_FUNCTION_ARGS)
316
316
/*
317
317
* Check for NaN
318
318
*/
319
- if (strcmp (str , "NaN" ) == 0 )
319
+ if (strcasecmp (str , "NaN" ) == 0 )
320
320
PG_RETURN_NUMERIC (make_result (& const_nan ));
321
321
322
322
/*
@@ -1239,34 +1239,15 @@ numeric_smaller(PG_FUNCTION_ARGS)
1239
1239
{
1240
1240
Numeric num1 = PG_GETARG_NUMERIC (0 );
1241
1241
Numeric num2 = PG_GETARG_NUMERIC (1 );
1242
- NumericVar arg1 ;
1243
- NumericVar arg2 ;
1244
- Numeric res ;
1245
-
1246
- /*
1247
- * Handle NaN
1248
- */
1249
- if (NUMERIC_IS_NAN (num1 ) || NUMERIC_IS_NAN (num2 ))
1250
- PG_RETURN_NUMERIC (make_result (& const_nan ));
1251
1242
1252
1243
/*
1253
- * Unpack the values, and decide which is the smaller one
1244
+ * Use cmp_numerics so that this will agree with the comparison
1245
+ * operators, particularly as regards comparisons involving NaN.
1254
1246
*/
1255
- init_var (& arg1 );
1256
- init_var (& arg2 );
1257
-
1258
- set_var_from_num (num1 , & arg1 );
1259
- set_var_from_num (num2 , & arg2 );
1260
-
1261
- if (cmp_var (& arg1 , & arg2 ) <= 0 )
1262
- res = make_result (& arg1 );
1247
+ if (cmp_numerics (num1 , num2 ) < 0 )
1248
+ PG_RETURN_NUMERIC (num1 );
1263
1249
else
1264
- res = make_result (& arg2 );
1265
-
1266
- free_var (& arg1 );
1267
- free_var (& arg2 );
1268
-
1269
- PG_RETURN_NUMERIC (res );
1250
+ PG_RETURN_NUMERIC (num2 );
1270
1251
}
1271
1252
1272
1253
@@ -1280,34 +1261,15 @@ numeric_larger(PG_FUNCTION_ARGS)
1280
1261
{
1281
1262
Numeric num1 = PG_GETARG_NUMERIC (0 );
1282
1263
Numeric num2 = PG_GETARG_NUMERIC (1 );
1283
- NumericVar arg1 ;
1284
- NumericVar arg2 ;
1285
- Numeric res ;
1286
-
1287
- /*
1288
- * Handle NaN
1289
- */
1290
- if (NUMERIC_IS_NAN (num1 ) || NUMERIC_IS_NAN (num2 ))
1291
- PG_RETURN_NUMERIC (make_result (& const_nan ));
1292
1264
1293
1265
/*
1294
- * Unpack the values, and decide which is the larger one
1266
+ * Use cmp_numerics so that this will agree with the comparison
1267
+ * operators, particularly as regards comparisons involving NaN.
1295
1268
*/
1296
- init_var (& arg1 );
1297
- init_var (& arg2 );
1298
-
1299
- set_var_from_num (num1 , & arg1 );
1300
- set_var_from_num (num2 , & arg2 );
1301
-
1302
- if (cmp_var (& arg1 , & arg2 ) >= 0 )
1303
- res = make_result (& arg1 );
1269
+ if (cmp_numerics (num1 , num2 ) > 0 )
1270
+ PG_RETURN_NUMERIC (num1 );
1304
1271
else
1305
- res = make_result (& arg2 );
1306
-
1307
- free_var (& arg1 );
1308
- free_var (& arg2 );
1309
-
1310
- PG_RETURN_NUMERIC (res );
1272
+ PG_RETURN_NUMERIC (num2 );
1311
1273
}
1312
1274
1313
1275
0 commit comments