@@ -44,7 +44,6 @@ namespace async_postgres::lua {
44
44
lua_protected_fn (query) {
45
45
lua->CheckType (1 , async_postgres::connection_meta);
46
46
lua->CheckType (2 , GLua::Type::String);
47
- lua->CheckType (3 , GLua::Type::Function);
48
47
49
48
auto state = lua_connection_state ();
50
49
if (state->query ) {
@@ -66,7 +65,6 @@ namespace async_postgres::lua {
66
65
lua->CheckType (1 , async_postgres::connection_meta);
67
66
lua->CheckType (2 , GLua::Type::String);
68
67
lua->CheckType (3 , GLua::Type::Table);
69
- lua->CheckType (4 , GLua::Type::Function);
70
68
71
69
auto state = lua_connection_state ();
72
70
if (state->query ) {
@@ -91,7 +89,6 @@ namespace async_postgres::lua {
91
89
lua->CheckType (1 , async_postgres::connection_meta);
92
90
lua->CheckType (2 , GLua::Type::String);
93
91
lua->CheckType (3 , GLua::Type::String);
94
- lua->CheckType (4 , GLua::Type::Function);
95
92
96
93
auto state = lua_connection_state ();
97
94
if (state->query ) {
@@ -114,7 +111,6 @@ namespace async_postgres::lua {
114
111
lua->CheckType (1 , async_postgres::connection_meta);
115
112
lua->CheckType (2 , GLua::Type::String);
116
113
lua->CheckType (3 , GLua::Type::Table);
117
- lua->CheckType (4 , GLua::Type::Function);
118
114
119
115
auto state = lua_connection_state ();
120
116
if (state->query ) {
@@ -138,7 +134,6 @@ namespace async_postgres::lua {
138
134
lua_protected_fn (describePrepared) {
139
135
lua->CheckType (1 , async_postgres::connection_meta);
140
136
lua->CheckType (2 , GLua::Type::String);
141
- lua->CheckType (3 , GLua::Type::Function);
142
137
143
138
auto state = lua_connection_state ();
144
139
if (state->query ) {
@@ -159,7 +154,6 @@ namespace async_postgres::lua {
159
154
lua_protected_fn (describePortal) {
160
155
lua->CheckType (1 , async_postgres::connection_meta);
161
156
lua->CheckType (2 , GLua::Type::String);
162
- lua->CheckType (3 , GLua::Type::Function);
163
157
164
158
auto state = lua_connection_state ();
165
159
if (state->query ) {
@@ -193,10 +187,11 @@ namespace async_postgres::lua {
193
187
194
188
lua_protected_fn (setNotifyCallback) {
195
189
lua->CheckType (1 , async_postgres::connection_meta);
196
- lua->CheckType (2 , GLua::Type::Function);
197
190
198
191
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
+ }
200
195
201
196
return 0 ;
202
197
}
@@ -205,6 +200,25 @@ namespace async_postgres::lua {
205
200
lua->CheckType (1 , async_postgres::connection_meta);
206
201
207
202
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
+
208
222
if (state->query ) {
209
223
auto & query = state->query .value ();
210
224
0 commit comments