Commit f7563e97 authored by Michael Meskes's avatar Michael Meskes

Synced parser.

Made ecpg parser use backend provided keyword list.
Changed whenever test so exit value is 0.
parent 1ac1bea0
...@@ -2351,6 +2351,13 @@ Mon, 12 May 2008 18:19:08 +0200 ...@@ -2351,6 +2351,13 @@ Mon, 12 May 2008 18:19:08 +0200
- Check for non-existant connection in prepare statement handling. - Check for non-existant connection in prepare statement handling.
- Do not close files that weren't opened. - Do not close files that weren't opened.
Tue, 20 May 2008 17:31:01 +0200
- Synced parser.
- Made ecpg parser use backend provided keyword list. One less file to
sync manually.
- Changed whenever test so exit value is 0.
- Set pgtypes library version to 3.1. - Set pgtypes library version to 3.1.
- Set compat library version to 3.1. - Set compat library version to 3.1.
- Set ecpg library version to 6.2. - Set ecpg library version to 6.2.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1998-2008, PostgreSQL Global Development Group # Copyright (c) 1998-2008, PostgreSQL Global Development Group
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.132 2008/03/18 17:46:23 petere Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.133 2008/05/20 23:17:32 meskes Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -25,7 +25,7 @@ override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \ ...@@ -25,7 +25,7 @@ override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
override CFLAGS += $(PTHREAD_CFLAGS) override CFLAGS += $(PTHREAD_CFLAGS)
OBJS= preproc.o type.o ecpg.o output.o parser.o \ OBJS= preproc.o type.o ecpg.o output.o parser.o \
keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o \ keywords.o c_keywords.o ecpg_keywords.o ../ecpglib/typename.o descriptor.o variable.o \
$(WIN32RES) $(WIN32RES)
all: submake-libpgport ecpg all: submake-libpgport ecpg
...@@ -56,6 +56,11 @@ endif ...@@ -56,6 +56,11 @@ endif
c_keywords.o keywords.o preproc.o parser.o: preproc.h c_keywords.o keywords.o preproc.o parser.o: preproc.h
# instead of maintaining our own list, take the one from the backend
# we cannot just link it in, but must copy and make some minor changes
keywords.c: % : $(top_srcdir)/src/backend/parser/%
sed -e 's/#include "parser\/parse.h"/#include "preproc.h"/' $< > $@
distprep: $(srcdir)/preproc.c $(srcdir)/preproc.h $(srcdir)/pgc.c distprep: $(srcdir)/preproc.c $(srcdir)/preproc.h $(srcdir)/pgc.c
install: all installdirs install: all installdirs
...@@ -68,7 +73,7 @@ uninstall: ...@@ -68,7 +73,7 @@ uninstall:
rm -f '$(DESTDIR)$(bindir)/ecpg$(X)' rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
clean distclean: clean distclean:
rm -f *.o ecpg$(X) rm -f keywords.c *.o ecpg$(X)
# garbage from partial builds # garbage from partial builds
@rm -f y.tab.c y.tab.h @rm -f y.tab.c y.tab.h
# garbage from development # garbage from development
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* keywords.c * keywords.c
* lexical token lookup for reserved words in postgres embedded SQL * lexical token lookup for reserved words in postgres embedded SQL
* *
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.21 2007/08/22 08:20:58 meskes Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.22 2008/05/20 23:17:32 meskes Exp $
* § * §
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,37 +21,39 @@ ...@@ -21,37 +21,39 @@
* search is used to locate entries. * search is used to locate entries.
*/ */
static const ScanKeyword ScanCKeywords[] = { static const ScanKeyword ScanCKeywords[] = {
/* name value */ /* name, value, category */
{"VARCHAR", VARCHAR}, /* category is not needed in ecpg, it is only here so we can share
{"auto", S_AUTO}, * the data structure with the backend */
{"bool", SQL_BOOL}, {"VARCHAR", VARCHAR, 0},
{"char", CHAR_P}, {"auto", S_AUTO, 0},
{"const", S_CONST}, {"bool", SQL_BOOL, 0},
{"enum", ENUM_P}, {"char", CHAR_P, 0},
{"extern", S_EXTERN}, {"const", S_CONST, 0},
{"float", FLOAT_P}, {"enum", ENUM_P, 0},
{"hour", HOUR_P}, {"extern", S_EXTERN, 0},
{"int", INT_P}, {"float", FLOAT_P, 0},
{"long", SQL_LONG}, {"hour", HOUR_P, 0},
{"minute", MINUTE_P}, {"int", INT_P, 0},
{"month", MONTH_P}, {"long", SQL_LONG, 0},
{"register", S_REGISTER}, {"minute", MINUTE_P, 0},
{"second", SECOND_P}, {"month", MONTH_P, 0},
{"short", SQL_SHORT}, {"register", S_REGISTER, 0},
{"signed", SQL_SIGNED}, {"second", SECOND_P, 0},
{"static", S_STATIC}, {"short", SQL_SHORT, 0},
{"struct", SQL_STRUCT}, {"signed", SQL_SIGNED, 0},
{"to", TO}, {"static", S_STATIC, 0},
{"typedef", S_TYPEDEF}, {"struct", SQL_STRUCT, 0},
{"union", UNION}, {"to", TO, 0},
{"unsigned", SQL_UNSIGNED}, {"typedef", S_TYPEDEF, 0},
{"varchar", VARCHAR}, {"union", UNION, 0},
{"volatile", S_VOLATILE}, {"unsigned", SQL_UNSIGNED, 0},
{"year", YEAR_P}, {"varchar", VARCHAR, 0},
{"volatile", S_VOLATILE, 0},
{"year", YEAR_P, 0},
}; };
const ScanKeyword * const ScanKeyword *
ScanCKeywordLookup(char *text) ScanCKeywordLookup(const char *text)
{ {
return DoLookup(text, &ScanCKeywords[0], endof(ScanCKeywords) - 1); return DoLookup(text, &ScanCKeywords[0], endof(ScanCKeywords) - 1);
} }
...@@ -4,11 +4,18 @@ ...@@ -4,11 +4,18 @@
* lexical token lookup for reserved words in postgres embedded SQL * lexical token lookup for reserved words in postgres embedded SQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.37 2007/11/15 21:14:45 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.38 2008/05/20 23:17:32 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres_fe.h"
#include <ctype.h>
#include "extern.h"
#include "preproc.h"
/* /*
* List of (keyword-name, keyword-token-value) pairs. * List of (keyword-name, keyword-token-value) pairs.
* *
...@@ -16,50 +23,129 @@ ...@@ -16,50 +23,129 @@
* search is used to locate entries. * search is used to locate entries.
*/ */
static const ScanKeyword ScanECPGKeywords[] = { static const ScanKeyword ScanECPGKeywords[] = {
/* name value */ /* name, value, category */
{"allocate", SQL_ALLOCATE}, /* category is not needed in ecpg, it is only here so we can share
{"autocommit", SQL_AUTOCOMMIT}, * the data structure with the backend */
{"bool", SQL_BOOL}, {"allocate", SQL_ALLOCATE, 0},
{"break", SQL_BREAK}, {"autocommit", SQL_AUTOCOMMIT, 0},
{"call", SQL_CALL}, {"bool", SQL_BOOL, 0},
{"cardinality", SQL_CARDINALITY}, {"break", SQL_BREAK, 0},
{"connect", SQL_CONNECT}, {"call", SQL_CALL, 0},
{"continue", SQL_CONTINUE}, {"cardinality", SQL_CARDINALITY, 0},
{"count", SQL_COUNT}, {"connect", SQL_CONNECT, 0},
{"data", SQL_DATA}, {"count", SQL_COUNT, 0},
{"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE}, {"data", SQL_DATA, 0},
{"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION}, {"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE, 0},
{"describe", SQL_DESCRIBE}, {"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION, 0},
{"descriptor", SQL_DESCRIPTOR}, {"describe", SQL_DESCRIBE, 0},
{"disconnect", SQL_DISCONNECT}, {"descriptor", SQL_DESCRIPTOR, 0},
{"found", SQL_FOUND}, {"disconnect", SQL_DISCONNECT, 0},
{"free", SQL_FREE}, {"found", SQL_FOUND, 0},
{"go", SQL_GO}, {"free", SQL_FREE, 0},
{"goto", SQL_GOTO}, {"get", SQL_GET, 0},
{"identified", SQL_IDENTIFIED}, {"go", SQL_GO, 0},
{"indicator", SQL_INDICATOR}, {"goto", SQL_GOTO, 0},
{"key_member", SQL_KEY_MEMBER}, {"identified", SQL_IDENTIFIED, 0},
{"length", SQL_LENGTH}, {"indicator", SQL_INDICATOR, 0},
{"long", SQL_LONG}, {"key_member", SQL_KEY_MEMBER, 0},
{"nullable", SQL_NULLABLE}, {"length", SQL_LENGTH, 0},
{"octet_length", SQL_OCTET_LENGTH}, {"long", SQL_LONG, 0},
{"open", SQL_OPEN}, {"nullable", SQL_NULLABLE, 0},
{"output", SQL_OUTPUT}, {"octet_length", SQL_OCTET_LENGTH, 0},
{"reference", SQL_REFERENCE}, {"open", SQL_OPEN, 0},
{"returned_length", SQL_RETURNED_LENGTH}, {"output", SQL_OUTPUT, 0},
{"returned_octet_length", SQL_RETURNED_OCTET_LENGTH}, {"reference", SQL_REFERENCE, 0},
{"scale", SQL_SCALE}, {"returned_length", SQL_RETURNED_LENGTH, 0},
{"section", SQL_SECTION}, {"returned_octet_length", SQL_RETURNED_OCTET_LENGTH, 0},
{"short", SQL_SHORT}, {"scale", SQL_SCALE, 0},
{"signed", SQL_SIGNED}, {"section", SQL_SECTION, 0},
{"sql", SQL_SQL}, /* strange thing, used for into sql descriptor {"short", SQL_SHORT, 0},
{"signed", SQL_SIGNED, 0},
{"sql", SQL_SQL, 0}, /* strange thing, used for into sql descriptor
* MYDESC; */ * MYDESC; */
{"sqlerror", SQL_SQLERROR}, {"sqlerror", SQL_SQLERROR, 0},
{"sqlprint", SQL_SQLPRINT}, {"sqlprint", SQL_SQLPRINT, 0},
{"sqlwarning", SQL_SQLWARNING}, {"sqlwarning", SQL_SQLWARNING, 0},
{"stop", SQL_STOP}, {"stop", SQL_STOP, 0},
{"struct", SQL_STRUCT}, {"struct", SQL_STRUCT, 0},
{"unsigned", SQL_UNSIGNED}, {"unsigned", SQL_UNSIGNED, 0},
{"var", SQL_VAR}, {"var", SQL_VAR, 0},
{"whenever", SQL_WHENEVER}, {"whenever", SQL_WHENEVER, 0},
}; };
/* This is all taken from src/backend/parser/keyword.c and adjusted for our needs. */
/*
* Do a binary search using plain strcmp() comparison.
*/
const ScanKeyword *
DoLookup(const char *word, const ScanKeyword *low, const ScanKeyword *high)
{
while (low <= high)
{
const ScanKeyword *middle;
int difference;
middle = low + (high - low) / 2;
difference = strcmp(middle->name, word);
if (difference == 0)
return middle;
else if (difference < 0)
low = middle + 1;
else
high = middle - 1;
}
return NULL;
}
/*
* ScanECPGKeywordLookup - see if a given word is a keyword
*
* Returns a pointer to the ScanKeyword table entry, or NULL if no match.
*
* The match is done case-insensitively. Note that we deliberately use a
* dumbed-down case conversion that will only translate 'A'-'Z' into 'a'-'z',
* even if we are in a locale where tolower() would produce more or different
* translations. This is to conform to the SQL99 spec, which says that
* keywords are to be matched in this way even though non-keyword identifiers
* receive a different case-normalization mapping.
*/
const ScanKeyword *
ScanECPGKeywordLookup(const char *text)
{
int len,
i;
char word[NAMEDATALEN];
const ScanKeyword *res;
/* First check SQL symbols defined by the backend. */
res = ScanKeywordLookup(text);
if (res)
return res;
len = strlen(text);
/* We assume all keywords are shorter than NAMEDATALEN. */
if (len >= NAMEDATALEN)
return NULL;
/*
* Apply an ASCII-only downcasing. We must not use tolower() since it may
* produce the wrong translation in some locales (eg, Turkish).
*/
for (i = 0; i < len; i++)
{
char ch = text[i];
if (ch >= 'A' && ch <= 'Z')
ch += 'a' - 'A';
word[i] = ch;
}
word[len] = '\0';
/*
* Now do a binary search using plain strcmp() comparison.
*/
return DoLookup(word, &ScanECPGKeywords[0], endof(ScanECPGKeywords) - 1);
}
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.70 2007/11/15 21:14:45 momjian Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.71 2008/05/20 23:17:32 meskes Exp $ */
#ifndef _ECPG_PREPROC_EXTERN_H #ifndef _ECPG_PREPROC_EXTERN_H
#define _ECPG_PREPROC_EXTERN_H #define _ECPG_PREPROC_EXTERN_H
#include "type.h" #include "type.h"
#include "parser/keywords.h"
#include <errno.h> #include <errno.h>
#ifndef CHAR_BIT #ifndef CHAR_BIT
...@@ -74,7 +75,6 @@ extern void base_yyerror(const char *); ...@@ -74,7 +75,6 @@ extern void base_yyerror(const char *);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t); extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *); extern char *mm_strdup(const char *);
extern void mmerror(int, enum errortype, char *,...); extern void mmerror(int, enum errortype, char *,...);
extern const ScanKeyword *ScanCKeywordLookup(char *);
extern void output_get_descr_header(char *); extern void output_get_descr_header(char *);
extern void output_get_descr(char *, char *); extern void output_get_descr(char *, char *);
extern void output_set_descr_header(char *); extern void output_set_descr_header(char *);
...@@ -96,8 +96,9 @@ extern void check_indicator(struct ECPGtype *); ...@@ -96,8 +96,9 @@ extern void check_indicator(struct ECPGtype *);
extern void remove_typedefs(int); extern void remove_typedefs(int);
extern void remove_variables(int); extern void remove_variables(int);
extern struct variable *new_variable(const char *, struct ECPGtype *, int); extern struct variable *new_variable(const char *, struct ECPGtype *, int);
extern const ScanKeyword *ScanKeywordLookup(char *text); extern const ScanKeyword *ScanCKeywordLookup(const char *);
extern const ScanKeyword *DoLookup(char *, const ScanKeyword *, const ScanKeyword *); extern const ScanKeyword *ScanECPGKeywordLookup(const char *text);
extern const ScanKeyword *DoLookup(const char *, const ScanKeyword *, const ScanKeyword *);
extern void scanner_init(const char *); extern void scanner_init(const char *);
extern void parser_init(void); extern void parser_init(void);
extern void scanner_finish(void); extern void scanner_finish(void);
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.165 2008/05/16 15:20:04 petere Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.166 2008/05/20 23:17:32 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -680,7 +680,7 @@ cppline {space}*#(.*\\{space})*.*{newline} ...@@ -680,7 +680,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
if (!isdefine()) if (!isdefine())
{ {
/* Is it an SQL/ECPG keyword? */ /* Is it an SQL/ECPG keyword? */
keyword = ScanKeywordLookup(yytext); keyword = ScanECPGKeywordLookup(yytext);
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.365 2008/05/16 15:20:04 petere Exp $ */ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.366 2008/05/20 23:17:32 meskes Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
...@@ -392,11 +392,11 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu ...@@ -392,11 +392,11 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
/* special embedded SQL token */ /* special embedded SQL token */
%token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK %token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
SQL_CALL SQL_CARDINALITY SQL_CONNECT SQL_CALL SQL_CARDINALITY SQL_CONNECT
SQL_CONTINUE SQL_COUNT SQL_DATA SQL_COUNT SQL_DATA
SQL_DATETIME_INTERVAL_CODE SQL_DATETIME_INTERVAL_CODE
SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE
SQL_DESCRIPTOR SQL_DISCONNECT SQL_FOUND SQL_DESCRIPTOR SQL_DISCONNECT SQL_FOUND
SQL_FREE SQL_GO SQL_GOTO SQL_IDENTIFIED SQL_FREE SQL_GET SQL_GO SQL_GOTO SQL_IDENTIFIED
SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH
SQL_OPEN SQL_OUTPUT SQL_REFERENCE SQL_OPEN SQL_OUTPUT SQL_REFERENCE
...@@ -427,7 +427,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu ...@@ -427,7 +427,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS
CONTENT_P CONVERSION_P COPY COST CREATE CREATEDB CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE CREATEDB
CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
...@@ -441,14 +441,14 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu ...@@ -441,14 +441,14 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
FALSE_P FAMILY FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM FALSE_P FAMILY FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD FREEZE FROM
FULL FUNCTION FULL FUNCTION
GET GLOBAL GRANT GRANTED GREATEST GROUP_P GLOBAL GRANT GRANTED GREATEST GROUP_P
HANDLER HAVING HEADER_P HOLD HOUR_P HANDLER HAVING HEADER_P HOLD HOUR_P
IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCLUDING INCREMENT IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P
INDEX INDEXES INHERIT INHERITS INITIALLY INNER_P INOUT INPUT_P INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY
INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
INTERVAL INTO INVOKER IS ISNULL ISOLATION INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
JOIN JOIN
...@@ -555,7 +555,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu ...@@ -555,7 +555,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
%type <str> ConstraintElem key_actions ColQualList cluster_index_specification %type <str> ConstraintElem key_actions ColQualList cluster_index_specification
%type <str> target_list target_el alias_clause type_func_name_keyword %type <str> target_list target_el alias_clause type_func_name_keyword
%type <str> qualified_name database_name alter_using type_function_name %type <str> qualified_name database_name alter_using type_function_name
%type <str> access_method attr_name index_name name func_name %type <str> access_method attr_name index_name name func_name opt_restart_seqs
%type <str> file_name AexprConst c_expr ConstTypename var_list %type <str> file_name AexprConst c_expr ConstTypename var_list
%type <str> a_expr b_expr TruncateStmt CommentStmt OnCommitOption opt_by %type <str> a_expr b_expr TruncateStmt CommentStmt OnCommitOption opt_by
%type <str> opt_indirection expr_list extract_list extract_arg %type <str> opt_indirection expr_list extract_list extract_arg
...@@ -1862,6 +1862,8 @@ OptSeqElem: CACHE NumConst ...@@ -1862,6 +1862,8 @@ OptSeqElem: CACHE NumConst
{ $$ = cat2_str(make_str("owned by"), $3); } { $$ = cat2_str(make_str("owned by"), $3); }
| START opt_with NumConst | START opt_with NumConst
{ $$ = cat_str(3, make_str("start"), $2, $3); } { $$ = cat_str(3, make_str("start"), $2, $3); }
| RESTART
{ $$ = make_str("restart"); }
| RESTART opt_with NumConst | RESTART opt_with NumConst
{ $$ = cat_str(3, make_str("restart"), $2, $3); } { $$ = cat_str(3, make_str("restart"), $2, $3); }
; ;
...@@ -2179,7 +2181,10 @@ opt_opfamily: FAMILY any_name { $$ = cat2_str(make_str("family"), $2); } ...@@ -2179,7 +2181,10 @@ opt_opfamily: FAMILY any_name { $$ = cat2_str(make_str("family"), $2); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
opt_recheck: RECHECK { $$ = make_str("recheck"); } opt_recheck: RECHECK {
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported RECHECK OPTION will be passed to backend");
$$ = make_str("recheck");
}
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
...@@ -2282,10 +2287,16 @@ attrs: '.' attr_name { $$ = cat2_str(make_str("."), $2); } ...@@ -2282,10 +2287,16 @@ attrs: '.' attr_name { $$ = cat2_str(make_str("."), $2); }
* truncate table relname1, relname2, .... * truncate table relname1, relname2, ....
* *
*****************************************************************************/ *****************************************************************************/
TruncateStmt: TRUNCATE opt_table qualified_name_list opt_drop_behavior TruncateStmt: TRUNCATE opt_table qualified_name_list opt_restart_seqs opt_drop_behavior
{ $$ = cat_str(4, make_str("truncate table"), $2, $3, $4); } { $$ = cat_str(5, make_str("truncate table"), $2, $3, $4, $5); }
; ;
opt_restart_seqs:
CONTINUE_P IDENTITY_P { $$ = cat2_str(make_str("continue"), make_str("identity")); }
| RESTART IDENTITY_P { $$ = cat2_str(make_str("restart"), make_str("identity")); }
| /* EMPTY */ { $$ = EMPTY; }
;
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
...@@ -2852,6 +2863,8 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name ...@@ -2852,6 +2863,8 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
{ $$ = cat_str(4, make_str("alter text search template"), $5, make_str("rename to"), $8); } { $$ = cat_str(4, make_str("alter text search template"), $5, make_str("rename to"), $8); }
| ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
{ $$ = cat_str(4, make_str("alter text search configuration"), $5, make_str("rename to"), $8); } { $$ = cat_str(4, make_str("alter text search configuration"), $5, make_str("rename to"), $8); }
| ALTER TYPE_P any_name RENAME TO name
{ $$ = cat_str(4, make_str("alter type"), $3, make_str("rename to"), $6); }
; ;
opt_column: COLUMN { $$ = make_str("column"); } opt_column: COLUMN { $$ = make_str("column"); }
...@@ -2960,6 +2973,7 @@ event: SELECT { $$ = make_str("select"); } ...@@ -2960,6 +2973,7 @@ event: SELECT { $$ = make_str("select"); }
| UPDATE { $$ = make_str("update"); } | UPDATE { $$ = make_str("update"); }
| DELETE_P { $$ = make_str("delete"); } | DELETE_P { $$ = make_str("delete"); }
| INSERT { $$ = make_str("insert"); } | INSERT { $$ = make_str("insert"); }
| TRUNCATE { $$ = make_str("truncate"); }
; ;
opt_instead: INSTEAD { $$ = make_str("instead"); } opt_instead: INSTEAD { $$ = make_str("instead"); }
...@@ -4538,29 +4552,26 @@ expr_list: a_expr ...@@ -4538,29 +4552,26 @@ expr_list: a_expr
{ $$ = cat_str(3, $1, make_str(","), $3); } { $$ = cat_str(3, $1, make_str(","), $3); }
; ;
extract_list: extract_arg FROM a_expr
{ $$ = cat_str(3, $1, make_str("from"), $3); }
| /* EMPTY */
{ $$ = EMPTY; }
;
type_list: Typename type_list: Typename
{ $$ = $1; } { $$ = $1; }
| type_list ',' Typename | type_list ',' Typename
{ $$ = cat_str(3, $1, ',', $3); } { $$ = cat_str(3, $1, ',', $3); }
; ;
array_expr: '[' expr_list ']' { $$ = cat_str(3, make_str("["), $2, make_str("]")); }
| '[' array_expr_list ']' { $$ = cat_str(3, make_str("["), $2, make_str("]")); }
| '[' ']' { $$ = make_str("[]"); }
;
array_expr_list: array_expr { $$ = $1; } array_expr_list: array_expr { $$ = $1; }
| array_expr_list ',' array_expr { $$ = cat_str(3, $1, make_str(","), $3); } | array_expr_list ',' array_expr { $$ = cat_str(3, $1, make_str(","), $3); }
; ;
extract_list: extract_arg FROM a_expr
array_expr: '[' expr_list ']' { $$ = cat_str(3, make_str("["), $2, make_str("]")); } { $$ = cat_str(3, $1, make_str("from"), $3); }
| '[' array_expr_list ']' { $$ = cat_str(3, make_str("["), $2, make_str("]")); } | /* EMPTY */
{ $$ = EMPTY; }
; ;
/* Allow delimited string SCONST in extract_arg as an SQL extension.
* - thomas 2001-04-12
*/
extract_arg: ident { $$ = $1; } extract_arg: ident { $$ = $1; }
| YEAR_P { $$ = make_str("year"); } | YEAR_P { $$ = make_str("year"); }
...@@ -4703,6 +4714,14 @@ target_list: target_list ',' target_el ...@@ -4703,6 +4714,14 @@ target_list: target_list ',' target_el
target_el: a_expr AS ColLabel target_el: a_expr AS ColLabel
{ $$ = cat_str(3, $1, make_str("as"), $3); } { $$ = cat_str(3, $1, make_str("as"), $3); }
/*
* We support omitting AS only for column labels that aren't
* any known keyword. There is an ambiguity against postfix
* operators: is "a ! b" an infix expression, or a postfix
* expression and a column label? We prefer to resolve this
* as an infix expression, which we accomplish by assigning
* IDENT a precedence higher than POSTFIXOP.
*/
| a_expr IDENT | a_expr IDENT
{ $$ = cat_str(3, $1, make_str("as"), $2); } { $$ = cat_str(3, $1, make_str("as"), $2); }
| a_expr | a_expr
...@@ -5999,7 +6018,7 @@ ECPGDeallocateDescr: DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar ...@@ -5999,7 +6018,7 @@ ECPGDeallocateDescr: DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
* manipulate a descriptor header * manipulate a descriptor header
*/ */
ECPGGetDescriptorHeader: GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
{ $$ = $3; } { $$ = $3; }
; ;
...@@ -6034,7 +6053,7 @@ desc_header_item: SQL_COUNT { $$ = ECPGd_count; } ...@@ -6034,7 +6053,7 @@ desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
* manipulate a descriptor * manipulate a descriptor
*/ */
ECPGGetDescriptor: GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems ECPGGetDescriptor: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
{ $$.str = $5; $$.name = $3; } { $$.str = $5; $$.name = $3; }
; ;
...@@ -6214,7 +6233,7 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action ...@@ -6214,7 +6233,7 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
} }
; ;
action : SQL_CONTINUE action : CONTINUE_P
{ {
$<action>$.code = W_NOTHING; $<action>$.code = W_NOTHING;
$<action>$.command = NULL; $<action>$.command = NULL;
...@@ -6280,7 +6299,6 @@ ECPGKeywords: ECPGKeywords_vanames { $$ = $1; } ...@@ -6280,7 +6299,6 @@ 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_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"); }
...@@ -6467,6 +6485,7 @@ ECPGunreserved_con: ABORT_P { $$ = make_str("abort"); } ...@@ -6467,6 +6485,7 @@ ECPGunreserved_con: ABORT_P { $$ = make_str("abort"); }
/* | CONNECTION { $$ = make_str("connection"); }*/ /* | CONNECTION { $$ = make_str("connection"); }*/
| CONSTRAINTS { $$ = make_str("constraints"); } | CONSTRAINTS { $$ = make_str("constraints"); }
| CONTENT_P { $$ = make_str("content"); } | CONTENT_P { $$ = make_str("content"); }
| CONTINUE_P { $$ = make_str("continue"); }
| CONVERSION_P { $$ = make_str("conversion"); } | CONVERSION_P { $$ = make_str("conversion"); }
| COPY { $$ = make_str("copy"); } | COPY { $$ = make_str("copy"); }
| COST { $$ = make_str("cost"); } | COST { $$ = make_str("cost"); }
...@@ -6515,6 +6534,7 @@ ECPGunreserved_con: ABORT_P { $$ = make_str("abort"); } ...@@ -6515,6 +6534,7 @@ ECPGunreserved_con: ABORT_P { $$ = make_str("abort"); }
| HEADER_P { $$ = make_str("header"); } | HEADER_P { $$ = make_str("header"); }
| HOLD { $$ = make_str("hold"); } | HOLD { $$ = make_str("hold"); }
/* | HOUR_P { $$ = make_str("hour"); }*/ /* | HOUR_P { $$ = make_str("hour"); }*/
| IDENTITY_P { $$ = make_str("identity"); }
| IF_P { $$ = make_str("if"); } | IF_P { $$ = make_str("if"); }
| IMMEDIATE { $$ = make_str("immediate"); } | IMMEDIATE { $$ = make_str("immediate"); }
| IMMUTABLE { $$ = make_str("immutable"); } | IMMUTABLE { $$ = make_str("immutable"); }
......
/* /*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.49 2008/05/17 01:28:25 adunstan Exp $ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.50 2008/05/20 23:17:32 meskes Exp $
*/ */
#ifndef _ECPG_PREPROC_TYPE_H #ifndef _ECPG_PREPROC_TYPE_H
#define _ECPG_PREPROC_TYPE_H #define _ECPG_PREPROC_TYPE_H
...@@ -190,10 +190,4 @@ struct fetch_desc ...@@ -190,10 +190,4 @@ struct fetch_desc
char *name; char *name;
}; };
typedef struct ScanKeyword
{
char *name;
int value;
} ScanKeyword;
#endif /* _ECPG_PREPROC_TYPE_H */ #endif /* _ECPG_PREPROC_TYPE_H */
...@@ -2,68 +2,68 @@ ...@@ -2,68 +2,68 @@
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT> [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 23: QUERY: alter user connectuser encrypted password 'connectpw' with 0 parameter on connection main [NO_PID]: ecpg_execute on line 23: query: alter user connectuser encrypted password 'connectpw'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 23: using PQexec [NO_PID]: ecpg_execute on line 23: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 23 Ok: ALTER ROLE [NO_PID]: ecpg_execute on line 23: OK: ALTER ROLE
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <DEFAULT> [NO_PID]: ECPGconnect: opening database connectdb on localhost port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT> for user connectdb [NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT> for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> [NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT>
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <REGRESSION_PORT> for user connectdb [NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <REGRESSION_PORT> for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT>
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <REGRESSION_PORT> for user connectdb [NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <REGRESSION_PORT> for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed. [NO_PID]: ecpg_finish: connection main closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection connectdb closed. [NO_PID]: ecpg_finish: connection connectdb closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <REGRESSION_PORT> for user connectdb [NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <REGRESSION_PORT> for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection (null) closed. [NO_PID]: ecpg_finish: connection (null) closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection connectdb closed. [NO_PID]: ecpg_finish: connection connectdb closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection connectdb closed. [NO_PID]: ecpg_finish: connection connectdb closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> with options connect_timeout=14 for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> with options connect_timeout=14 for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection connectdb closed. [NO_PID]: ecpg_finish: connection connectdb closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database nonexistant on localhost port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database nonexistant on localhost port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: could not open database: FATAL: database "nonexistant" does not exist [NO_PID]: ECPGconnect: could not open database: FATAL: database "nonexistant" does not exist
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection nonexistant closed. [NO_PID]: ecpg_finish: connection nonexistant closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlcode -402 in line 62, 'Could not connect to database nonexistant in line 62.'. [NO_PID]: raising sqlcode -402 on line 62: could not connect to database "nonexistant" on line 62
[NO_PID]: sqlca: code: -402, state: 08001 [NO_PID]: sqlca: code: -402, state: 08001
[NO_PID]: raising sqlcode -220 in line 63, 'No such connection CURRENT in line 63.'. [NO_PID]: raising sqlcode -220 on line 63: no such connection CURRENT on line 63
[NO_PID]: sqlca: code: -220, state: 08003 [NO_PID]: sqlca: code: -220, state: 08003
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
TCP/IP connections on port 20? TCP/IP connections on port 20?
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection connectdb closed. [NO_PID]: ecpg_finish: connection connectdb closed
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlcode -402 in line 66, 'Could not connect to database connectdb in line 66.'. [NO_PID]: raising sqlcode -402 on line 66: could not connect to database "connectdb" on line 66
[NO_PID]: sqlca: code: -402, state: 08001 [NO_PID]: sqlca: code: -402, state: 08001
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> for user connectuser [NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
...@@ -220,25 +220,27 @@ if (sqlca.sqlcode < 0) goto error;} ...@@ -220,25 +220,27 @@ if (sqlca.sqlcode < 0) goto error;}
/* exec sql whenever sqlerror stop ; */ /* exec sql whenever sqlerror stop ; */
#line 61 "whenever.pgc" #line 61 "whenever.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant ", ECPGt_EOIT, /* This cannot fail, thus we don't get an exit value not equal 0. */
/* However, it still test the precompiler output. */
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 ", ECPGt_EOIT,
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 62 "whenever.pgc" #line 64 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') warn ( ); if (sqlca.sqlwarn[0] == 'W') warn ( );
#line 62 "whenever.pgc" #line 64 "whenever.pgc"
if (sqlca.sqlcode < 0) exit (1);} if (sqlca.sqlcode < 0) exit (1);}
#line 62 "whenever.pgc" #line 64 "whenever.pgc"
{ ECPGtrans(__LINE__, NULL, "rollback"); { ECPGtrans(__LINE__, NULL, "rollback");
#line 63 "whenever.pgc" #line 65 "whenever.pgc"
if (sqlca.sqlwarn[0] == 'W') warn ( ); if (sqlca.sqlwarn[0] == 'W') warn ( );
#line 63 "whenever.pgc" #line 65 "whenever.pgc"
if (sqlca.sqlcode < 0) exit (1);} if (sqlca.sqlcode < 0) exit (1);}
#line 63 "whenever.pgc" #line 65 "whenever.pgc"
exit (0); exit (0);
} }
...@@ -82,11 +82,13 @@ sql error: relation "nonexistant" does not exist on line 47 ...@@ -82,11 +82,13 @@ sql error: relation "nonexistant" does not exist on line 47
[NO_PID]: sqlca: code: -400, state: 42P01 [NO_PID]: sqlca: code: -400, state: 42P01
[NO_PID]: ECPGtrans on line 59: action "rollback"; connection "regress1" [NO_PID]: ECPGtrans on line 59: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 62: query: select * from nonexistant ; with 0 parameter(s) on connection regress1 [NO_PID]: ecpg_execute on line 64: query: select 1 ; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 62: using PQexec [NO_PID]: ecpg_execute on line 64: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_check_PQresult on line 62: ERROR: relation "nonexistant" does not exist [NO_PID]: ecpg_execute on line 64: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 64: RESULT: 1 offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 65: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlstate 42P01 (sqlcode -400) on line 62: relation "nonexistant" does not exist on line 62
[NO_PID]: sqlca: code: -400, state: 42P01
...@@ -59,7 +59,9 @@ int main(void) ...@@ -59,7 +59,9 @@ int main(void)
exec sql rollback; exec sql rollback;
exec sql whenever sqlerror stop; exec sql whenever sqlerror stop;
exec sql select * into :i from nonexistant; /* This cannot fail, thus we don't get an exit value not equal 0. */
/* However, it still test the precompiler output. */
exec sql select 1 into :i;
exec sql rollback; exec sql rollback;
exit (0); exit (0);
} }
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