Re: how to add my source file?
От | dakotali kasap |
---|---|
Тема | Re: how to add my source file? |
Дата | |
Msg-id | 14428.22766.qm@web31309.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | how to add my source file? (dakotali kasap <dakotalidavid@yahoo.com>) |
Ответы |
Re: how to add my source file?
(Bruce Momjian <bruce@momjian.us>)
Re: how to add my source file? (Andrew Dunstan <andrew@dunslane.net>) |
Список | pgsql-hackers |
Sorry I did not want to bother you with the details, I just thought that there is smth that I have to do apart from addingthe object file name into the Makefile.<br /><br />So, here is the whole picture:<br /><br /><br />I want to writea function that takes the raw parsetree and rewrites it according to my rules, then produce new raw parsetrees.<br /><br/>I will call this function inside backend/tcop/postgres.c . I wrote an header file called my_rewriter.h and includethis inside postgres.c.<br /><br />my_writer.h looks like:<br />-------------------------------------------------<br/>#ifndef UWSDREWRITE_H<br />#define UWSDREWRITE_H<br /><br />#include"nodes/pg_list.h"<br />#include "nodes/nodes.h"<br /><br />typedef struct my_Projection<br />{<br /> char *relname;<br/> List attnames;<br /> char *result_relname;<br /><br />} my_Projection;<br /><br />.<br />.<br />.<br/><br />extern void my_analyze(Node *parsetree);<br />extern void my_rewrite(List *parsetree_list);<br /><br />#endifUWSDREWRITE_H<br />---------------------------------------------<br /><br /><br />my_writer.c looks like:<br />-------------------------------------------------<br/>#include "nodes/nodes.h"<br />#include <stdio.h><br />#include"nodes/pg_list.h"<br /><br /><br />static void my_string_print(char *s);<br />static void my_int_print(int i);<br/><br />static void my_string_print(char *s)<br />{<br /> FILE *outfile = fopen("/home/?/the_log.txt", "a");<br/> fprintf(outfile,"\n%s\n", s);<br /> fflush(stdout);<br /> fclose(outfile);<br />}<br /><br />static voidmy_int_print(int i)<br />{<br /> FILE *outfile = fopen("/home/?/the_log.txt", "a");<br /> fprintf(outfile,"\n theint is: %d\n", i);<br /> fflush(stdout);<br /> fclose(outfile);<br />}<br /><br />void UWSD_rewrite(List *parsetree_list)<br/>{<br /> ListCell *parsetree_item;<br /> <br /> foreach(parsetree_item, parsetree_list)<br/> {<br /> Node *parsetree = (Node *) lfirst(parsetree_item);<br /> UWSD_analyze(parsetree);<br/> }<br />}<br /><br />void UWSD_analyze(Node *parsetree)<br />{<br /> if(nodeTag(parsetree)==T_SelectStmt)<br/> {<br /> my_string_print("THIS IS A SELECT STMT");<br /> }<br /> else my_int_print(nodeTag(parsetree));<br />}<br /><br />-----------------------------------------------------------<br/><br /><br />Then I wrote a C file called my_writer.c, anddo the implementation of my_analyze(Node *parsetree) and my_rewrite(List *parsetree_list) functions. I need Node andList structures here, but when I include the necessary header files (#include "nodes/pg_list.h", #include "nodes/nodes.h"),I got errors at compile time like:<br /><br />---------------------------------------<br />../../../src/include/nodes/nodes.h:359:error: syntax error before ¡Node¢<br />../../../src/include/nodes/nodes.h:398: error:syntax error before ¡equal¢<br />../../../src/include/nodes/nodes.h:398: warning: type defaults to ¡int¢ in declarationof ¡equal¢<br />../../../src/include/nodes/nodes.h:398: warning: data definition has no type or storage class<br/>----------------------------------------<br /><br />I added the object file my_writer.o to the Makefile inside backend/parser/Makefile and configured again, but it did not work, what else should I do?<br /><br />regards,<br /><br/>dakotali<br /><br /><br /><br /><b><i>Andrew Dunstan <andrew@dunslane.net></i></b> wrote:<blockquote class="replbq"style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> dakotali kasap wrote:<br/>> Hi,<br />><br />> I have one source and one header file which are called my_writer.h and <br />>my_writer.c. I included my_writer.h inside postgres.c and do the <br />> implementation of declared functions insidemy_writer.c. When I <br />> include, some other header files of postgresql (like nodes/pg_list.h <br />> or nodes/nodes.h)in my_writer.c, it gives me compile errors that are <br />> related with these header files of postgresql,although there is no <br />> problem.<br />><br />> Do you know why?<br />><br /><br />We're not magicians,nor mindreaders. Unless you give us enough <br />information we can't possibly guess. At the very least you needto show <br />us what the offending code is and what the compiler error is.<br /><br />cheers<br /><br />andrew<br /></blockquote><br/><p> __________________________________________________<br />Do You Yahoo!?<br />Tired of spam? Yahoo!Mail has the best spam protection around <br />http://mail.yahoo.com
В списке pgsql-hackers по дате отправления: