Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pgresult_stream_any to be used by sequel_pg #443

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions ext/pg_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ pgresult_type_map_get(VALUE self)


static void
yield_hash(VALUE self, int ntuples, int nfields)
yield_hash(VALUE self, int ntuples, int nfields, void *data)
{
int tuple_num;
t_pg_result *this = pgresult_get_this(self);
Expand All @@ -1397,7 +1397,7 @@ yield_hash(VALUE self, int ntuples, int nfields)
}

static void
yield_array(VALUE self, int ntuples, int nfields)
yield_array(VALUE self, int ntuples, int nfields, void *data)
{
int row;
t_pg_result *this = pgresult_get_this(self);
Expand All @@ -1417,7 +1417,7 @@ yield_array(VALUE self, int ntuples, int nfields)
}

static void
yield_tuple(VALUE self, int ntuples, int nfields)
yield_tuple(VALUE self, int ntuples, int nfields, void *data)
{
int tuple_num;
t_pg_result *this = pgresult_get_this(self);
Expand All @@ -1436,8 +1436,9 @@ yield_tuple(VALUE self, int ntuples, int nfields)
}
}

static VALUE
pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int))
/* Non-static, and data pointer for use by sequel_pg */
VALUE
pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int, void*), void* data)
{
t_pg_result *this;
int nfields;
Expand Down Expand Up @@ -1465,7 +1466,7 @@ pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int))
pg_result_check( self );
}

yielder( self, ntuples, nfields );
yielder( self, ntuples, nfields, data );

pgresult = gvl_PQgetResult(pgconn);
if( pgresult == NULL )
Expand Down Expand Up @@ -1516,7 +1517,7 @@ pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int))
static VALUE
pgresult_stream_each(VALUE self)
{
return pgresult_stream_any(self, yield_hash);
return pgresult_stream_any(self, yield_hash, NULL);
}

/*
Expand All @@ -1532,7 +1533,7 @@ pgresult_stream_each(VALUE self)
static VALUE
pgresult_stream_each_row(VALUE self)
{
return pgresult_stream_any(self, yield_array);
return pgresult_stream_any(self, yield_array, NULL);
}

/*
Expand All @@ -1549,7 +1550,7 @@ pgresult_stream_each_tuple(VALUE self)
/* allocate VALUEs that are shared between all streamed tuples */
ensure_init_for_tuple(self);

return pgresult_stream_any(self, yield_tuple);
return pgresult_stream_any(self, yield_tuple, NULL);
}

/*
Expand Down