Prepared Statement failing for SELECT COUNT(*) AS test1_count FROM default

Description

SELECT COUNT AS test1_count FROM default

Lead to the following error

Caused by: java.sql.SQLException: Unable to decode prepared statement - cause: Unrecognizable prepared statement - cause: unable to convert to prepared statment.

Test case

@Test
public void testExecuteQuery() throws Exception
{
try (PreparedStatement preparedStatement = con.prepareStatement("INSERT INTO default (KEY, VALUE) VALUES ( ?, ?)"))
{
assertNotNull(preparedStatement);

for (int i = 0; i++< 100
{
preparedStatement.setString(1, "K"+i);
preparedStatement.setInt(2,i);

int inserted = preparedStatement.executeUpdate();
assertEquals(1, inserted);
}

}

try( PreparedStatement preparedStatement = con.prepareStatement("SELECT COUNT AS test1_count FROM default")) <------ FAILS HERE
{
assertNotNull(preparedStatement);
ResultSet rs = preparedStatement.executeQuery();
assertTrue(rs.next());
assertEquals( 100, rs.getInt(1) );
}

try ( PreparedStatement preparedStatement = con.prepareStatement( "SELECT default FROM default WHERE default >= ? order by default"))
{
assertNotNull(preparedStatement);
preparedStatement.setInt(1,50);
ResultSet rs = preparedStatement.executeQuery();
for (int i=0; i< 50;i++)
{
assertTrue(rs.next());
assertEquals(50+i, rs.getInt(1));
}

}

}

mvn test -Dtest=com.couchbase.PreparedStatementTest#testExecuteQuery

Components

Affects versions

Fix versions

Labels

Environment

dev

Link to Log File, atop/blg, CBCollectInfo, Core dump

None

Release Notes Description

None

blocks

Activity

Johan Larson December 4, 2015 at 1:40 PM

This has been fixed as part of other work on prepared statements. As of build 5523, the problem is gone.

Johan Larson December 2, 2015 at 6:05 PM

This problem is fixed as of build 5523. It was running into the problem with prepared statements that folks have been working on for a week, now.

The test also needs a brief delay (1 sec is plenty) after the creation of the test data, before the queries, presumably so the indexer can catch up with the newly created objects.

Don Pinto [X] November 4, 2015 at 3:13 PM

Hi Keshav,

Is there a workaround for this in beta? (maybe not using the query_drivers component ?)

Thanks,

Prerna Manaktala November 2, 2015 at 7:36 AM

I am getting the same error with:
4.1.0-4878 Enterprise Edition (build-4878)
I just changed the environment.properties and config.json to execute the specific test against the install.
mvn test -Dtest=com.couchbase.PreparedStatementTest#testExecuteQuery

config.json
{"node_info":[{"isMasterNode":"true","membasePassword":"password","n1qlPort":8093,"membaseUserId":"Administrator","port":8091,"machineUserId":"root","ip":"localhost","services":["kv","n1ql","index"],"machinePassword":"couchbase","indexPort":9102},{"isMasterNode":"false","membasePassword":"password","n1qlPort":8093,"membaseUserId":"Administrator","port":8091,"machineUserId":"root","ip":"localhost","services":["kv","n1ql","index"],"machinePassword":"couchbase","indexPort":9102}],
"bucket_info":[{"proxyPort":21000,"name":"default","replicaNumber":0,"ramQuotaMB":1000,"authType":"none"}],"global":{"membasePassword":"password","n1qlPort":8093,"membaseUserId":"Administrator","port":8091,"machineUserId":"root","ip":"localhost","services":["kv","n1ql","index"],"machinePassword":"couchbase","indexPort":9102}}

environment.properties
couchbasedb.test.url=jdbc:couchbase://172.23.107.56:8093
couchbasedb.test.sslurl=jdbc:couchbase://172.23.107.56:18093
couchbasedb.test.auth=product:Pr0dct,purchases:Prch3s3s
couchbasedb.test.config=config.json
couchbasedb.test.rqg_config=rqg_config.properties

Parag Agarwal October 21, 2015 at 3:00 AM

I am running watson, you are running sherlock. That might be the difference. Let me try with sherlock. So this might qualify as server bug

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Is this a Regression?

Yes

Triage

Untriaged

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created October 21, 2015 at 1:13 AM
Updated March 4, 2016 at 8:09 PM
Resolved December 4, 2015 at 1:40 PM
Instabug