Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: return a value of grn_rc type instead of void #3

Open
wants to merge 78 commits into
base: main
Choose a base branch
from

Conversation

komainu8
Copy link
Owner

Because grn_obj_unlink() may return GRN_INVALID_ARGUMENT when error occurs in this function.
Also, grn_obj_close() return a value of grn_rc.

abetomo and others added 30 commits September 15, 2024 10:40
groongaGH-1638

This is part of the task of replacing grn_bool with bool.
Not all of proc.c has been replaced. In this commit, only some of it was replaced.
groongaGH-1638

This is part of the task of replacing grn_bool with bool.
Not all of index_column.c has been replaced. In this commit, only some of it was replaced.
groongaGH-1638

This is part of the task of replacing grn_bool with bool.
…eader file (groonga#1954)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
… file (groonga#1958)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
macos-12 is deprecated.
Co-authored-by: takuya kodama <otegami@clear-code.com>
It seems that macOS has different floating point number precision than
Linux.
We'll drop support for GNU Autotools soon. So we don't want to
maintain this case.
This also fixes a build error on Alpine Linux 3.20.
groongaGH-1638

This is part of the task of replacing grn_bool with bool.
Not all of geo.c has been replaced. In this commit, only some of it was replaced.
…eader file (groonga#1964)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…roonga#1965)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…der file (groonga#1968)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…rmalize_options from grn_bool to bool

GitHub: groongaGH-1638

This is part of the task of replacing grn_bool with bool.
GitHub: groongaGH-1638

This is part of the task of replacing grn_bool with bool.
…ile (groonga#1971)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…roonga#1969)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…ile (groonga#1973)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…() reference to the header file (groonga#1974)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
kou and others added 25 commits October 4, 2024 18:29
RC must be treated as int16_t not int32_t or something.
…roonga#1983)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…groonga#1986)

GitHub: groonga#1817

Prepare to switch to documents automatically generated by Doxygen.
…roonga#1985)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…roonga#1988)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
Because there is a rpath issue in Rroonga.
Once resolved, we should enable mruby test on macos-latest.
…ile (groonga#1990)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…ile (groonga#1991)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…onga#1992)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
Generally, functions for release resource do nothing when NULL is
specified like "free(NULL)".

This changes API but this doesn't break backward compatibility.
Because no code exist that use the return value of `grn_obj_close()`
when we specify `grn_obj_close(ctx, NULL)` as below.

---

Following functions use the return value of `grn_obj_close()`.

```
./lib/com.c:  if (ctx == msg->ctx) { return grn_obj_close(ctx, obj); }
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  rc = grn_obj_close(ctx, obj);
./lib/db.c:  return grn_obj_close(ctx, obj); 
```

---

`grn_obj_close()` is used in `grn_msg_close()`.
However, the return value of `grn_msg_close()` uses no one.

```
% grep -r grn_msg_close ./**/*.c
./lib/com.c:grn_msg_close(grn_ctx *ctx, grn_obj *obj)
./lib/com.c:    grn_msg_close(ctx, msg);
./lib/com.c:    grn_msg_close(ctx, msg);
./src/grnslap.c:  grn_msg_close(ctx, msg);
./src/groonga.c:        grn_msg_close(&edge->ctx, msg);
./src/groonga.c:        grn_msg_close(ctx, msg);
./src/groonga.c:        grn_msg_close(&edge->ctx, obj);
./src/groonga.c:        grn_msg_close(ctx, obj);
./src/groonga.c:  grn_msg_close(ctx, (grn_obj *)msg);
./src/groonga.c:    grn_msg_close(ctx, msg);
./src/groonga.c:          grn_msg_close(ctx, msg);
./src/groonga.c:          grn_msg_close(ctx, msg);
./src/groonga.c:    grn_msg_close(ctx, msg);
./src/groonga.c:      grn_msg_close(ctx, msg);
```

---

`grn_obj_close()` is used in `grn_obj_remove_other()`.
`grn_obj_remove_other()` is used in `grn_obj_remove_internal()`.

`grn_obj_remove_internal()` is used as below.

```
./lib/db.c:      rc = grn_obj_remove_internal(ctx, target, flags);
./lib/db.c:      rc = grn_obj_remove_internal(ctx, column, flags);
./lib/db.c:        rc = grn_obj_remove_internal(ctx, obj, 0);
./lib/db.c:          rc = grn_obj_remove_internal(ctx, obj, 0);
./lib/db.c:          rc = grn_obj_remove_internal(ctx, obj, 0);
./lib/db.c:        rc = grn_obj_remove_internal(ctx, obj, 0);
./lib/db.c:          rc = grn_obj_remove_internal(ctx, object, flags);
./lib/db.c:          rc = grn_obj_remove_internal(ctx, object, flags);
./lib/db.c:      rc = grn_obj_remove_internal(ctx, obj, flags);
./lib/db.c:    rc = grn_obj_remove_internal(ctx, obj, flags);
./lib/db.c:      rc = grn_obj_remove_internal(ctx, obj, flags);
```

---

`grn_obj_remove_internal()` is used in `remove_index()`.
However, `grn_obj_remove_internal()` is not called when `target` is
`NULL` as below.

```c
    if (!target) { ... }     } else if (target->header.type == GRN_COLUMN_INDEX) {
      // TODO: multicolumn  MULTI_COLUMN_INDEXP
      rc = grn_obj_remove_internal(ctx, target, flags); }
```
So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in `remove_columns_raw()`
However, `grn_obj_remove_internal()` is not called when `column` is
`NULL` as below.

```c
    if (column) {
      rc = grn_obj_remove_internal(ctx, column, flags);
      if (rc != GRN_SUCCESS) {
        grn_obj_unlink(ctx, column);
        break;
      }
    } ...
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in
`grn_obj_remove_db_index_columns()`.
However, `grn_obj_remove_internal()` is not called when `obj` is `NULL`
as below.

```c
      if (obj && obj->header.type == GRN_COLUMN_INDEX) {
        rc = grn_obj_remove_internal(ctx, obj, 0);
        ...
      }
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in
`grn_obj_remove_db_reference_columns()`.
However, `grn_obj_remove_internal()` is not called when `obj` is `NULL`
as below.

```c
    while ((id = grn_table_cursor_next_inline(ctx, cur)) != GRN_ID_NIL) {
      grn_obj *obj = grn_ctx_at(ctx, id);
      grn_obj *range = NULL;

      if (!obj) {
        continue;
      }

...

        switch (range->header.type) {
        case GRN_TABLE_NO_KEY:
        case GRN_TABLE_HASH_KEY:
        case GRN_TABLE_PAT_KEY:
        case GRN_TABLE_DAT_KEY:
          rc = grn_obj_remove_internal(ctx, obj, 0);
          break;
        }
...
    }
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in
`grn_obj_remove_db_reference_tables()`.
However, `grn_obj_remove_internal()` is not called when `obj` is `NULL`
as below.

```c
    while ((id = grn_table_cursor_next_inline(ctx, cur)) != GRN_ID_NIL) {
      grn_obj *obj = grn_ctx_at(ctx, id);
      grn_obj *domain = NULL;

      if (!obj) {
        continue;
      }

...

        switch (domain->header.type) {
        case GRN_TABLE_NO_KEY:
        case GRN_TABLE_HASH_KEY:
        case GRN_TABLE_PAT_KEY:
        case GRN_TABLE_DAT_KEY:
          rc = grn_obj_remove_internal(ctx, obj, 0);
          break;
        }

...

    }
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in `grn_obj_remove_db_all_tables()`
However, `grn_obj_remove_internal()` is not called when `obj` is `NULL`
as below.

```c
    while ((id = grn_table_cursor_next_inline(ctx, cur)) != GRN_ID_NIL) {
      grn_obj *obj = grn_ctx_at(ctx, id);

      if (!obj) {
        continue;
      }

...

      switch (obj->header.type) {
      case GRN_TABLE_NO_KEY:
      case GRN_TABLE_HASH_KEY:
      case GRN_TABLE_PAT_KEY:
      case GRN_TABLE_DAT_KEY:
        rc = grn_obj_remove_internal(ctx, obj, 0);
        break;
      }

...

    }
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in `remove_reference_tables_raw()`.
However, `grn_obj_remove_internal()` is not called when `object` is
`NULL` as below.

```c
      object = grn_ctx_at(ctx, id);
      if (!object) {

        ...

      switch (object->header.type) {
      case GRN_TABLE_HASH_KEY:
      case GRN_TABLE_PAT_KEY:
      case GRN_TABLE_DAT_KEY:
        if (DB_OBJ(object)->id == table_id) {
          break;
        }

        if (object->header.domain == table_id) {
          rc = grn_obj_remove_internal(ctx, object, flags);
          is_removed = (grn_table_at(ctx, db, id) == GRN_ID_NIL);
        }
        break;

      ...

      case GRN_COLUMN_VAR_SIZE:
      case GRN_COLUMN_FIX_SIZE:
        if (object->header.domain == table_id) {
          break;
        }
        if (DB_OBJ(object)->range == table_id) {
          rc = grn_obj_remove_internal(ctx, object, flags);
          is_removed = (grn_table_at(ctx, db, id) == GRN_ID_NIL);
        }
        break;

      ...
    }
```

So, this changes API does not affect. 

---

`grn_obj_remove_internal()` is used in
`grn_ctx_remove_by_id_internal()`.
However, `grn_obj_remove_internal()` is not called when `obj` is `NULL`
as below.

```c
  if (obj) {
    grn_rc rc;
    if (is_top_level) {
      rc = grn_obj_remove_flags(ctx, obj, flags);
    } else {
      rc = grn_obj_remove_internal(ctx, obj, flags);
    }
    ...
  }
```

So, this changes API does not affect. 

---

`grn_obj_remove_flags()` is used as below.

```
./lib/db.c:  return grn_obj_remove_flags(ctx, obj, 0);
./lib/db.c:  return grn_obj_remove_flags(ctx, obj, GRN_OBJ_REMOVE_DEPENDENT);
./lib/db.c:    grn_rc rc = grn_obj_remove_flags(ctx, obj, flags);
./lib/db.c:      rc = grn_obj_remove_flags(ctx, obj, flags);
```

`grn_obj_remove_flags()` is used in `grn_ctx_remove_by_id_internal()`.
However, `grn_obj_remove_flags()` is not called when `obj` is `NULL` as
below.

```c
  if (obj) {
    grn_rc rc;
    if (is_top_level) {
      rc = grn_obj_remove_flags(ctx, obj, flags);
    } else {
      rc = grn_obj_remove_internal(ctx, obj, flags);
    }
    ...
  }
```

So, this changes API does not affect. 

---

`grn_obj_remove_flags()` is used in `grn_obj_remove_dependent()`.
However, the return value of `grn_obj_remove_dependent()` uses no one.

```
% grep -r grn_obj_remove_dependent ./**/*.c
./lib/db.c:grn_obj_remove_dependent(grn_ctx *ctx, grn_obj *obj)
```

---

`grn_obj_remove_flags()` is used in `grn_ctx_remove()`.
However, `grn_obj_remove_flags()` is not called when `obj` is `NULL` as
below.

```c
  grn_obj *obj = grn_ctx_get(ctx, name, name_size);
  if (obj) {
    grn_rc rc = grn_obj_remove_flags(ctx, obj, flags);
    if (rc == GRN_SUCCESS) {
      GRN_API_RETURN(rc);
    }
    if (!(flags & GRN_OBJ_REMOVE_ENSURE)) {
      GRN_API_RETURN(rc);
    }
  } ...
```

So, this changes API does not affect. 

---

`grn_obj_remove_flags()` is used in `grn_ctx_remove_by_id_internal()`
However, `grn_obj_remove_flags()` is not called when `obj` is `NULL` as
below.

```c
  grn_obj *obj = grn_ctx_at(ctx, id);
  if (obj) {
    grn_rc rc;
    if (is_top_level) {
      rc = grn_obj_remove_flags(ctx, obj, flags);
    } else {
      rc = grn_obj_remove_internal(ctx, obj, flags);
    }
```

So, this changes API does not affect.
grn_bulk_fin() may clear header.impl_flags in the future.
…file (groonga#1994)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…ile (groonga#1995)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
…der file (groonga#1997)

GitHub: groongaGH-1817

Prepare to switch to documents automatically generated by Doxygen.
Because grn_obj_unlink() may return GRN_INVALID_ARGUMENT when error
occurs in this function.
Also, grn_obj_close() return a value of grn_rc.
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants