arcapos / luapgsql

Lua binding for PostgreSQL
108 stars 24 forks source link

escapeBytea: use pushlstring #50

Closed daurnimator closed 6 years ago

daurnimator commented 6 years ago

Should use pushlstring to save a strlen.

Also, I'm curious why you return the length as a 2nd return at all?

mbalmer commented 6 years ago

Right. It should just pushlstring and leave out the second return, there is the length operator after all... Then I think the value returned as second return is wrong anyway, as per the libpq documentation it includes the trailing '\0'. So it should do lua_pushlstring(L, *p, to_length -1).

mbalmer commented 6 years ago

This is fixed in the head branch. Thanks for bringing it to my attention.