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

Projects
None yet
4 participants
@tiancaiamao
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Feb 2, 2018

LGTM

@shenli

This comment has been minimized.

Copy link
Member

commented Feb 2, 2018

/run-all-tests

@shenli

This comment has been minimized.

Copy link
Member

commented Feb 2, 2018

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor

commented Feb 2, 2018

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

@XuHuaiyu
Copy link
Contributor

left a comment

LGTM

@coocood

This comment has been minimized.

Copy link
Member

commented Feb 2, 2018

LGTM

@XuHuaiyu
Copy link
Contributor

left a comment

LGTM

@XuHuaiyu XuHuaiyu merged commit 2f8b1d2 into pingcap:release-1.0 Feb 2, 2018

12 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on release-1.0 at 72.48%
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
jenkins-ci-tidb/common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
jenkins-ci-tidb/mybatis-test Jenkins job succeeded.
Details
jenkins-ci-tidb/sqllogic-test Jenkins job succeeded.
Details
jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@tiancaiamao tiancaiamao deleted the tiancaiamao:update-release branch Apr 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.