Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa6ac35

Browse files
author
Michael Meskes
committed
Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to add out-of-scope cursor support to native mode.
1 parent525d2cb commitaa6ac35

File tree

20 files changed

+298
-142
lines changed

20 files changed

+298
-142
lines changed

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.62 2009/10/01 18:03:54 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.63 2010/01/26 09:07:31 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -1004,57 +1004,16 @@ rtypwidth(int sqltype, int sqllen)
10041004
return0;
10051005
}
10061006

1007-
staticstructvar_list
1008-
{
1009-
intnumber;
1010-
void*pointer;
1011-
structvar_list*next;
1012-
}*ivlist=NULL;
1013-
10141007
void
10151008
ECPG_informix_set_var(intnumber,void*pointer,intlineno)
10161009
{
1017-
structvar_list*ptr;
1018-
1019-
for (ptr=ivlist;ptr!=NULL;ptr=ptr->next)
1020-
{
1021-
if (ptr->number==number)
1022-
{
1023-
/* already known => just change pointer value */
1024-
ptr->pointer=pointer;
1025-
return;
1026-
}
1027-
}
1028-
1029-
/* a new one has to be added */
1030-
ptr= (structvar_list*)calloc(1L,sizeof(structvar_list));
1031-
if (!ptr)
1032-
{
1033-
structsqlca_t*sqlca=ECPGget_sqlca();
1034-
1035-
sqlca->sqlcode=ECPG_OUT_OF_MEMORY;
1036-
strncpy(sqlca->sqlstate,"YE001",sizeof("YE001"));
1037-
snprintf(sqlca->sqlerrm.sqlerrmc,sizeof(sqlca->sqlerrm.sqlerrmc),"out of memory on line %d",lineno);
1038-
sqlca->sqlerrm.sqlerrml=strlen(sqlca->sqlerrm.sqlerrmc);
1039-
/* free all memory we have allocated for the user */
1040-
ECPGfree_auto_mem();
1041-
}
1042-
else
1043-
{
1044-
ptr->number=number;
1045-
ptr->pointer=pointer;
1046-
ptr->next=ivlist;
1047-
ivlist=ptr;
1048-
}
1010+
ECPGset_var(number,pointer,lineno);
10491011
}
10501012

10511013
void*
10521014
ECPG_informix_get_var(intnumber)
10531015
{
1054-
structvar_list*ptr;
1055-
1056-
for (ptr=ivlist;ptr!=NULL&&ptr->number!=number;ptr=ptr->next);
1057-
return (ptr) ?ptr->pointer :NULL;
1016+
returnECPGget_var(number);
10581017
}
10591018

10601019
void

‎src/interfaces/ecpg/ecpglib/exports.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/exports.txt,v 1.6 2009/09/18 13:13:32 meskes Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/exports.txt,v 1.7 2010/01/26 09:07:31 meskes Exp $
22
# Functions to be exported by ecpglib DLL
33
ECPGallocate_desc 1
44
ECPGconnect 2
@@ -26,4 +26,6 @@ ECPGstatus 23
2626
ECPGtrans 24
2727
sqlprint 25
2828
ECPGget_PGconn 26
29-
ECPGtransactionStatus 27
29+
ECPGtransactionStatus 27
30+
ECPGset_var 28
31+
ECPGget_var 29

‎src/interfaces/ecpg/ecpglib/misc.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.53 2009/11/24 16:30:31 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.54 2010/01/26 09:07:31 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -505,3 +505,55 @@ ecpg_gettext(const char *msgid)
505505
}
506506

507507
#endif/* ENABLE_NLS */
508+
509+
staticstructvar_list
510+
{
511+
intnumber;
512+
void*pointer;
513+
structvar_list*next;
514+
}*ivlist=NULL;
515+
516+
void
517+
ECPGset_var(intnumber,void*pointer,intlineno)
518+
{
519+
structvar_list*ptr;
520+
521+
for (ptr=ivlist;ptr!=NULL;ptr=ptr->next)
522+
{
523+
if (ptr->number==number)
524+
{
525+
/* already known => just change pointer value */
526+
ptr->pointer=pointer;
527+
return;
528+
}
529+
}
530+
531+
/* a new one has to be added */
532+
ptr= (structvar_list*)calloc(1L,sizeof(structvar_list));
533+
if (!ptr)
534+
{
535+
structsqlca_t*sqlca=ECPGget_sqlca();
536+
sqlca->sqlcode=ECPG_OUT_OF_MEMORY;
537+
strncpy(sqlca->sqlstate,"YE001",sizeof("YE001"));
538+
snprintf(sqlca->sqlerrm.sqlerrmc,sizeof(sqlca->sqlerrm.sqlerrmc),"out of memory on line %d",lineno);
539+
sqlca->sqlerrm.sqlerrml=strlen(sqlca->sqlerrm.sqlerrmc);
540+
/* free all memory we have allocated for the user */
541+
ECPGfree_auto_mem();
542+
}
543+
else
544+
{
545+
ptr->number=number;
546+
ptr->pointer=pointer;
547+
ptr->next=ivlist;
548+
ivlist=ptr;
549+
}
550+
}
551+
552+
void*
553+
ECPGget_var(intnumber)
554+
{
555+
structvar_list*ptr;
556+
557+
for (ptr=ivlist;ptr!=NULL&&ptr->number!=number;ptr=ptr->next);
558+
return (ptr) ?ptr->pointer :NULL;
559+
}

