I’m testing GridDB Cloud with the C client. I insert a couple of rows into a container, but when I query them back, the row values sometimes come out as NULL (empty), even though I just inserted data.
Here’s a minimal example:
GSContainer *cont;
GSRow *row;
GSQuery *qry;
GSRowSet *rs;
// create row and insert
gsGetContainer(store, "sensor_data", &cont);
gsCreateRowByContainer(cont, &row);
gsSetRowFieldByString(row, 0, "sensor-01");
gsSetRowFieldByFloat(row, 1, 22.5f);
gsSetRowFieldByTimestamp(row, 2, gsCurrentTime());
gsPutRow(cont, NULL, row, NULL);
gsCloseRow(&row);
// query back
qry = gsQuery(cont, "SELECT *");
gsFetch(qry, &rs);
while (gsHasNextRow(rs)) {
GSRow *fetched;
gsNextRow(rs, &fetched);
const char *id;
float temp;
GSTimestamp ts;
gsGetRowFieldAsString(fetched, 0, &id);
gsGetRowFieldAsFloat(fetched, 1, &temp);
gsGetRowFieldAsTimestamp(fetched, 2, &ts);
printf("id=%s temp=%.2f ts=%lld\n", id, temp, (long long)ts);
gsCloseRow(&fetched);
}
I expected to get back the same row values:
sensor-0122.5timestamp
Sometimes id prints (null) and temp prints 0.00.
Am I handling gsNextRow and gsGetRowFieldAs… correctly? Do I need to commit/flush after gsPutRow, or is there something else in the C API that ensures the data is visible immediately after insert?
gsCloseRow(&fetched);and also moveGSRow *fetched;before the loop?