Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove rowset iterators

  • Loading branch information...
commit f5361b2020edaee8a6fda0153833fdfa4253e696 1 parent 9ac21d4
Mikko Koppanen authored
3  ChangeLog
... ... @@ -1,3 +1,6 @@
  1 +0.2.1
  2 +- Removed rowset iterators
  3 +
1 4 0.2.0
2 5 - Switched to Cassandra 1.x branch and dropped support for 0.8.x.
3 6 - Fixed tests to new Cassandra types
2  cassandra_driver.cpp
@@ -314,7 +314,6 @@ static int pdo_cassandra_handle_prepare(pdo_dbh_t *dbh, const char *sql, long sq
314 314 /* transfer handle with the statement */
315 315 S->H = H;
316 316 S->result.reset ();
317   - S->rowset_iterator = 0;
318 317
319 318 /* Fill in necessary driver data */
320 319 stmt->driver_data = S;
@@ -635,7 +634,6 @@ PHP_MINIT_FUNCTION(pdo_cassandra)
635 634 PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_COMPRESSION", PDO_CASSANDRA_ATTR_COMPRESSION);
636 635 PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_THRIFT_DEBUG", PDO_CASSANDRA_ATTR_THRIFT_DEBUG);
637 636 PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_PRESERVE_VALUES", PDO_CASSANDRA_ATTR_PRESERVE_VALUES);
638   - PHP_PDO_CASSANDRA_REGISTER_CONST_LONG("CASSANDRA_ATTR_ROWSET_ITERATOR", PDO_CASSANDRA_ATTR_ROWSET_ITERATOR);
639 637
640 638 #undef PHP_PDO_CASSANDRA_REGISTER_CONST_LONG
641 639
86 cassandra_statement.cpp
@@ -133,7 +133,6 @@ static int pdo_cassandra_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
133 133 static zend_bool pdo_cassandra_add_column(pdo_stmt_t *stmt, const std::string &name, int order)
134 134 {
135 135 pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
136   - pdo_cassandra_db_handle *H = static_cast <pdo_cassandra_db_handle *>(S->H);
137 136
138 137 try {
139 138 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
177 176 // Set column names and labels if we don't have them already
178 177 if (!S->original_column_names.size()) {
179 178
180   - if (S->rowset_iterator) {
181   - for (std::vector<Column>::iterator col_it = (*S->it).columns.begin(); col_it < (*S->it).columns.end(); col_it++) {
  179 + // Get unique column names
  180 + for (std::vector<CqlRow>::iterator it = S->result.get()->rows.begin(); it < S->result.get()->rows.end(); it++) {
  181 + for (std::vector<Column>::iterator col_it = (*it).columns.begin(); col_it < (*it).columns.end(); col_it++) {
182 182 if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
183 183 order++;
184 184 }
185 185 }
186   - } else {
187   - // Get unique column names
188   - for (std::vector<CqlRow>::iterator it = S->result.get()->rows.begin(); it < S->result.get()->rows.end(); it++) {
189   - for (std::vector<Column>::iterator col_it = (*it).columns.begin(); col_it < (*it).columns.end(); col_it++) {
190   - if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
191   - order++;
192   - }
193   - }
194   - }
195 186 }
196 187 stmt->column_count = order;
197 188 }
198 189 stmt->column_count = S->original_column_names.size();
199 190 } else {
200   - if (!S->rowset_iterator) {
201   - S->it++;
202   - }
  191 + S->it++;
203 192 }
204 193
205 194 if (S->it == S->result.get()->rows.end()) {
@@ -462,67 +451,6 @@ static int pdo_cassandra_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
462 451 }
463 452 /* }}} */
464 453
465   -int pdo_cassandra_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
466   -{
467   - pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
468   -
469   - if (!S->rowset_iterator) {
470   - pdo_cassandra_error_exception(stmt->dbh, PDO_CASSANDRA_GENERAL_ERROR, "PDO::nextRowset can only be used with rowset iterator", "");
471   - return 0;
472   - }
473   -
474   - S->it++;
475   -
476   - S->original_column_names.clear();
477   - S->column_name_labels.clear();
478   -
479   - if (S->it == S->result.get()->rows.end()) {
480   - S->has_iterator = 0;
481   - return 0;
482   - }
483   -
484   - int order = 0;
485   - for (std::vector<Column>::iterator col_it = (*S->it).columns.begin(); col_it < (*S->it).columns.end(); col_it++) {
486   - if (pdo_cassandra_add_column(stmt, (*col_it).name, order)) {
487   - order++;
488   - }
489   - }
490   - stmt->column_count = order;
491   - return 1;
492   -}
493   -
494   -static int pdo_cassandra_stmt_set_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
495   -{
496   - pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
497   - pdo_cassandra_constant attribute = static_cast <pdo_cassandra_constant>(attr);
498   -
499   -
500   - if (attribute == PDO_CASSANDRA_ATTR_ROWSET_ITERATOR) {
501   - convert_to_boolean(val);
502   -
503   - if (Z_BVAL_P(val) && stmt->executed) {
504   - pdo_cassandra_error_exception(stmt->dbh, PDO_CASSANDRA_GENERAL_ERROR, "Rowset iterator attribute must be set before executing the statement", "");
505   - return 0;
506   - }
507   -
508   - S->rowset_iterator = Z_BVAL_P(val);
509   - return 1;
510   - }
511   - return 0;
512   -}
513   -
514   -static int pdo_cassandra_stmt_get_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
515   -{
516   - pdo_cassandra_stmt *S = static_cast <pdo_cassandra_stmt *>(stmt->driver_data);
517   - pdo_cassandra_constant attribute = static_cast <pdo_cassandra_constant>(attr);
518   -
519   - if (attribute == PDO_CASSANDRA_ATTR_ROWSET_ITERATOR) {
520   - ZVAL_BOOL(val, S->rowset_iterator);
521   - return 1;
522   - }
523   - return 0;
524   -}
525   -
526 454 struct pdo_stmt_methods cassandra_stmt_methods = {
527 455 pdo_cassandra_stmt_dtor,
528 456 pdo_cassandra_stmt_execute,
@@ -530,10 +458,10 @@ struct pdo_stmt_methods cassandra_stmt_methods = {
530 458 pdo_cassandra_stmt_describe,
531 459 pdo_cassandra_stmt_get_column,
532 460 NULL, /* param_hook */
533   - pdo_cassandra_stmt_set_attr, /* set_attr */
534   - pdo_cassandra_stmt_get_attr, /* get_attr */
  461 + NULL, /* set_attr */
  462 + NULL, /* get_attr */
535 463 pdo_cassandra_stmt_get_column_meta,
536   - pdo_cassandra_stmt_next_rowset,
  464 + NULL, /* next rowset */
537 465 pdo_cassandra_stmt_cursor_close
538 466 };
539 467
11 package.xml
@@ -13,18 +13,16 @@
13 13 <date>2011-09-13</date>
14 14 <time>12:00:00</time>
15 15 <version>
16   - <release>0.2.0</release>
17   - <api>0.2.0</api>
  16 + <release>0.2.1</release>
  17 + <api>0.2.1</api>
18 18 </version>
19 19 <stability>
20 20 <release>beta</release>
21 21 <api>beta</api>
22 22 </stability>
23   - <license>PHP License</license>
  23 + <license>Apache License</license>
24 24 <notes>
25   -- Switched to Cassandra 1.x branch and dropped support for 0.8.x.
26   -- Fixed tests to new Cassandra types
27   -- Use the new schema information returned with CqlResults
  25 +- Removed rowset iterators
28 26 </notes>
29 27 <contents>
30 28 <dir name="/">
@@ -74,7 +72,6 @@
74 72 <file name="tests/024-multiplekeyspaces.phpt" role="doc" />
75 73 <file name="tests/025-activecolumnfamily.phpt" role="doc" />
76 74 <file name="tests/026-bigint.phpt" role="doc" />
77   - <file name="tests/027-rowsetiterator.phpt" role="doc" />
78 75 <file name="tests/config.inc-dist" role="doc" />
79 76 <file name="tests/skipif.inc" role="doc" />
80 77 </dir>
2  php_pdo_cassandra_int.hpp
@@ -111,7 +111,6 @@ typedef struct {
111 111
112 112 ColumnMap original_column_names;
113 113 ColumnMap column_name_labels;
114   - zend_bool rowset_iterator;
115 114 } pdo_cassandra_stmt;
116 115 /* }}} */
117 116
@@ -132,7 +131,6 @@ enum pdo_cassandra_constant {
132 131 PDO_CASSANDRA_ATTR_COMPRESSION,
133 132 PDO_CASSANDRA_ATTR_THRIFT_DEBUG,
134 133 PDO_CASSANDRA_ATTR_PRESERVE_VALUES,
135   - PDO_CASSANDRA_ATTR_ROWSET_ITERATOR,
136 134 PDO_CASSANDRA_ATTR_MAX
137 135 };
138 136 /* }}} */
65 tests/027-rowsetiterator.phpt
... ... @@ -1,65 +0,0 @@
1   ---TEST--
2   -Test sparse columns with rowset iterator
3   ---SKIPIF--
4   -<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5   ---FILE--
6   -<?php
7   -require_once(dirname(__FILE__) . '/config.inc');
8   -
9   -$db = new PDO($dsn);
10   -
11   -pdo_cassandra_init ($db, $keyspace);
12   -
13   -$db->exec ("CREATE COLUMNFAMILY extended_users (
14   - my_key varchar PRIMARY KEY);");
15   -
16   -$db->exec ("INSERT INTO extended_users(my_key, third) VALUES('two columns', 'aaa')");
17   -$db->exec ("INSERT INTO extended_users(my_key, secondrowdata, thirdcolumn) VALUES('three columns', 'Flat 2, Street 2', 'metadata')");
18   -$db->exec ("INSERT INTO extended_users(my_key, fourth, large, row) VALUES('four columns', 'large', 'row', 'data')");
19   -
20   -$stmt = $db->prepare ("SELECT * FROM extended_users");
21   -$stmt->setAttribute(PDO::CASSANDRA_ATTR_ROWSET_ITERATOR, true);
22   -$stmt->execute ();
23   -
24   -do {
25   - $row = $stmt->fetch(PDO::FETCH_ASSOC);
26   - var_dump ($row);
27   -} while ($stmt->nextRowSet ());
28   -
29   -try {
30   - $stmt = $db->prepare ("SELECT * FROM extended_users");
31   - $stmt->execute ();
32   - $stmt->setAttribute(PDO::CASSANDRA_ATTR_ROWSET_ITERATOR, true);
33   -} catch (PDOException $e) {
34   - echo $e->getMessage () . PHP_EOL;
35   -}
36   -pdo_cassandra_done ($db, $keyspace);
37   -
38   -echo "OK";
39   ---EXPECT--
40   -array(2) {
41   - ["my_key"]=>
42   - string(11) "two columns"
43   - ["third"]=>
44   - string(3) "aaa"
45   -}
46   -array(4) {
47   - ["my_key"]=>
48   - string(12) "four columns"
49   - ["fourth"]=>
50   - string(5) "large"
51   - ["large"]=>
52   - string(3) "row"
53   - ["row"]=>
54   - string(4) "data"
55   -}
56   -array(3) {
57   - ["my_key"]=>
58   - string(13) "three columns"
59   - ["secondrowdata"]=>
60   - string(16) "Flat 2, Street 2"
61   - ["thirdcolumn"]=>
62   - string(8) "metadata"
63   -}
64   -CQLSTATE[HY000] [0] Rowset iterator attribute must be set before executing the statement
65   -OK

0 comments on commit f5361b2

Please sign in to comment.
Something went wrong with that request. Please try again.