Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4057529
CLIENT-2383
DomPeliniAerospike Jan 8, 2024
1c7d6c8
Moved logic from conversions.c to individual functions
DomPeliniAerospike Feb 5, 2024
0afea08
Fixed compiler warning
DomPeliniAerospike Feb 5, 2024
2f83de6
Ran precommit lint
DomPeliniAerospike Feb 5, 2024
ca5e460
Merge branch 'dev' into CLIENT-2383
DomPeliniAerospike Nov 14, 2025
8475d8e
Fixed compile issue
DomPeliniAerospike Nov 14, 2025
9be3325
Update sec_index.c
DomPeliniAerospike Nov 14, 2025
a6cd67b
Fixed linting issue
DomPeliniAerospike Nov 14, 2025
1d76db0
Fixed doc build error
DomPeliniAerospike Nov 17, 2025
dc2df7b
Added test coverage
DomPeliniAerospike Nov 18, 2025
1012a31
Update where.c
DomPeliniAerospike Nov 18, 2025
c1bd2fb
Fixed linting issue
DomPeliniAerospike Nov 18, 2025
7fd63be
Update test_query.py
DomPeliniAerospike Nov 18, 2025
1ccc8e6
FF CLIENT-2383 to Dev (#867)
DomPeliniAerospike Nov 18, 2025
e58d71a
Update test_query.py
DomPeliniAerospike Nov 18, 2025
ccf0c3f
Merge branch 'CLIENT-2383' of https://github.com/aerospike/aerospike-…
DomPeliniAerospike Nov 18, 2025
957d1dc
Merge remote-tracking branch 'origin/dev' into CLIENT-2383
juliannguyen4 Jan 2, 2026
01bb57f
Merge remote-tracking branch 'origin/dev' into CLIENT-2383
juliannguyen4 Jan 2, 2026
ee34980
Merge remote-tracking branch 'origin/dev' into CLIENT-2383
juliannguyen4 Jan 13, 2026
1b2c9cd
Add error handling
juliannguyen4 Jan 13, 2026
271e721
Just make breaking change where index_cdt_create's ctx parameter can …
juliannguyen4 Jan 13, 2026
4511081
get_cdt_ctx() already checks if python ctx is a list or not after ret…
juliannguyen4 Jan 13, 2026
e9ee8dd
Cleanup and add error handling
juliannguyen4 Jan 13, 2026
adc81ca
We are no longer allowing the old behavior of passing a dict to ctx p…
juliannguyen4 Jan 13, 2026
98b055f
dont need to test exception messages since those aren't considered br…
juliannguyen4 Jan 13, 2026
7e63922
Remove since we no longer allow query.where() to take in a dictionary…
juliannguyen4 Jan 13, 2026
cb019b6
rm unused var from context manager
juliannguyen4 Jan 13, 2026
a235322
Fix test regressions. If createIndexWithDataAndCollectionType fails, …
juliannguyen4 Jan 13, 2026
e6719db
Not a helper
juliannguyen4 Jan 13, 2026
c53c5b2
fix dup var declaration
juliannguyen4 Jan 13, 2026
5440425
fix regression
juliannguyen4 Jan 13, 2026
c80f523
Just combine cleanup steps into one codepath to improve code coverage…
juliannguyen4 Jan 13, 2026
1bc07cd
Error message not set here. Was test coverage missing before?
juliannguyen4 Jan 13, 2026
286c943
Fix potentially freeing uninitialized cdt_ctx
juliannguyen4 Jan 13, 2026
d55f776
Add test case to cover invalid ctx
juliannguyen4 Jan 14, 2026
e41ce66
improve comment
juliannguyen4 Jan 14, 2026
f41dc11
This should slightly improve performance when invalid input types are…
juliannguyen4 Jan 14, 2026
6fc83a5
Forgot to add test case where None passed as ctx arg
juliannguyen4 Jan 14, 2026
1dc3c60
fix test...
juliannguyen4 Jan 14, 2026
ed7ba8a
Add test case where we explicitly pass in None to query.where
juliannguyen4 Jan 15, 2026
ffdbd22
clean up dead code.
juliannguyen4 Jan 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ PyObject *AerospikeClient_Index_Expr_Create(AerospikeClient *self,
/**
* Create secondary cdt index
*
* client.index_cdt_create(namespace, set, bin, index_name, ctx, policy)
* client.index_cdt_create(namespace, set, bin, index_type, index_datatype, index_name, ctx, policy)
*
*/
PyObject *AerospikeClient_Index_Cdt_Create(AerospikeClient *self,
Expand Down
1 change: 0 additions & 1 deletion src/include/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void raise_exception(as_error *err);
void raise_exception_base(as_error *err, PyObject *py_key, PyObject *py_bin,
PyObject *py_module, PyObject *py_func,
PyObject *py_name);
PyObject *raise_exception_old(as_error *err);
void remove_exception(as_error *err);
void set_aerospike_exc_attrs_using_tuple_of_attrs(PyObject *py_exc,
PyObject *py_tuple);
33 changes: 25 additions & 8 deletions src/main/client/sec_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ PyObject *AerospikeClient_Index_Expr_Create(AerospikeClient *self,
data_type, NULL, expr);
}

#define CTX_PARSE_ERROR_MESSAGE "Unable to parse ctx"

/**
*******************************************************************************************************
* Creates a cdt index for a bin in the Aerospike DB.
Expand Down Expand Up @@ -219,9 +221,12 @@ PyObject *AerospikeClient_Index_Cdt_Create(AerospikeClient *self,
PyObject *py_indextype = NULL;
PyObject *py_datatype = NULL;
PyObject *py_name = NULL;

PyObject *py_ctx = NULL;
as_cdt_ctx ctx;
bool ctx_in_use = false;
PyObject *py_ctx_dict = NULL;

PyObject *py_obj = NULL;
as_index_datatype data_type;
as_index_type index_type;
Expand All @@ -247,31 +252,43 @@ PyObject *AerospikeClient_Index_Cdt_Create(AerospikeClient *self,
goto CLEANUP;
}

// TODO: this should be refactored by using a new helper function to parse a ctx list instead of get_cdt_ctx()
// which only parses a dictionary containing a ctx list
py_ctx_dict = PyDict_New();
if (!py_ctx_dict) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT, CTX_PARSE_ERROR_MESSAGE);
goto CLEANUP;
}
int retval = PyDict_SetItemString(py_ctx_dict, "ctx", py_ctx);
if (retval == -1) {
Py_DECREF(py_ctx_dict);
as_error_update(&err, AEROSPIKE_ERR_CLIENT, CTX_PARSE_ERROR_MESSAGE);
goto CLEANUP;
}

as_static_pool static_pool;
memset(&static_pool, 0, sizeof(static_pool));

if (get_cdt_ctx(self, &err, &ctx, py_ctx, &ctx_in_use, &static_pool,
if (get_cdt_ctx(self, &err, &ctx, py_ctx_dict, &ctx_in_use, &static_pool,
SERIALIZER_PYTHON) != AEROSPIKE_OK) {
goto CLEANUP;
}
if (!ctx_in_use) {
goto CLEANUP;
}

// Even if this call fails, it will raise its own exception
// and the err object here will not be set. We don't raise an exception twice
py_obj = createIndexWithDataAndCollectionType(
self, py_policy, py_ns, py_set, py_bin, py_name, index_type, data_type,
&ctx, NULL);

as_cdt_ctx_destroy(&ctx);

return py_obj;

CLEANUP:
if (py_obj == NULL) {
Py_XDECREF(py_ctx_dict);

if (err.code != AEROSPIKE_OK) {
raise_exception_base(&err, Py_None, Py_None, Py_None, Py_None, py_name);
return NULL;
}

return py_obj;
}

Expand Down
45 changes: 37 additions & 8 deletions src/main/query/where.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ int64_t pyobject_to_int64(PyObject *py_obj)
}
}

#define CTX_PARSE_ERROR_MESSAGE "Unable to parse ctx"

// py_bin, py_val1, pyval2 are guaranteed to be non-NULL
// The rest of the PyObject parameters can be NULL and are optional.
// 3 cases for these optional parameters:
Expand All @@ -58,18 +60,41 @@ static int AerospikeQuery_Where_Add(AerospikeQuery *self, PyObject *py_ctx,
{
as_error err;
as_error_init(&err);

// TODO: does static pool go out of scope?
as_static_pool static_pool;
memset(&static_pool, 0, sizeof(static_pool));

as_cdt_ctx *pctx = NULL;
bool ctx_in_use = false;
// Used to pass ctx into get_cdt_ctx() helper
// Declared here to make cleanup logic simpler
PyObject *py_ctx_dict = NULL;

// Ctx is an optional parameter
if (py_ctx && !Py_IsNone(py_ctx)) {
// If user wanted to pass in an actual ctx

// Glue code to pass into get_cdt_ctx()
py_ctx_dict = PyDict_New();
if (!py_ctx_dict) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
CTX_PARSE_ERROR_MESSAGE);
goto error;
}
int retval = PyDict_SetItemString(py_ctx_dict, "ctx", py_ctx);
if (retval == -1) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
CTX_PARSE_ERROR_MESSAGE);
goto CLEANUP_PY_CTX_DICT_ON_ERROR;
}

if (py_ctx) {
// TODO: does static pool go out of scope?
as_static_pool static_pool;
memset(&static_pool, 0, sizeof(static_pool));
pctx = cf_malloc(sizeof(as_cdt_ctx));
memset(pctx, 0, sizeof(as_cdt_ctx));
if (get_cdt_ctx(self->client, &err, pctx, py_ctx, &ctx_in_use,

if (get_cdt_ctx(self->client, &err, pctx, py_ctx_dict, &ctx_in_use,
&static_pool, SERIALIZER_PYTHON) != AEROSPIKE_OK) {
return err.code;
goto CLEANUP_AS_CTX_ON_ERROR;
}
}

Expand All @@ -78,7 +103,7 @@ static int AerospikeQuery_Where_Add(AerospikeQuery *self, PyObject *py_ctx,
as_status status = as_exp_new_from_pyobject(self->client, py_expr,
&exp_list, &err, true);
if (status != AEROSPIKE_OK) {
goto CLEANUP_CTX_ON_ERROR;
goto CLEANUP_AS_CTX_ON_ERROR;
}
}

Expand Down Expand Up @@ -286,7 +311,7 @@ static int AerospikeQuery_Where_Add(AerospikeQuery *self, PyObject *py_ctx,
as_exp_destroy(exp_list);
}

CLEANUP_CTX_ON_ERROR:
CLEANUP_AS_CTX_ON_ERROR:
// The ctx ends up not being used by as_query
if (ctx_in_use) {
as_cdt_ctx_destroy(pctx);
Expand All @@ -295,6 +320,10 @@ static int AerospikeQuery_Where_Add(AerospikeQuery *self, PyObject *py_ctx,
cf_free(pctx);
}

CLEANUP_PY_CTX_DICT_ON_ERROR:
Py_XDECREF(py_ctx_dict);

error:
return 1;
}

Expand Down
7 changes: 4 additions & 3 deletions test/new_tests/test_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ def get_new_connection(add_config=None):
if res is not None:
break
res = res.split(".")
# major_ver = res[0]
# minor_ver = res[1]
# print("major_ver:", major_ver, "minor_ver:", minor_ver)
TestBaseClass.major_ver = res[0]
TestBaseClass.minor_ver = res[1]
# print("major_ver:", TestBaseClass.major_ver, "minor_ver:", TestBaseClass.minor_ver)

return client

@staticmethod
Expand Down
Loading
Loading