liquid_feedback_core

changeset 65:bdccc56fb705 v1.2.4

lf_update continues on error (but still reports errors)
and version number changed to v1.2.4 (without any other schema changes)
author jbe
date Sun Aug 15 17:10:47 2010 +0200 (2010-08-15)
parents 6dba5c0eb0ec
children bdee8dc73a63
files core.sql lf_update.c update/core-update.v1.2.3-v1.2.4.sql
line diff
     1.1 --- a/core.sql	Sat Jul 24 16:52:51 2010 +0200
     1.2 +++ b/core.sql	Sun Aug 15 17:10:47 2010 +0200
     1.3 @@ -6,7 +6,7 @@
     1.4  BEGIN;
     1.5  
     1.6  CREATE VIEW "liquid_feedback_version" AS
     1.7 -  SELECT * FROM (VALUES ('1.2.3', 1, 2, 3))
     1.8 +  SELECT * FROM (VALUES ('1.2.4', 1, 2, 4))
     1.9    AS "subquery"("string", "major", "minor", "revision");
    1.10  
    1.11  
     2.1 --- a/lf_update.c	Sat Jul 24 16:52:51 2010 +0200
     2.2 +++ b/lf_update.c	Sun Aug 15 17:10:47 2010 +0200
     2.3 @@ -6,6 +6,7 @@
     2.4  int main(int argc, char **argv) {
     2.5  
     2.6    // variable declarations:
     2.7 +  int err = 0;
     2.8    int i, count;
     2.9    char *conninfo;
    2.10    PGconn *db;
    2.11 @@ -57,97 +58,105 @@
    2.12    status = PQexec(db, "DELETE FROM \"expired_session\"");
    2.13    if (!status) {
    2.14      fprintf(stderr, "Error in pqlib while sending SQL command deleting expired sessions\n");
    2.15 -    return 1;
    2.16 -  }
    2.17 -  if (
    2.18 +    err = 1;
    2.19 +  } else if (
    2.20      PQresultStatus(status) != PGRES_COMMAND_OK &&
    2.21      PQresultStatus(status) != PGRES_TUPLES_OK
    2.22    ) {
    2.23      fprintf(stderr, "Error while executing SQL command deleting expired sessions:\n%s", PQresultErrorMessage(status));
    2.24 -    return 1;
    2.25 +    err = 1;
    2.26 +    PQclear(status);
    2.27 +  } else {
    2.28 +    PQclear(status);
    2.29    }
    2.30  
    2.31    // calculate member counts:
    2.32    status = PQexec(db, "SELECT \"calculate_member_counts\"()");
    2.33    if (!status) {
    2.34      fprintf(stderr, "Error in pqlib while sending SQL command calculating member counts\n");
    2.35 -    return 1;
    2.36 -  }
    2.37 -  if (
    2.38 +    err = 1;
    2.39 +  } else if (
    2.40      PQresultStatus(status) != PGRES_COMMAND_OK &&
    2.41      PQresultStatus(status) != PGRES_TUPLES_OK
    2.42    ) {
    2.43      fprintf(stderr, "Error while executing SQL command calculating member counts:\n%s", PQresultErrorMessage(status));
    2.44 -    return 1;
    2.45 +    err = 1;
    2.46 +    PQclear(status);
    2.47 +  } else {
    2.48 +    PQclear(status);
    2.49    }
    2.50  
    2.51    // update open issues:
    2.52    list = PQexec(db, "SELECT \"id\" FROM \"open_issue\"");
    2.53    if (!list) {
    2.54      fprintf(stderr, "Error in pqlib while sending SQL command selecting open issues\n");
    2.55 -    return 1;
    2.56 -  }
    2.57 -  if (PQresultStatus(list) != PGRES_TUPLES_OK) {
    2.58 +    err = 1;
    2.59 +  } else if (PQresultStatus(list) != PGRES_TUPLES_OK) {
    2.60      fprintf(stderr, "Error while executing SQL command selecting open issues:\n%s", PQresultErrorMessage(list));
    2.61 -    return 1;
    2.62 +    err = 1;
    2.63 +    PQclear(list);
    2.64 +  } else {
    2.65 +    count = PQntuples(list);
    2.66 +    for (i=0; i<count; i++) {
    2.67 +      const char *params[1];
    2.68 +      params[0] = PQgetvalue(list, i, 0);
    2.69 +      status = PQexecParams(
    2.70 +        db, "SELECT \"check_issue\"($1)", 1, NULL, params, NULL, NULL, 0
    2.71 +      );
    2.72 +      if (!status) {
    2.73 +        fprintf(stderr, "Error in pqlib while sending SQL command to call function \"check_issue\"(...):\n");
    2.74 +        err = 1;
    2.75 +      } else if (
    2.76 +        PQresultStatus(status) != PGRES_COMMAND_OK &&
    2.77 +        PQresultStatus(status) != PGRES_TUPLES_OK
    2.78 +      ) {
    2.79 +        fprintf(stderr, "Error while calling SQL function \"check_issue\"(...):\n%s", PQresultErrorMessage(status));
    2.80 +        err = 1;
    2.81 +        PQclear(status);
    2.82 +      } else {
    2.83 +        PQclear(status);
    2.84 +      }
    2.85 +    }
    2.86 +    PQclear(list);
    2.87    }
    2.88 -  count = PQntuples(list);
    2.89 -  for (i=0; i<count; i++) {
    2.90 -    const char *params[1];
    2.91 -    params[0] = PQgetvalue(list, i, 0);
    2.92 -    status = PQexecParams(
    2.93 -      db, "SELECT \"check_issue\"($1)", 1, NULL, params, NULL, NULL, 0
    2.94 -    );
    2.95 -    if (!status) {
    2.96 -      fprintf(stderr, "Error in pqlib while sending SQL command to call function \"check_issue\"(...):\n");
    2.97 -      return 1;
    2.98 -    }
    2.99 -    if (
   2.100 -      PQresultStatus(status) != PGRES_COMMAND_OK &&
   2.101 -      PQresultStatus(status) != PGRES_TUPLES_OK
   2.102 -    ) {
   2.103 -      fprintf(stderr, "Error while calling SQL function \"check_issue\"(...):\n%s", PQresultErrorMessage(status));
   2.104 -      return 1;
   2.105 -    }
   2.106 -    PQclear(status);
   2.107 -  }
   2.108 -  PQclear(list);
   2.109  
   2.110    // calculate ranks after voting is finished:
   2.111    // (NOTE: This is a seperate process to avoid long transactions with locking)
   2.112    list = PQexec(db, "SELECT \"id\" FROM \"issue_with_ranks_missing\"");
   2.113    if (!list) {
   2.114      fprintf(stderr, "Error in pqlib while sending SQL command selecting issues where ranks are missing\n");
   2.115 -    return 1;
   2.116 -  }
   2.117 -  if (PQresultStatus(list) != PGRES_TUPLES_OK) {
   2.118 +    err = 1;
   2.119 +  } else if (PQresultStatus(list) != PGRES_TUPLES_OK) {
   2.120      fprintf(stderr, "Error while executing SQL command selecting issues where ranks are missing:\n%s", PQresultErrorMessage(list));
   2.121 -    return 1;
   2.122 +    err = 1;
   2.123 +    PQclear(list);
   2.124 +  } else {
   2.125 +    count = PQntuples(list);
   2.126 +    for (i=0; i<count; i++) {
   2.127 +      const char *params[1];
   2.128 +      params[0] = PQgetvalue(list, i, 0);
   2.129 +      status = PQexecParams(
   2.130 +        db, "SELECT \"calculate_ranks\"($1)", 1, NULL, params, NULL, NULL, 0
   2.131 +      );
   2.132 +      if (!status) {
   2.133 +        fprintf(stderr, "Error in pqlib while sending SQL command to call function \"calculate_ranks\"(...):\n");
   2.134 +        err = 1;
   2.135 +      } else if (
   2.136 +        PQresultStatus(status) != PGRES_COMMAND_OK &&
   2.137 +        PQresultStatus(status) != PGRES_TUPLES_OK
   2.138 +      ) {
   2.139 +        fprintf(stderr, "Error while calling SQL function \"calculate_ranks\"(...):\n%s", PQresultErrorMessage(status));
   2.140 +        err = 1;
   2.141 +        PQclear(status);
   2.142 +      } else {
   2.143 +        PQclear(status);
   2.144 +      }
   2.145 +    }
   2.146 +    PQclear(list);
   2.147    }
   2.148 -  count = PQntuples(list);
   2.149 -  for (i=0; i<count; i++) {
   2.150 -    const char *params[1];
   2.151 -    params[0] = PQgetvalue(list, i, 0);
   2.152 -    status = PQexecParams(
   2.153 -      db, "SELECT \"calculate_ranks\"($1)", 1, NULL, params, NULL, NULL, 0
   2.154 -    );
   2.155 -    if (!status) {
   2.156 -      fprintf(stderr, "Error in pqlib while sending SQL command to call function \"calculate_ranks\"(...):\n");
   2.157 -      return 1;
   2.158 -    }
   2.159 -    if (
   2.160 -      PQresultStatus(status) != PGRES_COMMAND_OK &&
   2.161 -      PQresultStatus(status) != PGRES_TUPLES_OK
   2.162 -    ) {
   2.163 -      fprintf(stderr, "Error while calling SQL function \"calculate_ranks\"(...):\n%s", PQresultErrorMessage(status));
   2.164 -      return 1;
   2.165 -    }
   2.166 -    PQclear(status);
   2.167 -  }
   2.168 -  PQclear(list);
   2.169  
   2.170    // cleanup and exit
   2.171    PQfinish(db);
   2.172 -  return 0;
   2.173 +  return err;
   2.174  
   2.175  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/update/core-update.v1.2.3-v1.2.4.sql	Sun Aug 15 17:10:47 2010 +0200
     3.3 @@ -0,0 +1,9 @@
     3.4 +BEGIN;
     3.5 +
     3.6 +CREATE OR REPLACE VIEW "liquid_feedback_version" AS
     3.7 +  SELECT * FROM (VALUES ('1.2.4', 1, 2, 4))
     3.8 +  AS "subquery"("string", "major", "minor", "revision");
     3.9 +
    3.10 +-- no changes in database scheme except version number
    3.11 +
    3.12 +COMMIT;

Impressum / About Us