Changeset 25851
- Timestamp:
- Oct 15, 2009, 11:37:32 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/dbversion.md (added)
-
dbconfig/ipp.m4 (modified) (1 diff)
-
ippTools/configure.ac (modified) (2 diffs)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 diff)
-
ippTools/share/pxadmin_drop_tables.sql (modified) (1 diff)
-
ippTools/share/pxadmin_update_version.sql (added)
-
ippTools/src/camtool.c (modified) (2 diffs)
-
ippTools/src/chiptool.c (modified) (3 diffs)
-
ippTools/src/difftool.c (modified) (2 diffs)
-
ippTools/src/faketool.c (modified) (2 diffs)
-
ippTools/src/pxadmin.c (modified) (5 diffs)
-
ippTools/src/pxtools.c (modified) (1 diff)
-
ippTools/src/pxtools.h (modified) (1 diff)
-
ippTools/src/stacktool.c (modified) (2 diffs)
-
ippTools/src/warptool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/changes.txt
r25848 r25851 1410 1410 1411 1411 ALTER TABLE rcDestination ADD CONSTRAINT UNIQUE(name); 1412 1413 CREATE TABLE dbversion ( 1414 schema_version VARCHAR(64), 1415 updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP 1416 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1417 1418 INSERT INTO dbversion VALUES('1.1.56', CURRENT_TIMESTAMP); 1419 1420 1412 1421 -- Vesion 1.1.57 1422 1423 -- add changes for 1.1.57 here. Then uncomment the following before commiting 1424 1425 -- UPDATE dbversion set schema_version = '1.1.57', updated= CURRENT_TIMESTAMP(); -
trunk/dbconfig/ipp.m4
r25299 r25851 9 9 dnl include(telescope.md) 10 10 dnl include(skycell.md) 11 include(dbversion.md) 11 12 include(summitcopy.md) 12 13 include(new.md) -
trunk/ippTools/configure.ac
r25835 r25851 1 1 AC_PREREQ(2.61) 2 2 3 AC_INIT([ipptools], [1.1. 37], [ipp-support@ifa.hawaii.edu])3 AC_INIT([ipptools], [1.1.56], [ipp-support@ifa.hawaii.edu]) 4 4 AC_CONFIG_SRCDIR([autogen.sh]) 5 5 … … 58 58 CFLAGS="${CFLAGS=} -Wall -Werror" 59 59 60 IPPDB_VERSION=`$PKG_CONFIG --modversion ippdb` 61 AC_DEFINE_UNQUOTED(IPPDB_VERSION, $IPPDB_VERSION, [Version of ippdb]) 62 60 63 AC_CONFIG_FILES([ 61 64 Makefile -
trunk/ippTools/share/Makefile.am
r25822 r25851 216 216 pxadmin_create_mirror_tables.sql \ 217 217 pxadmin_drop_tables.sql \ 218 pxadmin_update_version.sql \ 218 219 pubtool_definerun.sql \ 219 220 pubtool_pending.sql \ -
trunk/ippTools/share/pxadmin_create_tables.sql
r25835 r25851 1 CREATE TABLE dbversion ( 2 schema_version VARCHAR(64), 3 updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP 4 ) ENGINE=innodb DEFAULT CHARSET=latin1; 5 1 6 CREATE TABLE pzDataStore ( 2 7 camera VARCHAR(64), -
trunk/ippTools/share/pxadmin_drop_tables.sql
r25816 r25851 1 1 SET FOREIGN_KEY_CHECKS=0; 2 2 3 DROP TABLE IF EXISTS dbversion; 3 4 DROP TABLE IF EXISTS pzDataStore; 4 5 DROP TABLE IF EXISTS summitExp; -
trunk/ippTools/src/camtool.c
r25840 r25851 1147 1147 } 1148 1148 1149 if (!pxExportVersion(config, f)) { 1150 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1151 return false; 1152 } 1153 1149 1154 psMetadata *where = psMetadataAlloc(); 1150 1155 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); … … 1227 1232 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1228 1233 1229 fprintf (stdout, "---- input ----\n"); 1234 #ifdef notdef 1235 fprintf (stderr, "---- input ----\n"); 1230 1236 psMetadataPrint (stderr, input, 1); 1237 #endif 1238 1239 if (!pxCheckImportVersion(config, input)) { 1240 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1241 return false; 1242 } 1231 1243 1232 1244 psMetadataItem *item = psMetadataLookup (input, "camRun"); -
trunk/ippTools/src/chiptool.c
r25840 r25851 1377 1377 } 1378 1378 1379 if (!pxExportVersion(config, f)) { 1380 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1381 return false; 1382 } 1383 1379 1384 psMetadata *where = psMetadataAlloc(); 1380 1385 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); … … 1468 1473 psVector *identifiers = psVectorAllocEmpty(16, PS_TYPE_U64); // Identifiers inserted 1469 1474 1475 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator 1476 1477 if (!pxCheckImportVersion(config, input)) { 1478 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1479 return false; 1480 } 1481 // first item is the dbversion, skip it 1482 psMetadataItem *dbversion = psMetadataGetAndIncrement(iter); 1483 (void) dbversion; 1484 1470 1485 if (!psDBTransaction(config->dbh)) { 1471 1486 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1473 1488 } 1474 1489 1475 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator1476 1490 psMetadataItem *item; // Item from iteration 1477 1491 while ((item = psMetadataGetAndIncrement(iter))) { -
trunk/ippTools/src/difftool.c
r25840 r25851 2099 2099 } 2100 2100 2101 if (!pxExportVersion(config, f)) { 2102 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 2103 return false; 2104 } 2101 2105 psMetadata *where = psMetadataAlloc(); 2102 2106 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); … … 2190 2194 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 2191 2195 2192 fprintf (stdout, "---- input ----\n"); 2196 #ifdef notdef 2197 fprintf (stderr, "---- input ----\n"); 2193 2198 psMetadataPrint (stderr, input, 1); 2194 2199 #endif 2200 2201 if (!pxCheckImportVersion(config, input)) { 2202 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 2203 return false; 2204 } 2195 2205 psMetadataItem *item = psMetadataLookup (input, "diffRun"); 2196 2206 psAssert (item, "entry not in input?"); -
trunk/ippTools/src/faketool.c
r25840 r25851 1270 1270 return false; 1271 1271 } 1272 1272 if (!pxExportVersion(config, f)) { 1273 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1274 return false; 1275 } 1273 1276 psMetadata *where = psMetadataAlloc(); 1274 1277 PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "=="); … … 1351 1354 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1352 1355 1353 fprintf (stdout, "---- input ----\n"); 1356 #ifdef notdef 1357 fprintf (stderr, "---- input ----\n"); 1354 1358 psMetadataPrint (stderr, input, 1); 1355 1359 #endif 1360 1361 if (!pxCheckImportVersion(config, input)) { 1362 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1363 return false; 1364 } 1356 1365 psMetadataItem *item = psMetadataLookup (input, "fakeRun"); 1357 1366 psAssert (item, "entry not in input?"); -
trunk/ippTools/src/pxadmin.c
r23310 r25851 2 2 * pxadmin.c 3 3 * 4 * Copyright (C) 2006-200 8Joshua Hoblitt4 * Copyright (C) 2006-2009 Joshua Hoblitt 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it … … 31 31 bool createMirrorMode(pxConfig *config); 32 32 bool deleteMode(pxConfig *config); 33 static bool insert_dbversion(pxConfig * config, const char *versionString); 33 34 static bool runMultipleStatments(pxConfig *config, const char *query); 34 35 … … 113 114 psFree(query); 114 115 116 if (!insert_dbversion(config, PACKAGE_VERSION)) { 117 psError(PS_ERR_UNKNOWN, false, "failed to set database version"); 118 return false; 119 } 120 115 121 // COMMIT 116 122 if (!psDBCommit(config->dbh)) { … … 148 154 } 149 155 psFree(query); 156 157 if (!insert_dbversion(config, PACKAGE_VERSION)) { 158 psError(PS_ERR_UNKNOWN, false, "failed to set database version"); 159 return false; 160 } 150 161 151 162 // COMMIT … … 262 273 return true; 263 274 } 275 276 #ifdef notdef 277 static bool update_dbversion(pxConfig * config, const char *versionString) 278 { 279 psString query = pxDataGet("pxadmin_update_version.sql"); 280 if (!query) { 281 psError(PS_ERR_UNKNOWN, false, "failed to retrieve SQL statement"); 282 psFree(query); 283 return false; 284 } 285 if (!p_psDBRunQueryF(config->dbh, query, versionString)) { 286 psError(PS_ERR_UNKNOWN, false, "database error"); 287 psFree(query); 288 return false; 289 } 290 return true; 291 } 292 #endif 293 static bool insert_dbversion(pxConfig * config, const char *versionString) 294 { 295 psString query = "INSERT INTO dbversion VALUES('%s', CURRENT_TIMESTAMP())"; 296 if (!query) { 297 psError(PS_ERR_UNKNOWN, false, "failed to retrieve SQL statement"); 298 psFree(query); 299 return false; 300 } 301 if (!p_psDBRunQueryF(config->dbh, query, versionString)) { 302 psError(PS_ERR_UNKNOWN, false, "database error"); 303 psFree(query); 304 return false; 305 } 306 return true; 307 } -
trunk/ippTools/src/pxtools.c
r25840 r25851 177 177 return true; 178 178 } 179 180 bool pxLookupVersion(pxConfig *config, psArray **pArray) 181 { 182 const char *query = "SELECT * FROM dbversion"; 183 184 if (!p_psDBRunQuery(config->dbh, query)) { 185 psError(PS_ERR_UNKNOWN, false, "database error"); 186 return false; 187 } 188 189 psArray *output = p_psDBFetchResult(config->dbh); 190 if (!output) { 191 psError(PS_ERR_UNKNOWN, false, "database error"); 192 return false; 193 } 194 if (!psArrayLength(output)) { 195 psFree(output); 196 psError(PS_ERR_UNKNOWN, true, "no rows in dbversion"); 197 return false; 198 } 199 if (psArrayLength(output) > 1) { 200 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found in dbversion: %" PRId64, 201 psArrayLength(output)); 202 return false; 203 } 204 *pArray = output; 205 206 return true; 207 } 208 209 psString pxGetDBVersion(pxConfig *config) 210 { 211 PS_ASSERT_PTR_NON_NULL(config, NULL); 212 213 psArray *array = NULL; 214 if (!pxLookupVersion(config, &array)) { 215 psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed"); 216 return NULL; 217 } 218 psMetadata *md = array->data[0]; 219 if (!md) { 220 psError(PS_ERR_UNKNOWN, true, "output of pxLookupVersion is null"); 221 return NULL; 222 } 223 224 psString version = psMetadataLookupStr(NULL, md, "schema_version"); 225 226 return version; 227 } 228 229 bool pxExportVersion(pxConfig *config, FILE *file) 230 { 231 PS_ASSERT_PTR_NON_NULL(config, NULL); 232 PS_ASSERT_PTR_NON_NULL(file, NULL); 233 234 psArray *array = NULL; 235 if (!pxLookupVersion(config, &array) || !array) { 236 psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed"); 237 return false; 238 } 239 if (!ippdbPrintMetadatas(file, array, "dbversion", true)) { 240 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 241 psFree(array); 242 return false; 243 } 244 return true; 245 } 246 247 bool pxCheckImportVersion(pxConfig *config, psMetadata *input) 248 { 249 PS_ASSERT_PTR_NON_NULL(config, NULL); 250 PS_ASSERT_PTR_NON_NULL(input, NULL); 251 252 // This code was adapted from the way camtool parses the structures. 253 // Is this really the way to do it? 254 psMetadataItem *multi_item = psMetadataLookup(input, "dbversion"); 255 if (!multi_item || (multi_item->type != PS_DATA_METADATA_MULTI)) { 256 psError(PS_ERR_UNKNOWN, true, "dbversion multi not found in input"); 257 return false; 258 } 259 260 psMetadataItem *dbversion = psListGet(multi_item->data.list, 0); 261 if (!dbversion) { 262 psError(PS_ERR_UNKNOWN, true, "dbversion not found in input"); 263 return false; 264 } 265 266 if (!strcmp(dbversion->name, "dbversion")) { 267 // horray 268 psMetadata *md = dbversion->data.md; 269 psString schema_version = pxGetDBVersion(config); 270 if (!schema_version) { 271 psError(PS_ERR_UNKNOWN, false, "pxGetDBVersion failed"); 272 return false; 273 } 274 275 psString import_version = psMetadataLookupStr(NULL, md, "schema_version"); 276 if (import_version && strcmp(import_version, schema_version)) { 277 psError(PS_ERR_UNKNOWN, true, "input file schema_version: %s does not match data base: %s", 278 import_version, schema_version); 279 return false; 280 } else if (!import_version) { 281 psError(PS_ERR_UNKNOWN, true, "input file schema_version is NULL"); 282 return false; 283 } else { 284 // YIPPEE this file is the same version 285 } 286 } else { 287 psError(PS_ERR_UNKNOWN, true, "Unexpected config dump format"); 288 return false; 289 } 290 291 return true; 292 } -
trunk/ippTools/src/pxtools.h
r25840 r25851 57 57 58 58 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code); 59 bool pxExportVersion(pxConfig *config, FILE *f); 60 bool pxCheckImportVersion(pxConfig *config, psMetadata *md); 59 61 60 62 psExit pxerrorGetExitStatus(void); -
trunk/ippTools/src/stacktool.c
r25840 r25851 1297 1297 } 1298 1298 1299 if (!pxExportVersion(config, f)) { 1300 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1301 return false; 1302 } 1299 1303 psMetadata *where = psMetadataAlloc(); 1300 1304 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); … … 1383 1387 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1384 1388 1385 fprintf (stdout, "---- input ----\n"); 1389 #ifdef notdef 1390 fprintf (stderr, "---- input ----\n"); 1386 1391 psMetadataPrint (stderr, input, 1); 1387 1392 #endif 1393 1394 if (!pxCheckImportVersion(config, input)) { 1395 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1396 return false; 1397 } 1388 1398 psMetadataItem *item = psMetadataLookup (input, "stackRun"); 1389 1399 psAssert (item, "entry not in input?"); -
trunk/ippTools/src/warptool.c
r25840 r25851 1753 1753 } 1754 1754 1755 if (!pxExportVersion(config, f)) { 1756 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1757 return false; 1758 } 1755 1759 psMetadata *where = psMetadataAlloc(); 1756 1760 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); … … 1845 1849 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1846 1850 1847 fprintf (stdout, "---- input ----\n"); 1851 #ifdef notdef 1852 fprintf (stderr, "---- input ----\n"); 1848 1853 psMetadataPrint (stderr, input, 1); 1854 #endif 1855 1856 if (!pxCheckImportVersion(config, input)) { 1857 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1858 return false; 1859 } 1849 1860 1850 1861 psMetadataItem *item = psMetadataLookup (input, "warpRun");
Note:
See TracChangeset
for help on using the changeset viewer.
