mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
@@ -2,20 +2,25 @@ SRCDIR= ../../..
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
||||
MAJOR_VERSION=2
|
||||
MINOR_VERSION=4
|
||||
PATCHLEVEL=9
|
||||
MINOR_VERSION=5
|
||||
PATCHLEVEL=0
|
||||
|
||||
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
|
||||
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
|
||||
-DINCLUDE_PATH=\"$(DESTDIR)$(HEADERDIR)\"
|
||||
-DINCLUDE_PATH=\"$(DESTDIR)$(HEADERDIR)\"
|
||||
|
||||
OBJ=y.tab.o pgc.o type.o ecpg.o ecpg_keywords.o ../../../backend/parser/scansup.o \
|
||||
OBJ=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o ../../../backend/parser/scansup.o \
|
||||
keywords.o c_keywords.o ../lib/typename.o
|
||||
|
||||
all:: ecpg
|
||||
|
||||
preproc.c preproc.h: preproc.y
|
||||
$(YACC) $(YFLAGS) $<
|
||||
mv y.tab.c preproc.c
|
||||
mv y.tab.h preproc.h
|
||||
|
||||
clean:
|
||||
rm -f *.o core a.out ecpg$(X) y.tab.h y.tab.c pgc.c *~
|
||||
rm -f *.o core a.out ecpg$(X) *~
|
||||
|
||||
install: all
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) ecpg$(X) $(DESTDIR)$(BINDIR)
|
||||
@@ -31,13 +36,10 @@ pgc.c: pgc.l
|
||||
$(LEX) $<
|
||||
mv lex.yy.c pgc.c
|
||||
|
||||
y.tab.h y.tab.c: preproc.y
|
||||
$(YACC) $(YFLAGS) $<
|
||||
|
||||
y.tab.o : y.tab.h ../include/ecpgtype.h keywords.c c_keywords.c ecpg_keywords.c
|
||||
preproc.o : preproc.h ../include/ecpgtype.h keywords.c c_keywords.c ecpg_keywords.c
|
||||
type.o : ../include/ecpgtype.h
|
||||
pgc.o : ../include/ecpgtype.h keywords.c c_keywords.c ecpg_keywords.c y.tab.h
|
||||
keywords.o: ../include/ecpgtype.h y.tab.h
|
||||
c_keywords.o: ../include/ecpgtype.h y.tab.h
|
||||
ecpg_keywords.o: ../include/ecpgtype.h y.tab.h
|
||||
pgc.o : ../include/ecpgtype.h keywords.c c_keywords.c ecpg_keywords.c preproc.h
|
||||
keywords.o: ../include/ecpgtype.h preproc.h
|
||||
c_keywords.o: ../include/ecpgtype.h preproc.h
|
||||
ecpg_keywords.o: ../include/ecpgtype.h preproc.h
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "postgres.h"
|
||||
#include "type.h"
|
||||
#include "y.tab.h"
|
||||
#include "extern.h"
|
||||
#include "preproc.h"
|
||||
|
||||
/*
|
||||
* List of (keyword-name, keyword-token-value) pairs.
|
||||
|
||||
@@ -25,6 +25,7 @@ extern char *optarg;
|
||||
struct _include_path *include_paths;
|
||||
int no_auto_trans = 0;
|
||||
struct cursor *cur = NULL;
|
||||
struct typedefs *types = NULL;
|
||||
|
||||
static void
|
||||
usage(char *progname)
|
||||
@@ -155,22 +156,22 @@ main(int argc, char *const argv[])
|
||||
{
|
||||
struct cursor *ptr;
|
||||
struct _defines *defptr;
|
||||
|
||||
struct typedefs *typeptr;
|
||||
|
||||
/* remove old cursor definitions if any are still there */
|
||||
for (ptr = cur; ptr != NULL;)
|
||||
{
|
||||
struct cursor *this = ptr;
|
||||
struct arguments *l1,
|
||||
*l2;
|
||||
struct arguments *l1, *l2;
|
||||
|
||||
free(ptr->command);
|
||||
free(ptr->name);
|
||||
for (l1 = argsinsert; l1; l1 = l2)
|
||||
for (l1 = ptr->argsinsert; l1; l1 = l2)
|
||||
{
|
||||
l2 = l1->next;
|
||||
free(l1);
|
||||
}
|
||||
for (l1 = argsresult; l1; l1 = l2)
|
||||
for (l1 = ptr->argsresult; l1; l1 = l2)
|
||||
{
|
||||
l2 = l1->next;
|
||||
free(l1);
|
||||
@@ -189,7 +190,19 @@ main(int argc, char *const argv[])
|
||||
defptr = defptr->next;
|
||||
free(this);
|
||||
}
|
||||
|
||||
/* and old typedefs */
|
||||
for (typeptr = types; typeptr != NULL;)
|
||||
{
|
||||
struct typedefs *this = typeptr;
|
||||
|
||||
free(typeptr->name);
|
||||
free(typeptr->type);
|
||||
ECPGfree_struct_member(typeptr->struct_member_list);
|
||||
typeptr = typeptr->next;
|
||||
free(this);
|
||||
}
|
||||
|
||||
/* initialize lex */
|
||||
lex_init();
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "postgres.h"
|
||||
#include "type.h"
|
||||
#include "extern.h"
|
||||
#include "y.tab.h"
|
||||
#include "preproc.h"
|
||||
|
||||
/*
|
||||
* List of (keyword-name, keyword-token-value) pairs.
|
||||
@@ -21,25 +20,38 @@
|
||||
*/
|
||||
static ScanKeyword ScanKeywords[] = {
|
||||
/* name value */
|
||||
{"bool", SQL_BOOL},
|
||||
{"break", SQL_BREAK},
|
||||
{"call", SQL_CALL},
|
||||
{"connect", SQL_CONNECT},
|
||||
{"connection", SQL_CONNECTION},
|
||||
{"continue", SQL_CONTINUE},
|
||||
{"deallocate", SQL_DEALLOCATE},
|
||||
{"disconnect", SQL_DISCONNECT},
|
||||
{"enum", SQL_ENUM},
|
||||
{"found", SQL_FOUND},
|
||||
{"free", SQL_FREE},
|
||||
{"go", SQL_GO},
|
||||
{"goto", SQL_GOTO},
|
||||
{"identified", SQL_IDENTIFIED},
|
||||
{"immediate", SQL_IMMEDIATE},
|
||||
{"indicator", SQL_INDICATOR},
|
||||
{"int", SQL_INT},
|
||||
{"long", SQL_LONG},
|
||||
{"open", SQL_OPEN},
|
||||
{"prepare", SQL_PREPARE},
|
||||
{"reference", SQL_REFERENCE},
|
||||
{"release", SQL_RELEASE},
|
||||
{"section", SQL_SECTION},
|
||||
{"short", SQL_SHORT},
|
||||
{"signed", SQL_SIGNED},
|
||||
{"sqlerror", SQL_SQLERROR},
|
||||
{"sqlprint", SQL_SQLPRINT},
|
||||
{"sqlwarning", SQL_SQLWARNING},
|
||||
{"stop", SQL_STOP},
|
||||
{"struct", SQL_STRUCT},
|
||||
{"unsigned", SQL_UNSIGNED},
|
||||
{"var", SQL_VAR},
|
||||
{"whenever", SQL_WHENEVER},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,63 +1,23 @@
|
||||
#include "parser/keywords.h"
|
||||
#include "type.h"
|
||||
#include <errno.h>
|
||||
|
||||
/* variables */
|
||||
|
||||
extern int braces_open,
|
||||
no_auto_trans;
|
||||
no_auto_trans, struct_level;
|
||||
extern char *yytext;
|
||||
extern int yylineno,
|
||||
yyleng;
|
||||
extern FILE *yyin,
|
||||
*yyout;
|
||||
|
||||
struct _include_path
|
||||
{
|
||||
char *path;
|
||||
struct _include_path *next;
|
||||
};
|
||||
|
||||
extern struct _include_path *include_paths;
|
||||
|
||||
struct cursor
|
||||
{
|
||||
char *name;
|
||||
char *command;
|
||||
struct arguments *argsinsert;
|
||||
struct arguments *argsresult;
|
||||
struct cursor *next;
|
||||
};
|
||||
|
||||
extern struct cursor *cur;
|
||||
|
||||
struct _defines
|
||||
{
|
||||
char *old;
|
||||
char *new;
|
||||
struct _defines *next;
|
||||
};
|
||||
|
||||
extern struct typedefs *types;
|
||||
extern struct _defines *defines;
|
||||
|
||||
/* This is a linked list of the variable names and types. */
|
||||
struct variable
|
||||
{
|
||||
char *name;
|
||||
struct ECPGtype *type;
|
||||
int brace_level;
|
||||
struct variable *next;
|
||||
};
|
||||
|
||||
extern struct ECPGtype ecpg_no_indicator;
|
||||
extern struct variable no_indicator;
|
||||
|
||||
struct arguments
|
||||
{
|
||||
struct variable *variable;
|
||||
struct variable *indicator;
|
||||
struct arguments *next;
|
||||
};
|
||||
|
||||
extern struct arguments *argsinsert;
|
||||
extern struct arguments *argsresult;
|
||||
|
||||
@@ -74,9 +34,10 @@ extern void yyerror(char *);
|
||||
|
||||
/* return codes */
|
||||
|
||||
#define OK 0
|
||||
#define PARSE_ERROR -1
|
||||
#define ILLEGAL_OPTION -2
|
||||
#define OK 0
|
||||
#define PARSE_ERROR -1
|
||||
#define ILLEGAL_OPTION -2
|
||||
#define INDICATOR_NOT_ARRAY -3
|
||||
|
||||
#define NO_INCLUDE_FILE ENOENT
|
||||
#define OUT_OF_MEMORY ENOMEM
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.10 1999/02/13 23:22:35 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.11 1999/02/20 07:01:00 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "type.h"
|
||||
#include "y.tab.h"
|
||||
#include "preproc.h"
|
||||
#include "parser/keywords.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
@@ -69,9 +69,6 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"createdb", CREATEDB},
|
||||
{"createuser", CREATEUSER},
|
||||
{"cross", CROSS},
|
||||
{"current", CURRENT}, /* 6.4 to 6.5 is migration time! CURRENT
|
||||
* will be removed in 6.5! Use OLD keyword
|
||||
* in rules. Jan */
|
||||
{"current_date", CURRENT_DATE},
|
||||
{"current_time", CURRENT_TIME},
|
||||
{"current_timestamp", CURRENT_TIMESTAMP},
|
||||
@@ -96,6 +93,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"end", END_TRANS},
|
||||
/***S*I***/
|
||||
{"except", EXCEPT},
|
||||
|
||||
{"execute", EXECUTE},
|
||||
{"exists", EXISTS},
|
||||
{"explain", EXPLAIN},
|
||||
@@ -125,6 +123,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"instead", INSTEAD},
|
||||
/***S*I***/
|
||||
{"intersect", INTERSECT},
|
||||
|
||||
{"interval", INTERVAL},
|
||||
{"into", INTO},
|
||||
{"is", IS},
|
||||
@@ -138,6 +137,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"left", LEFT},
|
||||
{"level", LEVEL},
|
||||
{"like", LIKE},
|
||||
{"limit", LIMIT},
|
||||
{"listen", LISTEN},
|
||||
{"load", LOAD},
|
||||
{"local", LOCAL},
|
||||
@@ -167,6 +167,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"nullif", NULLIF},
|
||||
{"numeric", NUMERIC},
|
||||
{"of", OF},
|
||||
{"offset", OFFSET},
|
||||
{"oids", OIDS},
|
||||
{"old", CURRENT},
|
||||
{"on", ON},
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "parser/gramparse.h"
|
||||
#include "parser/scansup.h"
|
||||
#include "type.h"
|
||||
#include "extern.h"
|
||||
#include "y.tab.h"
|
||||
#include "preproc.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
/* some versions of lex define this as a macro */
|
||||
@@ -241,7 +240,7 @@ cppline {space}*#.*(\\{space}*\n)*\n*
|
||||
}
|
||||
<xq>{xqstop} {
|
||||
BEGIN(SQL);
|
||||
yylval.str = strdup(scanstr(literal));
|
||||
yylval.str = mm_strdup(scanstr(literal));
|
||||
return SCONST;
|
||||
}
|
||||
<xq>{xqdouble} |
|
||||
@@ -276,7 +275,7 @@ cppline {space}*#.*(\\{space}*\n)*\n*
|
||||
}
|
||||
<xd>{xdstop} {
|
||||
BEGIN(SQL);
|
||||
yylval.str = strdup(literal);
|
||||
yylval.str = mm_strdup(literal);
|
||||
return CSTRING;
|
||||
}
|
||||
<xd>{xdinside} {
|
||||
@@ -292,7 +291,7 @@ cppline {space}*#.*(\\{space}*\n)*\n*
|
||||
}
|
||||
<xdc>{xdstop} {
|
||||
BEGIN(C);
|
||||
yylval.str = strdup(literal);
|
||||
yylval.str = mm_strdup(literal);
|
||||
return CSTRING;
|
||||
}
|
||||
<xdc>{xdinside} {
|
||||
@@ -316,14 +315,14 @@ cppline {space}*#.*(\\{space}*\n)*\n*
|
||||
}
|
||||
<SQL>{self} { return yytext[0]; }
|
||||
<SQL>{operator}/-[\.0-9] {
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return Op;
|
||||
}
|
||||
<SQL>{operator} {
|
||||
if (strcmp((char*)yytext,"!=") == 0)
|
||||
yylval.str = strdup("<>"); /* compatability */
|
||||
yylval.str = mm_strdup("<>"); /* compatability */
|
||||
else
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return Op;
|
||||
}
|
||||
<SQL>{param} {
|
||||
@@ -342,7 +341,6 @@ cppline {space}*#.*(\\{space}*\n)*\n*
|
||||
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
|
||||
lower_text[i] = tolower(lower_text[i]);
|
||||
|
||||
printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
keyword = ScanKeywordLookup((char*)lower_text);
|
||||
if (keyword != NULL) {
|
||||
return keyword->value;
|
||||
@@ -367,7 +365,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
|
||||
yb->buffer = YY_CURRENT_BUFFER;
|
||||
yb->lineno = yylineno;
|
||||
yb->filename = strdup(input_filename);
|
||||
yb->filename = mm_strdup(input_filename);
|
||||
yb->next = yy_buffer;
|
||||
|
||||
yy_buffer = yb;
|
||||
@@ -378,7 +376,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
}
|
||||
if (ptr == NULL)
|
||||
{
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return IDENT;
|
||||
}
|
||||
}
|
||||
@@ -470,7 +468,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
return ICONST;
|
||||
}
|
||||
<SQL>:{identifier}(("->"|\.){identifier})* {
|
||||
yylval.str = strdup((char*)yytext+1);
|
||||
yylval.str = mm_strdup((char*)yytext+1);
|
||||
return(CVARIABLE);
|
||||
}
|
||||
<SQL>{identifier} {
|
||||
@@ -484,7 +482,6 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
|
||||
lower_text[i] = tolower(lower_text[i]);
|
||||
|
||||
printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
keyword = ScanKeywordLookup((char*)lower_text);
|
||||
if (keyword != NULL) {
|
||||
return keyword->value;
|
||||
@@ -509,7 +506,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
|
||||
yb->buffer = YY_CURRENT_BUFFER;
|
||||
yb->lineno = yylineno;
|
||||
yb->filename = strdup(input_filename);
|
||||
yb->filename = mm_strdup(input_filename);
|
||||
yb->next = yy_buffer;
|
||||
|
||||
yy_buffer = yb;
|
||||
@@ -520,19 +517,26 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
}
|
||||
if (ptr == NULL)
|
||||
{
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return IDENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<SQL>{space} { /* ignore */ }
|
||||
<SQL>";" { BEGIN C; return SQL_SEMI; }
|
||||
<SQL>";" { /*
|
||||
* We may find a ';' inside a structure
|
||||
* definition in a TYPE or VAR statement.
|
||||
* This is not a EOL marker.
|
||||
*/
|
||||
if (struct_level == 0)
|
||||
BEGIN C;
|
||||
return SQL_SEMI; }
|
||||
<SQL>{other} { return yytext[0]; }
|
||||
<C>{exec}{space}{sql} { BEGIN SQL; return SQL_START; }
|
||||
<C>{ccomment} { /* ignore */ }
|
||||
<C>{cppline} {
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return(CPP_LINE);
|
||||
}
|
||||
<C>{identifier} {
|
||||
@@ -556,7 +560,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
|
||||
yb->buffer = YY_CURRENT_BUFFER;
|
||||
yb->lineno = yylineno;
|
||||
yb->filename = strdup(input_filename);
|
||||
yb->filename = mm_strdup(input_filename);
|
||||
yb->next = yy_buffer;
|
||||
|
||||
yy_buffer = yb;
|
||||
@@ -567,7 +571,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
}
|
||||
if (ptr == NULL)
|
||||
{
|
||||
yylval.str = strdup((char*)yytext);
|
||||
yylval.str = mm_strdup((char*)yytext);
|
||||
return IDENT;
|
||||
}
|
||||
}
|
||||
@@ -585,7 +589,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
<C>{exec}{space}{sql}{space}{define} {BEGIN(def_ident);}
|
||||
<def_ident>{space} {}
|
||||
<def_ident>{identifier} {
|
||||
old = strdup(yytext);
|
||||
old = mm_strdup(yytext);
|
||||
BEGIN(def);
|
||||
llen = 0;
|
||||
*literal = '\0';
|
||||
@@ -599,7 +603,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
if (strcmp(old, ptr->old) == 0)
|
||||
{
|
||||
free(ptr->new);
|
||||
ptr->new = strdup(scanstr(literal));
|
||||
ptr->new = mm_strdup(scanstr(literal));
|
||||
}
|
||||
}
|
||||
if (ptr == NULL)
|
||||
@@ -608,7 +612,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
|
||||
/* initial definition */
|
||||
this->old = old;
|
||||
this->new = strdup(scanstr(literal));
|
||||
this->new = mm_strdup(scanstr(literal));
|
||||
this->next = defines;
|
||||
defines = this;
|
||||
}
|
||||
@@ -666,7 +670,7 @@ printf("yyt= %s, lt = %s\n", yytext, lower_text);
|
||||
exit(NO_INCLUDE_FILE);
|
||||
}
|
||||
|
||||
input_filename = strdup(inc_file);
|
||||
input_filename = mm_strdup(inc_file);
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ));
|
||||
yylineno = 0;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "type.h"
|
||||
#include "extern.h"
|
||||
|
||||
/* malloc + error check */
|
||||
@@ -36,8 +35,8 @@ mm_strdup(const char *string)
|
||||
}
|
||||
|
||||
/* duplicate memberlist */
|
||||
static struct ECPGstruct_member *
|
||||
struct_member_dup(struct ECPGstruct_member * rm)
|
||||
struct ECPGstruct_member *
|
||||
ECPGstruct_member_dup(struct ECPGstruct_member * rm)
|
||||
{
|
||||
struct ECPGstruct_member *new = NULL;
|
||||
|
||||
@@ -71,7 +70,8 @@ void
|
||||
ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_member ** start)
|
||||
{
|
||||
struct ECPGstruct_member *ptr,
|
||||
*ne = (struct ECPGstruct_member *) mm_alloc(sizeof(struct ECPGstruct_member));
|
||||
*ne =
|
||||
(struct ECPGstruct_member *) mm_alloc(sizeof(struct ECPGstruct_member));
|
||||
|
||||
ne->name = strdup(name);
|
||||
ne->typ = type;
|
||||
@@ -112,7 +112,7 @@ ECPGmake_struct_type(struct ECPGstruct_member * rm)
|
||||
{
|
||||
struct ECPGtype *ne = ECPGmake_simple_type(ECPGt_struct, 1);
|
||||
|
||||
ne->u.members = struct_member_dup(rm);
|
||||
ne->u.members = ECPGstruct_member_dup(rm);
|
||||
|
||||
return ne;
|
||||
}
|
||||
@@ -160,6 +160,9 @@ get_type(enum ECPGttype typ)
|
||||
case ECPGt_NO_INDICATOR: /* no indicator */
|
||||
return ("ECPGt_NO_INDICATOR");
|
||||
break;
|
||||
case ECPGt_char_variable: /* string that should not be quoted */
|
||||
return ("ECPGt_char_variable");
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
@@ -202,23 +205,30 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in
|
||||
{
|
||||
ECPGdump_a_simple(o, name, typ->u.element->typ,
|
||||
typ->u.element->size, typ->size, NULL, prefix);
|
||||
if (ind_typ == &ecpg_no_indicator)
|
||||
if (ind_typ->typ == ECPGt_NO_INDICATOR)
|
||||
ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix);
|
||||
else
|
||||
{
|
||||
if (ind_typ->typ != ECPGt_array)
|
||||
{
|
||||
fprintf(stderr, "Indicator for an array has to be array too.\n");
|
||||
exit(INDICATOR_NOT_ARRAY);
|
||||
}
|
||||
ECPGdump_a_simple(o, ind_name, ind_typ->u.element->typ,
|
||||
ind_typ->u.element->size, ind_typ->size, NULL, prefix);
|
||||
}
|
||||
}
|
||||
else if (typ->u.element->typ == ECPGt_array)
|
||||
{
|
||||
yyerror("No nested arrays allowed (except strings)"); /* Array of array, */
|
||||
yyerror("No nested arrays allowed (except strings)"); /* array of array */
|
||||
}
|
||||
else if (typ->u.element->typ == ECPGt_struct)
|
||||
{
|
||||
/* Array of structs. */
|
||||
/* Array of structs */
|
||||
ECPGdump_a_struct(o, name, ind_name, typ->size, typ->u.element, ind_typ->u.element, NULL, prefix, ind_prefix);
|
||||
}
|
||||
else
|
||||
yyerror("Internal error: unknown datatype, pleqase inform pgsql-bugs@postgresql.org");
|
||||
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
|
||||
break;
|
||||
case ECPGt_struct:
|
||||
ECPGdump_a_struct(o, name, ind_name, 1, typ, ind_typ, NULL, prefix, ind_prefix);
|
||||
@@ -260,6 +270,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
|
||||
break;
|
||||
case ECPGt_char:
|
||||
case ECPGt_unsigned_char:
|
||||
case ECPGt_char_variable:
|
||||
sprintf(offset, "%ld*sizeof(char)", varcharsize);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -30,6 +30,7 @@ struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, long);
|
||||
struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
|
||||
struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, long);
|
||||
struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *);
|
||||
struct ECPGstruct_member * ECPGstruct_member_dup(struct ECPGstruct_member *);
|
||||
|
||||
/* Frees a type. */
|
||||
void ECPGfree_struct_member(struct ECPGstruct_member *);
|
||||
@@ -84,6 +85,54 @@ struct index
|
||||
|
||||
struct this_type
|
||||
{
|
||||
enum ECPGttype type_enum;
|
||||
char *type_str;
|
||||
enum ECPGttype type_enum;
|
||||
char *type_str;
|
||||
int type_dimension;
|
||||
int type_index;
|
||||
};
|
||||
|
||||
struct _include_path
|
||||
{
|
||||
char *path;
|
||||
struct _include_path *next;
|
||||
};
|
||||
|
||||
struct cursor
|
||||
{
|
||||
char *name;
|
||||
char *command;
|
||||
struct arguments *argsinsert;
|
||||
struct arguments *argsresult;
|
||||
struct cursor *next;
|
||||
};
|
||||
|
||||
struct typedefs
|
||||
{
|
||||
char *name;
|
||||
struct this_type *type;
|
||||
struct ECPGstruct_member *struct_member_list;
|
||||
struct typedefs *next;
|
||||
};
|
||||
|
||||
struct _defines
|
||||
{
|
||||
char *old;
|
||||
char *new;
|
||||
struct _defines *next;
|
||||
};
|
||||
|
||||
/* This is a linked list of the variable names and types. */
|
||||
struct variable
|
||||
{
|
||||
char *name;
|
||||
struct ECPGtype *type;
|
||||
int brace_level;
|
||||
struct variable *next;
|
||||
};
|
||||
|
||||
struct arguments
|
||||
{
|
||||
struct variable *variable;
|
||||
struct variable *indicator;
|
||||
struct arguments *next;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user