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

execute: set TableAsName and ColumnAsName for prepared statement #5776

Merged
merged 1 commit into from Feb 2, 2018

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Feb 2, 2018

This C++ code will panic in v1.0.7 because TiDB returns wrong column information for prepared statement.

#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>

int main() {
	sql::Driver* driver = get_driver_instance();
	sql::Connection *conn = driver->connect("127.0.0.1:4000", "root", "");
	conn->setSchema("test");
	conn->setClientOption("libmysql_debug", "d:t:0,client.trace");
	int on_off = 1;
	conn->setClientOption("clientTrace", &on_off);
	sql::PreparedStatement *stmt = conn->prepareStatement("select * from test limit ?");
	stmt->setInt(1, 2);
	stmt->execute();

	sql::ResultSet *res = stmt->executeQuery();
	std::cout << "00" << std::endl;
	while (res->next()) {
		std::cout << res->getInt64("a") << std::endl;
		std::cout << "22" << std::endl;
	}

	delete stmt;
	delete conn;
}

Set TableAsName and ColumnAsName for prepared statement will fix it.

PTAL @XuHuaiyu @coocood @shenli

@shenli
Copy link
Member

shenli commented Feb 2, 2018

LGTM

@shenli
Copy link
Member

shenli commented Feb 2, 2018

/run-all-tests

@shenli
Copy link
Member

shenli commented Feb 2, 2018

@XuHuaiyu @coocood PTAL

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Feb 2, 2018

/run-all-tests tidb-test=release-1.0 tikv=release-1.0 tidb-private-test=release-1.0

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coocood
Copy link
Member

coocood commented Feb 2, 2018

LGTM

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XuHuaiyu XuHuaiyu merged commit 2f8b1d2 into pingcap:release-1.0 Feb 2, 2018
@tiancaiamao tiancaiamao deleted the update-release branch April 24, 2018 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants