java使用netbeans定义的GUI调用postgreSQL中“postgres.c”中的用户定义函数
我正在尝试向PostgreSQL-8.4.15添加3个用户定义的函数。以下是3个功能:
(1)start_create_profile();
(2)make_profile();
(3)check_anomaly();
所有这些都写在src/backend/tcop中的文件“test.c”中。我想从^{exec_simple_query()
是用src/backend/tcop中的“postgres.c”编写的PostgreSQL函数。我想通过GUI直接调用(2)
下面是我在“test.c”中编写的代码:
#include "postgres.h"
#ifndef PROGPROFILE_H_
#define PROGPROFILE_H_
/* interfaces */
extern void start_create_profile(List *querytree_list);
extern void create_profile();
extern void check_anomaly(List *querytree_list);
#endif /* Test ProgProf */
void start_create_profile(List *querytree_list){
ListCell *l;
ListCell *tl;
FILE *f;
//if the file exist just open and write
//else create and write
f = fopen ("QueryParsed.txt", "a+");
Query *query_idr = (Query *)linitial(querytree_list);
// CMD_SELECT=0 CMD_INSERT=1 CMD_UPDATE=2
switch (query_idr->commandType)
{
case CMD_SELECT:
fputs("CMD_SELECT, ", f);
break;
case CMD_INSERT:
fputs("CMD_INSERT, ", f);
break;
case CMD_UPDATE:
fputs("CMD_UPDATE, ", f);
break;
default:
break;
}
//to have the ID of the table
foreach(l, query_idr->rtable){
Oid tab_idT = ((RangeTblEntry *) lfirst(l)) ->relid;
//char temp1[10];
char *tab_idTConverted = itoa(tab_idT);
/* This is not a table */
if (tab_idT == 0)
continue;
fputs(" tab_id: , ", f);
fputs(tab_idTConverted, f);
}
//to have the name of the targer list
foreach(tl, query_idr->targetList){
TargetEntry *tle = (TargetEntry *) lfirst(tl);
Oid tab_id = tle->resorigtbl;
int tab_idCast=(int)tab_id;
//char temp[10];
char *tab_idConverted = itoa(tab_idCast);
char *resname=tle->resname;
fputs("Name of column: ", f);
fputs(resname, f);
fputs(" ID: ", f);
fputs(tab_idConverted, f);
fputs("\n", f);
}
//close the file that we write
fputs("$", f);
fclose (f);
}
void create_profile(){
}
void check_anomaly(List *querytree_list){
}
现在我创建了一个非常简单的GUI,包括3个按钮(由java中的netbeans提供)。按钮1、按钮2、按钮3按顺序对应于start_create_profile()
,生成check_anomaly()
//initially button=0;
//inside exec_simple_query
if(button==1) start_create_profile();
if(button==2) check_anomaly;
每当我按下按钮2时,必须直接调用函数(2)。 你知道我必须如何设置这个变量,才能使用我的GUI从这三个函数中选择一个吗??如何通过GUI直接调用函数(2)
共 (0) 个答案