‎src/interfaces/ecpg/include/ecpglib.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* this is a small part of c.h since we don't want to leak all postgres
33
* definitions into ecpg programs
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.81 2010/01/15 10:44:36 meskes Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.82 2010/01/26 09:07:31 meskes Exp $
55
*/
66

77
#ifndef_ECPGLIB_H
@@ -85,6 +85,9 @@ voidECPGset_noind_null(enum ECPGttype, void *);
8585
boolECPGis_noind_null(enumECPGttype,void*);
8686
boolECPGdescribe(int,int,bool,constchar*,constchar*, ...);
8787

88+
voidECPGset_var(int,void*,int);
89+
void*ECPGget_var(intnumber);
90+
8891
/* dynamic result allocation */
8992
voidECPGfree_auto_mem(void);
9093

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* functions needed for descriptor handling
33
*
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.29 2010/01/05 16:38:23 meskes Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.30 2010/01/26 09:07:31 meskes Exp $
55
*
66
* since descriptor might be either a string constant or a string var
77
* we need to check for a constant if we expect a constant
@@ -317,7 +317,7 @@ struct variable *
317317
descriptor_variable(constchar*name,intinput)
318318
{
319319
staticchardescriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
320-
staticconststructECPGtypedescriptor_type= {ECPGt_descriptor,NULL,NULL, {NULL},0};
320+
staticconststructECPGtypedescriptor_type= {ECPGt_descriptor,NULL,NULL,NULL,{NULL},0};
321321
staticconststructvariablevarspace[2]= {
322322
{descriptor_names[0], (structECPGtype*)&descriptor_type,0,NULL},
323323
{descriptor_names[1], (structECPGtype*)&descriptor_type,0,NULL}

‎src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.14 2010/01/15 10:44:37 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.15 2010/01/26 09:07:31 meskes Exp $ */
22
ECPG: stmtClosePortalStmt block
33
{
44
if (INFORMIX_MODE)
@@ -310,11 +310,14 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
310310

311311
this->next = cur;
312312
this->name = $2;
313+
this->function = (current_function ? mm_strdup(current_function) : NULL);
313314
this->connection = connection;
314315
this->opened = false;
315316
this->command = cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
316317
this->argsinsert = argsinsert;
318+
this->argsinsert_oos = NULL;
317319
this->argsresult = argsresult;
320+
this->argsresult_oos = NULL;
318321
argsinsert = argsresult = NULL;
319322
cur = this;
320323

@@ -327,17 +330,17 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
327330
}
328331
comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
329332

330-
if (INFORMIX_MODE)
331-
{
332-
if (braces_open > 0) /* we're in a function */
333-
{
334-
$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
335-
}
336-
else
337-
$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
338-
}
333+
if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
334+
$$ = cat_str(4,
335+
adjust_outofscope_cursor_vars(this, true),
336+
adjust_outofscope_cursor_vars(this, false),
337+
make_str("ECPG_informix_reset_sqlca();"),
338+
comment);
339339
else
340-
$$ = comment;
340+
$$ = cat_str(3,
341+
adjust_outofscope_cursor_vars(this, true),
342+
adjust_outofscope_cursor_vars(this, false),
343+
comment);
341344
}
342345
ECPG: ClosePortalStmtCLOSEcursor_name block
343346
{

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.112 2010/01/02 16:58:11 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.113 2010/01/26 09:07:31 meskes Exp $ */
22

33
/* Main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* Copyright (c) 1996-2010, PostgreSQL Global Development Group */
@@ -419,8 +419,8 @@ main(int argc, char *const argv[])
419419
/* and structure member lists */
420420
memset(struct_member_list,0,sizeof(struct_member_list));
421421

422-
/* and our variable counter forInformix compatibility */
423-
ecpg_informix_var=0;
422+
/* and our variable counter forout of scope cursors' variables */
423+
ecpg_internal_var=0;
424424

425425
/* finally the actual connection */
426426
connection=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp