Permalink
Browse files

Remove rowset iterators

  • Loading branch information...
1 parent 9ac21d4 commit f5361b2020edaee8a6fda0153833fdfa4253e696 Mikko Koppanen committed Sep 13, 2011
Showing with 14 additions and 155 deletions.
  1. +3 −0 ChangeLog
  2. +0 −2 cassandra_driver.cpp
  3. +7 −79 cassandra_statement.cpp
  4. +4 −7 package.xml
  5. +0 −2 php_pdo_cassandra_int.hpp
  6. +0 −65 tests/027-rowsetiterator.phpt
View
3 ChangeLog
@@ -1,3 +1,6 @@
+0.2.1
+- Removed rowset iterators
+
0.2.0
- Switched to Cassandra 1.x branch and dropped support for 0.8.x.
- Fixed tests to new Cassandra types
View
2 cassandra_driver.cpp
@@ -314,7 +314,6 @@ static int pdo_cassandra_handle_prepare(pdo_dbh_t *dbh, const char *sql, long sq
/* transfer handle with the statement */
S->H = H;
S->result.reset ();
- S->rowset_iterator = 0;
/* Fill in necessary driver data */
stmt->driver_data = S;
@@ -635,7 +634,6 @@ PHP_MINIT_FUNCTION(pdo_cassandra)
PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_COMPRESSION", PDO_CASSANDRA_ATTR_COMPRESSION);
PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_THRIFT_DEBUG", PDO_CASSANDRA_ATTR_THRIFT_DEBUG);
PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_PRESERVE_VALUES", PDO_CASSANDRA_ATTR_PRESERVE_VALUES);
- PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_ROWSET_ITERATOR", PDO_CASSANDRA_ATTR_ROWSET_ITERATOR);
#undef PHP_PDO_CASSANDRA_REGISTER_CONST_LONG
View
86 cassandra_statement.cpp
@@ -133,7 +133,6 @@ static int pdo_cassandra_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
static zend_bool pdo_cassandra_add_column(pdo_stmt_t *stmt, const std::string &name, int order)
{
pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
- pdo_cassandra_db_handle *H = static_cast <pdo_cassandra_db_handle *>(S->H);
try {
S->original_column_names.left.at(name);
@@ -177,29 +176,19 @@ static int pdo_cassandra_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation
// Set column names and labels if we don't have them already
if (!S->original_column_names.size()) {
- if (S->rowset_iterator) {
- for (std::vector<Column>::iterator col_it = (*S->it).columns.begin(); col_it < (*S->it).columns.end(); col_it++) {
+ // Get unique column names
+ for (std::vector<CqlRow>::iterator it = S->result.get()->rows.begin(); it < S->result.get()->rows.end(); it++) {
+ for (std::vector<Column>::iterator col_it = (*it).columns.begin(); col_it < (*it).columns.end(); col_it++) {
if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
order++;
}
}
- } else {
- // Get unique column names
- for (std::vector<CqlRow>::iterator it = S->result.get()->rows.begin(); it < S->result.get()->rows.end(); it++) {
- for (std::vector<Column>::iterator col_it = (*it).columns.begin(); col_it < (*it).columns.end(); col_it++) {
- if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
- order++;
- }
- }
- }
}
stmt->column_count = order;
}
stmt->column_count = S->original_column_names.size();
} else {
- if (!S->rowset_iterator) {
- S->it++;
- }
+ S->it++;
}
if (S->it == S->result.get()->rows.end()) {
@@ -462,78 +451,17 @@ static int pdo_cassandra_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
}
/* }}} */
-int pdo_cassandra_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
-{
- pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
-
- if (!S->rowset_iterator) {
- pdo_cassandra_error_exception(stmt->dbh, PDO_CASSANDRA_GENERAL_ERROR, "PDO::nextRowset can only be used with rowset iterator", "");
- return 0;
- }
-
- S->it++;
-
- S->original_column_names.clear();
- S->column_name_labels.clear();
-
- if (S->it == S->result.get()->rows.end()) {
- S->has_iterator = 0;
- return 0;
- }
-
- int order = 0;
- for (std::vector<Column>::iterator col_it = (*S->it).columns.begin(); col_it < (*S->it).columns.end(); col_it++) {
- if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
- order++;
- }
- }
- stmt->column_count = order;
- return 1;
-}
-
-static int pdo_cassandra_stmt_set_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
-{
- pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
- pdo_cassandra_constant attribute = static_cast <pdo_cassandra_constant>(attr);
-
-
- if (attribute == PDO_CASSANDRA_ATTR_ROWSET_ITERATOR) {
- convert_to_boolean(val);
-
- if (Z_BVAL_P(val) && stmt->executed) {
- pdo_cassandra_error_exception(stmt->dbh, PDO_CASSANDRA_GENERAL_ERROR, "Rowset iterator attribute must be set before executing the statement", "");
- return 0;
- }
-
- S->rowset_iterator = Z_BVAL_P(val);
- return 1;
- }
- return 0;
-}
-
-static int pdo_cassandra_stmt_get_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
-{
- pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
- pdo_cassandra_constant attribute = static_cast <pdo_cassandra_constant>(attr);
-
- if (attribute == PDO_CASSANDRA_ATTR_ROWSET_ITERATOR) {
- ZVAL_BOOL(val, S->rowset_iterator);
- return 1;
- }
- return 0;
-}
-
struct pdo_stmt_methods cassandra_stmt_methods = {
pdo_cassandra_stmt_dtor,
pdo_cassandra_stmt_execute,
pdo_cassandra_stmt_fetch,
pdo_cassandra_stmt_describe,
pdo_cassandra_stmt_get_column,
NULL, /* param_hook */
- pdo_cassandra_stmt_set_attr, /* set_attr */
- pdo_cassandra_stmt_get_attr, /* get_attr */
+ NULL, /* set_attr */
+ NULL, /* get_attr */
pdo_cassandra_stmt_get_column_meta,
- pdo_cassandra_stmt_next_rowset,
+ NULL, /* next rowset */
pdo_cassandra_stmt_cursor_close
};
View
11 package.xml
@@ -13,18 +13,16 @@
<date>2011-09-13</date>
<time>12:00:00</time>
<version>
- <release>0.2.0</release>
- <api>0.2.0</api>
+ <release>0.2.1</release>
+ <api>0.2.1</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
- <license>PHP License</license>
+ <license>Apache License</license>
<notes>
-- Switched to Cassandra 1.x branch and dropped support for 0.8.x.
-- Fixed tests to new Cassandra types
-- Use the new schema information returned with CqlResults
+- Removed rowset iterators
</notes>
<contents>
<dir name="/">
@@ -74,7 +72,6 @@
<file name="tests/024-multiplekeyspaces.phpt" role="doc" />
<file name="tests/025-activecolumnfamily.phpt" role="doc" />
<file name="tests/026-bigint.phpt" role="doc" />
- <file name="tests/027-rowsetiterator.phpt" role="doc" />
<file name="tests/config.inc-dist" role="doc" />
<file name="tests/skipif.inc" role="doc" />
</dir>
View
2 php_pdo_cassandra_int.hpp
@@ -111,7 +111,6 @@ typedef struct {
ColumnMap original_column_names;
ColumnMap column_name_labels;
- zend_bool rowset_iterator;
} pdo_cassandra_stmt;
/* }}} */
@@ -132,7 +131,6 @@ enum pdo_cassandra_constant {
PDO_CASSANDRA_ATTR_COMPRESSION,
PDO_CASSANDRA_ATTR_THRIFT_DEBUG,
PDO_CASSANDRA_ATTR_PRESERVE_VALUES,
- PDO_CASSANDRA_ATTR_ROWSET_ITERATOR,
PDO_CASSANDRA_ATTR_MAX
};
/* }}} */
View
65 tests/027-rowsetiterator.phpt
@@ -1,65 +0,0 @@
---TEST--
-Test sparse columns with rowset iterator
---SKIPIF--
-<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
---FILE--
-<?php
-require_once(dirname(__FILE__) . '/config.inc');
-
-$db = new PDO($dsn);
-
-pdo_cassandra_init ($db, $keyspace);
-
-$db->exec ("CREATE COLUMNFAMILY extended_users (
- my_key varchar PRIMARY KEY);");
-
-$db->exec ("INSERT INTO extended_users(my_key, third) VALUES('two columns', 'aaa')");
-$db->exec ("INSERT INTO extended_users(my_key, secondrowdata, thirdcolumn) VALUES('three columns', 'Flat 2, Street 2', 'metadata')");
-$db->exec ("INSERT INTO extended_users(my_key, fourth, large, row) VALUES('four columns', 'large', 'row', 'data')");
-
-$stmt = $db->prepare ("SELECT * FROM extended_users");
-$stmt->setAttribute(PDO::CASSANDRA_ATTR_ROWSET_ITERATOR, true);
-$stmt->execute ();
-
-do {
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- var_dump ($row);
-} while ($stmt->nextRowSet ());
-
-try {
- $stmt = $db->prepare ("SELECT * FROM extended_users");
- $stmt->execute ();
- $stmt->setAttribute(PDO::CASSANDRA_ATTR_ROWSET_ITERATOR, true);
-} catch (PDOException $e) {
- echo $e->getMessage () . PHP_EOL;
-}
-pdo_cassandra_done ($db, $keyspace);
-
-echo "OK";
---EXPECT--
-array(2) {
- ["my_key"]=>
- string(11) "two columns"
- ["third"]=>
- string(3) "aaa"
-}
-array(4) {
- ["my_key"]=>
- string(12) "four columns"
- ["fourth"]=>
- string(5) "large"
- ["large"]=>
- string(3) "row"
- ["row"]=>
- string(4) "data"
-}
-array(3) {
- ["my_key"]=>
- string(13) "three columns"
- ["secondrowdata"]=>
- string(16) "Flat 2, Street 2"
- ["thirdcolumn"]=>
- string(8) "metadata"
-}
-CQLSTATE[HY000] [0] Rowset iterator attribute must be set before executing the statement
-OK

0 comments on commit f5361b2

Please sign in to comment.