X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 77903D1B4B8 for ; Sun, 7 Dec 2003 00:50:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92927-09 for ; Sat, 6 Dec 2003 20:49:41 -0400 (AST) Received: from web40011.mail.yahoo.com (web40011.mail.yahoo.com [66.218.78.29]) by svr1.postgresql.org (Postfix) with SMTP id B0748D1B484 for ; Sat, 6 Dec 2003 20:49:37 -0400 (AST) Message-ID: <20031207004940.4812.qmail@web40011.mail.yahoo.com> Received: from [195.251.255.233] by web40011.mail.yahoo.com via HTTP; Sun, 07 Dec 2003 00:49:40 GMT Date: Sun, 7 Dec 2003 00:49:40 +0000 (GMT) From: =?iso-8859-7?q?NK?= Subject: Help! Parser Stage: Get The Columns Of the Table To: pgsql-hackers@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1950028493-1070758180=:1982" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_20, FROM_ENDS_IN_NUMS, HTML_20_30, MAILTO_TO_SPAM_ADDR X-Spam-Level: X-Archive-Number: 200312/22 X-Sequence-Number: 4631 --0-1950028493-1070758180=:1982 Content-Type: text/plain; charset=iso-8859-7 Content-Transfer-Encoding: 8bit Dear Friends, I am trying to modify the parser of the postgresql so as to print all the columns of a table (or to put them in a seperate file) when the parser meets an Insert Statement. In the file (/src/backend/parser/gram.y) , InsertStmt: INSERT INTO qualified_name insert_rest { $4->relation = $3; $$ = (Node *) $4; } ; I can take the table name adding the following line of code printf($3->relname); The problem is that in the insert_column_item section (see the last section below) the var n is of type ResTarget and in case of insert and select the ResTarget->Name is null and not the name of the column (in the update command everything is ok- see also the line 371 in the file parsenodes.h ...typedef struct ResTarget {....} ). Could you please tell me the way to take the names of the columns? Every answer will be appreciated Thank You Very Much In Advance NK noc100@yahoo.gr insert_rest: VALUES '(' insert_target_list ')' { $$ = makeNode(InsertStmt); $$->cols = NIL; $$->targetList = $3; $$->selectStmt = NULL; } | DEFAULT VALUES { $$ = makeNode(InsertStmt); $$->cols = NIL; $$->targetList = NIL; $$->selectStmt = NULL; } | SelectStmt { $$ = makeNode(InsertStmt); $$->cols = NIL; $$->targetList = NIL; $$->selectStmt = $1; } | '(' insert_column_list ')' VALUES '(' insert_target_list ')' { $$ = makeNode(InsertStmt); $$->cols = $2; $$->targetList = $6; $$->selectStmt = NULL; } | '(' insert_column_list ')' SelectStmt { $$ = makeNode(InsertStmt); $$->cols = $2; $$->targetList = NIL; $$->selectStmt = $4; } ; insert_column_list: insert_column_item { $$ = makeList1($1); } | insert_column_list ',' insert_column_item { $$ = lappend($1, $3); } ; insert_column_item: ColId opt_indirection { ResTarget *n = makeNode(ResTarget); n->name = $1; n->indirection = $2; n->val = NULL; $$ = (Node *)n; } ; --------------------------------- Do You Yahoo!? Αποκτήστε την δωρεάν σας@yahoo.gr διεύθυνση στο Yahoo! Mail. --0-1950028493-1070758180=:1982 Content-Type: text/html; charset=iso-8859-7 Content-Transfer-Encoding: 8bit
Dear Friends,
 
I am trying to modify the parser of the postgresql so as to print all the columns of a table (or to put them in a seperate file) when the parser meets an Insert Statement.
In the <gram.y> file (/src/backend/parser/gram.y) ,
 
InsertStmt:
   INSERT INTO qualified_name insert_rest
    {
     $4->relation = $3;
     $$ = (Node *) $4;
    }
  ;
I can take the table name adding the following line of code
 
printf($3->relname);
 
 
The problem is that in the insert_column_item section (see the last section below) the var n is of type ResTarget and in case of insert and select the ResTarget->Name is null and not the name of the column (in the update command everything is ok- see also the line 371 in the file parsenodes.h ...typedef struct ResTarget {....} ). Could you please tell me the way to take the names of the columns?
 
Every answer will be appreciated
Thank  You Very Much In Advance
NK
 
insert_rest:
   VALUES '(' insert_target_list ')'
    {
     $$ = makeNode(InsertStmt);
     $$->cols = NIL;
     $$->targetList = $3;
     $$->selectStmt = NULL;
    }
   | DEFAULT VALUES
    {
     $$ = makeNode(InsertStmt);
     $$->cols = NIL;
     $$->targetList = NIL;
     $$->selectStmt = NULL;
    }
   | SelectStmt
    {
     $$ = makeNode(InsertStmt);
     $$->cols = NIL;
     $$->targetList = NIL;
     $$->selectStmt = $1;
    }
   | '(' insert_column_list ')' VALUES '(' insert_target_list ')'
    {
     $$ = makeNode(InsertStmt);
     $$->cols = $2;
     $$->targetList = $6;
     $$->selectStmt = NULL;
    }
   | '(' insert_column_list ')' SelectStmt
    {
     $$ = makeNode(InsertStmt);
     $$->cols = $2;
     $$->targetList = NIL;
     $$->selectStmt = $4;
    }
  ;
insert_column_list:
   insert_column_item      { $$ = makeList1($1); }
   | insert_column_list ',' insert_column_item
     { $$ = lappend($1, $3); }
  ;
insert_column_item:
   ColId opt_indirection
    {
     ResTarget *n = makeNode(ResTarget);
     n->name = $1;
     n->indirection = $2;
     n->val = NULL;
     $$ = (Node *)n;
    }
  ;
 



Do You Yahoo!?
Αποκτήστε την δωρεάν σας @yahoo.gr διεύθυνση στο Yahoo! Mail.
--0-1950028493-1070758180=:1982--