Skip to content

Commit c3707a4

Browse files
committed
Use more-portable coding for the check on handing out the last available
relopt_kind value in add_reloption_kind(). Per Zdenek Kotala.
1 parent fc2660f commit c3707a4

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/backend/access/common/reloptions.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.26 2009/04/04 21:12:30 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.27 2009/05/24 22:22:44 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -190,7 +190,7 @@ static relopt_string stringRelOpts[] =
190190
};
191191

192192
static relopt_gen **relOpts = NULL;
193-
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT << 1;
193+
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT;
194194

195195
static int num_custom_options = 0;
196196
static relopt_gen **custom_options = NULL;
@@ -278,17 +278,13 @@ initialize_reloptions(void)
278278
relopt_kind
279279
add_reloption_kind(void)
280280
{
281-
relopt_kind kind;
282-
283-
/* don't hand out the last bit so that the wraparound check is portable */
281+
/* don't hand out the last bit so that the enum's behavior is portable */
284282
if (last_assigned_kind >= RELOPT_KIND_MAX)
285283
ereport(ERROR,
286284
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
287285
errmsg("user-defined relation parameter types limit exceeded")));
288-
289-
kind = (relopt_kind) last_assigned_kind;
290286
last_assigned_kind <<= 1;
291-
return kind;
287+
return (relopt_kind) last_assigned_kind;
292288
}
293289

294290
/*

src/include/access/reloptions.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.14 2009/04/04 00:45:02 alvherre Exp $
14+
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.15 2009/05/24 22:22:44 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -41,7 +41,8 @@ typedef enum relopt_kind
4141
RELOPT_KIND_GIST = (1 << 5),
4242
/* if you add a new kind, make sure you update "last_default" too */
4343
RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_GIST,
44-
RELOPT_KIND_MAX = (1 << 31)
44+
/* some compilers treat enums as signed ints, so we can't use 1 << 31 */
45+
RELOPT_KIND_MAX = (1 << 30)
4546
} relopt_kind;
4647

4748
/* reloption namespaces allowed for heaps -- currently only TOAST */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy