Unix Technical Forum

Gist does not build with VC++ anymore

This is a discussion on Gist does not build with VC++ anymore within the pgsql Hackers forums, part of the PostgreSQL category; --> I've updated my VC++ build env with latest CVS, and it no longer builds because of changes to GIST: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 03:10 AM
Magnus Hagander
 
Posts: n/a
Default Gist does not build with VC++ anymore

I've updated my VC++ build env with latest CVS, and it no longer builds
because of changes to GIST:

src\backend\access\gist\gistutil.c(237) : error C2057: expected constant
expression
src\backend\access\gist\gistutil.c(237) : error C2466: cannot allocate
an array of constant size 0
src\backend\access\gist\gistutil.c(237) : error C2133: 'storage' :
unknown size


The problem appears to come from:
#define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))

Which can't be used in this context.

What would be the proper fix for that?

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 03:10 AM
Magnus Hagander
 
Posts: n/a
Default Re: Gist does not build with VC++ anymore

> I've updated my VC++ build env with latest CVS, and it no
> longer builds because of changes to GIST:
>
> src\backend\access\gist\gistutil.c(237) : error C2057:
> expected constant expression
> src\backend\access\gist\gistutil.c(237) : error C2466: cannot
> allocate an array of constant size 0
> src\backend\access\gist\gistutil.c(237) : error C2133: 'storage' :
> unknown size
>
>
> The problem appears to come from:
> #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))
>
> Which can't be used in this context.
>
> What would be the proper fix for that?


Hmm. Now that I look at it more clearly, it seems Hiroshi has a fix for
this in his submitted patch (that still had a lot of other problems in
the rest of it). I'm not sure if it's the proper fix, but it's there.
Comments on it?


--- src/backend/access/gist/gistutil.c.orig Thu Jun 22 20:46:55 2006
+++ src/backend/access/gist/gistutil.c Thu Jun 22 20:47:22 2006
@@ -228,6 +228,12 @@
/*
* makes union of two key
*/
+
+#ifdef _MSC_VER
+#undef GEVHDRSZ
+#define GEVHDRSZ (offsetof(GistEntryVector, vector))
+#endif
+
static void
gistMakeUnionKey( GISTSTATE *giststate, int attno,
GISTENTRY *entry1, bool
isnull1,



//Magnus

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 03:10 AM
Magnus Hagander
 
Posts: n/a
Default Re: Gist does not build with VC++ anymore

> > I've updated my VC++ build env with latest CVS, and it no longer
> > builds because of changes to GIST:
> >
> > src\backend\access\gist\gistutil.c(237) : error C2057:
> > expected constant expression
> > src\backend\access\gist\gistutil.c(237) : error C2466:

> cannot allocate
> > an array of constant size 0
> > src\backend\access\gist\gistutil.c(237) : error C2133: 'storage' :
> > unknown size
> >
> >
> > The problem appears to come from:
> > #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))
> >
> > Which can't be used in this context.
> >
> > What would be the proper fix for that?

>
> Hmm. Now that I look at it more clearly, it seems Hiroshi has
> a fix for this in his submitted patch (that still had a lot
> of other problems in the rest of it). I'm not sure if it's
> the proper fix, but it's there.


While I'm spamming everybody anyway, here's another thing that might fix
it? This one compiles and tests, and I *think* it does the right
thing... If it's correct, I think it looks like a cleaner solution.

//Magnus


RCS file: /projects/cvsroot/pgsql/src/include/access/gist.h,v
retrieving revision 1.52
diff -c -r1.52 gist.h
*** src/include/access/gist.h 5 Mar 2006 15:58:53 -0000 1.52
--- src/include/access/gist.h 24 Jun 2006 17:20:28 -0000
***************
*** 142,148 ****
GISTENTRY vector[1];
} GistEntryVector;

! #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))

/*
* macro to initialize a GISTENTRY
--- 142,148 ----
GISTENTRY vector[1];
} GistEntryVector;

! #define GEVHDRSZ (offsetof(GistEntryVector, vector))

/*
* macro to initialize a GISTENTRY

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 03:11 AM
Bruce Momjian
 
Posts: n/a
Default Re: Gist does not build with VC++ anymore


Patch applied. It seems offsetof() can only find structure members in
MSVC, not the offset of array elements in structures. Anyway,
offsetof() was finding the first element, so the "[0]" is not needed.

---------------------------------------------------------------------------

Magnus Hagander wrote:
> > > I've updated my VC++ build env with latest CVS, and it no longer
> > > builds because of changes to GIST:
> > >
> > > src\backend\access\gist\gistutil.c(237) : error C2057:
> > > expected constant expression
> > > src\backend\access\gist\gistutil.c(237) : error C2466:

> > cannot allocate
> > > an array of constant size 0
> > > src\backend\access\gist\gistutil.c(237) : error C2133: 'storage' :
> > > unknown size
> > >
> > >
> > > The problem appears to come from:
> > > #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))
> > >
> > > Which can't be used in this context.
> > >
> > > What would be the proper fix for that?

> >
> > Hmm. Now that I look at it more clearly, it seems Hiroshi has
> > a fix for this in his submitted patch (that still had a lot
> > of other problems in the rest of it). I'm not sure if it's
> > the proper fix, but it's there.

>
> While I'm spamming everybody anyway, here's another thing that might fix
> it? This one compiles and tests, and I *think* it does the right
> thing... If it's correct, I think it looks like a cleaner solution.
>
> //Magnus
>
>
> RCS file: /projects/cvsroot/pgsql/src/include/access/gist.h,v
> retrieving revision 1.52
> diff -c -r1.52 gist.h
> *** src/include/access/gist.h 5 Mar 2006 15:58:53 -0000 1.52
> --- src/include/access/gist.h 24 Jun 2006 17:20:28 -0000
> ***************
> *** 142,148 ****
> GISTENTRY vector[1];
> } GistEntryVector;
>
> ! #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))
>
> /*
> * macro to initialize a GISTENTRY
> --- 142,148 ----
> GISTENTRY vector[1];
> } GistEntryVector;
>
> ! #define GEVHDRSZ (offsetof(GistEntryVector, vector))
>
> /*
> * macro to initialize a GISTENTRY
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>


--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:21 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com