Changeset 25929 for trunk/ippTools/src/pubtool.c
- Timestamp:
- Oct 22, 2009, 4:51:58 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pubtool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pubtool.c
r25256 r25929 32 32 33 33 static bool defineclientMode(pxConfig *config); 34 static bool updateclientMode(pxConfig *config); 34 35 static bool definerunMode(pxConfig *config); 35 36 static bool pendingMode(pxConfig *config); … … 57 58 switch (config->mode) { 58 59 MODECASE(PUBTOOL_MODE_DEFINECLIENT, defineclientMode); 60 MODECASE(PUBTOOL_MODE_UPDATECLIENT, updateclientMode); 59 61 MODECASE(PUBTOOL_MODE_DEFINERUN, definerunMode); 60 62 MODECASE(PUBTOOL_MODE_PENDING, pendingMode); … … 94 96 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 95 97 96 if (!publishClientInsert(config->dbh, 0, product, stage, workdir, comment)) { 97 psError(PS_ERR_UNKNOWN, false, "Database error"); 98 return false; 99 } 98 if (!publishClientInsert(config->dbh, 0, 0, product, stage, workdir, comment)) { 99 psError(PS_ERR_UNKNOWN, false, "Database error"); 100 return false; 101 } 102 103 return true; 104 } 105 106 static bool updateclientMode(pxConfig *config) 107 { 108 PS_ASSERT_PTR_NON_NULL(config, false); 109 110 psMetadata *where = psMetadataAlloc(); // WHERE conditions 111 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 112 PXOPT_COPY_STR(config->args, where, "-product", "product", "=="); 113 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 114 PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE"); 115 116 PXOPT_LOOKUP_BOOL(active, config->args, "-active", false); 117 PXOPT_LOOKUP_BOOL(inactive, config->args, "-inactive", false); 118 119 if ((!active && !inactive) || (active && inactive)) { 120 psError(PS_ERR_UNKNOWN, false, "Must specify one, and only one, of -active and -inactive."); 121 psFree(where); 122 return false; 123 } 124 125 psString query = NULL; // Query to run 126 psStringAppend(&query, "UPDATE publishRun SET active = %d", active ? 1 : 0); 127 128 if (psListLength(where->list)) { 129 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 130 psStringAppend(&query, "\n AND %s", clause); 131 psFree(clause); 132 } 133 psFree(where); 134 135 if (!p_psDBRunQuery(config->dbh, query)) { 136 psError(PS_ERR_UNKNOWN, false, "Database error"); 137 psFree(query); 138 return false; 139 } 140 psFree(query); 141 142 long numUpdated = psDBAffectedRows(config->dbh); 143 psLogMsg("pubtool", PS_LOG_INFO, "%ld rows updated.", numUpdated); 100 144 101 145 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
