Skip to content

Conversation

@smari
Copy link
Contributor

@smari smari commented May 27, 2025

Add binary copy, prepared statements, and handling for JSON, JSONB and ENUM types.

Copy link
Owner

@rluba rluba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extend examples/example.jai to show how to use all the new functions (Prepared statements, binary copy, etc.) and add the new types as well (as a regression test)?

memcpy(be_value, *be_val, arg.type.runtime_size);
}
param_values[index] = be_value;
param_values[index] = be_value;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don’t reformat existing code without a good reason.

// }
if (result != newResult) {
// print("Connecting… %\n", result);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change should be reverted.

info := cast(*Type_Info_Integer) arg.type;
// @ToDo: implement unsigned ints
assert(info.signed, "Unsigned not yet supported");
//assert(info.signed, "Unsigned not yet supported");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you disable this?

bool_as_num := ifx arg.value_pointer.(*bool).* then cast(u8) 1 else cast(u8) 0;
be_value := alloc(1).(*u8);
network_val := hton(bool_as_num);
memcpy(be_value, *network_val, 1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you replace "pointer to constant" with "allocation for every bool"?


write_integer :: (col: int, name: string, info: *Type_Info, pointer: *void, col_type: Pq_Type, value: s64) -> bool {
if info.type != Type_Info_Tag.INTEGER {
if info.type != Type_Info_Tag.INTEGER && info.type != Type_Info_Tag.ENUM {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct! info gets cast to Type_Info_Integer below, which is not OK if it is actually a Type_Info_Enum. This would re-interpret the name pointer as the signed property!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants