Home > Archive > PostgreSQL Administration > October 2006 > Modifying Makefile









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Modifying Makefile
Mohamed Yassin Eltabakh

2006-10-25, 8:24 am

I'm modifying postgreSQL code and adding a new file (say new.c) under dir
"src/backend/parser". This file calls functions (PSQLexec, PQntuples,
PQgetvalue, ...).

The file looks like:
--------------------------------
#include "libpq-fe.h"
#include "common.h"
bool exec_sql()
{
PGresult *res;
char str[1000];
int TuplesNums;

strcpy(str, "SELECT id, fname FROM T;");
res = PSQLexec(str, false);
if (!res)
return false;
TuplesNums = PQntuples(res);
PQclear(res);

return true;
}
-------------------------

I updated the src/backend/parser/Makefile and added "new.o" to the OBJS
list, but when I compile I receive error:
.....undefined reference to `PSQLexec'
.....undefined reference to `PQntuples'
.....undefined reference to `PQclear'

Do you have an idea which Makefile should I update and how? because I'm not
familiar with writing Makefiles.

Thanks in advance


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

Tom Lane

2006-10-25, 8:24 am

"Mohamed Yassin Eltabakh" <meltabak@cs.purdue.edu> writes:
> I updated the src/backend/parser/Makefile and added "new.o" to the OBJS
> list, but when I compile I receive error:
> ....undefined reference to `PSQLexec'
> ....undefined reference to `PQntuples'
> ....undefined reference to `PQclear'


You seem to be trying to use the libpq client from inside the backend.
This is entirely inappropriate. If you need to run general-purpose SQL
queries you can use SPI, but code that is doing that probably does not
belong in /parser. Just about anything that makes sense to do during
parse analysis should be adequately supported by the system catalog
cache routines.

regards, tom lane

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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com