Mod ndb requests and responses
[edit] HTTP Requests and Responses: mod_ndb
| Request | Action | Result | Response Code | Notes |
|---|---|---|---|---|
| Unsupported Method | Any | 405 | ||
| Any | Any | Not connected to cluster | 503 | |
| Any | Any | Configuration error -- schema or table not found; index does not exist or is misdefined | 500 | |
| Any | Any | Ndb->startTransaction() fails | 500 | |
| Any | Any | readTuple(), equal(), getValue(), etc. fails | 404 | |
| Any | Any | NdbTransaction::execute() misc. failure | 500 | |
| GET | Read data | Success | 200 OK | |
| GET | Read data | No rows returned from scan operation | 404 | |
| GET | If-None-Match | Cache hit on ETag | 302 | |
| GET | Read | No key columns found in query | 404 | |
| POST | Update a row | Success | 204 | |
| POST | Insert a row | Success | 204 | |
| POST | Insert a row | Duplicate key error | 409 | |
| PUT | Insert a row | Success | (PUT is not yet implemented) | Should be 200 or 201 |
| PUT | Insert a row | Duplicate key error | (PUT is not yet implemented) | ?? |
| DELETE | Delete a row | Success | 204 | |
| Subrequest | Read | Too many operations in one TX | 500 | |
| Subrequest | Any | tx has already been aborted | 500 |
[edit] Notes
[edit] POST, PUT, and inserting records
HTTP/1.1 says (in sec. 9.6, regarding PUT):
The fundamental difference between POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entitiy enclosed with the request – the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource.
It also says
If the Request-URI refers to an already existing resource, the enclosed entitiy SHOULD be considered as a modified version of the one residing on the origin server.
Here's some of what this means for mod_ndb:
- To insert a record using PUT, the pathinfo part of the URL must uniquely identify the record.
- i.e. the PathInfo must include all parts of the PrimaryKey.
- There should be no "duplicate key on insert" errors for that PK; rather, mod_ndb should treat such a PUT as a "replacement."
- However, that strategy would not eliminate "duplicate key on insert" errors altogether. You could still get a "duplicate key" error on some other (non-PK) unique index.
- If you have a record < pk=1, attr_a = 2 , attr_b =3 >, and you replace it with a PUT to /ndb/table/1, where the request body contains "attr_b=4", the result should be a new record where <pk =1, attr_a=NULL,attr_b=4>.
- If you PUT a record without specifying a value for a non-NULL column, the PUT request should fail. (!?)
- You can insert a record using a POST, but not if the URL uses PathInfo.