@@ -44,7 +44,6 @@ namespace async_postgres::lua {
4444 lua_protected_fn (query) {
4545 lua->CheckType (1 , async_postgres::connection_meta);
4646 lua->CheckType (2 , GLua::Type::String);
47- lua->CheckType (3 , GLua::Type::Function);
4847
4948 auto state = lua_connection_state ();
5049 if (state->query ) {
@@ -66,7 +65,6 @@ namespace async_postgres::lua {
6665 lua->CheckType (1 , async_postgres::connection_meta);
6766 lua->CheckType (2 , GLua::Type::String);
6867 lua->CheckType (3 , GLua::Type::Table);
69- lua->CheckType (4 , GLua::Type::Function);
7068
7169 auto state = lua_connection_state ();
7270 if (state->query ) {
@@ -91,7 +89,6 @@ namespace async_postgres::lua {
9189 lua->CheckType (1 , async_postgres::connection_meta);
9290 lua->CheckType (2 , GLua::Type::String);
9391 lua->CheckType (3 , GLua::Type::String);
94- lua->CheckType (4 , GLua::Type::Function);
9592
9693 auto state = lua_connection_state ();
9794 if (state->query ) {
@@ -114,7 +111,6 @@ namespace async_postgres::lua {
114111 lua->CheckType (1 , async_postgres::connection_meta);
115112 lua->CheckType (2 , GLua::Type::String);
116113 lua->CheckType (3 , GLua::Type::Table);
117- lua->CheckType (4 , GLua::Type::Function);
118114
119115 auto state = lua_connection_state ();
120116 if (state->query ) {
@@ -138,7 +134,6 @@ namespace async_postgres::lua {
138134 lua_protected_fn (describePrepared) {
139135 lua->CheckType (1 , async_postgres::connection_meta);
140136 lua->CheckType (2 , GLua::Type::String);
141- lua->CheckType (3 , GLua::Type::Function);
142137
143138 auto state = lua_connection_state ();
144139 if (state->query ) {
@@ -159,7 +154,6 @@ namespace async_postgres::lua {
159154 lua_protected_fn (describePortal) {
160155 lua->CheckType (1 , async_postgres::connection_meta);
161156 lua->CheckType (2 , GLua::Type::String);
162- lua->CheckType (3 , GLua::Type::Function);
163157
164158 auto state = lua_connection_state ();
165159 if (state->query ) {
@@ -193,10 +187,11 @@ namespace async_postgres::lua {
193187
194188 lua_protected_fn (setNotifyCallback) {
195189 lua->CheckType (1 , async_postgres::connection_meta);
196- lua->CheckType (2 , GLua::Type::Function);
197190
198191 auto state = lua_connection_state ();
199- state->on_notify = GLua::AutoReference (lua, 2 );
192+ if (lua->IsType (2 , GLua::Type::Function)) {
193+ state->on_notify = GLua::AutoReference (lua, 2 );
194+ }
200195
201196 return 0 ;
202197 }
@@ -205,6 +200,25 @@ namespace async_postgres::lua {
205200 lua->CheckType (1 , async_postgres::connection_meta);
206201
207202 auto state = lua_connection_state ();
203+ if (state->reset_event ) {
204+ auto & event = state->reset_event .value ();
205+ while (state->reset_event .has_value () &&
206+ &event == &state->reset_event .value ()) {
207+ bool write =
208+ state->reset_event ->status == PGRES_POLLING_WRITING;
209+ bool read = state->reset_event ->status == PGRES_POLLING_READING;
210+ if (!write && !read) {
211+ break ;
212+ }
213+
214+ wait_for_socket (state->conn .get (), write, read);
215+ process_reset (lua, state);
216+ }
217+
218+ lua->PushBool (1 );
219+ return 1 ;
220+ }
221+
208222 if (state->query ) {
209223 auto & query = state->query .value ();
210224
0 commit comments