summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-05-24 22:22:44 +0000
committerTom Lane2009-05-24 22:22:44 +0000
commit8945d30a1502c90a3485b23803d031a92313fa97 (patch)
tree9410d840d97997a97783af2ed08586cc79abbde4
parent2e4af7b183a0ff87b88053014579f81f3807df7c (diff)
Use more-portable coding for the check on handing out the last available
relopt_kind value in add_reloption_kind(). Per Zdenek Kotala.
-rw-r--r--src/backend/access/common/reloptions.c10
-rw-r--r--src/include/access/reloptions.h3
2 files changed, 5 insertions, 8 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 4b0bfb9f01..aee17f06bf 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -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;
}
/*
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index 4eb7cf43ff..d0ed07b7b8 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -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 */