Thread: [GSoC] working status

[GSoC] working status

From
Charles Cui
Date:
Hi mentors and hackers,

   The second review is coming. Here is my working status so far. 1. Complete the thrift compact protocol implementation using bytea interface. 
2. Thrift type (binary protocol) is almost done, the only remaining part is struct encoding and decoding. With the thrift type, you can express your thrift struct using json, but stored using thrift bytes.
3. Set up travis CI. 4. better documents. 
Here is the repo with all recent changes
Let me know if you have any questions. 

Re: [GSoC] working status

From
Aleksander Alekseeev
Date:
Hello Charles,

>    The second review is coming. Here is my working status so far. 1.
> Complete the thrift compact protocol implementation using bytea
> interface. 2. Thrift type (binary protocol) is almost done, the only
> remaining part is struct encoding and decoding. With the thrift type,
> you can express your thrift struct using json, but stored using
> thrift bytes. 3. Set up travis CI. 4. better documents.
> Here is the repo with all recent changes
> (https://github.com/charles-cui/pg_thrift)
> Let me know if you have any questions.

Thanks for keeping us informed! Though it seems that the code is a
little bit broken at the moment:

```
pg_thrift.c:1313:26: error: too few arguments to function
‘array_create_iterator’ ArrayIterator iter =
array_create_iterator(parray, 0); ^~~~~~~~~~~~~~~~~~~~~
In file included from pg_thrift.c:5:
.../postgresql-install/include/server/utils/array.h:418:22:
note: declared here extern ArrayIterator
array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState
*mstate); ^~~~~~~~~~~~~~~~~~~~~
```

--
Best regards,
Aleksander Alekseev


Re: [GSoC] working status

From
Aleksander Alekseeev
Date:
Hello Charles,

> ```
> pg_thrift.c:1313:26: error: too few arguments to function
> ‘array_create_iterator’ ArrayIterator iter =
> array_create_iterator(parray, 0); ^~~~~~~~~~~~~~~~~~~~~
> In file included from pg_thrift.c:5:
> .../postgresql-install/include/server/utils/array.h:418:22:
> note: declared here extern ArrayIterator
> array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState
> *mstate); ^~~~~~~~~~~~~~~~~~~~~
> ```

I should probably explain this in a little more detail.

This was an attempt to build pg_thrift with PostgreSQL 10 (compiled from
REL_10_STABLE branch). Same issue with upcoming 11 version. I believe
you are testing the extension on some 9.x branch and don't see these
errors. Corresponding change in the API was done quite a long time ago,
in 2015 (see commit 13dbc7a8).

To solve this issue you can either use #ifdef's and maintain two
versions of the code for different versions of PostgreSQL or just
support only 10+. Both options are fine, at least by me personally.

--
Best regards,
Aleksander Alekseev


Re: [GSoC] working status

From
Aleksander Alekseeev
Date:
Hello Charles,

> > ```
> > pg_thrift.c:1313:26: error: too few arguments to function
> > ‘array_create_iterator’ ArrayIterator iter =
> > array_create_iterator(parray, 0); ^~~~~~~~~~~~~~~~~~~~~
> > In file included from pg_thrift.c:5:
> > .../postgresql-install/include/server/utils/array.h:418:22:
> > note: declared here extern ArrayIterator
> > array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState
> > *mstate); ^~~~~~~~~~~~~~~~~~~~~
> > ```
>
> I should probably explain this in a little more detail.
>
> This was an attempt to build pg_thrift with PostgreSQL 10 (compiled
> from REL_10_STABLE branch). Same issue with upcoming 11 version. I
> believe you are testing the extension on some 9.x branch and don't
> see these errors. Corresponding change in the API was done quite a
> long time ago, in 2015 (see commit 13dbc7a8).
>
> To solve this issue you can either use #ifdef's and maintain two
> versions of the code for different versions of PostgreSQL or just
> support only 10+. Both options are fine, at least by me personally.

And I should probably explain the "use #ifdef's" part. You can use
PG_VERSION_NUM macro to determine PostgreSQL version in this fashion:

```
/* In version 11 these macros have been changed */
#if PG_VERSION_NUM < 110000
#define PG_GETARG_JSONB_P(v) PG_GETARG_JSONB(v)
#define PG_RETURN_JSONB_P(v) PG_RETURN_JSONB(v)
#endif
```

In your case you can declare a wrapper for the array_create_iterator
procedure to make it work on both 9.x and 10.

--
Best regards,
Aleksander Alekseev


Re: [GSoC] working status

From
Charles Cui
Date:
yes, my CI test version is 9.4. will make it work on 10 by following your advices. Thanks.

On Mon, Jul 9, 2018, 5:22 AM Aleksander Alekseeev <a.alekseev@postgrespro.ru> wrote:
Hello Charles,

> > ```
> > pg_thrift.c:1313:26: error: too few arguments to function
> > ‘array_create_iterator’ ArrayIterator iter =
> > array_create_iterator(parray, 0); ^~~~~~~~~~~~~~~~~~~~~
> > In file included from pg_thrift.c:5:
> > .../postgresql-install/include/server/utils/array.h:418:22:
> > note: declared here extern ArrayIterator
> > array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState
> > *mstate); ^~~~~~~~~~~~~~~~~~~~~
> > ``` 
>
> I should probably explain this in a little more detail.
>
> This was an attempt to build pg_thrift with PostgreSQL 10 (compiled
> from REL_10_STABLE branch). Same issue with upcoming 11 version. I
> believe you are testing the extension on some 9.x branch and don't
> see these errors. Corresponding change in the API was done quite a
> long time ago, in 2015 (see commit 13dbc7a8).
>
> To solve this issue you can either use #ifdef's and maintain two
> versions of the code for different versions of PostgreSQL or just
> support only 10+. Both options are fine, at least by me personally.

And I should probably explain the "use #ifdef's" part. You can use
PG_VERSION_NUM macro to determine PostgreSQL version in this fashion:

```
/* In version 11 these macros have been changed */
#if PG_VERSION_NUM < 110000
#define PG_GETARG_JSONB_P(v) PG_GETARG_JSONB(v)
#define PG_RETURN_JSONB_P(v) PG_RETURN_JSONB(v)
#endif
```

In your case you can declare a wrapper for the array_create_iterator
procedure to make it work on both 9.x and 10.

--
Best regards,
Aleksander Alekseev