Обсуждение: Trouble including pg_type.h

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

Trouble including pg_type.h

От
"Vilches, Alejandro"
Дата:

Hi,

 

I’m having issues trying to include <catalog/pg_type.h> in my program.  With the include paths correctly set, the compiler is able to find this file, but the issue is that this file is doing #include “catalog/genbki.h” (even though they’re side by side), so the compiler is trying to look for “catalog/catalog/genbki.h”.

 

For me, “pg_type.h” is located in: “/usr/pgsql-9.3/include/server/catalog”.  So besides adding “/usr/pgsql-9.3/include” to the include path, I’ve also added “/usr/pgsql-9.3/include/server”, and in my program I’m doing #include <catalog/pg_type.h>.

 

I searched through the mailing list archives and I could only find one other related issue:  http://www.postgresql.org/message-id/1314638642557-4746983.post@n5.nabble.com.  However, this is not quite the issue I’m having.

 

Any help or tips you can give are greatly appreciated.

 

Thanks!

Alejandro

Re: Trouble including pg_type.h

От
Albe Laurenz
Дата:
Alejandro Vilches wrote:
> I’m having issues trying to include <catalog/pg_type.h> in my program.  With the include paths
> correctly set, the compiler is able to find this file, but the issue is that this file is doing
> #include “catalog/genbki.h” (even though they’re side by side), so the compiler is trying to look for
> “catalog/catalog/genbki.h”.
> 
> For me, “pg_type.h” is located in: “/usr/pgsql-9.3/include/server/catalog”.  So besides adding
> “/usr/pgsql-9.3/include” to the include path, I’ve also added “/usr/pgsql-9.3/include/server”, and in
> my program I’m doing #include <catalog/pg_type.h>.

Try

#include "catalog/pg_type.h"

What compiler on what platform are you using?

Yours,
Laurenz Albe

Re: Trouble including pg_type.h

От
"Vilches, Alejandro"
Дата:
Hi Laurenz,

Thanks for your help!

Actually, my apologies, the information previously provided was not quite accurate.  We're using Ubuntu and it seems
likethe "pg_type.h" header file is not included in the Postgres development package for Ubuntu (we're using Postgres
9.3). So we obtained the source and started copying some header files to try to build and we weren't copying all the
rightfiles.  Now we've solved the issue.
 

However, I was also wondering:
Is using "pg_type.h" in client programs (to get OID info for a result set) a supported use case?  Is there a reason why
it'snot included in the Postgres development package for Ubuntu?
 

Thanks!
Alejandro

-----Original Message-----
From: Albe Laurenz [mailto:laurenz.albe@wien.gv.at] 
Sent: Friday, September 4, 2015 2:50 AM
To: Vilches, Alejandro; pgsql-novice@postgresql.org
Subject: RE: Trouble including pg_type.h

Alejandro Vilches wrote:
> I’m having issues trying to include <catalog/pg_type.h> in my program.  
> With the include paths correctly set, the compiler is able to find 
> this file, but the issue is that this file is doing #include 
> “catalog/genbki.h” (even though they’re side by side), so the compiler is trying to look for
“catalog/catalog/genbki.h”.
> 
> For me, “pg_type.h” is located in: 
> “/usr/pgsql-9.3/include/server/catalog”.  So besides adding 
> “/usr/pgsql-9.3/include” to the include path, I’ve also added “/usr/pgsql-9.3/include/server”, and in my program I’m
doing#include <catalog/pg_type.h>.
 

Try

#include "catalog/pg_type.h"

What compiler on what platform are you using?

Yours,
Laurenz Albe

Re: Trouble including pg_type.h

От
Tom Lane
Дата:
"Vilches, Alejandro" <alejandro.vilches@intel.com> writes:
> However, I was also wondering:
> Is using "pg_type.h" in client programs (to get OID info for a result
> set) a supported use case?

Yeah, more or less.  We'd like to find a cleaner answer but so far there
is not one.

> Is there a reason why it's not included in the Postgres development
> package for Ubuntu?

You'd have to ask the Ubuntu packagers that.

            regards, tom lane


Re: Trouble including pg_type.h

От
Michael Wood
Дата:

On 05 Sep 2015 1:20 AM, "Vilches, Alejandro" <alejandro.vilches@intel.com> wrote:
> However, I was also wondering:
> Is using "pg_type.h" in client programs
> (to get OID info for a result set) a
> supported use case?  Is there a reason
> why it's not included in the Postgres
> development package for Ubuntu?

Looks like it's in the server dev package:

http://packages.ubuntu.com/search?searchon=contents&keywords=pg_type.h&mode=exactfilename&suite=trusty&arch=any

--
Michael Wood <esiotrot@gmail.com>

--
Michael Wood

Changing Data Types

От
Mike Frost
Дата:
Hi All,

This REALLY is a novice question

I'm writing a simple query where i need to return [Field A]/[Field B] so i can express [Field A] as a percentage

Both of these fields are BigInts, so i always get 0

What do i need to do to the data types in my query to enable decimal places?

Thanks!

Re: Changing Data Types

От
Thom Brown
Дата:
On 7 September 2015 at 11:20, Mike Frost <m_frost2010@hotmail.com> wrote:
Hi All,

This REALLY is a novice question

I'm writing a simple query where i need to return [Field A]/[Field B] so i can express [Field A] as a percentage

Both of these fields are BigInts, so i always get 0

What do i need to do to the data types in my query to enable decimal places?

You can cast at least one of them to numeric:

postgres=# SELECT 7::int / 10::int;
 ?column?
----------
        0
(1 row)

postgres=# SELECT 7::numeric / 10::int;
        ?column?       
------------------------
 0.70000000000000000000
(1 row)

Thom

Re: Changing Data Types

От
Mike Frost
Дата:
thanks man!

so the syntax in [fielname]::[datatype]?


From: thom@linux.com
Date: Mon, 7 Sep 2015 11:27:46 +0100
Subject: Re: [NOVICE] Changing Data Types
To: m_frost2010@hotmail.com
CC: tgl@sss.pgh.pa.us; pgsql-novice@postgresql.org

On 7 September 2015 at 11:20, Mike Frost <m_frost2010@hotmail.com> wrote:
Hi All,

This REALLY is a novice question

I'm writing a simple query where i need to return [Field A]/[Field B] so i can express [Field A] as a percentage

Both of these fields are BigInts, so i always get 0

What do i need to do to the data types in my query to enable decimal places?

You can cast at least one of them to numeric:

postgres=# SELECT 7::int / 10::int;
 ?column?
----------
        0
(1 row)

postgres=# SELECT 7::numeric / 10::int;
        ?column?       
------------------------
 0.70000000000000000000
(1 row)

Thom

Re: Changing Data Types

От
James David Smith
Дата:
More like column::datatype , but you get the idea yes.



On Mon, 7 Sep 2015 at 11:34 Mike Frost <m_frost2010@hotmail.com> wrote:
thanks man!

so the syntax in [fielname]::[datatype]?

From: thom@linux.com
Date: Mon, 7 Sep 2015 11:27:46 +0100
Subject: Re: [NOVICE] Changing Data Types
To: m_frost2010@hotmail.com
CC: tgl@sss.pgh.pa.us; pgsql-novice@postgresql.org


On 7 September 2015 at 11:20, Mike Frost <m_frost2010@hotmail.com> wrote:
Hi All,

This REALLY is a novice question

I'm writing a simple query where i need to return [Field A]/[Field B] so i can express [Field A] as a percentage

Both of these fields are BigInts, so i always get 0

What do i need to do to the data types in my query to enable decimal places?

You can cast at least one of them to numeric:

postgres=# SELECT 7::int / 10::int;
 ?column?
----------
        0
(1 row)

postgres=# SELECT 7::numeric / 10::int;
        ?column?       
------------------------
 0.70000000000000000000
(1 row)

Thom

Re: Changing Data Types

От
Thom Brown
Дата:
On 7 September 2015 at 11:33, Mike Frost <m_frost2010@hotmail.com> wrote:
thanks man!

so the syntax in [fielname]::[datatype]?

(note that emails to these mailing lists should be in plain text and responses below rather than above)

Yes, the section on type casting explains how it works: http://www.postgresql.org/docs/9.5/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS

Thom

Re: Changing Data Types

От
Mike Frost
Дата:
From: thom@linux.com
Date: Mon, 7 Sep 2015 11:38:59 +0100
Subject: Re: [NOVICE] Changing Data Types
To: m_frost2010@hotmail.com
CC: pgsql-novice@postgresql.org

On 7 September 2015 at 11:33, Mike Frost <m_frost2010@hotmail.com> wrote:
thanks man!

so the syntax in [fielname]::[datatype]?

(note that emails to these mailing lists should be in plain text and responses below rather than above)

Yes, the section on type casting explains how it works:
http://www.postgresql.org/docs/9.5/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS

Thom

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

Thanks guys!