[svn] commit: r768 - in /branches/each-ds/src/lib/auth/cpp: data_source_sqlite3.cc data_source_sqlite3.h

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Feb 9 10:15:18 UTC 2010


Author: mgraff
Date: Tue Feb  9 10:15:17 2010
New Revision: 768

Log:
checkpoint work; queries work now, but there is some sort of stack-smashing going on

Modified:
    branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc
    branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.h

Modified: branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc Tue Feb  9 10:15:17 2010
@@ -20,8 +20,7 @@
     int rc;
     sqlite3_stmt *prepared = NULL;
 
-    rc = sqlite3_prepare_v2(db, statement, strlen(statement) + 1,
-                            &prepared, NULL);
+    rc = sqlite3_prepare_v2(db, statement, -1, &prepared, NULL);
     if (rc != SQLITE_OK) {
         throw("could not prepare");
     }
@@ -76,6 +75,8 @@
     }
 
     sqlite3_reset(q_record);
+    sqlite3_clear_bindings(q_record);
+
     rc = sqlite3_bind_int(q_record, 1, zone_id);
     if (rc != SQLITE_OK) {
         throw("Could not bind 1");
@@ -89,37 +90,40 @@
         throw("Could not bind 3");
     }
 
-    RRsetPtr rrset = RRsetPtr(new RRset(name, RRClass("IN"), RRType("TXT"),
+    RRsetPtr rrset = RRsetPtr(new RRset(name, RRClass("IN"), rdtype,
                                         RRTTL(3600)));
+    int target_ttl = -1;
+    int sig_ttl = -1;
 
     // loop
     int rows = 0;
-    do {
+    rc = sqlite3_step(q_record);
+    while (rc == SQLITE_ROW) {
+        rows++;
+
+        const unsigned char *type = sqlite3_column_text(q_record, 0);
+        int ttl = sqlite3_column_int(q_record, 1);
+        const unsigned char *sigtype = sqlite3_column_text(q_record, 2);
+        const unsigned char *rdata = sqlite3_column_text(q_record, 3);
+
+        if (sigtype == NULL) {
+            RdataPtr item = createRdata(RRType((const char *)type),
+                RRClass("IN"), (const char *)rdata);
+            rrset->addRdata(item);
+            if (target_ttl == -1 || target_ttl > ttl) {
+                target_ttl = ttl;
+            }
+        } else {
+            if (sig_ttl == -1 || sig_ttl > ttl) {
+                sig_ttl = ttl;
+            }
+        }
+        
         rc = sqlite3_step(q_record);
-        if (rc == SQLITE_ROW) {
-            rows++;
-
-            const unsigned char *type = sqlite3_column_text(q_record, 0);
-            int ttl = sqlite3_column_int(q_record, 1);
-            const unsigned char *sigtype = sqlite3_column_text(q_record, 2);
-            const unsigned char *rdata = sqlite3_column_text(q_record, 3);
-
-            if (sigtype == NULL) {
-                rrset->addRdata(generic::TXT((const char *) rdata));
-            }
-
-            cout << "Found:"
-                 << name << " "
-                 << ttl << " "
-                 << type << " ";
-            if (sigtype != NULL) {
-                cout << sigtype << " ";
-            }
-            cout << rdata << endl;
-        }
-    } while (rc == SQLITE_ROW);
+    }
 
     if (rows > 0) {
+        rrset->setTTL(RRTTL(target_ttl));
         target.push_back(rrset);
     }
 

Modified: branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.h (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.h Tue Feb  9 10:15:17 2010
@@ -56,7 +56,7 @@
     void setupPreparedStatements(void);
     void execSetupQuery(const char *query);
     void checkAndSetupSchema(void);
-    
+
     sqlite3 *db;
     std::string database_name;
     int database_version;




More information about the bind10-changes mailing list