]> granicus.if.org Git - postgresql/commitdiff
Use more-portable coding for the check on handing out the last available
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 May 2009 22:22:44 +0000 (22:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 24 May 2009 22:22:44 +0000 (22:22 +0000)
relopt_kind value in add_reloption_kind().  Per Zdenek Kotala.

src/backend/access/common/reloptions.c
src/include/access/reloptions.h

index 37a546f909c674a347907b2c216ad7963e6980ba..2668fd8bfe143fd4c58949cb1b4ca95c51d218b4 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.26 2009/04/04 21:12:30 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.27 2009/05/24 22:22:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -190,7 +190,7 @@ static relopt_string stringRelOpts[] =
 };
 
 static relopt_gen **relOpts = NULL;
-static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT << 1;
+static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT;
 
 static int             num_custom_options = 0;
 static relopt_gen **custom_options = NULL;
@@ -278,17 +278,13 @@ initialize_reloptions(void)
 relopt_kind
 add_reloption_kind(void)
 {
-       relopt_kind             kind;
-
-       /* don't hand out the last bit so that the wraparound check is portable */
+       /* don't hand out the last bit so that the enum's behavior is portable */
        if (last_assigned_kind >= RELOPT_KIND_MAX)
                ereport(ERROR,
                                (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
                                 errmsg("user-defined relation parameter types limit exceeded")));
-
-       kind = (relopt_kind) last_assigned_kind;
        last_assigned_kind <<= 1;
-       return kind;
+       return (relopt_kind) last_assigned_kind;
 }
 
 /*
index 5ecc9345f1b60995c2f488e55a21c278740422c5..d078273217ffd57cb18062f280493646c7f89033 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.14 2009/04/04 00:45:02 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.15 2009/05/24 22:22:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,7 +41,8 @@ typedef enum relopt_kind
        RELOPT_KIND_GIST        = (1 << 5),
        /* if you add a new kind, make sure you update "last_default" too */
        RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_GIST,
-       RELOPT_KIND_MAX = (1 << 31)
+       /* some compilers treat enums as signed ints, so we can't use 1 << 31 */
+       RELOPT_KIND_MAX = (1 << 30)
 } relopt_kind;
 
 /* reloption namespaces allowed for heaps -- currently only TOAST */