#949 replace now() with LOCALTIMESTAMP and cast to_timestamp() as ::timestamp

This commit is contained in:
Oliver Gorwits
2023-03-03 14:08:10 +00:00
parent de1ec0dc67
commit 29402f0726
7 changed files with 17 additions and 17 deletions

View File

@@ -29,7 +29,7 @@ register_worker({ phase => 'early',
# select and do something with the updated set (see set archive, below)
vars->{'timestamp'} = ($job->is_offline and $job->entered)
? (schema('netdisco')->storage->dbh->quote($job->entered) .'::timestamp')
: 'to_timestamp('. (join '.', gettimeofday) .')';
: 'to_timestamp('. (join '.', gettimeofday) .')::timestamp';
# initialise the cache
vars->{'arps'} ||= [];

View File

@@ -21,7 +21,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my @subnets = gather_subnets($device);
# TODO: IPv6 subnets
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
my $now = 'to_timestamp('. (join '.', gettimeofday) .')::timestamp';
store_subnet($_, $now) for @subnets;
return Status->info(sprintf ' [%s] arpnip - processed %s Subnet entries',

View File

@@ -30,7 +30,7 @@ register_worker({ phase => 'early',
# select and do something with the updated set (see set archive, below)
vars->{'timestamp'} = ($job->is_offline and $job->entered)
? (schema('netdisco')->storage->dbh->quote($job->entered) .'::timestamp')
: 'to_timestamp('. (join '.', gettimeofday) .')';
: 'to_timestamp('. (join '.', gettimeofday) .')::timestamp';
# initialise the cache
vars->{'fwtable'} ||= {};
@@ -225,13 +225,13 @@ All four fields in the tuple are required. If you don't know the VLAN ID,
Netdisco supports using ID "0".
Optionally, a fifth argument can be the literal string passed to the time_last
field of the database record. If not provided, it defaults to C<now()>.
field of the database record. If not provided, it defaults to C<LOCALTIMESTAMP>.
=cut
sub store_node {
my ($ip, $vlan, $port, $mac, $now) = @_;
$now ||= 'now()';
$now ||= 'LOCALTIMESTAMP';
$vlan ||= 0;
schema('netdisco')->txn_do(sub {

View File

@@ -15,7 +15,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return Status->defer("macsuck failed: could not SNMP connect to $device");
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
my $now = 'to_timestamp('. (join '.', gettimeofday) .')::timestamp';
my $cd11_txrate = $snmp->cd11_txrate;
return unless $cd11_txrate and scalar keys %$cd11_txrate;

View File

@@ -19,7 +19,7 @@ register_worker({ phase => 'main' }, sub {
-bool => 'me.active',
-bool => 'nodes.active',
'nodes.switch' => $host,
'me.time_last' => \[ '>= now() - ?::interval', $interval ],
'me.time_last' => \[ '>= LOCALTIMESTAMP - ?::interval', $interval ],
},{
join => 'nodes',
columns => 'ip',
@@ -32,7 +32,7 @@ register_worker({ phase => 'main' }, sub {
# Unless we have IPs don't bother
if (scalar @ips) {
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
my $now = 'to_timestamp('. (join '.', gettimeofday) .')::timestamp';
my $resolved_nodes = nbtstat_resolve_async(\@ips);
# update node_nbt with status entries