Commit a0fed291 authored by Michael Meskes's avatar Michael Meskes

Sync and some minor cleanup/fixing work plus an EXEC SQL DESCRIBE prototype.

parent 5666462f
...@@ -1458,6 +1458,13 @@ Thu May 29 15:45:57 CEST 2003 ...@@ -1458,6 +1458,13 @@ Thu May 29 15:45:57 CEST 2003
- Changed parsing of variables to be able to reference one attribute - Changed parsing of variables to be able to reference one attribute
of the n-th entry in an array of structs. of the n-th entry in an array of structs.
Fri May 30 10:29:49 CEST 2003
- Synced parser.
- Added a dummy rule for EXEC SQL DESCRIBE that throws an error
message.
- Some minor cleanup/bug fixing.
- Set ecpg version to 2.12.0. - Set ecpg version to 2.12.0.
- Set ecpg library to 3.4.2. - Set ecpg library to 3.4.2.
- Set pgtypes library to 1.0.0 - Set pgtypes library to 1.0.0
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.71 2003/05/27 14:36:00 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.72 2003/05/30 08:39:00 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...@@ -169,6 +169,7 @@ main(int argc, char *const argv[]) ...@@ -169,6 +169,7 @@ main(int argc, char *const argv[])
/* system_includes = true; */ /* system_includes = true; */
add_preprocessor_define("dec_t=Numeric"); add_preprocessor_define("dec_t=Numeric");
add_preprocessor_define("intrvl_t=Interval"); add_preprocessor_define("intrvl_t=Interval");
add_preprocessor_define("dtime_t=Timestamp");
} }
else else
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* lexical token lookup for reserved words in postgres embedded SQL * lexical token lookup for reserved words in postgres embedded SQL
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.27 2002/10/21 13:09:31 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.28 2003/05/30 08:39:00 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,6 +38,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -38,6 +38,7 @@ static ScanKeyword ScanKeywords[] = {
{"data", SQL_DATA}, {"data", SQL_DATA},
{"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE}, {"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE},
{"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION}, {"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION},
{"describe", SQL_DESCRIBE},
{"descriptor", SQL_DESCRIPTOR}, {"descriptor", SQL_DESCRIPTOR},
{"disconnect", SQL_DISCONNECT}, {"disconnect", SQL_DISCONNECT},
{"enum", SQL_ENUM}, {"enum", SQL_ENUM},
...@@ -54,6 +55,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -54,6 +55,7 @@ static ScanKeyword ScanKeywords[] = {
{"nullable", SQL_NULLABLE}, {"nullable", SQL_NULLABLE},
{"octet_length", SQL_OCTET_LENGTH}, {"octet_length", SQL_OCTET_LENGTH},
{"open", SQL_OPEN}, {"open", SQL_OPEN},
{"output", SQL_OUTPUT},
{"reference", SQL_REFERENCE}, {"reference", SQL_REFERENCE},
{"release", SQL_RELEASE}, {"release", SQL_RELEASE},
{"returned_length", SQL_RETURNED_LENGTH}, {"returned_length", SQL_RETURNED_LENGTH},
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.113 2003/05/29 13:59:26 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.114 2003/05/30 08:39:01 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -569,33 +569,36 @@ cppline {space}*#(.*\\{space})+.* ...@@ -569,33 +569,36 @@ cppline {space}*#(.*\\{space})+.*
} }
} }
/* Is it an SQL keyword? */ if (ptr == NULL)
keyword = ScanKeywordLookup(yytext); {
if (keyword != NULL) /* Is it an SQL keyword? */
return keyword->value; keyword = ScanKeywordLookup(yytext);
if (keyword != NULL)
return keyword->value;
/* Is it an ECPG keyword? */ /* Is it an ECPG keyword? */
keyword = ScanECPGKeywordLookup( yytext); keyword = ScanECPGKeywordLookup( yytext);
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
/* Is it a C keyword? */ /* Is it a C keyword? */
keyword = ScanCKeywordLookup(yytext); keyword = ScanCKeywordLookup(yytext);
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
/* /*
* None of the above. Return it as an identifier. * None of the above. Return it as an identifier.
* *
* The backend would attempt to truncate and case-fold * The backend would attempt to truncate and case-fold
* the identifier, but I see no good reason for ecpg * the identifier, but I see no good reason for ecpg
* to do so; that's just another way that ecpg could get * to do so; that's just another way that ecpg could get
* out of step with the backend. * out of step with the backend.
*/ */
if (ptr == NULL) if (ptr == NULL)
{ {
yylval.str = mm_strdup(yytext); yylval.str = mm_strdup(yytext);
return IDENT; return IDENT;
}
} }
} }
<SQL>{other} { return yytext[0]; } <SQL>{other} { return yytext[0]; }
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.225 2003/05/29 13:59:26 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.226 2003/05/30 08:39:01 meskes Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
...@@ -207,12 +207,12 @@ create_questionmarks(char *name, bool array) ...@@ -207,12 +207,12 @@ create_questionmarks(char *name, bool array)
SQL_CALL SQL_CARDINALITY SQL_CONNECT SQL_CONNECTION SQL_CALL SQL_CARDINALITY SQL_CONNECT SQL_CONNECTION
SQL_CONTINUE SQL_COUNT SQL_CURRENT SQL_DATA SQL_CONTINUE SQL_COUNT SQL_CURRENT SQL_DATA
SQL_DATETIME_INTERVAL_CODE SQL_DATETIME_INTERVAL_CODE
SQL_DATETIME_INTERVAL_PRECISION SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE
SQL_DESCRIPTOR SQL_DISCONNECT SQL_ENUM SQL_FOUND SQL_DESCRIPTOR SQL_DISCONNECT SQL_ENUM SQL_FOUND
SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED
SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
SQL_LONG SQL_NAME SQL_NULLABLE SQL_OCTET_LENGTH SQL_LONG SQL_NAME SQL_NULLABLE SQL_OCTET_LENGTH
SQL_OPEN SQL_RELEASE SQL_REFERENCE SQL_OPEN SQL_OUTPUT SQL_RELEASE SQL_REFERENCE
SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR
SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
...@@ -369,7 +369,7 @@ create_questionmarks(char *name, bool array) ...@@ -369,7 +369,7 @@ create_questionmarks(char *name, bool array)
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose %type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
%type <str> opt_full func_arg OptWithOids opt_freeze opt_ecpg_into %type <str> opt_full func_arg OptWithOids opt_freeze opt_ecpg_into
%type <str> analyze_keyword opt_name_list ExplainStmt index_params %type <str> analyze_keyword opt_name_list ExplainStmt index_params
%type <str> index_list func_index index_elem opt_class access_method_clause %type <str> index_elem opt_class access_method_clause
%type <str> index_opt_unique IndexStmt func_return ConstInterval %type <str> index_opt_unique IndexStmt func_return ConstInterval
%type <str> func_args_list func_args opt_with def_arg overlay_placing %type <str> func_args_list func_args opt_with def_arg overlay_placing
%type <str> def_elem def_list definition DefineStmt select_with_parens %type <str> def_elem def_list definition DefineStmt select_with_parens
...@@ -439,12 +439,13 @@ create_questionmarks(char *name, bool array) ...@@ -439,12 +439,13 @@ create_questionmarks(char *name, bool array)
%type <str> struct_union_type s_struct_union vt_declarations %type <str> struct_union_type s_struct_union vt_declarations
%type <str> var_declaration type_declaration single_vt_declaration %type <str> var_declaration type_declaration single_vt_declaration
%type <str> ECPGSetAutocommit on_off variable_declarations %type <str> ECPGSetAutocommit on_off variable_declarations
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol %type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_output
%type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration %type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration
%type <str> reserved_keyword unreserved_keyword ecpg_interval %type <str> reserved_keyword unreserved_keyword ecpg_interval
%type <str> col_name_keyword func_name_keyword precision opt_scale %type <str> col_name_keyword func_name_keyword precision opt_scale
%type <str> ECPGTypeName variablelist ECPGColLabelCommon c_variable %type <str> ECPGTypeName variablelist ECPGColLabelCommon c_variable
%type <str> inf_val_list inf_col_list %type <str> inf_val_list inf_col_list using_descriptor ECPGDescribe
%type <str> into_descriptor
%type <struct_union> s_struct_union_symbol %type <struct_union> s_struct_union_symbol
...@@ -614,6 +615,15 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } ...@@ -614,6 +615,15 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
{ {
output_simple_statement($1); output_simple_statement($1);
} }
| ECPGDescribe
{
if (connection)
mmerror(PARSE_ERROR, ET_ERROR, "no at option for describe statement.\n");
fprintf(yyout, "{ /* ECPGdescribe(__LINE__, %s) */;", $1);
/* whenever_action(2); */
free($1);
}
| ECPGDisconnect | ECPGDisconnect
{ {
if (connection) if (connection)
...@@ -679,7 +689,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); } ...@@ -679,7 +689,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
| ECPGPrepare | ECPGPrepare
{ {
if (connection) if (connection)
mmerror(PARSE_ERROR, ET_ERROR, "no at option for set connection statement.\n"); mmerror(PARSE_ERROR, ET_ERROR, "no at option for prepare statement.\n");
fprintf(yyout, "{ ECPGprepare(__LINE__, %s);", $1); fprintf(yyout, "{ ECPGprepare(__LINE__, %s);", $1);
whenever_action(2); whenever_action(2);
...@@ -1890,7 +1900,7 @@ function_with_argtypes: func_name func_args { $$ = cat2_str($1, $2); }; ...@@ -1890,7 +1900,7 @@ function_with_argtypes: func_name func_args { $$ = cat2_str($1, $2); };
* *
* QUERY: * QUERY:
* create index <indexname> on <relname> * create index <indexname> on <relname>
* [ using <access> ] "(" (<col> with <op>)+ ")" * [ using <access> ] "(" ( <col> | using <opclass> ] )+ ")"
* [ where <predicate> ] * [ where <predicate> ]
* *
*****************************************************************************/ *****************************************************************************/
...@@ -1910,23 +1920,17 @@ access_method_clause: USING access_method ...@@ -1910,23 +1920,17 @@ access_method_clause: USING access_method
{ $$ = EMPTY; } { $$ = EMPTY; }
; ;
index_params: index_list { $$ = $1; } index_params: index_elem { $$ = $1; }
| func_index { $$ = $1; } | index_params ',' index_elem { $$ = $1; }
;
index_list: index_list ',' index_elem
{ $$ = cat_str(3, $1, make_str(","), $3); }
| index_elem
{ $$ = $1; }
;
func_index: func_name '(' name_list ')' opt_class
{ $$ = cat_str(5, $1, make_str("("), $3, ")", $5); }
; ;
index_elem: attr_name opt_class index_elem: attr_name opt_class
{ $$ = cat2_str($1, $2); } { $$ = cat2_str($1, $2); }
; | func_name '(' expr_list ')' opt_class
{ $$ = cat_str(5, $1, make_str("("), $3, ")", $5); }
| '(' a_expr ')' opt_class
{ $$ = cat_str(4, make_str("("), $2, make_str(")"), $4); }
;
opt_class: any_name { $$ = $1; } opt_class: any_name { $$ = $1; }
| USING any_name { $$ = cat2_str(make_str("using"), $2); } | USING any_name { $$ = cat2_str(make_str("using"), $2); }
...@@ -3873,7 +3877,7 @@ name_list: name ...@@ -3873,7 +3877,7 @@ name_list: name
; ;
name: ColId { $$ = $1; }; name: ColId { $$ = $1; };
database_name: ColId { $$ = $1; }; database_name: ColId { $$ = $1; };
access_method: ColId { $$ = $1; }; access_method: ColId { $$ = $1; };
attr_name: ColId { $$ = $1; }; attr_name: ColId { $$ = $1; };
...@@ -5135,28 +5139,33 @@ ECPGFree: SQL_FREE name { $$ = $2; }; ...@@ -5135,28 +5139,33 @@ ECPGFree: SQL_FREE name { $$ = $2; };
ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; }; ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; };
opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; } opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
| USING variablelist | USING variablelist { $$ = EMPTY; }
{
/* mmerror ("open cursor with variables not implemented yet"); */
$$ = EMPTY;
}
; ;
opt_sql: /*EMPTY*/ | SQL_SQL; using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
ecpg_into: INTO into_list
{ {
add_variable(&argsresult, descriptor_variable($4,0), &no_indicator);
$$ = EMPTY; $$ = EMPTY;
} }
| INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar ;
into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
{ {
add_variable(&argsresult, descriptor_variable($4,0), &no_indicator); add_variable(&argsresult, descriptor_variable($4,0), &no_indicator);
$$ = EMPTY; $$ = EMPTY;
} }
; ;
opt_sql: /*EMPTY*/ | SQL_SQL;
ecpg_into: INTO into_list { $$ = EMPTY; }
| into_descriptor { $$ = $1; }
| using_descriptor { $$ = $1; }
;
opt_ecpg_into: /*EMPTY*/ { $$ = EMPTY; } opt_ecpg_into: /*EMPTY*/ { $$ = EMPTY; }
| ecpg_into { $$ = $1; } | INTO into_list { $$ = EMPTY; }
| into_descriptor { $$ = $1; }
; ;
c_variable: civarind | civar; c_variable: civarind | civar;
...@@ -5166,11 +5175,36 @@ variablelist: c_variable | c_variable ',' variablelist; ...@@ -5166,11 +5175,36 @@ variablelist: c_variable | c_variable ',' variablelist;
/* /*
* As long as the prepare statement is not supported by the backend, we will * As long as the prepare statement is not supported by the backend, we will
* try to simulate it here so we get dynamic SQL * try to simulate it here so we get dynamic SQL
*
* It is supported now but not usable yet by ecpg.
*/ */
ECPGPrepare: PREPARE name FROM execstring ECPGPrepare: PREPARE name FROM execstring
{ $$ = cat2_str(make3_str(make_str("\""), $2, make_str("\",")), $4); } { $$ = cat2_str(make3_str(make_str("\""), $2, make_str("\",")), $4); }
; ;
/*
* We accept descibe but do nothing with it so far.
*/
ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
{
mmerror(PARSE_ERROR, ET_ERROR, "using unsupported describe statement.\n");
$$ = cat_str(3, make_str("input"), $3, $4);
}
| SQL_DESCRIBE opt_output name using_descriptor
{
mmerror(PARSE_ERROR, ET_ERROR, "using unsupported describe statement.\n");
$$ = cat_str(3, $2, $3, $4);
}
| SQL_DESCRIBE opt_output name into_descriptor
{
mmerror(PARSE_ERROR, ET_ERROR, "using unsupported describe statement.\n");
$$ = cat_str(3, $2, $3, $4);
}
;
opt_output: SQL_OUTPUT { $$ = make_str("output"); }
| /* EMPTY */ { $$ = EMPTY; }
;
/* /*
* dynamic SQL: descriptor based access * dynamic SQL: descriptor based access
* written by Christof Petig <christof.petig@wtal.de> * written by Christof Petig <christof.petig@wtal.de>
...@@ -5509,44 +5543,46 @@ ECPGKeywords: ECPGKeywords_vanames { $$ = $1; } ...@@ -5509,44 +5543,46 @@ ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
; ;
ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); } ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
| SQL_CALL { $$ = make_str("call"); } | SQL_CALL { $$ = make_str("call"); }
| SQL_CARDINALITY { $$ = make_str("cardinality"); } | SQL_CARDINALITY { $$ = make_str("cardinality"); }
| SQL_CONTINUE { $$ = make_str("continue"); } | SQL_CONTINUE { $$ = make_str("continue"); }
| SQL_COUNT { $$ = make_str("count"); } | SQL_COUNT { $$ = make_str("count"); }
| SQL_DATA { $$ = make_str("data"); } | SQL_DATA { $$ = make_str("data"); }
| SQL_DATETIME_INTERVAL_CODE { $$ = make_str("datetime_interval_code"); } | SQL_DATETIME_INTERVAL_CODE { $$ = make_str("datetime_interval_code"); }
| SQL_DATETIME_INTERVAL_PRECISION { $$ = make_str("datetime_interval_precision"); } | SQL_DATETIME_INTERVAL_PRECISION { $$ = make_str("datetime_interval_precision"); }
| SQL_FOUND { $$ = make_str("found"); } | SQL_FOUND { $$ = make_str("found"); }
| SQL_GO { $$ = make_str("go"); } | SQL_GO { $$ = make_str("go"); }
| SQL_GOTO { $$ = make_str("goto"); } | SQL_GOTO { $$ = make_str("goto"); }
| SQL_IDENTIFIED { $$ = make_str("identified"); } | SQL_IDENTIFIED { $$ = make_str("identified"); }
| SQL_INDICATOR { $$ = make_str("indicator"); } | SQL_INDICATOR { $$ = make_str("indicator"); }
| SQL_KEY_MEMBER { $$ = make_str("key_member"); } | SQL_KEY_MEMBER { $$ = make_str("key_member"); }
| SQL_LENGTH { $$ = make_str("length"); } | SQL_LENGTH { $$ = make_str("length"); }
| SQL_NAME { $$ = make_str("name"); } | SQL_NAME { $$ = make_str("name"); }
| SQL_NULLABLE { $$ = make_str("nullable"); } | SQL_NULLABLE { $$ = make_str("nullable"); }
| SQL_OCTET_LENGTH { $$ = make_str("octet_length"); } | SQL_OCTET_LENGTH { $$ = make_str("octet_length"); }
| SQL_RELEASE { $$ = make_str("release"); } | SQL_RELEASE { $$ = make_str("release"); }
| SQL_RETURNED_LENGTH { $$ = make_str("returned_length"); } | SQL_RETURNED_LENGTH { $$ = make_str("returned_length"); }
| SQL_RETURNED_OCTET_LENGTH { $$ = make_str("returned_octet_length"); } | SQL_RETURNED_OCTET_LENGTH { $$ = make_str("returned_octet_length"); }
| SQL_SCALE { $$ = make_str("scale"); } | SQL_SCALE { $$ = make_str("scale"); }
| SQL_SECTION { $$ = make_str("section"); } | SQL_SECTION { $$ = make_str("section"); }
| SQL_SQLERROR { $$ = make_str("sqlerror"); } | SQL_SQLERROR { $$ = make_str("sqlerror"); }
| SQL_SQLPRINT { $$ = make_str("sqlprint"); } | SQL_SQLPRINT { $$ = make_str("sqlprint"); }
| SQL_SQLWARNING { $$ = make_str("sqlwarning"); } | SQL_SQLWARNING { $$ = make_str("sqlwarning"); }
| SQL_STOP { $$ = make_str("stop"); } | SQL_STOP { $$ = make_str("stop"); }
; ;
ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); } ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); }
| SQL_DESCRIBE { $$ = make_str("describe"); }
| SQL_DISCONNECT { $$ = make_str("disconnect"); } | SQL_DISCONNECT { $$ = make_str("disconnect"); }
| SQL_OPEN { $$ = make_str("open"); } | SQL_OPEN { $$ = make_str("open"); }
| SQL_VAR { $$ = make_str("var"); } | SQL_VAR { $$ = make_str("var"); }
| SQL_WHENEVER { $$ = make_str("whenever"); } | SQL_WHENEVER { $$ = make_str("whenever"); }
; ;
/* additional keywords that can be SQL type names (but not ECPGColLabels) */ /* additional keywords that can be SQL type names (but not ECPGColLabels) */
ECPGTypeName: SQL_BOOL { $$ = make_str("bool"); } ECPGTypeName: SQL_BOOL { $$ = make_str("bool"); }
| SQL_LONG { $$ = make_str("long"); } | SQL_LONG { $$ = make_str("long"); }
| SQL_OUTPUT { $$ = make_str("output"); }
| SQL_SHORT { $$ = make_str("short"); } | SQL_SHORT { $$ = make_str("short"); }
| SQL_STRUCT { $$ = make_str("struct"); } | SQL_STRUCT { $$ = make_str("struct"); }
| SQL_SIGNED { $$ = make_str("signed"); } | SQL_SIGNED { $$ = make_str("signed"); }
...@@ -5578,28 +5614,29 @@ ColId: ident { $$ = $1; } ...@@ -5578,28 +5614,29 @@ ColId: ident { $$ = $1; }
/* Type identifier --- names that can be type names. /* Type identifier --- names that can be type names.
*/ */
type_name: ident { $$ = $1; } type_name: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; } | unreserved_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; } | ECPGKeywords { $$ = $1; }
| ECPGTypeName { $$ = $1; } | ECPGTypeName { $$ = $1; }
; ;
/* Function identifier --- names that can be function names. /* Function identifier --- names that can be function names.
*/ */
function_name: ident { $$ = $1; } function_name: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; } | unreserved_keyword { $$ = $1; }
| func_name_keyword { $$ = $1; } | func_name_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; } | ECPGKeywords { $$ = $1; }
; ;
/* Column label --- allowed labels in "AS" clauses. /* Column label --- allowed labels in "AS" clauses.
* This presently includes *all* Postgres keywords. * This presently includes *all* Postgres keywords.
*/ */
ColLabel: ECPGColLabel { $$ = $1; } ColLabel: ECPGColLabel { $$ = $1; }
| ECPGTypeName { $$ = $1; } | ECPGTypeName { $$ = $1; }
| CHAR_P { $$ = make_str("char"); } | CHAR_P { $$ = make_str("char"); }
| INT_P { $$ = make_str("int"); } | INPUT_P { $$ = make_str("input"); }
| UNION { $$ = make_str("union"); } | INT_P { $$ = make_str("int"); }
| UNION { $$ = make_str("union"); }
; ;
ECPGColLabelCommon: ident { $$ = $1; } ECPGColLabelCommon: ident { $$ = $1; }
...@@ -5693,7 +5730,6 @@ unreserved_keyword: ...@@ -5693,7 +5730,6 @@ unreserved_keyword:
| INDEX { $$ = make_str("index"); } | INDEX { $$ = make_str("index"); }
| INHERITS { $$ = make_str("inherits"); } | INHERITS { $$ = make_str("inherits"); }
| INOUT { $$ = make_str("inout"); } | INOUT { $$ = make_str("inout"); }
| INPUT_P { $$ = make_str("input"); }
| INSENSITIVE { $$ = make_str("insensitive"); } | INSENSITIVE { $$ = make_str("insensitive"); }
| INSERT { $$ = make_str("insert"); } | INSERT { $$ = make_str("insert"); }
| INSTEAD { $$ = make_str("instead"); } | INSTEAD { $$ = make_str("instead"); }
......
...@@ -30,13 +30,13 @@ main() ...@@ -30,13 +30,13 @@ main()
exec sql select * into :date1, :ts1 , :iv1 from date_test; exec sql select * into :date1, :ts1 , :iv1 from date_test;
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf ("Date: %s\n", text); printf ("Date: %s\n", text);
text = PGTYPEStimestamp_ttoa(ts1); text = PGTYPEStimestamp_to_asc(ts1);
printf ("timestamp: %s\n", text); printf ("timestamp: %s\n", text);
text = PGTYPESinterval_itoa(&iv1); text = PGTYPESinterval_to_asc(&iv1);
printf ("interval: %s\n", text); printf ("interval: %s\n", text);
PGTYPESdate_mdyjul(mdy, &date2); PGTYPESdate_mdyjul(mdy, &date2);
...@@ -49,19 +49,19 @@ main() ...@@ -49,19 +49,19 @@ main()
PGTYPESdate_julmdy(date2, mdy); PGTYPESdate_julmdy(date2, mdy);
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]); printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
ts1 = PGTYPEStimestamp_atot("2003-12-04 17:34:29", NULL); ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
text = PGTYPEStimestamp_ttoa(ts1); text = PGTYPEStimestamp_to_asc(ts1);
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(ts1)); printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(ts1));
PGTYPESdate_today(&date1); PGTYPESdate_today(&date1);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("today is %s\n", text); printf("today is %s\n", text);
fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end"; fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end";
out = (char*) malloc(strlen(fmt) + 1); out = (char*) malloc(strlen(fmt) + 1);
PGTYPESdate_fmtdate(date1, fmt, out); PGTYPESdate_fmt_asc(date1, fmt, out);
printf("Today in format \"%s\" is \"%s\"\n", fmt, out); printf("Today in format \"%s\" is \"%s\"\n", fmt, out);
free(out); free(out);
...@@ -73,78 +73,78 @@ main() ...@@ -73,78 +73,78 @@ main()
/* 0123456789012345678901234567890123456789012345678901234567890 /* 0123456789012345678901234567890123456789012345678901234567890
* 0 1 2 3 4 5 6 * 0 1 2 3 4 5 6
*/ */
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate1: %s\n", text); printf("defmtdate1: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mmmm. dd. yyyy"; fmt = "mmmm. dd. yyyy";
in = "12/25/95"; in = "12/25/95";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate2: %s\n", text); printf("defmtdate2: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "yy/mm/dd"; fmt = "yy/mm/dd";
in = "95/12/25"; in = "95/12/25";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate3: %s\n", text); printf("defmtdate3: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "yy/mm/dd"; fmt = "yy/mm/dd";
in = "1995, December 25th"; in = "1995, December 25th";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate4: %s\n", text); printf("defmtdate4: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "dd-mm-yy"; fmt = "dd-mm-yy";
in = "This is 25th day of December, 1995"; in = "This is 25th day of December, 1995";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate5: %s\n", text); printf("defmtdate5: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mmddyy"; fmt = "mmddyy";
in = "Dec. 25th, 1995"; in = "Dec. 25th, 1995";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate6: %s\n", text); printf("defmtdate6: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mmm. dd. yyyy"; fmt = "mmm. dd. yyyy";
in = "dec 25th 1995"; in = "dec 25th 1995";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate7: %s\n", text); printf("defmtdate7: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mmm. dd. yyyy"; fmt = "mmm. dd. yyyy";
in = "DEC-25-1995"; in = "DEC-25-1995";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate8: %s\n", text); printf("defmtdate8: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mm yy dd."; fmt = "mm yy dd.";
in = "12199525"; in = "12199525";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate9: %s\n", text); printf("defmtdate9: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "yyyy fierj mm dd."; fmt = "yyyy fierj mm dd.";
in = "19951225"; in = "19951225";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate10: %s\n", text); printf("defmtdate10: %s\n", text);
date1 = 0; text = ""; date1 = 0; text = "";
fmt = "mm/dd/yy"; fmt = "mm/dd/yy";
in = "122595"; in = "122595";
PGTYPESdate_defmtdate(&date1, fmt, in); PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_dtoa(date1); text = PGTYPESdate_to_asc(date1);
printf("defmtdate12: %s\n", text); printf("defmtdate12: %s\n", text);
exec sql rollback; exec sql rollback;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment