-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4049 from esl/feature-cets-rdbms-disco-cleaning-u…
…se-db-time Cleaning logic for discovery_nodes table - using database timestamp
- Loading branch information
Showing
8 changed files
with
164 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-module(mongoose_rdbms_timestamp). | ||
-export([prepare/0, | ||
select/0]). | ||
|
||
-spec prepare() -> ok. | ||
prepare() -> | ||
mongoose_rdbms:prepare(mim_timestamp, users, [], select_query()), | ||
ok. | ||
|
||
select_query() -> | ||
case {mongoose_rdbms:db_engine(global), mongoose_rdbms:db_type()} of | ||
{mysql, _} -> | ||
<<"SELECT UNIX_TIMESTAMP()">>; | ||
{pgsql, _} -> | ||
<<"SELECT ROUND(extract(epoch from now()))">>; | ||
{odbc, mssql} -> | ||
<<"SELECT DATEDIFF_BIG(second, '1970-01-01 00:00:00', GETUTCDATE())">>; | ||
Other -> | ||
error({prepare_timestamp_query_failed, Other}) | ||
end. | ||
|
||
-spec select() -> integer(). | ||
select() -> | ||
Res = mongoose_rdbms:execute_successfully(global, mim_timestamp, []), | ||
mongoose_rdbms:selected_to_integer(Res). %% ensure it is an integer |