dbTalk Databases Forums  

[BUGS] BUG #2395: Can't get right type oid by PQftype.

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2395: Can't get right type oid by PQftype. in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
wangshj
 
Posts: n/a

Default [BUGS] BUG #2395: Can't get right type oid by PQftype. - 04-15-2006 , 08:36 AM







The following bug has been logged online:

Bug reference: 2395
Logged by: wangshj
Email address: wangshj (AT) sduept (DOT) com
PostgreSQL version: 8.1.3
Operating system: CentOS release 4.3 (Final)
Description: Can't get right type oid by PQftype.
Details:

I create a domain type testdomainoid.

CREATE DOMAIN testdomainoid int CHECK(value >20);

In my database,the type oid of testdomainoid is 16385.But PQftype return 23
for testdomainoid's type oid.How could I get the testdomainoid's type oid.

--Creating a table use domain type.
CREATE TABLE test_domain_oid ( col testdomainoid );

--Insert a value.
INSERT INTO test_domain_oid VALUES (30);

//following is my test code.
#include <iostream>
#include "libpq-fe.h"
#include <sstream>

int main(int argc, char ** argv){
PGconn * conn = PQconnectdb("");
if( CONNECTION_OK != PQstatus(conn ) )
{
std::cout << "\nCan't connecte to db\n";
return 0;
}

PGresult * r = PQexec( conn, "SELECT col FROM test_domain_oid " );
if( PGRES_TUPLES_OK == PQresultStatus(r) )
{
Oid id = PQftype( r, 0 );
int mod = PQfmod( r, 0 );
std::cout<<"\noid: " << id<<"\nmod:" << mod <<std::endl;
}
else
{
std::cout << "\nQuery failed..\n";
return 0;
}

PQclear( r );
PQfinish( conn );
};

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

Reply With Quote
  #2  
Old   
Volkan YAZICI
 
Posts: n/a

Default Re: [BUGS] BUG #2395: Can't get right type oid by PQftype. - 04-15-2006 , 10:36 AM






On Apr 14 06:30, wangshj wrote:
Quote:
In my database,the type oid of testdomainoid is 16385. But PQftype return 23
for testdomainoid's type oid.
PQftype() returns the OID of the actual _type_ used in the domain.
Therefore, you get 23, OID of the int4/int type, in the above query.

Quote:
How could I get the testdomainoid's type oid.
Simply by querying pg_type catalog:

SELECT oid FROM pg_catalog.pg_type WHERE typname = 'testdomainoid';


Regards.

---------------------------(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


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.