Regarding the correct and best way to fetching a tablename in contrib module - Mailing list pgsql-hackers

From Gaurav Mishra
Subject Regarding the correct and best way to fetching a tablename in contrib module
Date
Msg-id CAOCUFr2p7DpZA=4sfyKo9zW5iHXMLo+H=hL9FKeot5ABJYt8KQ@mail.gmail.com
Whole thread Raw
Responses Re: Regarding the correct and best way to fetching a tablename incontrib module
List pgsql-hackers
Hi folks ,

I have developed a new data type in PostgreSQL. The handler associated with this data type is written in C language. This handler encrypts the column data. I need help on figuring out how to get the table name when my handler code is called during CRUD and Alter table operations.

let me elaborate a bit about the things i am gonna do here , So the thing is i am developing a cont-rib module and wants to capture table name inside that cont-rib module .

question:

1. Is there any way to capture a table name during CRUD and alter table  ?
I have seen some of the triggers but not able to make it (i don't thing there is any create table trigger exist ). in case If it is possible tell me a way to achieve it.

2. I though of extracting meta-data using pg_class but not helping it seems because i have to give explicitly a  rel-name(table-name) in where clause 
do you think any other way to achieve it ? please elaborate if any and please let me know.

3. Is there any callback functions available so that i can call those callback functions inside a code and if yes at what level we get tablename attached with colname .

Here is some example which will make you understand a bit about the things i am gonna do .

create table new_table(name varchar , new integer) ; 

insert into new_table values('abcdefghijkl' , 5004);

create table new_table1(name1 varchar , new1 integer) ; 

insert into new_table1 values('mnopqrst' , 5005);

So my extension should extact a tablename ,means i should know tablename with the built-in datatype I have declared .

here what i expect as a output :

create extension table_name-extract;

select extract_tablename();

table-name  datatype-name
new_table  name new
new_table1 name1 new1

extract_tablename : this function should give me a table name with data_type inside contrib module so that i can use in the extension .

Any help would be much appropriated .

Thanks and Regards,
Gaurav Mishra
9986425323 

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Incorrect fsync handling in pg_basebackup's tar_finish
Next
From: Chris Howard
Date:
Subject: Re: comma to delimit fractional seconds