supabase / pg_net

A PostgreSQL extension that enables asynchronous (non-blocking) HTTP/HTTPS requests with SQL
https://supabase.github.io/pg_net
Apache License 2.0
236 stars 18 forks source link

Help libuv #52

Closed steve-chavez closed 3 years ago

steve-chavez commented 3 years ago

Related to https://github.com/supabase/pg_net/pull/50

steve-chavez commented 3 years ago

@soedirgo This now compiles with pg <= 13. I still get a lot of warnings but fixing that will require a non-trivial rearrangement that you might want to do yourself

src/worker.c:64:6: warning: no previous prototype for 'destroy_curl_ctx_cb' [-Wmissing-prototypes]
   64 | void destroy_curl_ctx_cb(uv_handle_t *handle) {
      |      ^~~~~~~~~~~~~~~~~~~
src/worker.c:89:6: warning: no previous prototype for 'destroy_curl_ctx' [-Wmissing-prototypes]
   89 | void destroy_curl_ctx(struct curl_context *ctx) {
      |      ^~~~~~~~~~~~~~~~
src/worker.c:95:6: warning: no previous prototype for 'is_extension_loaded' [-Wmissing-prototypes]
   95 | bool is_extension_loaded(void) {
      |      ^~~~~~~~~~~~~~~~~~~
src/worker.c: In function 'is_extension_loaded':
src/worker.c:97:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   97 |     Oid extension_oid = get_extension_oid("pg_net", true);
      |     ^~~
src/worker.c: At top level:
src/worker.c:172:6: warning: no previous prototype for 'submit_request' [-Wmissing-prototypes]
  172 | void submit_request(int64 id, char *method, char *url,
      |      ^~~~~~~~~~~~~~
src/worker.c: In function 'submit_request':
src/worker.c:178:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  178 |     struct curl_context *ctx = (struct curl_context *)malloc(sizeof(*ctx));
      |     ^~~~~~
src/worker.c: At top level:
src/worker.c:218:6: warning: no previous prototype for 'check_curl_multi_info' [-Wmissing-prototypes]
  218 | void check_curl_multi_info(void) {
      |      ^~~~~~~~~~~~~~~~~~~~~
src/worker.c: In function 'check_curl_multi_info':
src/worker.c:221:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  221 |     struct curl_context *ctx;
      |     ^~~~~~
src/worker.c:233:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  233 |             int rc = msg->data.result;
      |             ^~~
src/worker.c: At top level:
src/worker.c:328:6: warning: no previous prototype for 'poll_cb' [-Wmissing-prototypes]
  328 | void poll_cb(uv_poll_t *req, int status, int events) {
      |      ^~~~~~~
src/worker.c: In function 'poll_cb':
src/worker.c:333:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  333 |     int running_handles;
      |     ^~~
src/worker.c:342:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  342 |     struct curl_context *context = (struct curl_context *)req;
      |     ^~~~~~
src/worker.c: At top level:
src/worker.c:348:5: warning: no previous prototype for 'socket_cb' [-Wmissing-prototypes]
  348 | int socket_cb(CURL *easy, curl_socket_t s, int what, void *userp,
      |     ^~~~~~~~~
src/worker.c: In function 'socket_cb':
src/worker.c:352:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  352 |     struct curl_context *ctx;
      |     ^~~~~~
src/worker.c:357:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  357 |             int r = uv_poll_init_socket(loop, &ctx->poll, s);
      |             ^~~
src/worker.c: At top level:
src/worker.c:386:6: warning: no previous prototype for 'on_timeout' [-Wmissing-prototypes]
  386 | void on_timeout(uv_timer_t *req) {
      |      ^~~~~~~~~~
src/worker.c:393:6: warning: no previous prototype for 'timer_cb' [-Wmissing-prototypes]
  393 | void timer_cb(CURLM *cm, long timeout_ms, void *userp) {
      |      ^~~~~~~~
src/worker.c:402:6: warning: no previous prototype for 'idle_cb' [-Wmissing-prototypes]
  402 | void idle_cb(uv_idle_t *idle) {
      |      ^~~~~~~
src/worker.c: In function 'idle_cb':
src/worker.c:439:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  439 |         int rc = SPI_execute_with_args(sql, argCount, argTypes, argValues, NULL,
      |         ^~~
src/worker.c:480:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  480 |             char *url = (char *)malloc(strlen(url_tmp) + 1);
      |             ^~~~
src/worker.c:483:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  483 |             struct curl_slist *headers = NULL;
      |             ^~~~~~
src/worker.c:493:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  493 |             char *body = NULL;
      |             ^~~~
src/worker.c:514:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  514 |             char *sql = "INSERT INTO net._http_response(id) VALUES ($1)";
      |             ^~~~
src/worker.c: In function 'worker_main':
src/worker.c:545:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  545 |     int err = curl_global_init(CURL_GLOBAL_ALL);
      |     ^~~
At top level:
src/worker.c:109:15: warning: 'header_cb' defined but not used [-Wunused-function]
  109 | static size_t header_cb(void *contents, size_t size, size_t nmemb,
      |               ^~~~~~~~~
src/worker.c:102:15: warning: 'body_cb' defined but not used [-Wunused-function]
  102 | static size_t body_cb(void *contents, size_t size, size_t nmemb, void *userp) {
      |               ^~~~~~~
src/worker.c:64:6: warning: no previous prototype for 'destroy_curl_ctx_cb' [-Wmissing-prototypes]
   64 | void destroy_curl_ctx_cb(uv_handle_t *handle) {
      |      ^~~~~~~~~~~~~~~~~~~
src/worker.c:89:6: warning: no previous prototype for 'destroy_curl_ctx' [-Wmissing-prototypes]
   89 | void destroy_curl_ctx(struct curl_context *ctx) {
      |      ^~~~~~~~~~~~~~~~
src/worker.c:95:6: warning: no previous prototype for 'is_extension_loaded' [-Wmissing-prototypes]
   95 | bool is_extension_loaded(void) {
      |      ^~~~~~~~~~~~~~~~~~~
src/worker.c: In function 'is_extension_loaded':
src/worker.c:97:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   97 |     Oid extension_oid = get_extension_oid("pg_net", true);
      |     ^~~
src/worker.c: At top level:
src/worker.c:172:6: warning: no previous prototype for 'submit_request' [-Wmissing-prototypes]
  172 | void submit_request(int64 id, char *method, char *url,
      |      ^~~~~~~~~~~~~~
src/worker.c: In function 'submit_request':
src/worker.c:178:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  178 |     struct curl_context *ctx = (struct curl_context *)malloc(sizeof(*ctx));
      |     ^~~~~~
src/worker.c: At top level:
src/worker.c:218:6: warning: no previous prototype for 'check_curl_multi_info' [-Wmissing-prototypes]
  218 | void check_curl_multi_info(void) {
      |      ^~~~~~~~~~~~~~~~~~~~~
src/worker.c: In function 'check_curl_multi_info':
src/worker.c:221:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  221 |     struct curl_context *ctx;
      |     ^~~~~~
src/worker.c:233:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  233 |             int rc = msg->data.result;
      |             ^~~
src/worker.c: At top level:
src/worker.c:328:6: warning: no previous prototype for 'poll_cb' [-Wmissing-prototypes]
  328 | void poll_cb(uv_poll_t *req, int status, int events) {
      |      ^~~~~~~
src/worker.c: In function 'poll_cb':
src/worker.c:333:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  333 |     int running_handles;
      |     ^~~
src/worker.c:342:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  342 |     struct curl_context *context = (struct curl_context *)req;
      |     ^~~~~~
src/worker.c: At top level:
src/worker.c:348:5: warning: no previous prototype for 'socket_cb' [-Wmissing-prototypes]
  348 | int socket_cb(CURL *easy, curl_socket_t s, int what, void *userp,
      |     ^~~~~~~~~
src/worker.c: In function 'socket_cb':
src/worker.c:352:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  352 |     struct curl_context *ctx;
      |     ^~~~~~
src/worker.c:357:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  357 |             int r = uv_poll_init_socket(loop, &ctx->poll, s);
      |             ^~~
src/worker.c: At top level:
src/worker.c:386:6: warning: no previous prototype for 'on_timeout' [-Wmissing-prototypes]
  386 | void on_timeout(uv_timer_t *req) {
      |      ^~~~~~~~~~
src/worker.c:393:6: warning: no previous prototype for 'timer_cb' [-Wmissing-prototypes]
  393 | void timer_cb(CURLM *cm, long timeout_ms, void *userp) {
      |      ^~~~~~~~
src/worker.c:402:6: warning: no previous prototype for 'idle_cb' [-Wmissing-prototypes]
  402 | void idle_cb(uv_idle_t *idle) {
      |      ^~~~~~~
src/worker.c: In function 'idle_cb':
src/worker.c:439:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  439 |         int rc = SPI_execute_with_args(sql, argCount, argTypes, argValues, NULL,
      |         ^~~
src/worker.c:480:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  480 |             char *url = (char *)malloc(strlen(url_tmp) + 1);
      |             ^~~~
src/worker.c:483:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  483 |             struct curl_slist *headers = NULL;
      |             ^~~~~~
src/worker.c:493:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  493 |             char *body = NULL;
      |             ^~~~
src/worker.c:514:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  514 |             char *sql = "INSERT INTO net._http_response(id) VALUES ($1)";
      |             ^~~~
src/worker.c: In function 'worker_main':
src/worker.c:545:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  545 |     int err = curl_global_init(CURL_GLOBAL_ALL);
      |     ^~~
At top level:
src/worker.c:109:15: warning: 'header_cb' defined but not used [-Wunused-function]
  109 | static size_t header_cb(void *contents, size_t size, size_t nmemb,
      |               ^~~~~~~~~
src/worker.c:102:15: warning: 'body_cb' defined but not used [-Wunused-function]
  102 | static size_t body_cb(void *contents, size_t size, size_t nmemb, void *userp) {
      |               ^~~~~~~
soedirgo commented 3 years ago

Thanks!