Exemple #1
0
/*!
  \brief Open select cursor

  \return DB_OK on success
  \return DB_FAILED on failure
 */
int db_d_open_select_cursor(void)
{
    dbCursor *cursor;
    int stat;
    dbToken token;
    dbString select;
    int mode;

    /* get the arg(s) */
    db_init_string(&select);
    DB_RECV_STRING(&select);
    DB_RECV_INT(&mode);

    /* create a cursor */
    cursor = (dbCursor *) db_malloc(sizeof(dbCursor));
    if (cursor == NULL)
	return db_get_error_code();
    token = db_new_token((dbAddress) cursor);
    if (token < 0)
	return db_get_error_code();
    db_init_cursor(cursor);

    /* call the procedure */
    stat = db_driver_open_select_cursor(&select, cursor, mode);
    db_free_string(&select);

    /* send the return code */
    if (stat != DB_OK) {
	DB_SEND_FAILURE();
	return DB_OK;
    }
    DB_SEND_SUCCESS();

    /* mark this as a readonly cursor */
    db_set_cursor_type_readonly(cursor);

    /* add this cursor to the cursors managed by the driver state */
    db__add_cursor_to_driver_state(cursor);

    /* results */
    DB_SEND_TOKEN(&token);
    DB_SEND_INT(cursor->type);
    DB_SEND_INT(cursor->mode);
    DB_SEND_TABLE_DEFINITION(cursor->table);
    return DB_OK;
}
Exemple #2
0
/*!
  \brief Set column name

  \param index pointer to dbIndex
  \param column_num column number
  \param name name to be set

  \return DB_OK on success
  \return DB_FAILED on error
*/
int db_set_index_column_name(dbIndex * index, int column_num, const char *name)
{
    if (column_num < 0 || column_num >= index->numColumns) {
	db_error(_("db_set_index_column_name(): invalid column number"));
	return db_get_error_code();
    }
    return db_set_string(&index->columnNames[column_num], name);
}
Exemple #3
0
/*!
  \brief Allocate index columns

  \param index pointer to dbIndex
  \param ncols number of columns to be allocated

  \return DB_OK
*/
int db_alloc_index_columns(dbIndex * index, int ncols)
{
    index->columnNames = db_alloc_string_array(ncols);
    if (index->columnNames == NULL)
	return db_get_error_code();
    index->numColumns = ncols;

    return DB_OK;
}
Exemple #4
0
int db__recv_index_array(dbIndex ** list, int *count)
{
    int i;

    DB_RECV_INT(count);

    *list = db_alloc_index_array(*count);
    if (*list == NULL)
	return db_get_error_code();

    for (i = 0; i < *count; i++) {
	DB_RECV_INDEX(&((*list)[i]));
    }

    return DB_OK;
}
Exemple #5
0
int db__recv_index(dbIndex * index)
{
    int i, ncols;

    db_init_index(index);
    DB_RECV_STRING(&index->indexName);
    DB_RECV_STRING(&index->tableName);
    DB_RECV_CHAR(&index->unique);

    DB_RECV_INT(&ncols);

    if (db_alloc_index_columns(index, ncols) != DB_OK)
	return db_get_error_code();

    for (i = 0; i < ncols; i++) {
	DB_RECV_STRING(&index->columnNames[i]);
    }

    return DB_OK;
}
Exemple #6
0
/*!
  \brief Receive table definition

  \param[out] table

  \return
*/
int db__recv_table_definition(dbTable ** table)
{
    int i, ncols;
    dbTable *t;

    DB_RECV_INT(&ncols);

    *table = t = db_alloc_table(ncols);
    if (t == NULL)
	return db_get_error_code();

    for (i = 0; i < t->numColumns; i++) {
	DB_RECV_COLUMN_DEFINITION(&t->columns[i]);
    }
    DB_RECV_STRING(&t->tableName);
    DB_RECV_STRING(&t->description);

    DB_RECV_INT(&t->priv_insert);
    DB_RECV_INT(&t->priv_delete);

    return DB_OK;
}