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

Commit210055a

Browse files
committed
here are some patches for 6.5.0 which I already submitted but have never
been applied. The patches are in the .tar.gz attachment at the end:varchar-array.patch this patch adds support for arrays of bpchar() and varchar(), which where always missing from postgres. These datatypes can be used to replace the _char4, _char8, etc., which were dropped some time ago.block-size.patch this patch fixes many errors in the parser and other program which happen with very large query statements (> 8K) when using a page size larger than 8192. This patch is needed if you want to submit queries larger than 8K. Postgres supports tuples up to 32K but you can't insert them because you can't submit queries larger than 8K. My patch fixes this problem. The patch also replaces all the occurrences of `8192' and `1<<13' in the sources with the proper constants defined in include files. You should now never find 8192 hardwired in C code, just to make code clearer.--Massimo Dal Zotto
1 parentda5f1dd commit210055a

File tree

27 files changed

+273
-66
lines changed

27 files changed

+273
-66
lines changed

‎src/backend/commands/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.74 1999/04/25 03:19:09 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.75 1999/05/0319:09:38 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1061,7 +1061,7 @@ GetIndexRelations(Oid main_relation_oid,
10611061
}
10621062
}
10631063

1064-
#defineEXT_ATTLEN 5*8192
1064+
#defineEXT_ATTLEN 5*BLCKSZ
10651065

10661066
/*
10671067
returns 1 is c is in s

‎src/backend/libpq/be-fsstubs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.28 1999/02/13 23:15:41 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.29 1999/05/03 19:09:39 momjian Exp $
1111
*
1212
* NOTES
1313
* This should be moved to a more appropriate place. It is here
@@ -44,7 +44,9 @@
4444
/* [PA] is Pascal André <andre@via.ecp.fr> */
4545

4646
/*#define FSDB 1*/
47-
#defineMAX_LOBJ_FDS 256
47+
#defineMAX_LOBJ_FDS256
48+
#defineBUFSIZE1024
49+
#defineFNAME_BUFSIZE8192
4850

4951
staticLargeObjectDesc*cookies[MAX_LOBJ_FDS];
5052

@@ -257,9 +259,8 @@ lo_import(text *filename)
257259
intnbytes,
258260
tmp;
259261

260-
#defineBUFSIZE 1024
261262
charbuf[BUFSIZE];
262-
charfnamebuf[8192];
263+
charfnamebuf[FNAME_BUFSIZE];
263264
LargeObjectDesc*lobj;
264265
OidlobjOid;
265266

@@ -324,9 +325,8 @@ lo_export(Oid lobjId, text *filename)
324325
intnbytes,
325326
tmp;
326327

327-
#defineBUFSIZE 1024
328328
charbuf[BUFSIZE];
329-
charfnamebuf[8192];
329+
charfnamebuf[FNAME_BUFSIZE];
330330
LargeObjectDesc*lobj;
331331
mode_toumask;
332332

‎src/backend/parser/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for parser
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.19 1998/07/26 04:30:30 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.20 1999/05/03 19:09:40 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -37,7 +37,9 @@ gram.c parse.h: gram.y
3737

3838
scan.c:scan.l
3939
$(LEX)$<
40-
mv lex.yy.c scan.c
40+
sed -e's/#define YY_BUF_SIZE .*/#define YY_BUF_SIZE 65536/'\
41+
<lex.yy.c>scan.c
42+
rm -f lex.yy.c
4143

4244
# The following dependencies on parse.h are computed by
4345
# make depend, but we state them here explicitly anyway because

‎src/backend/parser/gram.y

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.71 1999/04/27 13:33:43 wieck Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.72 1999/05/03 19:09:41 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -3290,7 +3290,6 @@ Typename: Array opt_array_bounds
32903290
else
32913291
$$->setof = FALSE;
32923292
}
3293-
| Character
32943293
| SETOF Array
32953294
{
32963295
$$ = $2;
@@ -3301,6 +3300,7 @@ Typename: Array opt_array_bounds
33013300
Array: Generic
33023301
| Datetime
33033302
| Numeric
3303+
| Character
33043304
;
33053305

33063306
Generic: generic
@@ -3425,10 +3425,6 @@ opt_decimal: '(' Iconst ',' Iconst ')'
34253425

34263426
/* SQL92 character data types
34273427
* The following implements CHAR() and VARCHAR().
3428-
* We do it here instead of the 'Generic' production
3429-
* because we don't want to allow arrays of VARCHAR().
3430-
* I haven't thought about whether that will work or not.
3431-
*- ay 6/95
34323428
*/
34333429
Character: character '(' Iconst ')'
34343430
{

‎src/backend/parser/scan.l

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.47 1999/03/17 20:17:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.48 1999/05/03 19:09:42 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,6 +32,11 @@
3232
#include"parse.h"
3333
#include"utils/builtins.h"
3434

35+
#ifdef YY_READ_BUF_SIZE
36+
#undef YY_READ_BUF_SIZE
37+
#endif
38+
#defineYY_READ_BUF_SIZEMAX_PARSE_BUFFER
39+
3540
externchar *parseString;
3641
staticchar *parseCh;
3742

‎src/backend/port/hpux/fixade.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: fixade.h,v 1.5 1999/02/13 23:17:33 momjian Exp $
10+
* $Id: fixade.h,v 1.6 1999/05/03 19:09:44 momjian Exp $
1111
*
1212
* NOTES
1313
*This must be included in EVERY source file.
@@ -47,11 +47,11 @@
4747
*/
4848
structHP_WAY_BOGUS
4949
{
50-
charhpwb_bogus[8192];
50+
charhpwb_bogus[8191+1];
5151
};
5252
structHP_TOO_BOGUS
5353
{
54-
inthptb_bogus[8192];
54+
inthptb_bogus[8191+1];
5555
};
5656

5757
#endif/* BROKEN_STRUCT_INIT */

‎src/backend/tcop/postgres.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.109 1999/05/01 17:16:25 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.110 1999/05/03 19:09:54 momjian Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -452,14 +452,14 @@ pg_parse_and_plan(char *query_string,/* string to execute */
452452
else
453453
{
454454
/* Print condensed query string to fit in one log line */
455-
charbuff[8192+1];
455+
charbuff[MAX_QUERY_SIZE+1];
456456
charc,
457457
*s,
458458
*d;
459459
intn,
460460
is_space=1;
461461

462-
for (s=query_string,d=buff,n=0; (c=*s)&& (n<8192);s++)
462+
for (s=query_string,d=buff,n=0; (c=*s)&& (n<MAX_QUERY_SIZE);s++)
463463
{
464464
switch (c)
465465
{
@@ -1539,7 +1539,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15391539
if (!IsUnderPostmaster)
15401540
{
15411541
puts("\nPOSTGRES backend interactive interface ");
1542-
puts("$Revision: 1.109 $ $Date: 1999/05/01 17:16:25 $\n");
1542+
puts("$Revision: 1.110 $ $Date: 1999/05/03 19:09:54 $\n");
15431543
}
15441544

15451545
/* ----------------

‎src/backend/utils/adt/arrayfuncs.c

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.38 1999/02/13 23:19:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.39 1999/05/0319:09:59 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include<ctype.h>
1616
#include<stdio.h>
1717
#include<string.h>
18+
#include<stdarg.h>
1819

1920
#include"postgres.h"
2021

@@ -26,6 +27,7 @@
2627
#include"storage/fd.h"
2728
#include"fmgr.h"
2829
#include"utils/array.h"
30+
#include"utils/elog.h"
2931

3032
#include"libpq/libpq-fs.h"
3133
#include"libpq/be-fsstubs.h"
@@ -614,7 +616,9 @@ array_out(ArrayType *v, Oid element_type)
614616
i,
615617
j,
616618
k,
619+
#ifndefTCL_ARRAYS
617620
l,
621+
#endif
618622
indx[MAXDIM];
619623
booldummy_bool;
620624
intndim,
@@ -1274,6 +1278,156 @@ array_assgn(ArrayType *array,
12741278
return (char*)array;
12751279
}
12761280

1281+
/*
1282+
* array_map()
1283+
*
1284+
* Map an arbitrary function to an array and return a new array with
1285+
* same dimensions and the source elements transformed by fn().
1286+
*/
1287+
ArrayType*
1288+
array_map(ArrayType*v,
1289+
Oidtype,
1290+
char*(fn)(char*p, ...),
1291+
OidretType,
1292+
intnargs,
1293+
...)
1294+
{
1295+
ArrayType*result;
1296+
void*args[4];
1297+
char**values;
1298+
char*elt;
1299+
int*dim;
1300+
intndim;
1301+
intnitems;
1302+
inti;
1303+
intnbytes=0;
1304+
intinp_typlen;
1305+
boolinp_typbyval;
1306+
inttyplen;
1307+
booltypbyval;
1308+
chartypdelim;
1309+
Oidtypelem;
1310+
Oidproc;
1311+
chartypalign;
1312+
char*s;
1313+
char*p;
1314+
va_listap;
1315+
1316+
/* Large objects not yet supported */
1317+
if (ARR_IS_LO(v)== true) {
1318+
elog(ERROR,"array_map: large objects not supported");
1319+
}
1320+
1321+
/* Check nargs */
1322+
if ((nargs<0)|| (nargs>4)) {
1323+
elog(ERROR,"array_map: invalid nargs: %d",nargs);
1324+
}
1325+
1326+
/* Copy extra args to local variable */
1327+
va_start(ap,nargs);
1328+
for (i=0;i<nargs;i++) {
1329+
args[i]= (void*)va_arg(ap,char*);
1330+
}
1331+
va_end(ap);
1332+
1333+
/* Lookup source and result types. Unneeded variables are reused. */
1334+
system_cache_lookup(type, false,&inp_typlen,&inp_typbyval,
1335+
&typdelim,&typelem,&proc,&typalign);
1336+
system_cache_lookup(retType, false,&typlen,&typbyval,
1337+
&typdelim,&typelem,&proc,&typalign);
1338+
1339+
/* Allocate temporary array for new values */
1340+
ndim=ARR_NDIM(v);
1341+
dim=ARR_DIMS(v);
1342+
nitems=getNitems(ndim,dim);
1343+
values= (char**)palloc(nitems*sizeof(char*));
1344+
MemSet(values,0,nitems*sizeof(char*));
1345+
1346+
/* Loop over source data */
1347+
s= (char*)ARR_DATA_PTR(v);
1348+
for (i=0;i<nitems;i++) {
1349+
/* Get source element */
1350+
if (inp_typbyval) {
1351+
switch (inp_typlen) {
1352+
case1:
1353+
elt= (char*) ((int) (*(char*)s));
1354+
break;
1355+
case2:
1356+
elt= (char*) ((int) (*(int16*)s));
1357+
break;
1358+
case3:
1359+
case4:
1360+
default:
1361+
elt= (char*) (*(int32*)s);
1362+
break;
1363+
}
1364+
s+=inp_typlen;
1365+
}else {
1366+
elt=s;
1367+
if (inp_typlen>0) {
1368+
s+=inp_typlen;
1369+
}else {
1370+
s+=INTALIGN(*(int32*)s);
1371+
}
1372+
}
1373+
1374+
/*
1375+
* Apply the given function to source elt and extra args.
1376+
* nargs is the number of extra args taken by fn().
1377+
*/
1378+
switch (nargs) {
1379+
case0:
1380+
p= (char*) (*fn) (elt);
1381+
break;
1382+
case1:
1383+
p= (char*) (*fn) (elt,args[0]);
1384+
break;
1385+
case2:
1386+
p= (char*) (*fn) (elt,args[0],args[1]);
1387+
break;
1388+
case3:
1389+
p= (char*) (*fn) (elt,args[0],args[1],args[2]);
1390+
break;
1391+
case4:
1392+
default:
1393+
p= (char*) (*fn) (elt,args[0],args[1],args[2],args[3]);
1394+
break;
1395+
}
1396+
1397+
/* Update values and total result size */
1398+
if (typbyval) {
1399+
values[i]= (char*)p;
1400+
nbytes+=typlen;
1401+
}else {
1402+
intlen;
1403+
len= ((typlen>0) ?typlen :INTALIGN(*(int32*)p));
1404+
/* Needed because _CopyArrayEls tries to pfree items */
1405+
if (p==elt) {
1406+
p= (char*)palloc(len);
1407+
memcpy(p,elt,len);
1408+
}
1409+
values[i]= (char*)p;
1410+
nbytes+=len;
1411+
}
1412+
}
1413+
1414+
/* Allocate and initialize the result array */
1415+
nbytes+=ARR_OVERHEAD(ndim);
1416+
result= (ArrayType*)palloc(nbytes);
1417+
MemSet(result,0,nbytes);
1418+
1419+
memcpy((char*)result, (char*)&nbytes,sizeof(int));
1420+
memcpy((char*)ARR_NDIM_PTR(result), (char*)&ndim,sizeof(int));
1421+
memcpy((char*)ARR_DIMS(result),ARR_DIMS(v),2*ndim*sizeof(int));
1422+
1423+
/* Copy new values into the result array. values is pfreed. */
1424+
_CopyArrayEls((char**)values,
1425+
ARR_DATA_PTR(result),nitems,
1426+
typlen,typalign,typbyval);
1427+
1428+
returnresult;
1429+
}
1430+
12771431
/*-----------------------------------------------------------------------------
12781432
* array_eq :
12791433
* compares two arrays for equality

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp