Skip to content

Commit

Permalink
sqlite doesn't have NOW() or INTERVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnewton committed Mar 19, 2014
1 parent d6263bd commit 22457ef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions raddb/mods-config/sql/ippool/sqlite/queries.conf
Expand Up @@ -20,15 +20,15 @@
SET nasipaddress = '', pool_key = 0, \
callingstationid = '', username = '', \
expiry_time = NULL \
WHERE expiry_time <= NOW() - INTERVAL 1 SECOND \
WHERE expiry_time <= datetime(strftime('%%s', 'now') - 1, 'unixepoch') \
AND nasipaddress = '%{Nas-IP-Address}'"



## The ORDER BY clause of this query tries to allocate the same IP-address
## which user had last session...
allocate_find = "SELECT framedipaddress FROM ${ippool_table} \
WHERE pool_name = '%{control:Pool-Name}' AND (expiry_time < NOW() OR expiry_time IS NULL) \
WHERE pool_name = '%{control:Pool-Name}' AND (expiry_time < datetime('now') OR expiry_time IS NULL) \
ORDER BY (username <> '%{User-Name}'), \
(callingstationid <> '%{Calling-Station-Id}'), \
expiry_time \
Expand Down Expand Up @@ -58,15 +58,15 @@ pool_check = "SELECT id FROM ${ippool_table} \
allocate_update = "UPDATE ${ippool_table} \
SET nasipaddress = '%{NAS-IP-Address}', pool_key = '${pool_key}', \
callingstationid = '%{Calling-Station-Id}', username = '%{User-Name}', \
expiry_time = NOW() + INTERVAL ${lease_duration} SECOND \
expiry_time = datetime(strftime('%%s', 'now') + ${lease_duration}, 'unixepoch') \
WHERE framedipaddress = '%I' AND expiry_time IS NULL"



## This series of queries frees an IP number when an accounting
## START record arrives
start_update = "UPDATE ${ippool_table} \
SET expiry_time = NOW() + INTERVAL ${lease_duration} SECOND \
SET expiry_time = datetime(strftime('%%s', 'now') + ${lease_duration}, 'unixepoch') \
WHERE nasipaddress = '%{NAS-IP-Address}' AND pool_key = '${pool_key}' \
AND username = '%{User-Name}' \
AND callingstationid = '%{Calling-Station-Id}' \
Expand All @@ -87,7 +87,7 @@ stop_clear = "UPDATE ${ippool_table} \
## This series of queries frees an IP number when an accounting
## ALIVE record arrives
alive_update = "UPDATE ${ippool_table} \
SET expiry_time = NOW() + INTERVAL ${lease_duration} SECOND \
SET expiry_time = datetime(strftime('%%s', 'now') + ${lease_duration}, 'unixepoch') \
WHERE nasipaddress = '%{Nas-IP-Address}' AND pool_key = '${pool_key}' \
AND username = '%{User-Name}' \
AND callingstationid = '%{Calling-Station-Id}' \
Expand Down

0 comments on commit 22457ef

Please sign in to comment.