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

insert timestamp failure with 0000-00-00 00:00:00.000000 in prepare statement #7501

Closed
lysu opened this issue Aug 27, 2018 · 0 comments · Fixed by #7506
Closed

insert timestamp failure with 0000-00-00 00:00:00.000000 in prepare statement #7501

lysu opened this issue Aug 27, 2018 · 0 comments · Fixed by #7506
Assignees
Labels
type/bug The issue is confirmed as a bug. type/compatibility

Comments

@lysu
Copy link
Contributor

lysu commented Aug 27, 2018

  1. What did you do?
    CREATE TABLE timestamp_insert ( id INT NOT NULL PRIMARY KEY, tstamp TIMESTAMP NOT NULL )

then prepare and exec a insert 0000-00-00 00:00:00.000000 into tstamp

    stmt= const_cast<char *>("INSERT INTO timestamp_insert ( id, tstamp ) VALUES ( ?, ? )");
    if(mysql_stmt_prepare(mysql_stmt, stmt, strlen(stmt)))
    {
        my_chk_stmt(&mysql, mysql_stmt, __LINE__);
    }

    memset(mysql_bind_param, 0, sizeof(mysql_bind_param));
    mysql_bind_param[0].buffer_type= MYSQL_TYPE_LONG;
    mysql_bind_param[0].buffer= (char*)&id;
    mysql_bind_param[0].is_null= 0;
    mysql_bind_param[0].length= 0;
    mysql_bind_param[1].buffer_type= MYSQL_TYPE_TIMESTAMP;
    mysql_bind_param[1].buffer= &tstamp;
    mysql_bind_param[1].is_null= 0;
    mysql_bind_param[1].length= 0;
    if(mysql_stmt_bind_param(mysql_stmt, mysql_bind_param))
    {
        my_chk_stmt(&mysql, mysql_stmt, __LINE__);
    }

    id= 2;
    tstamp.year= 0;
    tstamp.month= 0;
    tstamp.day= 0;
    tstamp.hour= 0;
    tstamp.minute= 0;
    tstamp.second= 0;
    tstamp.second_part= 0;

    if(mysql_stmt_execute(mysql_stmt))
    {
        my_chk_stmt(&mysql, mysql_stmt, __LINE__);
    }
  1. What did you expect to see?
success
  1. What did you see instead?
1292 : invalid time format: '0'
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
2.1.0.rc1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant