__PACKAGE__->new_guid('NEWID()');
-sub _sql_server_2005_or_higher {
+sub __sql_server_x_or_higher {
+ my ($self, $version) = @_;
+
if (exists $_[0]->_server_info->{normalized_dbms_version}) {
- if ($_[0]->_server_info->{normalized_dbms_version} >= 9) {
+ if ($_[0]->_server_info->{normalized_dbms_version} >= $version) {
return 1
} else {
return 0
return undef;
}
+sub __offset_bindtype { +{ dbd_attrs => DBI::SQL_INTEGER() } }
+sub __rows_bindtype { +{ dbd_attrs => DBI::SQL_INTEGER() } }
+
+sub _sql_server_2005_or_higher { shift->__sql_server_x_or_higher(9) }
+sub _sql_server_2012_or_higher { shift->__sql_server_x_or_higher(11) }
+
sub _prep_for_execute {
my $self = shift;
my ($op, $ident, $args) = @_;
sub sql_limit_dialect {
my $self = shift;
+ my $supports_ofn = $self->_sql_server_2012_or_higher;
+
+ unless (defined $supports_ofn) {
+ # User is connecting via DBD::Sybase and has no permission to run
+ # stored procedures like xp_msver, or version detection failed for some
+ # other reason.
+ # So, we use a query to check if OFN is implemented.
+ try {
+ $self->_get_dbh->selectrow_array('SELECT 1 ORDER BY 1 OFFSET 0 ROWS');
+ $supports_ofn = 1;
+ };
+ }
+ return 'OffsetFetchNext' if $supports_ofn;
+
my $supports_rno = $self->_sql_server_2005_or_higher;
unless (defined $supports_rno) {
$supports_rno = 1;
};
}
+ return 'RowNumberOver' if $supports_rno;
- return $supports_rno ? 'RowNumberOver' : 'Top';
+ return 'Top';
}
sub _ping {