Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapi.pm and GetInfo.pm syntax fixes for array usage #2884

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Mapi.pm and GetInfo.pm syntax fixes for array usage #2884

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2011-09-16 19:43:21 +0200
From: Rémy Chibois <>
To: clients devs <>
Version: 11.5.1 (Aug2011) [obsolete]

Last updated: 2011-09-30 10:58:44 +0200

Comment 16289

Date: 2011-09-16 19:43:21 +0200
From: Rémy Chibois <>

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3
Build Identifier:

Using those two modules, a lot of warnings about incorrect syntax pop up.
Also, GetInfo.pm uses an incorrect number of arguments while trying to sprintf a version string.

Please find below a patch trying to solve these problems:

===================
diff -Nur -x '.am' -x '.in' -x '*.msc' -x README -x 'Tests' perl/DBD/monetdb/GetInfo.pm perl-patches/DBD/monetdb/GetInfo.pm
--- perl/DBD/monetdb/GetInfo.pm 2011-09-01 15:11:32.000000000 +0200
+++ perl-patches/DBD/monetdb/GetInfo.pm 2011-09-16 19:13:16.000000000 +0200
@@ -22,7 +22,7 @@

my $sql_driver = 'monetdb';
my $sql_ver_fmt = '%02d.%02d.%04d'; ODBC version string: ..
-my $sql_driver_ver = sprintf $sql_ver_fmt, split(/./, $DBD::monetdb::VERSION);
+my $sql_driver_ver = sprintf $sql_ver_fmt, split(/./, $DBD::monetdb::VERSION), 0;

