Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0271d5

Browse files
committed
Remove useless range checks on INT8 sequences
There's no point in checking if an INT8 sequence has a seqmin and seqmaxvalue is outside the range of the minimum and maximum values for an int64type. These both use the same underlying types so an INT8 certainlycannot be outside the minimum and maximum values supported by int64.This code is fairly harmless and it seems likely that most compilerswould optimize it out anyway, never-the-less, let's remove it replacingit with a small comment to mention why the check is not needed.Author: Greg Nancarrow, with the comment revised by David RowleyDiscussion:https://postgr.es/m/CAJcOf-c9KBUZ8ow_6e%3DWSfbbEyTKfqV%3DVwoFuODQVYMySHtusw%40mail.gmail.com
1 parent5bd38d2 commite0271d5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/backend/commands/sequence.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,9 @@ init_params(ParseState *pstate, List *options, bool for_identity,
14601460
seqdataform->log_cnt=0;
14611461
}
14621462

1463+
/* Validate maximum value. No need to check INT8 as seqmax is an int64 */
14631464
if ((seqform->seqtypid==INT2OID&& (seqform->seqmax<PG_INT16_MIN||seqform->seqmax>PG_INT16_MAX))
1464-
|| (seqform->seqtypid==INT4OID&& (seqform->seqmax<PG_INT32_MIN||seqform->seqmax>PG_INT32_MAX))
1465-
|| (seqform->seqtypid==INT8OID&& (seqform->seqmax<PG_INT64_MIN||seqform->seqmax>PG_INT64_MAX)))
1465+
|| (seqform->seqtypid==INT4OID&& (seqform->seqmax<PG_INT32_MIN||seqform->seqmax>PG_INT32_MAX)))
14661466
{
14671467
charbufx[100];
14681468

@@ -1497,9 +1497,9 @@ init_params(ParseState *pstate, List *options, bool for_identity,
14971497
seqdataform->log_cnt=0;
14981498
}
14991499

1500+
/* Validate minimum value. No need to check INT8 as seqmin is an int64 */
15001501
if ((seqform->seqtypid==INT2OID&& (seqform->seqmin<PG_INT16_MIN||seqform->seqmin>PG_INT16_MAX))
1501-
|| (seqform->seqtypid==INT4OID&& (seqform->seqmin<PG_INT32_MIN||seqform->seqmin>PG_INT32_MAX))
1502-
|| (seqform->seqtypid==INT8OID&& (seqform->seqmin<PG_INT64_MIN||seqform->seqmin>PG_INT64_MAX)))
1502+
|| (seqform->seqtypid==INT4OID&& (seqform->seqmin<PG_INT32_MIN||seqform->seqmin>PG_INT32_MAX)))
15031503
{
15041504
charbufm[100];
15051505

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp