Dev-Owl commented on issue #5544: URL: https://github.com/apache/couchdb/issues/5544#issuecomment-2907671314
Disclaimer: I'm not good at reading Erlang and this is the first time I looked into the CouchDB code. I did run my checks with the help of Copilot to help me identify relevant parts. All my checks were made on the current main branch, I did not check other branches. I was unable to compile and debug the code. In short: I think it's save to call the db/_index endpoint via POST with the same index again, nothing will happen in the database because on how Erlang compares objects. The duplication check is more implicit than explicit in the code. The details: 1. The request is handled by `mango_httpd:handle_index_req` 2. `mango_httpd:handle_index_req` tries to load the current ddoc from the database 3. `mango_idx:add` is called that then calls (for JSON index) `mango_idx_view:add` 4. Due to how the data structure is created, the `mango_idx:add` returns the same object (for an existing) index as already loaded by `mango_httpd:handle_index_req` 5. The code in `mango_httpd:handle_index_req` returns with an `exists` and `mango_crud:insert` is not called -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
