Changeset 10989 for trunk/ippdb/src/ippdb.c
- Timestamp:
- Jan 8, 2007, 4:08:31 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippdb/src/ippdb.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/src/ippdb.c
r10753 r10989 2800 2800 static void newExpRowFree(newExpRow *object); 2801 2801 2802 newExpRow *newExpRowAlloc(const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles )2802 newExpRow *newExpRowAlloc(const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles, psS16 fault) 2803 2803 { 2804 2804 newExpRow *_object; … … 2814 2814 _object->exp_type = psStringCopy(exp_type); 2815 2815 _object->imfiles = imfiles; 2816 _object->fault = fault; 2816 2817 2817 2818 return _object; … … 2866 2867 return false; 2867 2868 } 2869 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, "NOT NULL", 0)) { 2870 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 2871 psFree(md); 2872 return false; 2873 } 2868 2874 2869 2875 bool status = psDBCreateTable(dbh, NEWEXP_TABLE_NAME, md); … … 2879 2885 } 2880 2886 2881 bool newExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles )2887 bool newExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles, psS16 fault) 2882 2888 { 2883 2889 psMetadata *md = psMetadataAlloc(); … … 2914 2920 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, imfiles)) { 2915 2921 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles"); 2922 psFree(md); 2923 return false; 2924 } 2925 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, fault)) { 2926 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 2916 2927 psFree(md); 2917 2928 return false; … … 2940 2951 bool newExpInsertObject(psDB *dbh, newExpRow *object) 2941 2952 { 2942 return newExpInsert(dbh, object->exp_tag, object->exp_id, object->camera, object->telescope, object->dateobs, object->exp_type, object->imfiles );2953 return newExpInsert(dbh, object->exp_tag, object->exp_id, object->camera, object->telescope, object->dateobs, object->exp_type, object->imfiles, object->fault); 2943 2954 } 2944 2955 … … 3048 3059 return false; 3049 3060 } 3061 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, object->fault)) { 3062 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 3063 psFree(md); 3064 return false; 3065 } 3050 3066 3051 3067 … … 3092 3108 return false; 3093 3109 } 3094 3095 return newExpRowAlloc(exp_tag, exp_id, camera, telescope, dateobs, exp_type, imfiles); 3110 psS16 fault = psMetadataLookupS16(&status, md, "fault"); 3111 if (!status) { 3112 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fault"); 3113 return false; 3114 } 3115 3116 return newExpRowAlloc(exp_tag, exp_id, camera, telescope, dateobs, exp_type, imfiles, fault); 3096 3117 } 3097 3118 psArray *newExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 3205 3226 static void newImfileRowFree(newImfileRow *object); 3206 3227 3207 newImfileRow *newImfileRowAlloc(const char *exp_tag, const char *class, const char *class_id, const char *uri )3228 newImfileRow *newImfileRowAlloc(const char *exp_tag, const char *class, const char *class_id, const char *uri, psS16 fault) 3208 3229 { 3209 3230 newImfileRow *_object; … … 3216 3237 _object->class_id = psStringCopy(class_id); 3217 3238 _object->uri = psStringCopy(uri); 3239 _object->fault = fault; 3218 3240 3219 3241 return _object; … … 3251 3273 return false; 3252 3274 } 3275 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, "NOT NULL", 0)) { 3276 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 3277 psFree(md); 3278 return false; 3279 } 3253 3280 3254 3281 bool status = psDBCreateTable(dbh, NEWIMFILE_TABLE_NAME, md); … … 3264 3291 } 3265 3292 3266 bool newImfileInsert(psDB * dbh, const char *exp_tag, const char *class, const char *class_id, const char *uri )3293 bool newImfileInsert(psDB * dbh, const char *exp_tag, const char *class, const char *class_id, const char *uri, psS16 fault) 3267 3294 { 3268 3295 psMetadata *md = psMetadataAlloc(); … … 3284 3311 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 3285 3312 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 3313 psFree(md); 3314 return false; 3315 } 3316 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, fault)) { 3317 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 3286 3318 psFree(md); 3287 3319 return false; … … 3310 3342 bool newImfileInsertObject(psDB *dbh, newImfileRow *object) 3311 3343 { 3312 return newImfileInsert(dbh, object->exp_tag, object->class, object->class_id, object->uri );3344 return newImfileInsert(dbh, object->exp_tag, object->class, object->class_id, object->uri, object->fault); 3313 3345 } 3314 3346 … … 3403 3435 return false; 3404 3436 } 3437 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, object->fault)) { 3438 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); 3439 psFree(md); 3440 return false; 3441 } 3405 3442 3406 3443 … … 3432 3469 return false; 3433 3470 } 3434 3435 return newImfileRowAlloc(exp_tag, class, class_id, uri); 3471 psS16 fault = psMetadataLookupS16(&status, md, "fault"); 3472 if (!status) { 3473 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item fault"); 3474 return false; 3475 } 3476 3477 return newImfileRowAlloc(exp_tag, class, class_id, uri, fault); 3436 3478 } 3437 3479 psArray *newImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
Note:
See TracChangeset
for help on using the changeset viewer.
