]> granicus.if.org Git - postgresql/commitdiff
*** empty log message ***
authorMichael Meskes <meskes@postgresql.org>
Fri, 15 Oct 1999 19:02:08 +0000 (19:02 +0000)
committerMichael Meskes <meskes@postgresql.org>
Fri, 15 Oct 1999 19:02:08 +0000 (19:02 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/TODO
src/interfaces/ecpg/preproc/Makefile
src/interfaces/ecpg/preproc/keywords.c
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/preproc.y

index f0043ed9bd84d5b0fde7ebba374535e2a945c713..bd2a6f9e157a82978dedef4bb3951fbe8bf33798 100644 (file)
@@ -674,3 +674,14 @@ Thu Oct  7 15:12:58 CEST 1999
        - Set ecpg version to 2.6.6
        - Set library version to 3.0.4
 
+Tue Oct 12 07:26:50 CEST 1999
+
+       - Simplified C part of parser.
+
+Fri Oct 15 17:05:25 CEST 1999
+
+       - Synced preproc.y with gram.y.
+       - Synced pgc.l with scan.l.
+        - Synced keyword.c.
+       - Finished C parser changes, so initializers are correctly parsed.
+       - Set ecpg version to 2.6.7
index 36d929ea0bae83250d392fd2b15c4ef91b9f77e8..9e9f94b1570911903b27d7c92e65b8c717f29b9c 100644 (file)
@@ -13,8 +13,13 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS
 
 The line numbering is not exact.
 
+What happens to the output variable during read if there was an
+indicator-error? 
+
+Add a semantic check level, e.g. check if a table really exists.
+
 Missing statements:
- - exec slq ifdef
+ - exec sql ifdef
  - exec sql allocate
  - exec sql deallocate
  - SQLSTATE
index 337e094419195ca82f99d604c44d0cb4bd89ebf7..ac0015cbd274252aa5dfeb77668205a3fd300946 100644 (file)
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
 
 MAJOR_VERSION=2
 MINOR_VERSION=6
-PATCHLEVEL=6
+PATCHLEVEL=7
 
 CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
        -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
index 3c65d99fb013d5ee87ed9c40f0d21db814cafbc9..398d8c7a3ddcb1d62c30784f0d4962111a865558 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.18 1999/10/08 11:05:02 meskes Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.19 1999/10/15 19:02:08 meskes Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,6 +61,7 @@ static ScanKeyword ScanKeywords[] = {
        {"coalesce", COALESCE},
        {"collate", COLLATE},
        {"column", COLUMN},
+       {"comment", COMMENT},
        {"commit", COMMIT},
        {"committed", COMMITTED},
        {"constraint", CONSTRAINT},
index 80a8547ed6578ec65681b6d52e4c4505449b0169..498fe689e5fd05e354c62f8872c1c11e150e2c0b 100644 (file)
@@ -1,3 +1,4 @@
+
 /* This is a modified version of src/backend/parser/scan.l */
 %{
 #include <ctype.h>
@@ -90,6 +91,10 @@ xhstop                       {quote}
 xhinside               [^']*
 xhcat                  {quote}{space}*\n{space}*{quote}
 
+/* C version of hex number 
+ */
+xch                    0[xX][0-9A-Fa-f]*
+
 /* Extended quote
  * xqdouble implements SQL92 embedded quote
  * xqcat allows strings to cross input lines
@@ -150,10 +155,10 @@ real                      (((({digit}*\.{digit}+)|({digit}+\.{digit}*))([Ee][-+]?{digit}+)?)|({digi
 
 param                  \${integer}
 
-comment                        ("--"|"//").*\n
+comment                        ("--"|"//").*
 ccomment               "//".*\n
 
-space                  [ \t\n\f]
+space                  [ \t\n\r\f]
 other                  .
 
 /* some stuff needed for ecpg */
@@ -242,7 +247,6 @@ cppline             {space}*#.*(\\{space}*\n)*\n*
                                }
 <xq>{xqstop}   {
                                        BEGIN(SQL);
-                                       /* yylval.str = mm_strdup(scanstr(literal));*/
                                        yylval.str = mm_strdup(literal);
                                        return SCONST;
                                }
@@ -319,13 +323,6 @@ cppline            {space}*#.*(\\{space}*\n)*\n*
                                        if (*endptr != '\0' || errno == ERANGE)
                                        {
                                                errno = 0;
-#if 0
-                                               yylval.dval = strtod(((char *)yytext),&endptr);
-                                               if (*endptr != '\0' || errno == ERANGE)
-                                                       yyerror("ERROR: Bad integer input");
-                                               yyerror("WARNING: Integer input is out of range; promoted to float");
-                                               return FCONST;
-#endif
                                                yylval.str = mm_strdup((char*)yytext);
                                                 return SCONST;
                                        }
@@ -414,6 +411,19 @@ cppline            {space}*#.*(\\{space}*\n)*\n*
 <SQL>{other}                   { return yytext[0]; }
 <C>{exec}{space}*{sql}         { BEGIN SQL; return SQL_START; }
 <C>{ccomment}                  { /* ignore */ } 
+<C>{xch}                       {
+                                       char* endptr;
+
+                                       errno = 0;
+                                       yylval.ival = strtol((char *)yytext,&endptr,16);
+                                       if (*endptr != '\0' || errno == ERANGE)
+                                       {
+                                               errno = 0;
+                                               yylval.str = mm_strdup((char*)yytext);
+                                                return SCONST;
+                                       }
+                                       return ICONST;
+                               }
 <C>{cppline}                   {
                                        yylval.str = mm_strdup((char*)yytext);
                                        return(CPP_LINE);
@@ -470,7 +480,7 @@ cppline             {space}*#.*(\\{space}*\n)*\n*
 <C>\[                  { return('['); }
 <C>\]                  { return(']'); }
 <C>\=                  { return('='); }
-<C>{other}                     { return S_ANYTHING; }
+<C>{other}             { return S_ANYTHING; }
 <C>{exec}{space}{sql}{space}{define}   {BEGIN(def_ident);}
 <def_ident>{space}     {}
 <def_ident>{identifier}        {
index 5f4bd2a36479fca93b8371bdfa740e3ec0e06874..06895e197972281556613a9ecb369adf3fe581c6 100644 (file)
@@ -724,7 +724,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
  */
 %token  ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE,
                BACKWARD, BEFORE, BINARY,
-               CACHE, CLUSTER, COPY, CREATEDB, CREATEUSER, CYCLE,
+               CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
                 DATABASE, DELIMITERS, DO,
                EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND,
                 FORWARD, FUNCTION, HANDLER,
@@ -785,7 +785,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
 %type  <str>    update_target_el opt_id relation_name database_name
 %type  <str>    access_method attr_name class index_name name func_name
 %type  <str>    file_name AexprConst ParamNo TypeId
-%type  <str>   in_expr_nodes a_expr b_expr TruncateStmt
+%type  <str>   in_expr_nodes a_expr b_expr TruncateStmt CommentStmt
 %type  <str>   opt_indirection expr_list extract_list extract_arg
 %type  <str>   position_list substr_list substr_from
 %type  <str>   trim_list in_expr substr_for attr attrs
@@ -839,15 +839,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
 %type  <str>   constraints_set_mode
 
 %type  <str>   ECPGWhenever ECPGConnect connection_target ECPGOpen opt_using
-%type  <str>   indicator ECPGExecute ecpg_expr dotext ECPGPrepare
-%type  <str>    storage_clause opt_initializer vartext c_anything blockstart
-%type  <str>    blockend variable_list variable var_anything do_anything
+%type  <str>   indicator ECPGExecute ecpg_expr ECPGPrepare
+%type  <str>    storage_clause opt_initializer c_anything blockstart
+%type  <str>    blockend variable_list variable c_thing c_term
 %type  <str>   opt_pointer cvariable ECPGDisconnect dis_name
 %type  <str>   stmt symbol opt_symbol ECPGRelease execstring server_name
-%type  <str>   connection_object opt_server opt_port c_thing opt_reference
+%type  <str>   connection_object opt_server opt_port c_stuff opt_reference
 %type  <str>    user_name opt_user char_variable ora_user ident
-%type  <str>    db_prefix server opt_options opt_connection_name
-%type  <str>   ECPGSetConnection c_line cpp_line s_enum ECPGTypedef
+%type  <str>    db_prefix server opt_options opt_connection_name c_list
+%type  <str>   ECPGSetConnection cpp_line s_enum ECPGTypedef c_args
 %type  <str>   enum_type civariableonly ECPGCursorStmt ECPGDeallocate
 %type  <str>   ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
 %type  <str>   sql_declaration sql_variable_list sql_variable opt_at
@@ -882,6 +882,7 @@ opt_at:     SQL_AT connection_target        { connection = $2; }
 stmt:  AddAttrStmt                     { output_statement($1, 0); }
                | AlterUserStmt         { output_statement($1, 0); }
                | ClosePortalStmt       { output_statement($1, 0); }
+               | CommentStmt           { output_statement($1, 0); }
                | CopyStmt              { output_statement($1, 0); }
                | CreateStmt            { output_statement($1, 0); }
                | CreateAsStmt          { output_statement($1, 0); }
@@ -1892,7 +1893,23 @@ opt_portal_name:  IN name                { $$ = cat2_str(make1_str("in"), $2); }
                | /*EMPTY*/             { $$ = make1_str(""); }
                ;
 
-
+/*****************************************************************************
+ *
+ *             QUERY:
+ *                     comment on [ table <relname> | column <relname>.<attribu
+ *                                is 'text'
+ *
+ *****************************************************************************/
+CommentStmt:    COMMENT ON COLUMN relation_name '.' attr_name IS Sconst
+                        {
+                               cat2_str(cat5_str(make1_str("comment on column"), $4, make1_str(","), $6, make1_str("is")), $8);
+                        }
+                | COMMENT ON TABLE relation_name IS Sconst
+                        {
+                                cat4_str(make1_str("comment on table"), $4, make1_str("is"), $6);
+                       }
+                       ;
+                       
 /*****************************************************************************
  *
  *             QUERY:
@@ -4195,6 +4212,7 @@ ColId:  ident                                     { $$ = $1; }
                | BACKWARD                      { $$ = make1_str("backward"); }
                | BEFORE                        { $$ = make1_str("before"); }
                | CACHE                         { $$ = make1_str("cache"); }
+               | COMMENT                       { $$ = make1_str("comment"); } 
                | COMMITTED                     { $$ = make1_str("committed"); }
                | CONSTRAINTS                   { $$ = make1_str("constraints"); }
                | CREATEDB                      { $$ = make1_str("createdb"); }
@@ -4265,6 +4283,7 @@ ColId:  ident                                     { $$ = $1; }
                | TIMEZONE_HOUR                 { $$ = make1_str("timezone_hour"); }
                 | TIMEZONE_MINUTE               { $$ = make1_str("timezone_minute"); }
                | TRIGGER                       { $$ = make1_str("trigger"); }
+               | TRUNCATE                      { $$ = make1_str("truncate"); }
                | TRUSTED                       { $$ = make1_str("trusted"); }
                | TYPE_P                        { $$ = make1_str("type"); }
                | VALID                         { $$ = make1_str("valid"); }
@@ -4673,8 +4692,7 @@ type: simple_type
                {
                        $$.type_str = $1;
                        $$.type_enum = ECPGt_int;
-               
-       $$.type_dimension = -1;
+                       $$.type_dimension = -1;
                        $$.type_index = -1;
                }
        | symbol
@@ -4689,7 +4707,7 @@ type: simple_type
                        struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
                }
 
-enum_type: s_enum '{' c_line '}'
+enum_type: s_enum '{' c_list '}'
        {
                $$ = cat4_str($1, make1_str("{"), $3, make1_str("}"));
        }
@@ -4828,7 +4846,7 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
                }
 
 opt_initializer: /* empty */           { $$ = make1_str(""); }
-       | '=' vartext                   { $$ = make2_str(make1_str("="), $2); }
+       | '=' c_term                    { $$ = make2_str(make1_str("="), $2); }
 
 opt_pointer: /* empty */       { $$ = make1_str(""); }
        | '*'                   { $$ = make1_str("*"); }
@@ -5367,7 +5385,7 @@ action : SQL_CONTINUE {
         $<action>$.command = strdup($3);
        $<action>$.str = cat2_str(make1_str("goto "), $3);
 }
-       | DO name '(' dotext ')' {
+       | DO name '(' c_args ')' {
        $<action>$.code = W_DO;
        $<action>$.command = make4_str($2, make1_str("("), $4, make1_str(")"));
        $<action>$.str = cat2_str(make1_str("do"), mm_strdup($<action>$.command));
@@ -5377,7 +5395,7 @@ action : SQL_CONTINUE {
         $<action>$.command = NULL;
         $<action>$.str = make1_str("break");
 }
-       | SQL_CALL name '(' dotext ')' {
+       | SQL_CALL name '(' c_args ')' {
        $<action>$.code = W_DO;
        $<action>$.command = make4_str($2, make1_str("("), $4, make1_str(")"));
        $<action>$.str = cat2_str(make1_str("call"), mm_strdup($<action>$.command));
@@ -5726,11 +5744,8 @@ into_list : coutputvariable | into_list ',' coutputvariable;
 
 ecpgstart: SQL_START { reset_variables();}
 
-dotext: /* empty */            { $$ = make1_str(""); }
-       | dotext do_anything    { $$ = make2_str($1, $2); }
-
-vartext: var_anything          { $$ = $1; }
-        | vartext var_anything { $$ = make2_str($1, $2); }
+c_args: /* empty */            { $$ = make1_str(""); }
+       | c_list                { $$ = $1; }
 
 coutputvariable : cvariable indicator {
                add_variable(&argsresult, find_variable($1), ($2 == NULL) ? &no_indicator : find_variable($2)); 
@@ -5754,6 +5769,7 @@ indicator: /* empty */                    { $$ = NULL; }
 
 ident: IDENT   { $$ = $1; }
        | CSTRING       { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); };
+
 /*
  * C stuff
  */
@@ -5762,13 +5778,27 @@ symbol: IDENT   { $$ = $1; }
 
 cpp_line: CPP_LINE     { $$ = $1; }
 
-c_line: c_anything { $$ = $1; }
-       | c_line c_anything
-               {
-                       $$ = make2_str($1, $2);
-               }
+c_stuff: c_anything    { $$ = $1; }
+       | c_stuff c_anything
+                       {
+                               $$ = cat2_str($1, $2);
+                       }
+       | c_stuff '(' c_stuff ')'
+                       {
+                               $$ = cat4_str($1, make1_str("("), $3, make1_str(")"));
+                       }
+
+c_list: c_term                 { $$ = $1; }
+       | c_term ',' c_list     { $$ = make3_str($1, make1_str(","), $3); }
+
+c_term:  c_stuff               { $$ = $1; }
+       | '{' c_list '}'        { $$ = make3_str(make1_str("{"), $2, make1_str("}")); }
 
-c_thing: c_anything | ';' { $$ = make1_str(";"); }
+c_thing:       c_anything      { $$ = $1; }
+       |       '('             { $$ = make1_str("("); }
+       |       ')'             { $$ = make1_str(")"); }
+       |       ','             { $$ = make1_str(","); }
+       |       ';'             { $$ = make1_str(";"); }
 
 c_anything:  IDENT     { $$ = $1; }
        | CSTRING       { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
@@ -5800,22 +5830,9 @@ c_anything:  IDENT       { $$ = $1; }
        | S_ANYTHING    { $$ = make_name(); }
         | '['          { $$ = make1_str("["); }
        | ']'           { $$ = make1_str("]"); }
-       | '('           { $$ = make1_str("("); }
-       | ')'           { $$ = make1_str(")"); }
+/*        | '('                { $$ = make1_str("("); }
+       | ')'           { $$ = make1_str(")"); }*/
        | '='           { $$ = make1_str("="); }
-       | ','           { $$ = make1_str(","); }
-
-do_anything: IDENT     { $$ = $1; }
-        | CSTRING       { $$ = make3_str(make1_str("\""), $1, make1_str("\""));}
-        | Iconst        { $$ = $1; }
-       | Fconst        { $$ = $1; }
-       | ','           { $$ = make1_str(","); }
-
-var_anything: IDENT            { $$ = $1; }
-       | CSTRING               { $$ = make3_str(make1_str("\""), $1, make1_str("\"")); }
-       | Iconst                { $$ = $1; }
-       | Fconst                { $$ = $1; }
-       | '{' c_line '}'        { $$ = make3_str(make1_str("{"), $2, make1_str("}")); }
 
 blockstart : '{' {
     braces_open++;