File tree Expand file tree Collapse file tree 5 files changed +36
-6
lines changed Expand file tree Collapse file tree 5 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.64 2004/12/31 22:01:22 pgsql Exp $
11
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.65 2005/02/27 08:31:30 neilc Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -361,6 +361,25 @@ text_int4(PG_FUNCTION_ARGS)
361
361
return result ;
362
362
}
363
363
364
+ /* Cast int4 -> bool */
365
+ Datum
366
+ int4_bool (PG_FUNCTION_ARGS )
367
+ {
368
+ if (PG_GETARG_INT32 (0 ) == 0 )
369
+ PG_RETURN_BOOL (false);
370
+ else
371
+ PG_RETURN_BOOL (true);
372
+ }
373
+
374
+ /* Cast bool -> int4 */
375
+ Datum
376
+ bool_int4 (PG_FUNCTION_ARGS )
377
+ {
378
+ if (PG_GETARG_BOOL (0 ) == false)
379
+ PG_RETURN_INT32 (0 );
380
+ else
381
+ PG_RETURN_INT32 (1 );
382
+ }
364
383
365
384
/*
366
385
* ============================
Original file line number Diff line number Diff line change 37
37
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
38
38
* Portions Copyright (c) 1994, Regents of the University of California
39
39
*
40
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.255 2005/02/26 18:43:34 tgl Exp $
40
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.256 2005/02/27 08:31:30 neilc Exp $
41
41
*
42
42
*-------------------------------------------------------------------------
43
43
*/
53
53
*/
54
54
55
55
/* yyyymmddN */
56
- #define CATALOG_VERSION_NO 200502261
56
+ #define CATALOG_VERSION_NO 200502271
57
57
58
58
#endif
Original file line number Diff line number Diff line change 10
10
*
11
11
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
12
12
*
13
- * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.17 2005/01/01 05:43:09 momjian Exp $
13
+ * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.18 2005/02/27 08:31:30 neilc Exp $
14
14
*
15
15
* NOTES
16
16
* the genbki.sh script reads this file and generates .bki
@@ -101,6 +101,10 @@ DATA(insert ( 1700 23 1744 a ));
101
101
DATA (insert ( 1700 700 1745 i ));
102
102
DATA (insert ( 1700 701 1746 i ));
103
103
104
+ /* Allow explicit coercions between int4 and bool */
105
+ DATA (insert ( 23 16 2557 e ));
106
+ DATA (insert ( 16 23 2558 e ));
107
+
104
108
/*
105
109
* OID category: allow implicit conversion from any integral type (including
106
110
* int8, to support OID literals > 2G) to OID, as well as assignment coercion
Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.350 2005/02/26 18:43:34 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.351 2005/02/27 08:31:30 neilc Exp $
11
11
*
12
12
* NOTES
13
13
* The script catalog/genbki.sh reads this file and generates .bki
@@ -3604,6 +3604,11 @@ DATA(insert OID = 2550 ( integer_pl_date PGNSP PGUID 14 f f t f i 2 1082 "23 1
3604
3604
DATA (insert OID = 2556 ( pg_tablespace_databases PGNSP PGUID 12 f f t t s 1 26 "26" _null_ pg_tablespace_databases - _null_ ));
3605
3605
DESCR ("returns database oids in a tablespace" );
3606
3606
3607
+ DATA (insert OID = 2557 ( bool PGNSP PGUID 12 f f t f i 1 16 "23" _null_ int4_bool - _null_ ));
3608
+ DESCR ("convert int4 to boolean" );
3609
+ DATA (insert OID = 2558 ( int4 PGNSP PGUID 12 f f t f i 1 23 "16" _null_ bool_int4 - _null_ ));
3610
+ DESCR ("convert boolean to int4" );
3611
+
3607
3612
3608
3613
/*
3609
3614
* Symbolic values for provolatile column: these indicate whether the result
Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.252 2004/12/31 22:03:45 pgsql Exp $
10
+ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.253 2005/02/27 08:31:30 neilc Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -111,6 +111,8 @@ extern Datum i2toi4(PG_FUNCTION_ARGS);
111
111
extern Datum i4toi2 (PG_FUNCTION_ARGS );
112
112
extern Datum int2_text (PG_FUNCTION_ARGS );
113
113
extern Datum text_int2 (PG_FUNCTION_ARGS );
114
+ extern Datum int4_bool (PG_FUNCTION_ARGS );
115
+ extern Datum bool_int4 (PG_FUNCTION_ARGS );
114
116
extern Datum int4_text (PG_FUNCTION_ARGS );
115
117
extern Datum text_int4 (PG_FUNCTION_ARGS );
116
118
extern Datum int4eq (PG_FUNCTION_ARGS );
You can’t perform that action at this time.
0 commit comments