[65418] trunk/base/src/cregistry/sql.c

raimue at macports.org raimue at macports.org
Thu Mar 25 18:35:51 PDT 2010


Revision: 65418
          http://trac.macports.org/changeset/65418
Author:   raimue at macports.org
Date:     2010-03-25 18:35:50 -0700 (Thu, 25 Mar 2010)
Log Message:
-----------
cregistry:
No need for custom NOW(), use strftime('%s', 'now') instead

Modified Paths:
--------------
    trunk/base/src/cregistry/sql.c

Modified: trunk/base/src/cregistry/sql.c
===================================================================
--- trunk/base/src/cregistry/sql.c	2010-03-26 01:35:23 UTC (rev 65417)
+++ trunk/base/src/cregistry/sql.c	2010-03-26 01:35:50 UTC (rev 65418)
@@ -106,19 +106,6 @@
 }
 
 /**
- * NOW function for sqlite3. Takes no arguments. Returns the unix timestamp of
- * the current time.
- *
- * @param [in] context sqlite3-defined structure
- * @param [in] argc    number of arguments - always 2 and hence unused
- * @param [in] argv    0: value to match; 1: pattern to match against
- */
-static void sql_now(sqlite3_context* context, int argc UNUSED,
-        sqlite3_value** argv UNUSED) {
-    sqlite3_result_int(context, time(NULL));
-}
-
-/**
  * Creates tables in the registry. This function is called upon an uninitialized
  * database to create the tables needed to record state between invocations of
  * `port`.
@@ -134,7 +121,7 @@
         /* metadata table */
         "CREATE TABLE registry.metadata (key UNIQUE, value)",
         "INSERT INTO registry.metadata (key, value) VALUES ('version', 1.000)",
-        "INSERT INTO registry.metadata (key, value) VALUES ('created', NOW())",
+        "INSERT INTO registry.metadata (key, value) VALUES ('created', strftime('%s', 'now'))",
 
         /* ports table */
         "CREATE TABLE registry.ports ("
@@ -199,8 +186,6 @@
     /* I'm not error-checking these. I don't think I need to. */
     sqlite3_create_function(db, "REGEXP", 2, SQLITE_UTF8, NULL, sql_regexp,
             NULL, NULL);
-    sqlite3_create_function(db, "NOW", 0, SQLITE_ANY, NULL, sql_now, NULL,
-            NULL);
 
     sqlite3_create_collation(db, "VERSION", SQLITE_UTF8, NULL, sql_version);
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100325/a7532a55/attachment-0001.html>


More information about the macports-changes mailing list