Skip to content

Commit 30f16e7

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent 6124c67 commit 30f16e7

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/interfaces/ecpg/include/sqlca.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef POSTGRES_SQLCA_H
22
#define POSTGRES_SQLCA_H
33

4+
#define SQLERRMC_LEN 70
5+
46
#ifdef __cplusplus
57
extern "C"
68
{
@@ -14,7 +16,7 @@ extern "C"
1416
struct
1517
{
1618
int sqlerrml;
17-
char sqlerrmc[70];
19+
char sqlerrmc[SQLERRMC_LEN];
1820
} sqlerrm;
1921
char sqlerrp[8];
2022
long sqlerrd[6];

src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ register_error(long code, char *fmt,...)
109109

110110
sqlca.sqlcode = code;
111111
va_start(args, fmt);
112-
vsprintf(sqlca.sqlerrm.sqlerrmc, fmt, args);
112+
vsnprintf(sqlca.sqlerrm.sqlerrmc, SQLERRMC_LEN, fmt, args);
113113
va_end(args);
114114
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
115115

@@ -649,7 +649,8 @@ ECPGexecute(struct statement * stmt)
649649
int nfields,
650650
ntuples,
651651
act_tuple,
652-
act_field;
652+
act_field,
653+
isarray;
653654

654655
case PGRES_TUPLES_OK:
655656
nfields = PQnfields(results);
@@ -678,6 +679,16 @@ ECPGexecute(struct statement * stmt)
678679
return (false);
679680
}
680681

682+
array_query = (char *)ecpg_alloc(strlen("select typelem from pg_type where oid=") + 11, stmt -> lineno);
683+
sprintf(array_query, "select typelem from pg_type where oid=%d", PQftype(results, act_field));
684+
query = PQexec(stmt->connection->connection, array_query);
685+
isarray = 0;
686+
if (PQresultStatus(query) == PGRES_TUPLES_OK) {
687+
isarray = atol((char *)PQgetvalue(query, 0, 0));
688+
ECPGlog("ECPGexecute line %d: TYPE database: %d C: %d array: %s\n", stmt->lineno, PQftype(results, act_field), var->type, isarray ? "yes" : "no");
689+
}
690+
PQclear(query);
691+
681692
/*
682693
* if we don't have enough space, we cannot read all
683694
* tuples
@@ -726,14 +737,6 @@ ECPGexecute(struct statement * stmt)
726737
add_mem(var->value, stmt->lineno);
727738
}
728739

729-
#if 0
730-
array_query = (char *)ecpg_alloc(strlen("select typelem from pg_type where oid=") + 11, stmt -> lineno);
731-
sprintf(array_query, "select typelem from pg_type where oid=%d", PQftype(results, act_field));
732-
query = PQexec(stmt->connection->connection, array_query);
733-
if (PQresultStatus(query) == PGRES_TUPLES_OK)
734-
ECPGlog("ECPGexecute line %d: TYPE database: %d C: %d array OID: %s\n", stmt->lineno, PQftype(results, act_field), var->type, (char *)PQgetvalue(query, 0, 0));
735-
PQclear(query);
736-
#endif
737740
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
738741
{
739742
pval = (char *)PQgetvalue(results, act_tuple, act_field);

src/interfaces/ecpg/test/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
all: stp.so test1 test2 test3 test4 test5 perftest
22

33
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
4-
#LDFLAGS=-g -I../include -I/usr/include/postgresql -L/usr/lib/postgresql -L../lib -lecpg -lpq -lcrypt
5-
LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
4+
LDFLAGS=-g -I../include -I/usr/include/postgresql -L/usr/lib/postgresql -L../lib -lecpg -lpq -lcrypt
5+
#LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
66

77
#ECPG=/usr/local/pgsql/bin/ecpg
8-
#ECPG=../preproc/ecpg -I../include
9-
ECPG=/usr/bin/ecpg -I/usr/include/postgresql
8+
ECPG=../preproc/ecpg -I../include
9+
#ECPG=/usr/bin/ecpg -I/usr/include/postgresql
1010

1111
.SUFFIXES: .pgc .c
1212

@@ -22,7 +22,7 @@ perftest: perftest.c
2222

2323
stp.so: stp.c
2424
cc -fPIC -I../include -I/usr/include/postgresql -c -o stp.o stp.c
25-
ld -Bdynamic -shared -soname stp.so -o stp.so stp.o -lpq -lecpg
25+
ld -Bdynamic -shared -soname stp.so -o stp.so stp.o -lpq -lecpg -lc
2626

2727

2828
clean:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy