Skip to content

Commit

Permalink
Fix get_returning_data (no expected result)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkgrgis committed Dec 28, 2024
1 parent b697b8b commit 05f387d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
19 changes: 5 additions & 14 deletions sqlite_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2897,33 +2897,24 @@ get_returning_data(ForeignScanState *node)
}
else
{
TupleDesc tupleDescriptor = tupleSlot->tts_tupleDescriptor;
AttInMetadata *attinmeta = TupleDescGetAttInMetadata(tupleDescriptor);

/*
* On error, be sure to release the PGresult on the way out. Callers
* do not have PG_TRY blocks to ensure this happens.
*/
PG_TRY();
{
TupleDesc tupleDescriptor = tupleSlot->tts_tupleDescriptor;

make_tuple_from_result_row(dmstate->stmt,
tupleDescriptor,
dmstate->retrieved_attrs,
tupleSlot->tts_values,
tupleSlot->tts_isnull,
dmstate->rel,
dmstate->attinmeta,
attinmeta,
node);
// ExecStoreVirtualTuple(tupleSlot);
/*HeapTuple newtup;
newtup = make_tuple_from_result_row(dmstate->result,
dmstate->next_tuple,
dmstate->rel,
dmstate->attinmeta,
dmstate->retrieved_attrs,
node,
dmstate->temp_cxt);
ExecStoreHeapTuple(newtup, slot, false);
*/
}
PG_CATCH();
{
Expand Down
22 changes: 14 additions & 8 deletions sqlite_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ pg_column_void_text_error()
}

/*
* convert_sqlite_to_pg: Convert Sqlite data into PostgreSQL's compatible data types
* convert_sqlite_to_pg:
* Convert SQLite data as sqlite3_value into PostgreSQL's compatible Datum
*/
NullableDatum
sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *attinmeta, AttrNumber attnum, int sqlite_value_affinity, int AffinityBehaviourFlags)
sqlite_convert_to_pg(Form_pg_attribute att,
sqlite3_value * val,
AttInMetadata *attinmeta,
AttrNumber attnum,
int sqlite_value_affinity,
int AffinityBehaviourFlags)
{
Oid pgtyp = att->atttypid;
Datum value_datum = 0;
Expand Down Expand Up @@ -114,7 +120,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *
break;
}
case SQLITE_BLOB: /* <-- proper and recommended SQLite affinity of value for pgtyp */
case SQLITE3_TEXT: /* threated as UTF-8 text BLOB */
case SQLITE3_TEXT: /* treated as UTF-8 text BLOB */
{
value_datum = (Datum) palloc0(value_byte_size_blob_or_utf8 + VARHDRSZ);
memcpy(VARDATA(value_datum), sqlite3_value_blob(val), value_byte_size_blob_or_utf8);
Expand Down Expand Up @@ -375,6 +381,10 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *
sqlite_value_to_pg_error();
break;
}
/*
* SQLite UUID output always normalized to blob.
* In sqlite_data_norm.c there is special additional C function.
*/
case SQLITE_BLOB: /* <-- proper and recommended SQLite affinity of value for pgtyp */
{
if (value_byte_size_blob_or_utf8 != UUID_LEN)
Expand All @@ -383,7 +393,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *
errmsg("PostgreSQL uuid data type allows only %d bytes SQLite blob value", UUID_LEN)));
break;
}
else
else
{
const unsigned char * sqlite_blob = 0;
pg_uuid_t *retval = (pg_uuid_t *) palloc0(sizeof(pg_uuid_t));
Expand All @@ -394,10 +404,6 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *
break;
}
}
/*
* SQLite UUID output always normalized to blob.
* In sqlite_data_norm.c there is special additional C function.
*/
case SQLITE3_TEXT:
{
if (value_byte_size_blob_or_utf8)
Expand Down

0 comments on commit 05f387d

Please sign in to comment.