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

Commitbaeb879

Browse files
committed
Fix case issues with quotes.
1 parent0f367cf commitbaeb879

File tree

4 files changed

+106
-72
lines changed

4 files changed

+106
-72
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.60 1997/11/07 20:51:47 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.61 1997/11/10 05:10:21 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -131,8 +131,8 @@ static char *progname = (char *) NULL;
131131
*/
132132
staticcharExecfile[MAXPATHLEN]="";
133133

134-
staticintServerSock_INET=INVALID_SOCK;/* stream socket server */
135-
staticintServerSock_UNIX=INVALID_SOCK;/* stream socket server */
134+
staticintServerSock_INET=INVALID_SOCK;/* stream socket server */
135+
staticintServerSock_UNIX=INVALID_SOCK;/* stream socket server */
136136

137137
/*
138138
* Set by the -o option
@@ -149,8 +149,8 @@ static char ExtraOptions[ARGV_SIZE] = "";
149149
staticintReinit=1;
150150
staticintSendStop=0;
151151

152-
staticintNetServer=0;/* if not zero, postmaster listen for
153-
non-local connections */
152+
staticintNetServer=0;/* if not zero, postmaster listen for
153+
* non-local connections */
154154
staticintMultiplexedBackends=0;
155155
staticintMultiplexedBackendPort;
156156

@@ -318,8 +318,8 @@ PostmasterMain(int argc, char *argv[])
318318
else
319319
DebugLvl=1;
320320
break;
321-
case'i':
322-
NetServer=1;
321+
case'i':
322+
NetServer=1;
323323
break;
324324
case'm':
325325
MultiplexedBackends=1;
@@ -394,15 +394,15 @@ PostmasterMain(int argc, char *argv[])
394394
}
395395

396396
if (NetServer)
397-
{
398-
status=StreamServerPort(hostName,PostPortName,&ServerSock_INET);
399-
if (status!=STATUS_OK)
400-
{
401-
fprintf(stderr,"%s: cannot create INET stream port\n",
402-
progname);
403-
exit(1);
404-
}
405-
}
397+
{
398+
status=StreamServerPort(hostName,PostPortName,&ServerSock_INET);
399+
if (status!=STATUS_OK)
400+
{
401+
fprintf(stderr,"%s: cannot create INET stream port\n",
402+
progname);
403+
exit(1);
404+
}
405+
}
406406
status=StreamServerPort(NULL,PostPortName,&ServerSock_UNIX);
407407
if (status!=STATUS_OK)
408408
{
@@ -487,11 +487,13 @@ usage(const char *progname)
487487
staticint
488488
ServerLoop(void)
489489
{
490-
fd_setrmask,basemask;
490+
fd_setrmask,
491+
basemask;
491492
intnSockets,
492493
nSelected,
493494
status,
494-
oldFd,newFd;
495+
oldFd,
496+
newFd;
495497
Dlelem*next,
496498
*curr;
497499

@@ -511,11 +513,11 @@ ServerLoop(void)
511513
FD_SET(ServerSock_UNIX,&basemask);
512514
nSockets=ServerSock_UNIX;
513515
if (ServerSock_INET!=INVALID_SOCK)
514-
{
515-
FD_SET(ServerSock_INET,&basemask);
516-
if (ServerSock_INET>ServerSock_UNIX)
517-
nSockets=ServerSock_INET;
518-
}
516+
{
517+
FD_SET(ServerSock_INET,&basemask);
518+
if (ServerSock_INET>ServerSock_UNIX)
519+
nSockets=ServerSock_INET;
520+
}
519521
nSockets++;
520522

521523
#ifdefHAVE_SIGPROCMASK
@@ -563,14 +565,14 @@ ServerLoop(void)
563565

564566
/* new connection pending on our well-known port's socket */
565567
oldFd=-1;
566-
if (FD_ISSET(ServerSock_UNIX,&rmask))
567-
oldFd=ServerSock_UNIX;
568-
elseif (ServerSock_INET!=INVALID_SOCK&&
569-
FD_ISSET(ServerSock_INET,&rmask))
570-
oldFd=ServerSock_INET;
568+
if (FD_ISSET(ServerSock_UNIX,&rmask))
569+
oldFd=ServerSock_UNIX;
570+
elseif (ServerSock_INET!=INVALID_SOCK&&
571+
FD_ISSET(ServerSock_INET,&rmask))
572+
oldFd=ServerSock_INET;
571573
if (oldFd >=0)
572574
{
573-
575+
574576
/*
575577
* connect and make an addition to PortList. If the
576578
* connection dies and we notice it, just forget about the
@@ -587,9 +589,9 @@ ServerLoop(void)
587589
progname,newFd);
588590
}
589591
elseif (DebugLvl)
590-
fprintf(stderr,
591-
"%s: ServerLoop: connect failed: (%d) %s\n",
592-
progname,errno,strerror(errno));
592+
fprintf(stderr,
593+
"%s: ServerLoop: connect failed: (%d) %s\n",
594+
progname,errno,strerror(errno));
593595
--nSelected;
594596
FD_CLR(oldFd,&rmask);
595597
}
@@ -823,7 +825,7 @@ ConnStartup(Port *port, int *status,
823825
staticvoid
824826
send_error_reply(Port*port,constchar*errormsg)
825827
{
826-
intrc;/* return code from write */
828+
intrc;/* return code from write */
827829
char*reply;
828830

829831
/*
@@ -1299,8 +1301,10 @@ ExitPostmaster(int status)
12991301
* Not sure of the semantics here.When the Postmaster dies, should
13001302
* the backends all be killed? probably not.
13011303
*/
1302-
if (ServerSock_INET!=INVALID_SOCK)close(ServerSock_INET);
1303-
if (ServerSock_UNIX!=INVALID_SOCK)close(ServerSock_UNIX);
1304+
if (ServerSock_INET!=INVALID_SOCK)
1305+
close(ServerSock_INET);
1306+
if (ServerSock_UNIX!=INVALID_SOCK)
1307+
close(ServerSock_UNIX);
13041308
exitpg(status);
13051309
}
13061310

@@ -1315,10 +1319,9 @@ dumpstatus(SIGNAL_ARGS)
13151319

13161320
fprintf(stderr,"%s: dumpstatus:\n",progname);
13171321
fprintf(stderr,"\tsock %d: nBytes=%d, laddr=0x%lx, raddr=0x%lx\n",
1318-
port->sock,port->nBytes,
1319-
(longint)port->laddr.in.sin_addr.s_addr,
1320-
(longint)port->raddr.in.sin_addr.s_addr);
1322+
port->sock,port->nBytes,
1323+
(longint)port->laddr.in.sin_addr.s_addr,
1324+
(longint)port->raddr.in.sin_addr.s_addr);
13211325
curr=DLGetSucc(curr);
13221326
}
13231327
}
1324-

‎src/include/c.h

Lines changed: 4 additions & 4 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: c.h,v 1.26 1997/10/30 23:36:56 momjian Exp $
10+
* $Id: c.h,v 1.27 1997/11/10 05:10:34 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -697,8 +697,8 @@ typedef struct Exception
697697
#defineINT_ALIGN_MASK (sizeof(int32) - 1)
698698

699699
/* This function gets call too often, so we inline it if we can */
700-
#defineMemSet(start,val,len)do \
701-
{/* are we aligned for int32? */ \
700+
#defineMemSet(start,val,len)do \
701+
{/* are we aligned for int32? */ \
702702
/* We have to cast the pointer to int \
703703
so we can do the AND */ \
704704
if (((int)(start)&INT_ALIGN_MASK)==0&& \
@@ -707,7 +707,7 @@ typedef struct Exception
707707
/* \
708708
* We got this number by testing this \
709709
* against the stock memset() on \
710-
* bsd/os 3.0.Larger values were \
710+
* bsd/os 3.0.Larger values were \
711711
* slower. \
712712
*/ \
713713
(len) <=64) \

‎src/interfaces/libpq/fe-connect.c

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.43 1997/11/07 20:52:15 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.44 1997/11/10 05:10:45 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -340,8 +340,9 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
340340

341341
if (!pghost||pghost[0]=='\0')
342342
{
343-
conn->pghost=NULL;
344-
if (tmp=getenv("PGHOST"))conn->pghost=strdup(tmp);
343+
conn->pghost=NULL;
344+
if (tmp=getenv("PGHOST"))
345+
conn->pghost=strdup(tmp);
345346
}
346347
else
347348
conn->pghost=strdup(pghost);
@@ -413,14 +414,23 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha
413414
{
414415
if (((tmp= (char*)dbName)&& (dbName[0]!='\0'))||
415416
((tmp=getenv("PGDATABASE"))))
416-
{
417417
conn->dbName=strdup(tmp);
418-
}
419418
else
420419
conn->dbName=strdup(conn->pguser);
421-
for (i=0;conn->dbName[i];i++)
422-
if (isupper(conn->dbName[i]))
423-
conn->dbName[i]=tolower(conn->dbName[i]);
420+
421+
/*
422+
* if the table name is surrounded by double-quotes, then
423+
* don't convert case
424+
*/
425+
if (*conn->dbName=='"')
426+
{
427+
strcpy(conn->dbName,conn->dbName+1);
428+
*(conn->dbName+strlen(conn->dbName)-1)='\0';
429+
}
430+
else
431+
for (i=0;conn->dbName[i];i++)
432+
if (isupper(conn->dbName[i]))
433+
conn->dbName[i]=tolower(conn->dbName[i]);
424434
}
425435
else
426436
conn->dbName=NULL;
@@ -470,7 +480,9 @@ connectDB(PGconn *conn)
470480
MsgTypemsgtype;
471481
intladdrlen=sizeof(structsockaddr);
472482
Port*port=conn->port;
473-
intportno,family,len;
483+
intportno,
484+
family,
485+
len;
474486

475487
/*
476488
* Initialize the startup packet.
@@ -498,8 +510,8 @@ connectDB(PGconn *conn)
498510
port= (Port*)malloc(sizeof(Port));
499511
MemSet((char*)port,0,sizeof(Port));
500512

501-
if (conn->pghost&&
502-
(!(hp=gethostbyname(conn->pghost))||hp->h_addrtype!=AF_INET))
513+
if (conn->pghost&&
514+
(!(hp=gethostbyname(conn->pghost))||hp->h_addrtype!=AF_INET))
503515
{
504516
(void)sprintf(conn->errorMessage,
505517
"connectDB() -- unknown hostname: %s\n",
@@ -510,17 +522,17 @@ connectDB(PGconn *conn)
510522
portno=atoi(conn->pgport);
511523
port->raddr.in.sin_family=family=conn->pghost ?AF_INET :AF_UNIX;
512524
if (family==AF_INET)
513-
{
514-
memmove((char*)&(port->raddr.in.sin_addr),
515-
(char*)hp->h_addr,
516-
hp->h_length);
517-
port->raddr.in.sin_port=htons((unsigned short) (portno));
518-
len=sizeof(structsockaddr_in);
519-
}
525+
{
526+
memmove((char*)&(port->raddr.in.sin_addr),
527+
(char*)hp->h_addr,
528+
hp->h_length);
529+
port->raddr.in.sin_port=htons((unsigned short) (portno));
530+
len=sizeof(structsockaddr_in);
531+
}
520532
else
521-
{
522-
len=UNIXSOCK_PATH(port->raddr.un,portno);
523-
}
533+
{
534+
len=UNIXSOCK_PATH(port->raddr.un,portno);
535+
}
524536
/* connect to the server */
525537
if ((port->sock=socket(family,SOCK_STREAM,0))<0)
526538
{
@@ -529,12 +541,12 @@ connectDB(PGconn *conn)
529541
errno,strerror(errno));
530542
gotoconnect_errReturn;
531543
}
532-
if (connect(port->sock, (structsockaddr*)&port->raddr,len)<0)
544+
if (connect(port->sock, (structsockaddr*)&port->raddr,len)<0)
533545
{
534546
(void)sprintf(conn->errorMessage,
535-
"connectDB() failed: Is the postmaster running at '%s' on port '%s'?\n",
536-
conn->pghost ?conn->pghost :"UNIX Socket",
537-
conn->pgport);
547+
"connectDB() failed: Is the postmaster running at '%s' on port '%s'?\n",
548+
conn->pghost ?conn->pghost :"UNIX Socket",
549+
conn->pgport);
538550
gotoconnect_errReturn;
539551
}
540552
if (family==AF_INET)
@@ -779,7 +791,8 @@ packetSend(Port *port,
779791
PacketLenlen,
780792
boolnonBlocking)
781793
{
782-
PacketLendoneLen=write(port->sock,buf,len);
794+
PacketLendoneLen=write(port->sock,buf,len);
795+
783796
if (doneLen<len)
784797
{
785798
return (STATUS_ERROR);

‎src/interfaces/libpq/fe-exec.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.39 1997/11/03 04:21:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.40 1997/11/10 05:10:50 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,6 +17,7 @@
1717
#include<signal.h>
1818
#include<string.h>
1919
#include<errno.h>
20+
#include<ctype.h>
2021
#include"postgres.h"
2122
#include"libpq/pqcomm.h"
2223
#include"libpq/pqsignal.h"
@@ -31,12 +32,14 @@
3132

3233
#ifdefTIOCGWINSZ
3334
structwinsizescreen_size;
35+
3436
#else
3537
structwinsize
3638
{
3739
intws_row;
3840
intws_col;
3941
}screen_size;
42+
4043
#endif
4144

4245
/* the rows array in a PGresGroup has to grow to accommodate the rows */
@@ -1674,6 +1677,7 @@ int
16741677
PQfnumber(PGresult*res,constchar*field_name)
16751678
{
16761679
inti;
1680+
char*field_case;
16771681

16781682
if (!res)
16791683
{
@@ -1686,13 +1690,27 @@ PQfnumber(PGresult *res, const char *field_name)
16861690
res->attDescs==NULL)
16871691
return-1;
16881692

1693+
field_case=strdup(field_name);
1694+
if (*field_case=='"')
1695+
{
1696+
strcpy(field_case,field_case+1);
1697+
*(field_case+strlen(field_case)-1)='\0';
1698+
}
1699+
else
1700+
for (i=0;field_case;i++)
1701+
if (isupper(field_case[i]))
1702+
field_case[i]=tolower(field_case[i]);
1703+
16891704
for (i=0;i<res->numAttributes;i++)
16901705
{
1691-
if (strcasecmp(field_name,res->attDescs[i].name)==0)
1706+
if (strcmp(field_name,res->attDescs[i].name)==0)
1707+
{
1708+
free(field_case);
16921709
returni;
1710+
}
16931711
}
1712+
free(field_case);
16941713
return-1;
1695-
16961714
}
16971715

16981716
Oid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp