Changeset 7500
- Timestamp:
- Jun 9, 2006, 6:22:07 PM (20 years ago)
- Location:
- branches/jhoblitt/ippdb
- Files:
-
- 8 edited
-
src/ippdb.c (modified) (12 diffs)
-
src/ippdb.h (modified) (4 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)
-
tests/pop.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/jhoblitt/ippdb/src/ippdb.c
r7460 r7500 10529 10529 static void detRunRowFree(detRunRow *object); 10530 10530 10531 detRunRow *detRunRowAlloc(const char *det_type )10531 detRunRow *detRunRowAlloc(const char *det_type, psS32 iteration) 10532 10532 { 10533 10533 detRunRow *object; … … 10537 10537 10538 10538 object->det_type = psStringCopy(det_type); 10539 object->iteration = iteration; 10539 10540 10540 10541 return object; … … 10562 10563 return false; 10563 10564 } 10565 if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, 0)) { 10566 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 10567 psFree(md); 10568 return false; 10569 } 10564 10570 10565 10571 status = psDBCreateTable(dbh, DETRUN_TABLE_NAME, md); … … 10575 10581 } 10576 10582 10577 bool detRunInsert(psDB * dbh, const char *det_type )10583 bool detRunInsert(psDB * dbh, const char *det_type, psS32 iteration) 10578 10584 { 10579 10585 psMetadata *md; … … 10586 10592 return false; 10587 10593 } 10594 if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, iteration)) { 10595 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 10596 psFree(md); 10597 return false; 10598 } 10588 10599 10589 10600 status = psDBInsertOneRow(dbh, DETRUN_TABLE_NAME, md); … … 10593 10604 } 10594 10605 10595 bool detRunPop(psDB *dbh, char **det_type )10606 bool detRunPop(psDB *dbh, char **det_type, psS32 *iteration) 10596 10607 { 10597 10608 psArray *rowSet; … … 10643 10654 return false; 10644 10655 } 10656 *iteration = psMetadataLookupS32(&status, row, "iteration"); 10657 if (!status) { 10658 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration"); 10659 psFree(row); 10660 return false; 10661 } 10645 10662 10646 10663 psFree(row); … … 10651 10668 bool detRunInsertObject(psDB *dbh, detRunRow *object) 10652 10669 { 10653 return detRunInsert(dbh, object->det_type );10670 return detRunInsert(dbh, object->det_type, object->iteration); 10654 10671 } 10655 10672 … … 10657 10674 { 10658 10675 char det_type[256]; 10659 10660 if (!detRunPop(dbh, (char **)&det_type)) { 10676 psS32 iteration; 10677 10678 if (!detRunPop(dbh, (char **)&det_type, &iteration)) { 10661 10679 psError(PS_ERR_UNKNOWN, false, "failed to pop a database row"); 10662 10680 return NULL; 10663 10681 } 10664 10682 10665 return detRunRowAlloc(det_type );10683 return detRunRowAlloc(det_type, iteration); 10666 10684 } 10667 10685 … … 10767 10785 return NULL; 10768 10786 } 10787 if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, object->iteration)) { 10788 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 10789 psFree(md); 10790 return NULL; 10791 } 10769 10792 10770 10793 return md; … … 10775 10798 bool status; 10776 10799 char *det_type; 10800 psS32 iteration; 10777 10801 10778 10802 det_type = psMetadataLookupPtr(&status, md, "det_type"); … … 10781 10805 return false; 10782 10806 } 10783 10784 return detRunRowAlloc(det_type); 10807 iteration = psMetadataLookupS32(&status, md, "iteration"); 10808 if (!status) { 10809 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item iteration"); 10810 return false; 10811 } 10812 10813 return detRunRowAlloc(det_type, iteration); 10785 10814 } 10786 10815 psArray *detRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
branches/jhoblitt/ippdb/src/ippdb.h
r7460 r7500 4208 4208 typedef struct { 4209 4209 char *det_type; 4210 psS32 iteration; 4210 4211 } detRunRow; 4211 4212 … … 4216 4217 4217 4218 detRunRow *detRunRowAlloc( 4218 const char *det_type 4219 const char *det_type, 4220 psS32 iteration 4219 4221 ); 4220 4222 … … 4246 4248 bool detRunInsert( 4247 4249 psDB *dbh, ///< Database handle 4248 const char *det_type 4250 const char *det_type, 4251 psS32 iteration 4249 4252 ); 4250 4253 … … 4256 4259 bool detRunPop( 4257 4260 psDB *dbh, ///< Database handle 4258 char **det_type 4261 char **det_type, 4262 psS32 *iteration 4259 4263 ); 4260 4264 -
branches/jhoblitt/ippdb/tests/alloc.c
r7460 r7500 880 880 detRunRow *object; 881 881 882 object = detRunRowAlloc("a string" );882 object = detRunRowAlloc("a string", -32 ); 883 883 884 884 if (!object) { … … 887 887 888 888 if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) { 889 psFree(object); 890 exit(EXIT_FAILURE); 891 } 892 if (!object->iteration == -32) { 889 893 psFree(object); 890 894 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/insert.c
r7460 r7500 343 343 } 344 344 345 if (!detRunInsert(dbh, "a string" )) {345 if (!detRunInsert(dbh, "a string", -32)) { 346 346 exit(EXIT_FAILURE); 347 347 } -
branches/jhoblitt/ippdb/tests/insertobject.c
r7460 r7500 498 498 } 499 499 500 object = detRunRowAlloc("a string" );500 object = detRunRowAlloc("a string", -32); 501 501 if (!object) { 502 502 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/metadatafromobject.c
r7460 r7500 1059 1059 bool status; 1060 1060 1061 object = detRunRowAlloc("a string" );1061 object = detRunRowAlloc("a string", -32); 1062 1062 if (!object) { 1063 1063 exit(EXIT_FAILURE); … … 1072 1072 1073 1073 if (strncmp(psMetadataLookupPtr(&status, md, "det_type"), "a string", MAX_STRING_LENGTH)) { 1074 psFree(md); 1075 exit(EXIT_FAILURE); 1076 } 1077 if (!psMetadataLookupS32(&status, md, "iteration") == -32) { 1074 1078 psFree(md); 1075 1079 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/objectfrommetadata.c
r7460 r7500 1581 1581 exit(EXIT_FAILURE); 1582 1582 } 1583 if (!psMetadataAddS32(md, PS_LIST_TAIL, "iteration", 0, NULL, -32)) { 1584 psFree(md); 1585 exit(EXIT_FAILURE); 1586 } 1583 1587 1584 1588 object = detRunObjectFromMetadata(md); … … 1591 1595 1592 1596 if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) { 1597 psFree(object); 1598 exit(EXIT_FAILURE); 1599 } 1600 if (!object->iteration == -32) { 1593 1601 psFree(object); 1594 1602 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/pop.c
r7460 r7500 484 484 psDB *dbh; 485 485 char det_type[256]; 486 487 dbh = psDBInit("localhost", "test", NULL, "test"); 488 if (!dbh) { 489 exit(EXIT_FAILURE); 490 } 491 492 if (!detRunPop(dbh, (char **)&det_type)) { 486 psS32 iteration; 487 488 dbh = psDBInit("localhost", "test", NULL, "test"); 489 if (!dbh) { 490 exit(EXIT_FAILURE); 491 } 492 493 if (!detRunPop(dbh, (char **)&det_type, &iteration)) { 493 494 exit(EXIT_FAILURE); 494 495 }
Note:
See TracChangeset
for help on using the changeset viewer.
