Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a0fed291
Commit
a0fed291
authored
May 30, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync and some minor cleanup/fixing work plus an EXEC SQL DESCRIBE prototype.
parent
5666462f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
114 deletions
+163
-114
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+7
-0
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg.c
+2
-1
src/interfaces/ecpg/preproc/ecpg_keywords.c
src/interfaces/ecpg/preproc/ecpg_keywords.c
+3
-1
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+28
-25
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+94
-58
src/interfaces/ecpg/test/dt_test.pgc
src/interfaces/ecpg/test/dt_test.pgc
+29
-29
No files found.
src/interfaces/ecpg/ChangeLog
View file @
a0fed291
...
@@ -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
...
...
src/interfaces/ecpg/preproc/ecpg.c
View file @
a0fed291
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.7
1 2003/05/27 14:36
:00 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.7
2 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
{
{
...
...
src/interfaces/ecpg/preproc/ecpg_keywords.c
View file @
a0fed291
...
@@ -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.2
7 2002/10/21 13:09:31
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.2
8 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
},
...
...
src/interfaces/ecpg/preproc/pgc.l
View file @
a0fed291
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.11
3 2003/05/29 13:59:26
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.11
4 2003/05/30 08:39:01
meskes Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -569,6 +569,8 @@ cppline {space}*#(.*\\{space})+.*
...
@@ -569,6 +569,8 @@ cppline {space}*#(.*\\{space})+.*
}
}
}
}
if (ptr == NULL)
{
/* Is it an SQL keyword? */
/* Is it an SQL keyword? */
keyword = ScanKeywordLookup(yytext);
keyword = ScanKeywordLookup(yytext);
if (keyword != NULL)
if (keyword != NULL)
...
@@ -598,6 +600,7 @@ cppline {space}*#(.*\\{space})+.*
...
@@ -598,6 +600,7 @@ cppline {space}*#(.*\\{space})+.*
return IDENT;
return IDENT;
}
}
}
}
}
<SQL>{other} { return yytext[0]; }
<SQL>{other} { return yytext[0]; }
<C>{exec_sql} { BEGIN SQL; return SQL_START; }
<C>{exec_sql} { BEGIN SQL; return SQL_START; }
<C>{informix_special} {
<C>{informix_special} {
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
a0fed291
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.22
5 2003/05/29 13:59:26
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.22
6 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,22 +1920,16 @@ access_method_clause: USING access_method
...
@@ -1910,22 +1920,16 @@ 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; }
...
@@ -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,10 +5175,35 @@ variablelist: c_variable | c_variable ',' variablelist;
...
@@ -5166,10 +5175,35 @@ 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
...
@@ -5538,6 +5572,7 @@ ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
...
@@ -5538,6 +5572,7 @@ ECPGKeywords_vanames: SQL_BREAK { $$ = make_str("break"); }
;
;
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"); }
...
@@ -5547,6 +5582,7 @@ ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); }
...
@@ -5547,6 +5582,7 @@ ECPGKeywords_rest: SQL_CONNECT { $$ = make_str("connect"); }
/* 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"); }
...
@@ -5598,6 +5634,7 @@ function_name: ident { $$ = $1; }
...
@@ -5598,6 +5634,7 @@ function_name: ident { $$ = $1; }
ColLabel: ECPGColLabel { $$ = $1; }
ColLabel: ECPGColLabel { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| CHAR_P { $$ = make_str("char"); }
| CHAR_P { $$ = make_str("char"); }
| INPUT_P { $$ = make_str("input"); }
| INT_P { $$ = make_str("int"); }
| INT_P { $$ = make_str("int"); }
| UNION { $$ = make_str("union"); }
| UNION { $$ = make_str("union"); }
;
;
...
@@ -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"); }
...
...
src/interfaces/ecpg/test/dt_test.pgc
View file @
a0fed291
...
@@ -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_t
toa
(ts1);
text = PGTYPEStimestamp_t
o_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_t
toa
(ts1);
text = PGTYPEStimestamp_t
o_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_fmt
date
(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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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_defmt
date
(&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;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment