Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5728

BINLOG_GTID_POS(..) does not return proper error unless mysql_store_result is called

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.8
    • 10.0.9
    • None

    Description

      When I use BINLOG_GTID_POS(..) on a server where binary log is not enabled, I expect it to return ER_NO_BINARY_LOGGING. It does so lets say in MySQL client, but with some API variants it does not.

      C API:

      #include <my_global.h>
      #include <mysql.h>
       
      int main(int argc, char **argv)
      {  
      	MYSQL con;
      	mysql_init(&con);
       
      	if (mysql_real_connect(&con, "127.0.0.1", "root", "", 
      		"test", 3306, NULL, 0) == NULL) 
      	{
      		fprintf(stderr, "ERROR: %s\n", mysql_error(&con));
      		exit(1);
      	}
       
      	mysql_query(&con,"select binlog_gtid_pos('a',1)");
      	// If I call mysql_store_result(&con) here, everything works.
      	// If I call mysql_use_result(&con) or nothing at all, there is no error
      	fprintf(stderr,"Here should be an error: %s\n",mysql_error(&con));
      	
      	mysql_close(&con);
      }

      Perl:

      use DBD::mysql;
      use strict;
       
      my $dsn = "dbi:mysql:host=127.0.0.1:port=3306:user=root:database=test";
      my $dbh = DBI->connect($dsn);
       
      unless (defined $dbh) {
      	print STDERR "Could not connect to $dsn\n";
      	exit(1);
      }
       
      my $sth = $dbh->prepare("SELECT binlog_gtid_pos('a',1)");
      # If I set mysql_store_result here, or nothing at all, everything works.
      # If I set mysql_use_result, it does not
      $sth->{'mysql_use_result'}=1;
      unless (defined $sth) {
      	print STDERR $dbh->errstr(), "\n";
      	exit(1);
      }
       
      $sth->execute();
      print "Here should be an error: ", $sth->errstr(), "\n";
      $sth->finish();
      $dbh->disconnect();

      In both cases output is

      Here should be an error: 

      Current tree:

      revision-id: monty@askmonty.org-20140222011156-i1pa6zm2iltb4usv
      revno: 4007
      branch-nick: 10.0

      Attachments

        Activity

          Pushed to 10.0

          The reason for this behaviour was that the error was thrown only during
          execution of the statement, not during parsing. I added a check for binlog
          open at the parsing stage, so now the error is thrown early.

          The problem could be reproduced also in the mysql command line client with
          something like PREPARE s FROM 'SELECT binlog_gtid_pos("", 0)'

          The reason the examples did not get the error at runtime is that they did not
          complete the processing. The error should have be seen if doing something like
          mysql_fetch_row() or $sth->fetchrow_array().

          knielsen Kristian Nielsen added a comment - Pushed to 10.0 The reason for this behaviour was that the error was thrown only during execution of the statement, not during parsing. I added a check for binlog open at the parsing stage, so now the error is thrown early. The problem could be reproduced also in the mysql command line client with something like PREPARE s FROM 'SELECT binlog_gtid_pos("", 0)' The reason the examples did not get the error at runtime is that they did not complete the processing. The error should have be seen if doing something like mysql_fetch_row() or $sth->fetchrow_array().

          People

            knielsen Kristian Nielsen
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.