<!--
-$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.299 2004/10/04 14:42:46 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.300 2004/10/04 22:49:47 tgl Exp $
-->
<appendix id="release">
</para>
</listitem>
+ <listitem>
+ <para>
+ The arithmetic operators associated with the <quote>char</> data type
+ have been removed.
+ </para>
+ </listitem>
+
<listitem>
<para>
The server now warns of empty strings passed to
</para>
</listitem>
+ <listitem>
+ <para>
+ The arithmetic operators associated with the <quote>char</> data type
+ have been removed.
+ </para>
+ <para>
+ Formerly, the parser would select these operators in many situations
+ where an <quote>unable to select an operator</> error would be more
+ appropriate, such as <literal>null * null</>. If you actually want
+ to do arithmetic on a <quote>char</> column, you can cast it to integer.
+ </para>
+ </listitem>
+
<listitem>
<para>
Syntax checking of array input values considerably tightened up (Joe)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.40 2004/08/29 04:12:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.41 2004/10/04 22:49:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
+#include <limits.h>
+
#include "libpq/pqformat.h"
#include "utils/builtins.h"
+#ifndef SCHAR_MAX
+#define SCHAR_MAX (0x7F)
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN (-SCHAR_MAX-1)
+#endif
+
+
/*****************************************************************************
* USER I/O ROUTINES *
*****************************************************************************/
/*
* NOTE: comparisons are done as though char is unsigned (uint8).
- * Arithmetic is done as though char is signed (int8).
+ * Conversions to and from integer are done as though char is signed (int8).
*
* You wanted consistency?
*/
PG_RETURN_BOOL((uint8) arg1 >= (uint8) arg2);
}
-Datum
-charpl(PG_FUNCTION_ARGS)
-{
- char arg1 = PG_GETARG_CHAR(0);
- char arg2 = PG_GETARG_CHAR(1);
-
- PG_RETURN_CHAR((int8) arg1 + (int8) arg2);
-}
Datum
-charmi(PG_FUNCTION_ARGS)
+chartoi4(PG_FUNCTION_ARGS)
{
char arg1 = PG_GETARG_CHAR(0);
- char arg2 = PG_GETARG_CHAR(1);
- PG_RETURN_CHAR((int8) arg1 - (int8) arg2);
+ PG_RETURN_INT32((int32) ((int8) arg1));
}
Datum
-charmul(PG_FUNCTION_ARGS)
+i4tochar(PG_FUNCTION_ARGS)
{
- char arg1 = PG_GETARG_CHAR(0);
- char arg2 = PG_GETARG_CHAR(1);
-
- PG_RETURN_CHAR((int8) arg1 * (int8) arg2);
-}
-
-Datum
-chardiv(PG_FUNCTION_ARGS)
-{
- char arg1 = PG_GETARG_CHAR(0);
- char arg2 = PG_GETARG_CHAR(1);
+ int32 arg1 = PG_GETARG_INT32(0);
- if (arg2 == 0)
+ if (arg1 < SCHAR_MIN || arg1 > SCHAR_MAX)
ereport(ERROR,
- (errcode(ERRCODE_DIVISION_BY_ZERO),
- errmsg("division by zero")));
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("\"char\" out of range")));
- PG_RETURN_CHAR((int8) arg1 / (int8) arg2);
+ PG_RETURN_CHAR((int8) arg1);
}
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.249 2004/08/29 04:13:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.250 2004/10/04 22:49:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200408031
+#define CATALOG_VERSION_NO 200410041
#endif
*
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.15 2004/08/29 05:06:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.16 2004/10/04 22:49:54 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert ( 25 19 407 i ));
DATA(insert ( 1042 19 409 i ));
DATA(insert ( 1043 19 1400 i ));
+/* Cross-category casts between int4 and "char" */
+DATA(insert ( 18 23 77 e ));
+DATA(insert ( 23 18 78 e ));
/*
* Datetime category
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.128 2004/08/29 05:06:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.129 2004/10/04 22:49:54 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
DATA(insert OID = 633 ( ">" PGNSP PGUID b f 18 18 16 631 632 0 0 0 0 chargt scalargtsel scalargtjoinsel ));
DATA(insert OID = 634 ( ">=" PGNSP PGUID b f 18 18 16 632 631 0 0 0 0 charge scalargtsel scalargtjoinsel ));
-DATA(insert OID = 635 ( "+" PGNSP PGUID b f 18 18 18 0 0 0 0 0 0 charpl - - ));
-DATA(insert OID = 636 ( "-" PGNSP PGUID b f 18 18 18 0 0 0 0 0 0 charmi - - ));
-DATA(insert OID = 637 ( "*" PGNSP PGUID b f 18 18 18 0 0 0 0 0 0 charmul - - ));
-DATA(insert OID = 638 ( "/" PGNSP PGUID b f 18 18 18 0 0 0 0 0 0 chardiv - - ));
-
DATA(insert OID = 639 ( "~" PGNSP PGUID b f 19 25 16 0 640 0 0 0 0 nameregexeq regexeqsel regexeqjoinsel ));
#define OID_NAME_REGEXEQ_OP 639
DATA(insert OID = 640 ( "!~" PGNSP PGUID b f 19 25 16 0 639 0 0 0 0 nameregexne regexnesel regexnejoinsel ));
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.346 2004/10/04 22:13:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.347 2004/10/04 22:49:55 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DESCR("greater-than");
DATA(insert OID = 74 ( charge PGNSP PGUID 12 f f t f i 2 16 "18 18" _null_ charge - _null_ ));
DESCR("greater-than-or-equal");
-DATA(insert OID = 1248 ( charpl PGNSP PGUID 12 f f t f i 2 18 "18 18" _null_ charpl - _null_ ));
-DESCR("add");
-DATA(insert OID = 1250 ( charmi PGNSP PGUID 12 f f t f i 2 18 "18 18" _null_ charmi - _null_ ));
-DESCR("subtract");
-DATA(insert OID = 77 ( charmul PGNSP PGUID 12 f f t f i 2 18 "18 18" _null_ charmul - _null_ ));
-DESCR("multiply");
-DATA(insert OID = 78 ( chardiv PGNSP PGUID 12 f f t f i 2 18 "18 18" _null_ chardiv - _null_ ));
-DESCR("divide");
+DATA(insert OID = 77 ( int4 PGNSP PGUID 12 f f t f i 1 23 "18" _null_ chartoi4 - _null_ ));
+DESCR("convert char to int4");
+DATA(insert OID = 78 ( char PGNSP PGUID 12 f f t f i 1 18 "23" _null_ i4tochar - _null_ ));
+DESCR("convert int4 to char");
DATA(insert OID = 79 ( nameregexeq PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ nameregexeq - _null_ ));
DESCR("matches regex., case-sensitive");
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.250 2004/08/30 02:54:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.251 2004/10/04 22:49:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum charle(PG_FUNCTION_ARGS);
extern Datum chargt(PG_FUNCTION_ARGS);
extern Datum charge(PG_FUNCTION_ARGS);
-extern Datum charpl(PG_FUNCTION_ARGS);
-extern Datum charmi(PG_FUNCTION_ARGS);
-extern Datum charmul(PG_FUNCTION_ARGS);
-extern Datum chardiv(PG_FUNCTION_ARGS);
+extern Datum chartoi4(PG_FUNCTION_ARGS);
+extern Datum i4tochar(PG_FUNCTION_ARGS);
extern Datum text_char(PG_FUNCTION_ARGS);
extern Datum char_text(PG_FUNCTION_ARGS);