Exemplo n.º 1
0
/*================================================
 * is_record_missing_data_entry - Check if record is 
 * orphaned in index (is in index, but lacks data)
 *==============================================*/
BOOLEAN
is_record_missing_data_entry (CNSTRING key)
{
	RECORD rec=0;
	if (!isrecord(BTR, str2rkey(key)))
		return FALSE;
	if ((rec = qkey_to_record(key))) {
		release_record(rec);
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 2
0
tbl_p table_project ( tbl_p t, const char *dest_name,
		      int num_fields, char *fields[] )
{
  schema_p s = t->sch;
  schema_p dest = make_sub_schema ( s, dest_name, num_fields, fields );
  if ( dest == NULL ) return NULL;

  record rec = new_record ( s ), rec_dest = new_record ( dest );

  set_tbl_position ( t, TBL_BEG );
  while ( get_record ( rec, s ) ) 
    {
      fill_sub_record ( rec_dest, dest, rec, s );
      put_record_info (DEBUG, rec_dest, dest);
      append_record ( rec_dest, dest );
    }

  release_record (rec, s);
  release_record (rec_dest, dest);

  return dest->tbl;
}
Exemplo n.º 3
0
void table_display ( tbl_p t )
{
  if (t == NULL) return;
  display_tbl_header (t);
  
  schema_p s = t->sch;
  record rec = new_record ( s );
  set_tbl_position ( t, TBL_BEG );
  while ( get_record (rec, s) )
    {
      display_record (rec, s);
    }
  put_msg (FORCE, "\n");

  release_record (rec, s);
}
Exemplo n.º 4
0
static void insert_row ()
{
  char tbl_name[30];
	
  fscanf (in_s, " into %s values (", tbl_name);
  put_msg(DEBUG, "table name: \"%s\".\n", tbl_name);
  schema_p sch = get_schema (tbl_name);
  if (!sch)
    {
      put_msg (ERROR, "Schema \"%s\" does not exist.\n", tbl_name);
      skip_line ();
      return;
    }
  /* put_schema_info (DEBUG, sch); */
  record rec = new_filled_record ( sch );

  append_record (rec, sch);
  release_record (rec, sch);
}
Exemplo n.º 5
0
/*=====================================
 * check_indi -- check indi record
 *  and record any records needing fixing
 *  in tofix list
 *===================================*/
static BOOLEAN
check_indi (CNSTRING key, RECORD rec)
{
    static char prevkey[MAXKEYWIDTH+1];
    CACHEEL icel1=0;
    RECORD recx=0;

    if (eqstr(key, prevkey)) {
        report_error(ERR_DUPINDI, _("Duplicate individual for %s"), key);
    }
    icel1 = indi_to_cacheel(rec);
    lock_cache(icel1);

    recx = get_record_for_cel(icel1);
    ASSERT(todo.pass == 1);
    process_indi(recx);

    unlock_cache(icel1);
    check_pointers(key, rec);
    append_indiseq_null(seq_indis, strsave(key), NULL, TRUE, TRUE);
    release_record(recx);
    return TRUE;
}
Exemplo n.º 6
0
/*==========================================================
 * add_indi_by_edit -- Add new person to database by editing
 * (with user interaction)
 * returns addref'd record
 *========================================================*/
RECORD
add_indi_by_edit (RFMT rfmt)
{
	FILE *fp;
	RECORD indi0=0;
	NODE indi=0;
	STRING str, msg;
	BOOLEAN emp;
	XLAT ttmi = transl_get_predefined_xlat(MEDIN);

	if (readonly) {
		message(_(qSronlya));
		return NULL;
	}

/* Create person template for user to edit */

	if (!(fp = fopen(editfile, LLWRITETEXT)))
		return NULL;
	prefix_file_for_edit(fp);

	/* prefer useroption in this db */
	if ((str = getlloptstr("INDIREC", NULL)))
		fprintf(fp, "%s\n", str);
	else { /* default */
		fprintf(fp, "0 INDI\n1 NAME Fname/Surname\n1 SEX MF\n");
		fprintf(fp, "1 BIRT\n  2 DATE\n  2 PLAC\n");
		fprintf(fp, "1 DEAT\n  2 DATE\n  2 PLAC\n1 SOUR\n");
	}

/* Have user edit new person record */

	fclose(fp);
	do_edit();
	while (TRUE) {
		INT cnt;
		if (indi0) {
			release_record(indi0);
			indi0=0;
		}
		indi0 = file_to_record(editfile, ttmi, &msg, &emp);
		if (!indi0) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			} 
			break;
		}
		indi = nztop(indi0);
		cnt = resolve_refn_links(indi);
		/* check validation & allow user to reedit if invalid */
		/* this is a showstopper, so alternative is to abort */
		if (!valid_indi_tree(indi, &msg, NULL)) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			}
			release_record(indi0);
			indi0 = NULL;
			break;
		}
		/* Allow user to reedit if desired if any refn links unresolved */
		/* this is not a showstopper, so alternative is to continue */
		if (cnt > 0) {
			char msgb[120];
			llstrncpyf(msgb, sizeof(msgb), uu8
				, get_unresolved_ref_error_string(cnt), cnt);
			if (ask_yes_or_no_msg(msgb, _(qSireditopt))) {
				write_indi_to_file_for_edit(indi, editfile, rfmt);
				do_edit();
				continue;
			}
		}
		break;
	}
	if (!indi0 || !ask_yes_or_no(_(qScfpadd))) {
		if (indi0) release_record(indi0);
		return NULL;
	}
	
	/* add the new record to the database */
	add_new_indi_to_db(indi0);

	msg_status(_(qSgdpadd), indi_to_name(nztop(indi0), 35));
	return indi0;
}
Exemplo n.º 7
0
tbl_p table_search (tbl_p t, char *attr, char *op, int val)
{
	schema_p 			s;
	field_desc_p 		f;
	int 				i;

	pager_profiler_reset();

	int (*pointer)(int, int);

	if (t == NULL) return NULL;

	s = t->sch;

	for ( f = s->first; f != NULL; f = f->next, i++)
		if ( strcmp (f->name, attr) == 0)
		{
			if ( f->type != INT_TYPE )
			{
				put_msg (ERROR, "\"%s\" is not an integer field.\n", attr);
				return NULL;
			}
			break;
		}

	if ( f == NULL ) return NULL;

	char tmp_name[30] = "tmp_tbl__";
	strcat (tmp_name, s->name);
	schema_p res_sch = copy_schema ( s, tmp_name );
	record rec = new_record ( s );

	if(strcmp(op, "<") == 0)
	{
		//printf("Less than search \n");
		pointer = &less_than;
	}
	else if(strcmp(op, "<=") == 0)
	{
		//printf("Less then or equal search \n");
		pointer = &less_than_equal;
	}
	else if(strcmp(op, ">") == 0)
	{
		//printf("Greater then search \n");
		pointer = &greater_then;
	}
	else if(strcmp(op, ">=") == 0)
	{
		//printf("Greater then or equal search \n");
		pointer = &greater_then_equal;
	}
	else if(strcmp(op, "!=") == 0)
	{
		//printf("Not equal search \n");
		pointer = &not_equal;
	}
	else
	{
		//printf("Equal search \n");
		pointer = &int_equal;
	}

	set_tbl_position ( t, TBL_BEG );
	while ( find_record_int_val(rec, s, f->offset, pointer, val) )
	{
		put_record_info (DEBUG, rec, s);
		append_record ( rec, res_sch );
	}

	release_record (rec, s);

	put_pager_profiler_info(INFO);

	return res_sch->tbl;
}