DB-Handy
view release on metacpan or search on metacpan
lib/DB/Handy.pm view on Meta::CPAN
$err = $! if $ok;
close FH if $ok;
return $self->_err("Cannot rewrite schema: $err");
}
return 1;
}
# Does $v look like a number that Perl can use in arithmetic without
# complaining under -w? Leading and trailing whitespace is allowed, an
# optional sign, a decimal part and an exponent; everything else -- the
# empty string, 'abc', '12abc', '0x10', 'Inf', 'NaN' -- is not numeric.
#
# The same test used to be written out three times (index key encoding,
# type validation and record packing) and the FLOAT paths had no test at
# all, which is how "isn't numeric" warnings escaped from inside this
# module. Keep it in one place so the three callers cannot drift apart.
sub _looks_numeric {
my($v) = @_;
return 0 unless defined $v;
return $v =~ /^\s*[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?\s*$/ ? 1 : 0;
}
lib/DB/Handy.pm view on Meta::CPAN
=item B<FLOAT>
An 8-byte IEEE 754 double. Stored size on disk: 8 bytes.
Index keys use an order-preserving encoding so that the binary sort
order of the index matches numeric order. The C<.dat> file itself holds
the machine's native double -- see L</"BUGS AND LIMITATIONS"> for what
that means when a data file is copied between machines.
A value that is not numeric at all is stored as C<0> and is not an
error, the same rule C<INT> follows. C<'abc'>, C<'12abc'>, C<'0x10'>,
C<'Inf'> and C<'NaN'> are all stored as C<0>; only a leading sign, digits,
a decimal point and an exponent are read as a number. Up to 1.08 this
column type had no such test and passed the value straight to C<pack>,
so a non-numeric value emitted an C<isn't numeric> warning from inside
DB::Handy -- twice per row when the column was indexed -- regardless of
the caller's warning settings.
=item B<CHAR(n)>
A fixed-length string of exactly C<n> bytes. Values shorter than C<n> are
NUL-padded on write; trailing NULs are stripped on read.
( run in 1.552 second using v1.01-cache-2.11-cpan-60884a8df76 )