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

Commit135ecf8

Browse files
author
Michael Meskes
committed
Re-added forgotten cache.
1 parent7da19ca commit135ecf8

File tree

1 file changed

+78
-106
lines changed

1 file changed

+78
-106
lines changed

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

Lines changed: 78 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.27 2003/11/08 19:46:27 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.28 2003/11/10 20:28:30 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -230,12 +230,25 @@ next_insert(char *text)
230230
return (*ptr=='\0') ?NULL :ptr;
231231
}
232232

233+
staticvoid
234+
ECPGtypeinfocache_push(structECPGtype_information_cache**cache,intoid,boolisarray,intlineno)
235+
{
236+
structECPGtype_information_cache*new_entry
237+
= (structECPGtype_information_cache*)ECPGalloc(sizeof(structECPGtype_information_cache),lineno);
238+
239+
new_entry->oid=oid;
240+
new_entry->isarray=isarray;
241+
new_entry->next=*cache;
242+
*cache=new_entry;
243+
}
244+
233245
staticenumARRAY_TYPE
234246
ECPGis_type_an_array(inttype,conststructstatement*stmt,conststructvariable*var)
235247
{
236248
char*array_query;
237249
enumARRAY_TYPEisarray=ECPG_ARRAY_NOT_SET;
238250
PGresult*query;
251+
structECPGtype_information_cache*cache_entry;
239252

240253
if ((stmt->connection->cache_head)==NULL)
241254
{
@@ -245,117 +258,76 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
245258
* these values.
246259
*/
247260
#definenot_an_array_in_ecpg ECPG_ARRAY_NONE
248-
249-
switch (type)
250-
{
251-
caseBOOLOID:isarray=ECPG_ARRAY_NONE;
252-
break;
253-
caseBYTEAOID:isarray=ECPG_ARRAY_NONE;
254-
break;
255-
caseCHAROID:isarray=ECPG_ARRAY_NONE;
256-
break;
257-
caseNAMEOID:isarray=not_an_array_in_ecpg;
258-
break;
259-
caseINT8OID:isarray=ECPG_ARRAY_NONE;
260-
break;
261-
caseINT2OID:isarray=ECPG_ARRAY_NONE;
262-
break;
263-
caseINT2VECTOROID:isarray=ECPG_ARRAY_VECTOR;
264-
break;
265-
caseINT4OID:isarray=ECPG_ARRAY_NONE;
266-
break;
267-
caseREGPROCOID:isarray=ECPG_ARRAY_NONE;
268-
break;
269-
caseTEXTOID:isarray=ECPG_ARRAY_NONE;
270-
break;
271-
caseOIDOID:isarray=ECPG_ARRAY_NONE;
272-
break;
273-
caseTIDOID:isarray=ECPG_ARRAY_NONE;
274-
break;
275-
caseXIDOID:isarray=ECPG_ARRAY_NONE;
276-
break;
277-
caseCIDOID:isarray=ECPG_ARRAY_NONE;
278-
break;
279-
caseOIDVECTOROID:isarray=ECPG_ARRAY_VECTOR;
280-
break;
281-
casePOINTOID:isarray=ECPG_ARRAY_VECTOR;
282-
break;
283-
caseLSEGOID:isarray=ECPG_ARRAY_VECTOR;
284-
break;
285-
casePATHOID:isarray=ECPG_ARRAY_NONE;
286-
break;
287-
caseBOXOID:isarray=ECPG_ARRAY_VECTOR;
288-
break;
289-
casePOLYGONOID:isarray=ECPG_ARRAY_NONE;
290-
break;
291-
caseLINEOID:isarray=ECPG_ARRAY_VECTOR;
292-
break;
293-
caseFLOAT4OID:isarray=ECPG_ARRAY_NONE;
294-
break;
295-
caseFLOAT8OID:isarray=ECPG_ARRAY_NONE;
296-
break;
297-
caseABSTIMEOID:isarray=ECPG_ARRAY_NONE;
298-
break;
299-
caseRELTIMEOID:isarray=ECPG_ARRAY_NONE;
300-
break;
301-
caseTINTERVALOID:isarray=ECPG_ARRAY_NONE;
302-
break;
303-
caseUNKNOWNOID:isarray=ECPG_ARRAY_NONE;
304-
break;
305-
caseCIRCLEOID:isarray=ECPG_ARRAY_NONE;
306-
break;
307-
caseCASHOID:isarray=ECPG_ARRAY_NONE;
308-
break;
309-
caseINETOID:isarray=ECPG_ARRAY_NONE;
310-
break;
311-
caseCIDROID:isarray=ECPG_ARRAY_NONE;
312-
break;
313-
caseBPCHAROID:isarray=ECPG_ARRAY_NONE;
314-
break;
315-
caseVARCHAROID:isarray=ECPG_ARRAY_NONE;
316-
break;
317-
caseDATEOID:isarray=ECPG_ARRAY_NONE;
318-
break;
319-
caseTIMEOID:isarray=ECPG_ARRAY_NONE;
320-
break;
321-
caseTIMESTAMPOID:isarray=ECPG_ARRAY_NONE;
322-
break;
323-
caseTIMESTAMPTZOID:isarray=ECPG_ARRAY_NONE;
324-
break;
325-
caseINTERVALOID:isarray=ECPG_ARRAY_NONE;
326-
break;
327-
caseTIMETZOID:isarray=ECPG_ARRAY_NONE;
328-
break;
329-
caseZPBITOID:isarray=ECPG_ARRAY_NONE;
330-
break;
331-
caseVARBITOID:isarray=ECPG_ARRAY_NONE;
332-
break;
333-
caseNUMERICOID:isarray=ECPG_ARRAY_NONE;
334-
break;
335-
default:break;
336-
}
261+
262+
/* populate cache with well known types to speed things up */
263+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOOLOID,ECPG_ARRAY_NONE,stmt->lineno);
264+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BYTEAOID,ECPG_ARRAY_NONE,stmt->lineno);
265+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CHAROID,ECPG_ARRAY_NONE,stmt->lineno);
266+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NAMEOID,not_an_array_in_ecpg,stmt->lineno);
267+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT8OID,ECPG_ARRAY_NONE,stmt->lineno);
268+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2OID,ECPG_ARRAY_NONE,stmt->lineno);
269+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2VECTOROID,ECPG_ARRAY_VECTOR,stmt->lineno);
270+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT4OID,ECPG_ARRAY_NONE,stmt->lineno);
271+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),REGPROCOID,ECPG_ARRAY_NONE,stmt->lineno);
272+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TEXTOID,ECPG_ARRAY_NONE,stmt->lineno);
273+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDOID,ECPG_ARRAY_NONE,stmt->lineno);
274+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIDOID,ECPG_ARRAY_NONE,stmt->lineno);
275+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),XIDOID,ECPG_ARRAY_NONE,stmt->lineno);
276+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDOID,ECPG_ARRAY_NONE,stmt->lineno);
277+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDVECTOROID,ECPG_ARRAY_VECTOR,stmt->lineno);
278+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POINTOID,ECPG_ARRAY_VECTOR,stmt->lineno);
279+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LSEGOID,ECPG_ARRAY_VECTOR,stmt->lineno);
280+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),PATHOID,ECPG_ARRAY_NONE,stmt->lineno);
281+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOXOID,ECPG_ARRAY_VECTOR,stmt->lineno);
282+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POLYGONOID,ECPG_ARRAY_NONE,stmt->lineno);
283+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LINEOID,ECPG_ARRAY_VECTOR,stmt->lineno);
284+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT4OID,ECPG_ARRAY_NONE,stmt->lineno);
285+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT8OID,ECPG_ARRAY_NONE,stmt->lineno);
286+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ABSTIMEOID,ECPG_ARRAY_NONE,stmt->lineno);
287+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),RELTIMEOID,ECPG_ARRAY_NONE,stmt->lineno);
288+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TINTERVALOID,ECPG_ARRAY_NONE,stmt->lineno);
289+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),UNKNOWNOID,ECPG_ARRAY_NONE,stmt->lineno);
290+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIRCLEOID,ECPG_ARRAY_NONE,stmt->lineno);
291+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CASHOID,ECPG_ARRAY_NONE,stmt->lineno);
292+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INETOID,ECPG_ARRAY_NONE,stmt->lineno);
293+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDROID,ECPG_ARRAY_NONE,stmt->lineno);
294+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BPCHAROID,ECPG_ARRAY_NONE,stmt->lineno);
295+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARCHAROID,ECPG_ARRAY_NONE,stmt->lineno);
296+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),DATEOID,ECPG_ARRAY_NONE,stmt->lineno);
297+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMEOID,ECPG_ARRAY_NONE,stmt->lineno);
298+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMESTAMPOID,ECPG_ARRAY_NONE,stmt->lineno);
299+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMESTAMPTZOID,ECPG_ARRAY_NONE,stmt->lineno);
300+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INTERVALOID,ECPG_ARRAY_NONE,stmt->lineno);
301+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMETZOID,ECPG_ARRAY_NONE,stmt->lineno);
302+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ZPBITOID,ECPG_ARRAY_NONE,stmt->lineno);
303+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARBITOID,ECPG_ARRAY_NONE,stmt->lineno);
304+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NUMERICOID,ECPG_ARRAY_NONE,stmt->lineno);
337305
}
338306

