/* header */
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.382 2008/11/11 11:41:23 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.383 2008/11/13 11:54:39 meskes Exp $ */
/* Copyright comment */
%{
struct prep prep;
}
/* tokens */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.383 2008/11/13 11:54:39 meskes Exp $ */
/* special embedded SQL token */
%token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
SQL_CALL SQL_CARDINALITY SQL_CONNECT
%type <str> SeqOptElem
%type <str> opt_by
%type <str> NumericOnly
-%type <str> FloatOnly
-%type <str> IntegerOnly
%type <str> CreatePLangStmt
%type <str> opt_trusted
%type <str> handler_name
%type <str> file_name
%type <str> func_name
%type <str> AexprConst
+%type <str> Iconst
%type <str> RoleId
%type <str> SignedIconst
%type <str> ColId
%type <str> reserved_keyword
%type <str> SpecialRuleRelation
/* ecpgtype */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.383 2008/11/13 11:54:39 meskes Exp $ */
%type <str> ECPGAllocateDescr
%type <str> ECPGCKeywords
%type <str> ECPGColId
%type <str> char_variable
%type <str> civar
%type <str> civarind
-%type <str> ColId_or_real_sconst
%type <str> ColLabel
%type <str> connect_options
%type <str> connection_object
%type <str> dis_name
%type <str> ecpg_bconst
%type <str> ecpg_fconst
-%type <str> ecpg_iconst
%type <str> ecpg_ident
%type <str> ecpg_interval
%type <str> ecpg_into
%type <str> ecpg_param
-%type <str> ecpg_real_iconst
-%type <str> ecpg_real_sconst
%type <str> ecpg_sconst
%type <str> ecpg_using
%type <str> ecpg_xconst
{
$$ = cat_str(2,make_str("user"),$2);
}
-| SYSID ecpg_iconst
+| SYSID Iconst
{
$$ = cat_str(2,make_str("sysid"),$2);
}
{
$$ = $1;
}
-| ColId_or_real_sconst
+| ColId_or_Sconst
{
$$ = $1;
}
zone_value:
-ecpg_real_sconst
+ ecpg_sconst
{
$$ = $1;
}
{
$$ = cat_str(3,$1,$2,$3);
}
-| ConstInterval '(' ecpg_iconst ')' ecpg_sconst opt_interval
+| ConstInterval '(' Iconst ')' ecpg_sconst opt_interval
{
$$ = cat_str(6,$1,make_str("("),$3,make_str(")"),$5,$6);
}
{
$$ = cat_str(4,make_str("alter"),$2,$3,make_str("set not null"));
}
-| ALTER opt_column ColId SET STATISTICS IntegerOnly
+| ALTER opt_column ColId SET STATISTICS SignedIconst
{
$$ = cat_str(5,make_str("alter"),$2,$3,make_str("set statistics"),$6);
}
NumericOnly:
- FloatOnly
- {
- $$ = $1;
-}
-| IntegerOnly
- {
- $$ = $1;
-}
-;
-
-
- FloatOnly:
ecpg_fconst
{
$$ = $1;
{
$$ = cat_str(2,make_str("-"),$2);
}
-;
-
-
- IntegerOnly:
- SignedIconst
+| SignedIconst
{
$$ = $1;
}
+;
+
+
;
TriggerFuncArg:
- ecpg_iconst
+ Iconst
{
$$ = $1;
}
{
$$ = $1;
}
-| ecpg_real_sconst
+| ecpg_sconst
{
$$ = $1;
}
{
$$ = $1;
}
-| ecpg_real_sconst
+| ecpg_sconst
{
$$ = $1;
}
opclass_item:
- OPERATOR ecpg_iconst any_operator opt_recheck
+ OPERATOR Iconst any_operator opt_recheck
{
$$ = cat_str(4,make_str("operator"),$2,$3,$4);
}
-| OPERATOR ecpg_iconst any_operator oper_argtypes opt_recheck
+| OPERATOR Iconst any_operator oper_argtypes opt_recheck
{
$$ = cat_str(5,make_str("operator"),$2,$3,$4,$5);
}
-| FUNCTION ecpg_iconst func_name func_args
+| FUNCTION Iconst func_name func_args
{
$$ = cat_str(4,make_str("function"),$2,$3,$4);
}
-| FUNCTION ecpg_iconst '(' type_list ')' func_name func_args
+| FUNCTION Iconst '(' type_list ')' func_name func_args
{
$$ = cat_str(7,make_str("function"),$2,make_str("("),$4,make_str(")"),$6,$7);
}
opclass_drop:
- OPERATOR ecpg_iconst '(' type_list ')'
+ OPERATOR Iconst '(' type_list ')'
{
$$ = cat_str(5,make_str("operator"),$2,make_str("("),$4,make_str(")"));
}
-| FUNCTION ecpg_iconst '(' type_list ')'
+| FUNCTION Iconst '(' type_list ')'
{
$$ = cat_str(5,make_str("function"),$2,make_str("("),$4,make_str(")"));
}
{
$$ = cat_str(3,make_str("template"),$2,make_str("default"));
}
-| ENCODING opt_equal ecpg_real_sconst
+| ENCODING opt_equal ecpg_sconst
{
$$ = cat_str(3,make_str("encoding"),$2,$3);
}
-| ENCODING opt_equal ecpg_iconst
+| ENCODING opt_equal Iconst
{
$$ = cat_str(3,make_str("encoding"),$2,$3);
}
{ $$ = cat2_str($1, $2.str); }
| SETOF SimpleTypename opt_array_bounds
{ $$ = $$ = cat_str(3, make_str("setof"), $2, $3.str); }
-| SimpleTypename ARRAY '[' ecpg_iconst ']'
+| SimpleTypename ARRAY '[' Iconst ']'
{
$$ = cat_str(4,$1,make_str("array ["),$4,make_str("]"));
}
-| SETOF SimpleTypename ARRAY '[' ecpg_iconst ']'
+| SETOF SimpleTypename ARRAY '[' Iconst ']'
{
$$ = cat_str(5,make_str("setof"),$2,make_str("array ["),$5,make_str("]"));
}
{
$$ = cat_str(2,$1,$2);
}
-| ConstInterval '(' ecpg_iconst ')' opt_interval
+| ConstInterval '(' Iconst ')' opt_interval
{
$$ = cat_str(5,$1,make_str("("),$3,make_str(")"),$5);
}
opt_float:
- '(' ecpg_iconst ')'
+ '(' Iconst ')'
{
$$ = cat_str(3,make_str("("),$2,make_str(")"));
}
CharacterWithLength:
- character '(' ecpg_iconst ')' opt_charset
+ character '(' Iconst ')' opt_charset
{
$$ = cat_str(5,$1,make_str("("),$3,make_str(")"),$5);
}
ConstDatetime:
- TIMESTAMP '(' ecpg_iconst ')' opt_timezone
+ TIMESTAMP '(' Iconst ')' opt_timezone
{
$$ = cat_str(4,make_str("timestamp ("),$3,make_str(")"),$5);
}
{
$$ = cat_str(2,make_str("timestamp"),$2);
}
-| TIME '(' ecpg_iconst ')' opt_timezone
+| TIME '(' Iconst ')' opt_timezone
{
$$ = cat_str(4,make_str("time ("),$3,make_str(")"),$5);
}
{
$$ = make_str("second");
}
-| SECOND_P '(' ecpg_iconst ')'
+| SECOND_P '(' Iconst ')'
{
$$ = cat_str(3,make_str("second ("),$3,make_str(")"));
}
{
$$ = make_str("current_time");
}
-| CURRENT_TIME '(' ecpg_iconst ')'
+| CURRENT_TIME '(' Iconst ')'
{
$$ = cat_str(3,make_str("current_time ("),$3,make_str(")"));
}
{
$$ = make_str("current_timestamp");
}
-| CURRENT_TIMESTAMP '(' ecpg_iconst ')'
+| CURRENT_TIMESTAMP '(' Iconst ')'
{
$$ = cat_str(3,make_str("current_timestamp ("),$3,make_str(")"));
}
{
$$ = make_str("localtime");
}
-| LOCALTIME '(' ecpg_iconst ')'
+| LOCALTIME '(' Iconst ')'
{
$$ = cat_str(3,make_str("localtime ("),$3,make_str(")"));
}
{
$$ = make_str("localtimestamp");
}
-| LOCALTIMESTAMP '(' ecpg_iconst ')'
+| LOCALTIMESTAMP '(' Iconst ')'
{
$$ = cat_str(3,make_str("localtimestamp ("),$3,make_str(")"));
}
AexprConst:
- ecpg_iconst
+ Iconst
{
$$ = $1;
}
{
$$ = $1;
}
-| ecpg_real_sconst
+| ecpg_sconst
{
$$ = $1;
}
{
$$ = cat_str(3,$1,$2,$3);
}
-| ConstInterval '(' ecpg_iconst ')' ecpg_sconst opt_interval
+| ConstInterval '(' Iconst ')' ecpg_sconst opt_interval
{
$$ = cat_str(6,$1,make_str("("),$3,make_str(")"),$5,$6);
}
{
$$ = make_str("null");
}
+ | civar { $$ = $1; }
| civarind { $$ = $1; }
;
+ Iconst:
+ ICONST
+ { $$ = make_name(); }
+;
+
+
RoleId:
ColId
{
SignedIconst:
- ecpg_iconst
+ Iconst
{
$$ = $1;
}
- | '+' ecpg_real_iconst { $$ = cat_str(2, make_str("+"), $2); }
- | '-' ecpg_real_iconst { $$ = cat_str(2, make_str("-"), $2); }
+ | civar { $$ = $1; }
+| '+' Iconst
+ {
+ $$ = cat_str(2,make_str("+"),$2);
+}
+| '-' Iconst
+ {
+ $$ = cat_str(2,make_str("-"),$2);
+}
;
{
$$ = $1;
}
- | ecpg_real_sconst
+ | ecpg_sconst
{
/* We can only process double quoted strings not single quotes ones,
* so we change the quotes.
- * Note, that the rule for ecpg_real_sconst adds these single quotes. */
+ * Note, that the rule for ecpg_sconst adds these single quotes. */
$1[0] = '\"';
$1[strlen($1)-1] = '\"';
$$ = $1;
| IP { $$ = make_name(); }
;
-opt_port: ':' ecpg_iconst { $$ = make2_str(make_str(":"), $2); }
+opt_port: ':' Iconst { $$ = make2_str(make_str(":"), $2); }
| /*EMPTY*/ { $$ = EMPTY; }
;
{
if ($1[0] == '\"')
$$ = $1;
- else if ($1[1] == '$') /* variable */
- {
- enum ECPGttype type = argsinsert->variable->type->type;
+ else
+ $$ = make3_str(make_str("\""), $1, make_str("\""));
+ }
+ | civar
+ {
+ enum ECPGttype type = argsinsert->variable->type->type;
- /* if array see what's inside */
- if (type == ECPGt_array)
- type = argsinsert->variable->type->u.element->type;
+ /* if array see what's inside */
+ if (type == ECPGt_array)
+ type = argsinsert->variable->type->u.element->type;
- /* handle varchars */
- if (type == ECPGt_varchar)
- $$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
- else
- $$ = mm_strdup(argsinsert->variable->name);
- }
+ /* handle varchars */
+ if (type == ECPGt_varchar)
+ $$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
else
- $$ = make3_str(make_str("\""), $1, make_str("\""));
+ $$ = mm_strdup(argsinsert->variable->name);
}
;
opt_opt_value: /*EMPTY*/
{ $$ = EMPTY; }
- | '=' ecpg_iconst
+ | '=' Iconst
{ $$ = make2_str(make_str("="), $2); }
| '=' ecpg_ident
{ $$ = make2_str(make_str("="), $2); }
+ | '=' civar
+ { $$ = make2_str(make_str("="), $2); }
;
prepared_name: name {
}
;
-opt_bit_field: ':' ecpg_iconst { $$ =cat2_str(make_str(":"), $2); }
+opt_bit_field: ':' Iconst { $$ =cat2_str(make_str(":"), $2); }
| /* EMPTY */ { $$ = EMPTY; }
;
| civarind { $$ = EMPTY; }
;
-UsingConst: ecpg_real_iconst { $$ = $1; }
+UsingConst: Iconst { $$ = $1; }
| ecpg_fconst { $$ = $1; }
- | ecpg_real_sconst { $$ = $1; }
+ | ecpg_sconst { $$ = $1; }
| ecpg_bconst { $$ = $1; }
| ecpg_xconst { $$ = $1; }
;
}
;
-IntConstVar: ecpg_real_iconst
+IntConstVar: Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
- | '-' ecpg_real_iconst
+ | '-' Iconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(make_str("-"), $2);
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var;
}
- | ecpg_real_sconst
+ | ecpg_sconst
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = $1 + 1;
ecpg_fconst: FCONST { $$ = make_name(); } ;
-ecpg_real_iconst:
- ICONST { $$ = make_name(); } ;
-
-ecpg_iconst: ecpg_real_iconst { $$ = $1; }
- | civar { $$ = $1; }
- ;
-
-ecpg_real_sconst:
+ecpg_sconst:
SCONST
{
/* could have been input as '' or $$ */
| DOLCONST { $$ = $1; }
;
-ecpg_sconst: ecpg_real_sconst { $$ = $1; }
- | civar { $$ = $1; }
- ;
-
ecpg_xconst: XCONST { $$ = make_name(); } ;
ecpg_ident: IDENT { $$ = make_name(); }
| UIDENT { $$ = $1; }
;
-ColId_or_real_sconst: ColId { $$ = $1; }
- | ecpg_real_sconst { $$ = $1; }
- ;
-
quoted_ident_stringvar: name
{ $$ = make3_str(make_str("\""), $1, make_str("\"")); }
| char_variable
;
c_anything: ecpg_ident { $$ = $1; }
- | ecpg_real_iconst { $$ = $1; }
+ | Iconst { $$ = $1; }
| ecpg_fconst { $$ = $1; }
- | ecpg_real_sconst { $$ = $1; }
+ | ecpg_sconst { $$ = $1; }
| '*' { $$ = make_str("*"); }
| '+' { $$ = make_str("+"); }
| '-' { $$ = make_str("-"); }
| DEALLOCATE PREPARE ALL { $$ = make_str("all"); }
;
-Iresult: ecpg_iconst { $$ = $1; }
+Iresult: Iconst { $$ = $1; }
| '(' Iresult ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
| Iresult '+' Iresult { $$ = cat_str(3, $1, make_str("+"), $3); }
| Iresult '-' Iresult { $$ = cat_str(3, $1, make_str("-"), $3); }
| Iresult '*' Iresult { $$ = cat_str(3, $1, make_str("*"), $3); }
| Iresult '/' Iresult { $$ = cat_str(3, $1, make_str("/"), $3); }
| Iresult '%' Iresult { $$ = cat_str(3, $1, make_str("%"), $3); }
- | ecpg_real_sconst { $$ = $1; }
+ | ecpg_sconst { $$ = $1; }
| ColId { $$ = $1; }
;
int
main ()
{
-/*
- EXEC SQL BEGIN DECLARE SECTION;
- char *fname = "/tmp/foo";
- EXEC SQL END DECLARE SECTION;
-*/
-
ECPGdebug (1, stderr);
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
-#line 19 "copystdout.pgc"
+#line 13 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 19 "copystdout.pgc"
+#line 13 "copystdout.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table foo ( a int , b varchar ) ", ECPGt_EOIT, ECPGt_EORT);
-#line 20 "copystdout.pgc"
+#line 14 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 20 "copystdout.pgc"
+#line 14 "copystdout.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT);
-#line 21 "copystdout.pgc"
+#line 15 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 21 "copystdout.pgc"
+#line 15 "copystdout.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT);
-#line 22 "copystdout.pgc"
+#line 16 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 22 "copystdout.pgc"
+#line 16 "copystdout.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT);
-#line 23 "copystdout.pgc"
+#line 17 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 23 "copystdout.pgc"
+#line 17 "copystdout.pgc"
- /* produces expected file "/tmp/foo" */
- /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */
- /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */
-
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT);
-#line 29 "copystdout.pgc"
+#line 19 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 29 "copystdout.pgc"
+#line 19 "copystdout.pgc"
printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 32 "copystdout.pgc"
+#line 22 "copystdout.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 32 "copystdout.pgc"
+#line 22 "copystdout.pgc"
return 0;
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 20: query: create table foo ( a int , b varchar ) ; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 14: query: create table foo ( a int , b varchar ) ; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 20: using PQexec
+[NO_PID]: ecpg_execute on line 14: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 20: OK: CREATE TABLE
+[NO_PID]: ecpg_execute on line 14: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 21: query: insert into foo values ( 5 , 'abc' ) ; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 15: query: insert into foo values ( 5 , 'abc' ) ; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 21: using PQexec
+[NO_PID]: ecpg_execute on line 15: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 21: OK: INSERT 0 1
+[NO_PID]: ecpg_execute on line 15: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 22: query: insert into foo values ( 6 , 'def' ) ; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 16: query: insert into foo values ( 6 , 'def' ) ; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 22: using PQexec
+[NO_PID]: ecpg_execute on line 16: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 22: OK: INSERT 0 1
+[NO_PID]: ecpg_execute on line 16: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 23: query: insert into foo values ( 7 , 'ghi' ) ; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 17: query: insert into foo values ( 7 , 'ghi' ) ; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 23: using PQexec
+[NO_PID]: ecpg_execute on line 17: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
+[NO_PID]: ecpg_execute on line 17: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 29: query: copy foo to stdout with delimiter ','; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 19: query: copy foo to stdout with delimiter ','; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 29: using PQexec
+[NO_PID]: ecpg_execute on line 19: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 29: COPY OUT data transfer in progress
+[NO_PID]: ecpg_execute on line 19: COPY OUT data transfer in progress
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 29: got PGRES_COMMAND_OK after PGRES_COPY_OUT
+[NO_PID]: ecpg_execute on line 19: got PGRES_COMMAND_OK after PGRES_COPY_OUT
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000