my @Keywords = qw(
BOOLEAN
diff -Nur -x '.am' -x '.in' -x '*.msc' -x README -x 'Tests' perl/Mapi.pm perl-patches/Mapi.pm
--- perl/Mapi.pm 2011-09-01 15:11:33.000000000 +0200
+++ perl-patches/Mapi.pm 2011-09-16 19:14:16.000000000 +0200
@@ -25,8 +25,8 @@

sub pass_chal {
my ($passwd, @Challenge) = @_;

  • if ($challenge[2] == 9) {
  • my $pwhash = $challenge[5];
    if ($pwhash eq 'SHA512') {
    $passwd = sha512_hex($passwd);
    } elsif ($pwhash eq 'SHA256') {
    @@ -39,33 +39,33 @@
    warn "unsupported password hash: ".$pwhash;
    return;
    }
  • } elsif ($challenge[2] == 8) {
    can leave passwd cleartext
    } else {
  • warn "unsupported protocol version: ".@Challenge[2];
  • warn "unsupported protocol version: ".$challenge[2];
    return;
    }
  • my @cyphers = split(/,/, $challenge[3]);
    my $chal;
    foreach (@cyphers) {
    if ($_ eq 'SHA512') {
  •  $chal = "{$_}".sha512_hex($passwd.@challenge[0]);
    
  •  $chal = "{$_}".sha512_hex($passwd.$challenge[0]);
     last;
    
    } elsif ($_ eq 'SHA256') {
  •  $chal = "{$_}".sha256_hex($passwd.@challenge[0]);
    
  •  $chal = "{$_}".sha256_hex($passwd.$challenge[0]);
     last;
    
    } elsif ($_ eq 'SHA1') {
  •  $chal = "{$_}".sha1_hex($passwd.@challenge[0]);
    
  •  $chal = "{$_}".sha1_hex($passwd.$challenge[0]);
     last;
    
    } elsif ($_ eq 'MD5') {
  •  $chal = "{$_}".md5_hex($passwd.@challenge[0]);
    
  •  $chal = "{$_}".md5_hex($passwd.$challenge[0]);
     last;
    
    }
    }
    if (!$chal) {
    we assume v8's "plain"
  • $chal = "{plain}".$passwd.$challenge[0];
    }
return $chal;

@@ -118,7 +118,7 @@
$self->{socket}->close;
print "Following redirect: $prompt\n" if ($self->{trace});
my @tokens = split(/[\n/:?]+/, $prompt); dirty, but it's Perl anyway

  • return new Mapi($tokens[3], $tokens[4], $user, $passwd, $lang, $tokens[5], $trace);
    } elsif ($prompt =~ /^^mapi:merovingian://proxy/) {
    proxied redirect
    do {
    @@ -240,7 +240,7 @@
    my $row = $self->{lines}[$self->{next}++];
    my @chars = split(//, $row);
  • if ($chars[0] eq '!') {
    $self->error($row);
    my $i = 1;
    while ($self->{lines}[$i] =~ '!') {
    @@ -249,11 +249,11 @@
    }
    $self->{active} = 0;
    return -1
  • } elsif (@chars[0] eq '&') {
  • } elsif ($chars[0] eq '&') {
    not expected
  • } elsif (@chars[0] eq '%') {
  • } elsif ($chars[0] eq '%') {
    header line
  • } elsif (@chars[0] eq '[') {
  • } elsif ($chars[0] eq '[') {
    row result
    $self->{row} = $row;
    if ($self->{nrcols} < 0) {
    @@ -261,13 +261,13 @@
    $self->{nrcols}++;
    }
    $self->{active} = 1;
  • } elsif (@chars[0] eq '=') {
  • } elsif ($chars[0] eq '=') {
    xml result line
    $self->{row} = substr($row, 1); skip =
    $self->{active} = 1;
  • } elsif (@chars[0] eq '^') {
  • } elsif ($chars[0] eq '^') {
    ^ redirect, ie use different server
  • } elsif ($chars[0] eq '') {
    warnings etc, skip, and return what follows
    return $self->getRow;
    }
    @@ -293,9 +293,9 @@
    $self->{offset} = 0;
    $self->{hdrs} = [];
  • if (@chars[0] eq '&') {
  • if (@chars[1] eq '1' || @chars[1] eq 6) {
  •  if (@chars[1] eq '1') {
    
  • if ($chars[0] eq '&') {
  • if ($chars[1] eq '1' || $chars[1] eq 6) {
  •  if ($chars[1] eq '1') {
        &1 id result-count nr-cols rows-in-this-block
       my ($dummy,$id,$cnt,$nrcols,$replysize) = split(' ', $header);
       $self->{id} = $id;
    

@@ -321,7 +321,7 @@
$self->{row} = $self->{lines}[$self->{next}++];

    $self->{active} = 1;
  • } elsif (@chars[1] eq '2') { updates
  • } elsif ($chars[1] eq '2') { updates
    my ($dummy,$cnt) = split(' ', $header);
    $self->{count} = $cnt;
    $self->{nrcols} = 1;
    @@ -329,16 +329,16 @@
    $self->{row} = "" . $cnt;
    $self->{next} = $cnt; all done
    return -2;
  • } elsif (@chars[1] eq '3') { transaction
  • } elsif ($chars[1] eq '3') { transaction
    nothing todo
  • } elsif (@chars[1] eq '4') { auto_commit
  • } elsif ($chars[1] eq '4') { auto_commit
    my ($dummy,$ac) = split(' ', $header);
    if ($ac eq 't') {
    $self->{auto_commit} = 1;
    } else {
    $self->{auto_commit} = 0;
    }
  • } elsif (@chars[1] eq '5') { prepare
  • } elsif ($chars[1] eq '5') { prepare
    my ($dummy,$id,$cnt,$nrcols,$replysize) = split(' ', $header);
    TODO parse result, rows (type, digits, scale)
    $self->{count} = $cnt;
    ===================

Reproducible: Always

Steps to Reproduce:

  1. Connect to database using DBI (e.g.: code from "perldoc DBD::monetdb")
  2. Issue a: $dbh->table_info('', '%', '%');

Comment 16290

Date: 2011-09-16 19:45:17 +0200
From: Rémy Chibois <>

(my apologies for the inline patch)

Comment 16293

Date: 2011-09-17 11:09:26 +0200
From: Rémy Chibois <>

Created attachment 75
Proposed patch to fix syntax and sprintf warnings

Added patch as attachment

Attached file: MonetDB-11.5.1-MonetDB-CLI.patch (text/plain, 5411 bytes)
Description: Proposed patch to fix syntax and sprintf warnings

Comment 16296

Date: 2011-09-19 10:27:37 +0200
From: @sjoerdmullender

Changeset 4c0e28fea94d made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=4c0e28fea94d

Changeset description:

Perl: Fixed a bunch of syntax errors.
This fixes bug #2884.  With thanks to Rémy Chibois.

Comment 16302

Date: 2011-09-19 16:37:50 +0200
From: @sjoerdmullender

The test for bug #2885 is also a test for this bug.

Comment 16351

Date: 2011-09-30 10:58:44 +0200
From: @grobian

Released in Aug2011-SP1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant