Thread: [GENERAL] BUG in Prepared transactions from C code using JSON

[GENERAL] BUG in Prepared transactions from C code using JSON

From
Арсен Арутюнян
Date:
i've got table with json field.

i'm trying to insert from C function some json data.
i'm using SPI_execute_plan function to do this.

json data prepared with StringInfo
simple example:

StringInfo Message = makeStringInfo();

appendStringInfoString(Message, "{\"Command\":227,\"Status\":2,\"JobId\":4"});
Datum Values[2];

Values[0] = Int32GetDatum(227);
Values[1] = CStringGetDatum(Message->data);

ret = SPI_execute_plan(PreparedTr, Values, NULL, false, 0);

if (ret > 0 && SPI_tuptable != NULL && SPI_processed){
///// Data inserted 
}after selection inserted data looks like 

 "Command":227,"Status":2,"JobId":4}

first { simboll is lost....

Arsen





--
Арсен Арутюнян