Skip to content

Commit

Permalink
more constants for client version (major/minor/full version string)
Browse files Browse the repository at this point in the history
  • Loading branch information
real-dam committed Nov 24, 2017
1 parent 0280594 commit 6ef7464
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
15 changes: 13 additions & 2 deletions Firebird.xs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,26 @@ short length, char ISC_FAR *updated

MODULE = DBD::Firebird PACKAGE = DBD::Firebird

INCLUDE: Firebird.xsi

#ifndef FB_API_VER
#define FB_API_VER 0
#endif

BOOT:
HV *stash = gv_stashpv( "DBD::Firebird", TRUE );
newCONSTSUB( stash, "fb_api_ver", newSViv(FB_API_VER) );
newCONSTSUB( stash, "client_major_version", newSViv( isc_get_client_major_version() ) );
newCONSTSUB( stash, "client_minor_version", newSViv( isc_get_client_minor_version() ) );
{
char version_string[1024];
isc_get_client_version(version_string);
int len = strlen(version_string);
if (len > 1023)
die("Version string buffer overflow detected");
SV *ver = newSVpv(version_string, len);
newCONSTSUB( stash, "client_version", ver );
}

INCLUDE: Firebird.xsi

MODULE = DBD::Firebird PACKAGE = DBD::Firebird::db

Expand Down
6 changes: 1 addition & 5 deletions t/00-base.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {
$^W = 1;
}

use Test::More tests => 8;
use Test::More tests => 7;

use_ok('DBI');

Expand All @@ -22,8 +22,4 @@ use_ok('DBD::Firebird::TableInfo::Basic');
use_ok('DBD::Firebird::TableInfo::Firebird21');
use_ok('DBD::Firebird::TypeInfo');

can_ok( 'DBD::Firebird' => 'fb_api_ver' );

diag( "Firebird API version is " . DBD::Firebird->fb_api_ver );

# diag("\$DBI::VERSION=$DBI::VERSION");
28 changes: 28 additions & 0 deletions t/001-client-version.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Test that everything compiles, so the rest of the test suite can
# load modules without having to check if it worked.
#
# 2011-01-29 stefan(s.bv.)
# Stolen from DBD::SQLite ;)
#

use strict;
BEGIN {
$| = 1;
$^W = 1;
}

use Test::More tests => 4;

use DBD::Firebird;

can_ok( 'DBD::Firebird' => 'fb_api_ver' );
can_ok( 'DBD::Firebird' => 'client_major_version' );
can_ok( 'DBD::Firebird' => 'client_minor_version' );
can_ok( 'DBD::Firebird' => 'client_version' );

note( "Firebird API version is " . DBD::Firebird->fb_api_ver );
note( "Firebird client major version is " . DBD::Firebird->client_major_version );
note( "Firebird client minor version is " . DBD::Firebird->client_minor_version );
note( "Firebird client version is " . DBD::Firebird->client_version );

# diag("\$DBI::VERSION=$DBI::VERSION");

0 comments on commit 6ef7464

Please sign in to comment.