Commit a9b78014 authored by Robert Anderson's avatar Robert Anderson
Browse files

Fix use of signed vs unsigned numerics



Replaced the incorrect use of @BIG_INTEGER@ variable which
implied that the numerical value would be signed (default
in at least MySQL).

Note: PostgreSQL does not support signed/unsigned numerics,
INT8 has been kept for this reason.

Change-Id: I5a0892f7e14f723d5b35f8beca5138890f3e550c
Signed-off-by: default avatarRobert Anderson <randerson@lbsd.net>
parent 6bb7fe6f
......@@ -38,8 +38,8 @@ CREATE TABLE @PREFIX@accounting (
AccountingPeriod SMALLINT NOT NULL, /* 0 - Track by day, 1 - Track by week, 2 - Track by month */
/* Limits for this period */
MessageCountLimit @BIG_INTEGER@, /* Limit is in Kbyte, NULL means no limit */
MessageCumulativeSizeLimit @BIG_INTEGER@, /* LImit is in Kbyte, NULL means no limit */
MessageCountLimit @BIG_INTEGER_UNSIGNED@, /* Limit is in Kbyte, NULL means no limit */
MessageCumulativeSizeLimit @BIG_INTEGER_UNSIGNED@, /* LImit is in Kbyte, NULL means no limit */
/* Verdict if limits are exceeded */
Verdict VARCHAR(255), /* Verdict when limit is exceeded */
......@@ -64,10 +64,10 @@ CREATE TABLE @PREFIX@accounting_tracking (
PeriodKey VARCHAR(@TRACK_KEY_LEN@),
/* Last time this record was update */
LastUpdate @BIG_INTEGER@, /* NULL means not updated yet */
LastUpdate @BIG_INTEGER_UNSIGNED@, /* NULL means not updated yet */
MessageCount @BIG_INTEGER@,
MessageCumulativeSize @BIG_INTEGER@, /* Counter is in Kbyte */
MessageCount @BIG_INTEGER_UNSIGNED@,
MessageCumulativeSize @BIG_INTEGER_UNSIGNED@, /* Counter is in Kbyte */
UNIQUE (AccountingID,TrackKey,PeriodKey),
FOREIGN KEY (AccountingID) REFERENCES @PREFIX@accounting(ID)
......
......@@ -31,13 +31,13 @@ CREATE TABLE @PREFIX@checkhelo (
/* Blacklisting, we want to reject people impersonating us */
UseBlacklist SMALLINT, /* Checks blacklist table */
BlacklistPeriod @BIG_INTEGER@, /* Period to keep the host blacklisted for, if not set or 0
BlacklistPeriod @BIG_INTEGER_UNSIGNED@, /* Period to keep the host blacklisted for, if not set or 0
the check will be live */
/* Random helo prevention */
UseHRP SMALLINT, /* Use helo randomization prevention */
HRPPeriod @BIG_INTEGER@, /* Period/window we check for random helo's */
HRPLimit @BIG_INTEGER@, /* Our limit for the number of helo's is this */
HRPPeriod @BIG_INTEGER_UNSIGNED@, /* Period/window we check for random helo's */
HRPLimit @BIG_INTEGER_UNSIGNED@, /* Our limit for the number of helo's is this */
/* RFC compliance options */
RejectInvalid SMALLINT, /* Reject invalid HELO */
......@@ -100,7 +100,7 @@ CREATE TABLE @PREFIX@checkhelo_whitelist (
CREATE TABLE @PREFIX@checkhelo_tracking (
Address VARCHAR(64) NOT NULL,
Helo VARCHAR(255) NOT NULL,
LastUpdate @BIG_INTEGER@ NOT NULL,
LastUpdate @BIG_INTEGER_UNSIGNED@ NOT NULL,
UNIQUE (Address,Helo)
) @CREATE_TABLE_SUFFIX@;
......
......@@ -61,7 +61,7 @@ case "$database" in
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/ENGINE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIGINT_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@INT_UNSIGNED@/INT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
......@@ -74,7 +74,7 @@ case "$database" in
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/TYPE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIG_INTEGER@/BIGINT UNSIGNED/' \
-e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/255/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
;;
......@@ -86,7 +86,7 @@ case "$database" in
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/TYPE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIG_INTEGER@/BIGINT UNSIGNED/' \
-e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
;;
......@@ -98,7 +98,7 @@ case "$database" in
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/SERIAL PRIMARY KEY/' \
-e 's/@BIG_INTEGER@/INT8/' \
-e 's/@BIG_INTEGER_UNSIGNED@/INT8/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
......@@ -110,7 +110,7 @@ case "$database" in
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/INTEGER PRIMARY KEY AUTOINCREMENT/' \
-e 's/@BIG_INTEGER@/INT8/' \
-e 's/@BIG_INTEGER_UNSIGNED@/UNSIGNED BIG INT/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
......
......@@ -160,7 +160,7 @@ CREATE TABLE @PREFIX@session_tracking (
Sender VARCHAR(255),
Size @BIG_INTEGER@,
Size @BIG_INTEGER_UNSIGNED@,
RecipientData TEXT, /* Policy state information */
......
......@@ -31,7 +31,7 @@ CREATE TABLE @PREFIX@greylisting (
/* General greylisting settings */
UseGreylisting SMALLINT, /* Actually use greylisting */
GreylistPeriod @BIG_INTEGER@, /* Period in seconds to greylist for */
GreylistPeriod @BIG_INTEGER_UNSIGNED@, /* Period in seconds to greylist for */
/* Record tracking */
Track VARCHAR(255) NOT NULL, /* Format: <type>:<spec>
......@@ -39,24 +39,24 @@ CREATE TABLE @PREFIX@greylisting (
*/
/* Bypass greylisting: sender+recipient level */
GreylistAuthValidity @BIG_INTEGER@, /* Period for which last authenticated greylist entry is valid for.
GreylistAuthValidity @BIG_INTEGER_UNSIGNED@, /* Period for which last authenticated greylist entry is valid for.
This effectively bypasses greylisting for the second email a sender
sends a recipient. */
GreylistUnAuthValidity @BIG_INTEGER@, /* Same as above but for unauthenticated entries */
GreylistUnAuthValidity @BIG_INTEGER_UNSIGNED@, /* Same as above but for unauthenticated entries */
/* Auto-whitelisting: sending server level */
UseAutoWhitelist SMALLINT, /* Use auto-whitelisting */
AutoWhitelistPeriod @BIG_INTEGER@, /* Period to look back to find authenticated triplets */
AutoWhitelistCount @BIG_INTEGER@, /* Count of authenticated triplets after which we auto-whitelist */
AutoWhitelistPercentage @BIG_INTEGER@, /* Percentage of at least Count triplets that must be authenticated
AutoWhitelistPeriod @BIG_INTEGER_UNSIGNED@, /* Period to look back to find authenticated triplets */
AutoWhitelistCount @BIG_INTEGER_UNSIGNED@, /* Count of authenticated triplets after which we auto-whitelist */
AutoWhitelistPercentage @BIG_INTEGER_UNSIGNED@, /* Percentage of at least Count triplets that must be authenticated
before auto-whitelisting. This changes the behaviour or Count */
/* Auto-blacklisting: sending server level */
UseAutoBlacklist SMALLINT, /* Use auto-blacklisting */
AutoBlacklistPeriod @BIG_INTEGER@, /* Period to look back to find unauthenticated triplets */
AutoBlacklistCount @BIG_INTEGER@, /* Count of authenticated triplets after which we auto-whitelist */
AutoBlacklistPercentage @BIG_INTEGER@, /* Percentage of at least Count triplets that must be authenticated
AutoBlacklistPeriod @BIG_INTEGER_UNSIGNED@, /* Period to look back to find unauthenticated triplets */
AutoBlacklistCount @BIG_INTEGER_UNSIGNED@, /* Count of authenticated triplets after which we auto-whitelist */
AutoBlacklistPercentage @BIG_INTEGER_UNSIGNED@, /* Percentage of at least Count triplets that must be authenticated
before auto-whitelisting. This changes the behaviour or Count */
Comment VARCHAR(1024),
......@@ -88,8 +88,8 @@ CREATE TABLE @PREFIX@greylisting_autowhitelist (
TrackKey VARCHAR(@TRACK_KEY_LEN@) NOT NULL,
Added @BIG_INTEGER@ NOT NULL,
LastSeen @BIG_INTEGER@ NOT NULL,
Added @BIG_INTEGER_UNSIGNED@ NOT NULL,
LastSeen @BIG_INTEGER_UNSIGNED@ NOT NULL,
Comment VARCHAR(1024),
......@@ -104,7 +104,7 @@ CREATE TABLE @PREFIX@greylisting_autoblacklist (
TrackKey VARCHAR(@TRACK_KEY_LEN@) NOT NULL,
Added @BIG_INTEGER@ NOT NULL,
Added @BIG_INTEGER_UNSIGNED@ NOT NULL,
Comment VARCHAR(1024),
......@@ -120,11 +120,11 @@ CREATE TABLE @PREFIX@greylisting_tracking (
Sender VARCHAR(255) NOT NULL,
Recipient VARCHAR(255) NOT NULL,
FirstSeen @BIG_INTEGER@ NOT NULL,
LastUpdate @BIG_INTEGER@ NOT NULL,
FirstSeen @BIG_INTEGER_UNSIGNED@ NOT NULL,
LastUpdate @BIG_INTEGER_UNSIGNED@ NOT NULL,
Tries @BIG_INTEGER@ NOT NULL, /* Authentication tries */
Count @BIG_INTEGER@ NOT NULL, /* Authenticated count */
Tries @BIG_INTEGER_UNSIGNED@ NOT NULL, /* Authentication tries */
Count @BIG_INTEGER_UNSIGNED@ NOT NULL, /* Authenticated count */
UNIQUE(TrackKey,Sender,Recipient)
) @CREATE_TABLE_SUFFIX@;
......
......@@ -35,7 +35,7 @@ CREATE TABLE @PREFIX@quotas (
*/
/* Period over which this policy is valid, this is in seconds */
Period @BIG_INTEGER@,
Period @BIG_INTEGER_UNSIGNED@,
Verdict VARCHAR(255),
Data TEXT,
......@@ -59,7 +59,7 @@ CREATE TABLE @PREFIX@quotas_limits (
QuotasID @SERIAL_REF_TYPE@,
Type VARCHAR(255), /* "MessageCount" or "MessageCumulativeSize" */
CounterLimit @BIG_INTEGER@,
CounterLimit @BIG_INTEGER_UNSIGNED@,
Comment VARCHAR(1024),
......@@ -79,7 +79,7 @@ CREATE TABLE @PREFIX@quotas_tracking (
TrackKey VARCHAR(@TRACK_KEY_LEN@),
/* Last time this record was update */
LastUpdate @BIG_INTEGER@, /* NULL means not updated yet */
LastUpdate @BIG_INTEGER_UNSIGNED@, /* NULL means not updated yet */
Counter NUMERIC(10,4),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment