Changeset 15582
- Timestamp:
- Nov 9, 2007, 5:56:56 PM (19 years ago)
- Location:
- trunk/ippdb
- Files:
-
- 7 edited
-
src/ippdb.c (modified) (9 diffs)
-
src/ippdb.h (modified) (3 diffs)
-
tests/alloc.c (modified) (2 diffs)
-
tests/insert.c (modified) (1 diff)
-
tests/insertobject.c (modified) (1 diff)
-
tests/metadatafromobject.c (modified) (2 diffs)
-
tests/objectfrommetadata.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/src/ippdb.c
r15576 r15582 23065 23065 static void flatcorrExpRowFree(flatcorrExpRow *object); 23066 23066 23067 flatcorrExpRow *flatcorrExpRowAlloc(psS64 corr_id, psS64 chip_id , const char *state)23067 flatcorrExpRow *flatcorrExpRowAlloc(psS64 corr_id, psS64 chip_id) 23068 23068 { 23069 23069 flatcorrExpRow *_object; … … 23074 23074 _object->corr_id = corr_id; 23075 23075 _object->chip_id = chip_id; 23076 _object->state = psStringCopy(state);23077 23076 23078 23077 return _object; … … 23081 23080 static void flatcorrExpRowFree(flatcorrExpRow *object) 23082 23081 { 23083 psFree(object->state);23084 23082 } 23085 23083 … … 23087 23085 { 23088 23086 psMetadata *md = psMetadataAlloc(); 23089 if (!psMetadataAdd(md, PS_LIST_TAIL, "corr_id", PS_DATA_S64, "Primary Key ", 0)) {23087 if (!psMetadataAdd(md, PS_LIST_TAIL, "corr_id", PS_DATA_S64, "Primary Key fkey(corr_id) ref flatcorrRun(corr_id)", 0)) { 23090 23088 psError(PS_ERR_UNKNOWN, false, "failed to add item corr_id"); 23091 23089 psFree(md); 23092 23090 return false; 23093 23091 } 23094 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key ", 64)) {23092 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(chip_id) ref chipRun(chip_id)", 64)) { 23095 23093 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 23096 23094 psFree(md); 23097 23095 return false; 23098 23096 } 23099 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "fkey(corr_id) ref flatcorrRun(corr_id)", "64")) {23100 psError(PS_ERR_UNKNOWN, false, "failed to add item state");23101 psFree(md);23102 return false;23103 }23104 23097 23105 23098 bool status = psDBCreateTable(dbh, FLATCORREXP_TABLE_NAME, md); … … 23115 23108 } 23116 23109 23117 bool flatcorrExpInsert(psDB * dbh, psS64 corr_id, psS64 chip_id , const char *state)23110 bool flatcorrExpInsert(psDB * dbh, psS64 corr_id, psS64 chip_id) 23118 23111 { 23119 23112 psMetadata *md = psMetadataAlloc(); … … 23125 23118 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) { 23126 23119 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 23127 psFree(md);23128 return false;23129 }23130 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) {23131 psError(PS_ERR_UNKNOWN, false, "failed to add item state");23132 23120 psFree(md); 23133 23121 return false; … … 23156 23144 bool flatcorrExpInsertObject(psDB *dbh, flatcorrExpRow *object) 23157 23145 { 23158 return flatcorrExpInsert(dbh, object->corr_id, object->chip_id , object->state);23146 return flatcorrExpInsert(dbh, object->corr_id, object->chip_id); 23159 23147 } 23160 23148 … … 23239 23227 return false; 23240 23228 } 23241 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) {23242 psError(PS_ERR_UNKNOWN, false, "failed to add item state");23243 psFree(md);23244 return false;23245 }23246 23229 23247 23230 … … 23263 23246 return false; 23264 23247 } 23265 char* state = psMetadataLookupPtr(&status, md, "state"); 23266 if (!status) { 23267 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 23268 return false; 23269 } 23270 23271 return flatcorrExpRowAlloc(corr_id, chip_id, state); 23248 23249 return flatcorrExpRowAlloc(corr_id, chip_id); 23272 23250 } 23273 23251 psArray *flatcorrExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
trunk/ippdb/src/ippdb.h
r15576 r15582 11320 11320 psS64 corr_id; 11321 11321 psS64 chip_id; 11322 char *state;11323 11322 } flatcorrExpRow; 11324 11323 … … 11330 11329 flatcorrExpRow *flatcorrExpRowAlloc( 11331 11330 psS64 corr_id, 11332 psS64 chip_id, 11333 const char *state 11331 psS64 chip_id 11334 11332 ); 11335 11333 … … 11362 11360 psDB *dbh, ///< Database handle 11363 11361 psS64 corr_id, 11364 psS64 chip_id, 11365 const char *state 11362 psS64 chip_id 11366 11363 ); 11367 11364 -
trunk/ippdb/tests/alloc.c
r15576 r15582 2522 2522 flatcorrExpRow *object; 2523 2523 2524 object = flatcorrExpRowAlloc(-64, -64 , "a string");2524 object = flatcorrExpRowAlloc(-64, -64 ); 2525 2525 2526 2526 if (!object) { … … 2533 2533 } 2534 2534 if (!object->chip_id == -64) { 2535 psFree(object);2536 exit(EXIT_FAILURE);2537 }2538 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) {2539 2535 psFree(object); 2540 2536 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insert.c
r15576 r15582 778 778 } 779 779 780 if (!flatcorrExpInsert(dbh, -64, -64 , "a string")) {780 if (!flatcorrExpInsert(dbh, -64, -64)) { 781 781 exit(EXIT_FAILURE); 782 782 } -
trunk/ippdb/tests/insertobject.c
r15576 r15582 1136 1136 } 1137 1137 1138 object = flatcorrExpRowAlloc(-64, -64 , "a string");1138 object = flatcorrExpRowAlloc(-64, -64); 1139 1139 if (!object) { 1140 1140 exit(EXIT_FAILURE); -
trunk/ippdb/tests/metadatafromobject.c
r15576 r15582 2850 2850 bool status; 2851 2851 2852 object = flatcorrExpRowAlloc(-64, -64 , "a string");2852 object = flatcorrExpRowAlloc(-64, -64); 2853 2853 if (!object) { 2854 2854 exit(EXIT_FAILURE); … … 2865 2865 exit(EXIT_FAILURE); 2866 2866 } 2867 psFree(md);2868 exit(EXIT_FAILURE);2869 }2870 if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) {2871 2867 psFree(md); 2872 2868 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r15576 r15582 4469 4469 exit(EXIT_FAILURE); 4470 4470 } 4471 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) {4472 psFree(md);4473 exit(EXIT_FAILURE);4474 }4475 4471 4476 4472 object = flatcorrExpObjectFromMetadata(md); … … 4485 4481 exit(EXIT_FAILURE); 4486 4482 } 4487 psFree(object);4488 exit(EXIT_FAILURE);4489 }4490 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) {4491 4483 psFree(object); 4492 4484 exit(EXIT_FAILURE);
Note:
See TracChangeset
for help on using the changeset viewer.