339-
if (isarray==ECPG_ARRAY_NOT_SET)
307+
for (cache_entry= (stmt->connection->cache_head);cache_entry!=NULL;cache_entry=cache_entry->next)
308+
{
309+
if (cache_entry->oid==type)
310+
returncache_entry->isarray;
311+
}
312+
313+
array_query= (char*)ECPGalloc(strlen("select typlen from pg_type where oid= and typelem<>0")+11,stmt->lineno);
314+
sprintf(array_query,"select typlen from pg_type where oid=%d and typelem<>0",type);
315+
query=PQexec(stmt->connection->connection,array_query);
316+
ECPGfree(array_query);
317+
if (PQresultStatus(query)==PGRES_TUPLES_OK)
340318
{
341-
array_query= (char*)ECPGalloc(strlen("select typlen from pg_type where oid= and typelem<>0")+11,stmt->lineno);
342-
sprintf(array_query,"select typlen from pg_type where oid=%d and typelem<>0",type);
343-
query=PQexec(stmt->connection->connection,array_query);
344-
ECPGfree(array_query);
345-
if (PQresultStatus(query)==PGRES_TUPLES_OK)
319+
isarray= (atol((char*)PQgetvalue(query,0,0))==-1) ?ECPG_ARRAY_ARRAY :ECPG_ARRAY_VECTOR;
320+
if (ECPGDynamicType(type)==SQL3_CHARACTER||
321+
ECPGDynamicType(type)==SQL3_CHARACTER_VARYING)
346322
{
347-
isarray= (atol((char*)PQgetvalue(query,0,0))==-1) ?ECPG_ARRAY_ARRAY :ECPG_ARRAY_VECTOR;
348-
if (ECPGDynamicType(type)==SQL3_CHARACTER||
349-
ECPGDynamicType(type)==SQL3_CHARACTER_VARYING)
350-
{
351-
/*
352-
* arrays of character strings are not yet implemented
353-
*/
354-
isarray=ECPG_ARRAY_NONE;
355-
}
323+
/*
324+
* arrays of character strings are not yet implemented
325+
*/
326+
isarray=ECPG_ARRAY_NONE;
356327
}
357-
PQclear(query);
358328
}
329+
PQclear(query);
330+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),type,isarray,stmt->lineno);
359331
ECPGlog("ECPGexecute line %d: TYPE database: %d C: %d array: %d\n",stmt->lineno,type,var->type,isarray);
360332
returnisarray;
361333
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp