Обсуждение: Re: [COMMITTERS] pgsql: Implement table partitioning.

Поиск
Список
Период
Сортировка

Re: [COMMITTERS] pgsql: Implement table partitioning.

От
Stephen Frost
Дата:
* Robert Haas (rhaas@postgresql.org) wrote:
> Implement table partitioning.

My compiler apparently doesn't care for this:

.../src/backend/catalog/partition.c: In function ‘partition_rbound_cmp’:
.../src/backend/catalog/partition.c:1787:13: warning: ‘cmpval’ may be used uninitialized in this function
[-Wmaybe-uninitialized]if (cmpval == 0 && lower1 != lower2)            ^ 

Thanks!

Stephen

Re: [COMMITTERS] pgsql: Implement table partitioning.

От
Robert Haas
Дата:
On Thu, Dec 8, 2016 at 1:49 PM, Stephen Frost <sfrost@snowman.net> wrote:
> * Robert Haas (rhaas@postgresql.org) wrote:
>> Implement table partitioning.
>
> My compiler apparently doesn't care for this:
>
> .../src/backend/catalog/partition.c: In function ‘partition_rbound_cmp’:
> .../src/backend/catalog/partition.c:1787:13: warning: ‘cmpval’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
>   if (cmpval == 0 && lower1 != lower2)

So, apparently your compiler doesn't recognize that the loop always
has to execute at least once, because we don't support a table
partitioned on zero attributes.  If you initialize cmpval to 0 at the
top of the function, does that fix it?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: [COMMITTERS] pgsql: Implement table partitioning.

От
Stephen Frost
Дата:
Robert,

* Robert Haas (robertmhaas@gmail.com) wrote:
> On Thu, Dec 8, 2016 at 1:49 PM, Stephen Frost <sfrost@snowman.net> wrote:
> > * Robert Haas (rhaas@postgresql.org) wrote:
> >> Implement table partitioning.
> >
> > My compiler apparently doesn't care for this:
> >
> > .../src/backend/catalog/partition.c: In function ‘partition_rbound_cmp’:
> > .../src/backend/catalog/partition.c:1787:13: warning: ‘cmpval’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
> >   if (cmpval == 0 && lower1 != lower2)
>
> So, apparently your compiler doesn't recognize that the loop always
> has to execute at least once, because we don't support a table
> partitioned on zero attributes.  If you initialize cmpval to 0 at the
> top of the function, does that fix it?

Yes, that makes the compiler warning go away.

... your compiler knows that key->partnatts will always be >= 1?

Thanks!

Stephen

Re: [COMMITTERS] pgsql: Implement table partitioning.

От
Robert Haas
Дата:
On Thu, Dec 8, 2016 at 2:11 PM, Stephen Frost <sfrost@snowman.net> wrote:
> Yes, that makes the compiler warning go away.

Great, pushed.

> ... your compiler knows that key->partnatts will always be >= 1?

:-)

I think my compiler is too dumb to notice that int x; printf("%d", x);
is a reference to an uninitialized variable.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: [COMMITTERS] pgsql: Implement table partitioning.

От
Stephen Frost
Дата:
* Robert Haas (robertmhaas@gmail.com) wrote:
> On Thu, Dec 8, 2016 at 2:11 PM, Stephen Frost <sfrost@snowman.net> wrote:
> > Yes, that makes the compiler warning go away.
>
> Great, pushed.

Awesome, thanks!

> > ... your compiler knows that key->partnatts will always be >= 1?
>
> :-)
>
> I think my compiler is too dumb to notice that int x; printf("%d", x);
> is a reference to an uninitialized variable.

Made me laugh, thanks again. :)

Stephen

Re: [HACKERS] [COMMITTERS] pgsql: Implement table partitioning.

От
Stephen Frost
Дата:
Robert,

* Robert Haas (robertmhaas@gmail.com) wrote:
> On Thu, Dec 8, 2016 at 1:49 PM, Stephen Frost <sfrost@snowman.net> wrote:
> > * Robert Haas (rhaas@postgresql.org) wrote:
> >> Implement table partitioning.
> >
> > My compiler apparently doesn't care for this:
> >
> > .../src/backend/catalog/partition.c: In function ‘partition_rbound_cmp’:
> > .../src/backend/catalog/partition.c:1787:13: warning: ‘cmpval’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
> >   if (cmpval == 0 && lower1 != lower2)
>
> So, apparently your compiler doesn't recognize that the loop always
> has to execute at least once, because we don't support a table
> partitioned on zero attributes.  If you initialize cmpval to 0 at the
> top of the function, does that fix it?

Yes, that makes the compiler warning go away.

... your compiler knows that key->partnatts will always be >= 1?

Thanks!

Stephen

Re: [HACKERS] [COMMITTERS] pgsql: Implement table partitioning.

От
Stephen Frost
Дата:
* Robert Haas (robertmhaas@gmail.com) wrote:
> On Thu, Dec 8, 2016 at 2:11 PM, Stephen Frost <sfrost@snowman.net> wrote:
> > Yes, that makes the compiler warning go away.
>
> Great, pushed.

Awesome, thanks!

> > ... your compiler knows that key->partnatts will always be >= 1?
>
> :-)
>
> I think my compiler is too dumb to notice that int x; printf("%d", x);
> is a reference to an uninitialized variable.

Made me laugh, thanks again. :)

Stephen