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

Commit982430f

Browse files
committed
Put back encoding-conversion step in processing of incoming queries;
I had inadvertently omitted it while rearranging things to supportlength-counted incoming messages. Also, change the parser's API backto accepting a 'char *' query string instead of 'StringInfo', as thelatter wasn't buying us anything except overhead. (I think when I putit in I had some notion of making the parser API 8-bit-clean, butseeing that flex depends on null-terminated input, that's not reallyever gonna happen.)
1 parent351372e commit982430f

File tree

11 files changed

+69
-75
lines changed

11 files changed

+69
-75
lines changed

‎src/backend/executor/spi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.90 2003/04/24 21:16:43 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.91 2003/04/27 20:09:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -967,7 +967,6 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self)
967967
staticint
968968
_SPI_execute(constchar*src,inttcount,_SPI_plan*plan)
969969
{
970-
StringInfoDatastri;
971970
List*raw_parsetree_list;
972971
List*query_list_list;
973972
List*plan_list;
@@ -994,10 +993,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
994993
/*
995994
* Parse the request string into a list of raw parse trees.
996995
*/
997-
initStringInfo(&stri);
998-
appendStringInfoString(&stri,src);
999-
1000-
raw_parsetree_list=pg_parse_query(&stri,argtypes,nargs);
996+
raw_parsetree_list=pg_parse_query(src,argtypes,nargs);
1001997

1002998
/*
1003999
* Do parse analysis and rule rewrite for each raw parsetree.

‎src/backend/optimizer/util/clauses.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.134 2003/04/08 23:20:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.135 2003/04/2720:09:44 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHORDATEMAJOR EVENT
@@ -1692,7 +1692,6 @@ inline_function(Oid funcid, Oid result_type, List *args,
16921692
boolisNull;
16931693
MemoryContextoldcxt;
16941694
MemoryContextmycxt;
1695-
StringInfoDatastri;
16961695
List*raw_parsetree_list;
16971696
List*querytree_list;
16981697
Query*querytree;
@@ -1752,10 +1751,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
17521751
* we care about. Also, we can punt as soon as we detect more than
17531752
* one command in the function body.
17541753
*/
1755-
initStringInfo(&stri);
1756-
appendStringInfo(&stri,"%s",src);
1757-
1758-
raw_parsetree_list=pg_parse_query(&stri,
1754+
raw_parsetree_list=pg_parse_query(src,
17591755
funcform->proargtypes,
17601756
funcform->pronargs);
17611757
if (length(raw_parsetree_list)!=1)

‎src/backend/parser/parse_type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.55 2003/04/24 21:16:43 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.56 2003/04/27 20:09:44 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -437,7 +437,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod)
437437
initStringInfo(&buf);
438438
appendStringInfo(&buf,"SELECT (NULL::%s)",str);
439439

440-
raw_parsetree_list=parser(&buf,NULL,0);
440+
raw_parsetree_list=parser(buf.data,NULL,0);
441441

442442
/*
443443
* Make sure we got back exactly what we expected and no more;

‎src/backend/parser/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.55 2002/09/04 20:31:24 momjian Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.56 2003/04/27 20:09:44 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -45,7 +45,7 @@ static bool have_lookahead;/* lookahead_token set? */
4545
* Returns a list of raw (un-analyzed) parse trees.
4646
*/
4747
List*
48-
parser(StringInfostr,Oid*typev,intnargs)
48+
parser(constchar*str,Oid*typev,intnargs)
4949
{
5050
intyyresult;
5151

‎src/backend/parser/scan.l

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.104 2003/04/24 21:16:43 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.105 2003/04/27 20:09:44 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -595,18 +595,23 @@ yyerror(const char *message)
595595
* Called before any actual parsing is done
596596
*/
597597
void
598-
scanner_init(StringInfostr)
598+
scanner_init(constchar *str)
599599
{
600+
Sizeslen =strlen(str);
601+
600602
/*
601603
* Might be left over after ereport()
602604
*/
603605
if (YY_CURRENT_BUFFER)
604606
yy_delete_buffer(YY_CURRENT_BUFFER);
605607

606-
scanbuf =palloc(str->len +2);
607-
memcpy(scanbuf, str->data, str->len);
608-
scanbuf[str->len] = scanbuf[str->len +1] = YY_END_OF_BUFFER_CHAR;
609-
scanbufhandle =yy_scan_buffer(scanbuf, str->len +2);
608+
/*
609+
* Make a scan buffer with special termination needed by flex.
610+
*/
611+
scanbuf =palloc(slen +2);
612+
memcpy(scanbuf, str, slen);
613+
scanbuf[slen] = scanbuf[slen +1] = YY_END_OF_BUFFER_CHAR;
614+
scanbufhandle =yy_scan_buffer(scanbuf, slen +2);
610615

611616
/* initialize literal buffer to a reasonable but expansible size */
612617
literalalloc =128;

‎src/backend/postmaster/pgstat.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2003, PostgreSQL Global Development Group
1515
*
16-
*$Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.34 2003/04/26 02:57:14 tgl Exp $
16+
*$Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.35 2003/04/27 20:09:44 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -446,7 +446,7 @@ pgstat_bestart(void)
446446
* ----------
447447
*/
448448
void
449-
pgstat_report_activity(char*what)
449+
pgstat_report_activity(constchar*what)
450450
{
451451
PgStat_MsgActivitymsg;
452452
intlen;
@@ -455,7 +455,8 @@ pgstat_report_activity(char *what)
455455
return;
456456

457457
len=strlen(what);
458-
len=pg_mbcliplen((constunsignedchar*)what,len,PGSTAT_ACTIVITY_SIZE-1);
458+
len=pg_mbcliplen((constunsignedchar*)what,len,
459+
PGSTAT_ACTIVITY_SIZE-1);
459460

460461
memcpy(msg.m_what,what,len);
461462
msg.m_what[len]='\0';

‎src/backend/tcop/postgres.c

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.324 2003/04/24 21:16:43 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.325 2003/04/27 20:09:44 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -60,16 +60,15 @@
6060

6161
#include"pgstat.h"
6262

63+
externintoptind;
64+
externchar*optarg;
65+
6366

6467
/* ----------------
6568
*global variables
6669
* ----------------
6770
*/
68-
69-
externintoptind;
70-
externchar*optarg;
71-
72-
char*debug_query_string;/* for pgmonitor and
71+
constchar*debug_query_string;/* for pgmonitor and
7372
* log_min_error_statement */
7473

7574
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
@@ -339,22 +338,18 @@ ReadCommand(StringInfo inBuf)
339338
* but it is still needed for parsing of SQL function bodies.
340339
*/
341340
List*
342-
pg_parse_and_rewrite(char*query_string,/* string to execute */
341+
pg_parse_and_rewrite(constchar*query_string,/* string to execute */
343342
Oid*typev,/* parameter types */
344343
intnargs)/* number of parameters */
345344
{
346345
List*raw_parsetree_list;
347346
List*querytree_list;
348347
List*list_item;
349-
StringInfoDatastri;
350-
351-
initStringInfo(&stri);
352-
appendStringInfoString(&stri,query_string);
353348

354349
/*
355350
* (1) parse the request string into a list of raw parse trees.
356351
*/
357-
raw_parsetree_list=pg_parse_query(&stri,typev,nargs);
352+
raw_parsetree_list=pg_parse_query(query_string,typev,nargs);
358353

359354
/*
360355
* (2) Do parse analysis and rule rewrite.
@@ -385,12 +380,12 @@ pg_parse_and_rewrite(char *query_string,/* string to execute */
385380
* commands are not processed any further than the raw parse stage.
386381
*/
387382
List*
388-
pg_parse_query(StringInfoquery_string,Oid*typev,intnargs)
383+
pg_parse_query(constchar*query_string,Oid*typev,intnargs)
389384
{
390385
List*raw_parsetree_list;
391386

392387
if (log_statement)
393-
elog(LOG,"query: %s",query_string->data);
388+
elog(LOG,"query: %s",query_string);
394389

395390
if (log_parser_stats)
396391
ResetUsage();
@@ -569,7 +564,7 @@ pg_plan_query(Query *querytree)
569564
*/
570565

571566
void
572-
pg_exec_query_string(StringInfoquery_string,/* string to execute */
567+
pg_exec_query_string(constchar*query_string,/* string to execute */
573568
CommandDestdest,/* where results should go */
574569
MemoryContextparse_context)/* context for
575570
* parsetrees */
@@ -582,7 +577,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
582577
stop_t;
583578
boolsave_log_duration=log_duration;
584579

585-
debug_query_string=query_string->data;
580+
debug_query_string=query_string;
586581

587582
/*
588583
* We use save_log_duration so "SET log_duration = true" doesn't
@@ -1248,7 +1243,7 @@ PostgresMain(int argc, char *argv[], const char *username)
12481243
GucSourcegucsource;
12491244
char*tmp;
12501245
intfirstchar;
1251-
StringInfoparser_input;
1246+
StringInfoinput_message;
12521247
boolsend_rfq;
12531248

12541249
/*
@@ -1831,7 +1826,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18311826
if (!IsUnderPostmaster)
18321827
{
18331828
puts("\nPOSTGRES backend interactive interface ");
1834-
puts("$Revision: 1.324 $ $Date: 2003/04/24 21:16:43 $\n");
1829+
puts("$Revision: 1.325 $ $Date: 2003/04/27 20:09:44 $\n");
18351830
}
18361831

18371832
/*
@@ -1933,7 +1928,7 @@ PostgresMain(int argc, char *argv[], const char *username)
19331928
MemoryContextSwitchTo(QueryContext);
19341929
MemoryContextResetAndDeleteChildren(QueryContext);
19351930

1936-
parser_input=makeStringInfo();
1931+
input_message=makeStringInfo();
19371932

19381933
/*
19391934
* (1) tell the frontend we're ready for a new query.
@@ -1983,7 +1978,7 @@ PostgresMain(int argc, char *argv[], const char *username)
19831978
/*
19841979
* (3) read a command (loop blocks here)
19851980
*/
1986-
firstchar=ReadCommand(parser_input);
1981+
firstchar=ReadCommand(input_message);
19871982

19881983
/*
19891984
* (4) disable async signal conditions again.
@@ -2009,25 +2004,29 @@ PostgresMain(int argc, char *argv[], const char *username)
20092004
switch (firstchar)
20102005
{
20112006
case'Q':/* simple query */
2012-
/*
2013-
* Process the query string.
2014-
*
2015-
* Note: transaction command start/end is now done within
2016-
*pg_exec_query_string(), not here.
2017-
*/
2018-
if (log_statement_stats)
2019-
ResetUsage();
2007+
{
2008+
/*
2009+
* Process the query string.
2010+
*
2011+
*Note: transaction command start/end is now done within
2012+
* pg_exec_query_string(), not here.
2013+
*/
2014+
constchar*query_string=pq_getmsgstring(input_message);
20202015

2021-
pgstat_report_activity(parser_input->data);
2016+
if (log_statement_stats)
2017+
ResetUsage();
20222018

2023-
pg_exec_query_string(parser_input,
2024-
whereToSendOutput,
2025-
QueryContext);
2019+
pgstat_report_activity(query_string);
20262020

2027-
if (log_statement_stats)
2028-
ShowUsage("QUERY STATISTICS");
2021+
pg_exec_query_string(query_string,
2022+
whereToSendOutput,
2023+
QueryContext);
20292024

2030-
send_rfq= true;
2025+
if (log_statement_stats)
2026+
ShowUsage("QUERY STATISTICS");
2027+
2028+
send_rfq= true;
2029+
}
20312030
break;
20322031

20332032
case'F':/* fastpath function call */
@@ -2037,7 +2036,7 @@ PostgresMain(int argc, char *argv[], const char *username)
20372036
/* start an xact for this function invocation */
20382037
start_xact_command();
20392038

2040-
if (HandleFunctionRequest(parser_input)==EOF)
2039+
if (HandleFunctionRequest(input_message)==EOF)
20412040
{
20422041
/* lost frontend connection during F message input */
20432042

‎src/include/parser/gramparse.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: gramparse.h,v 1.25 2002/09/04 20:31:45 momjian Exp $
10+
* $Id: gramparse.h,v 1.26 2003/04/27 20:09:44 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#ifndefGRAMPARSE_H
1616
#defineGRAMPARSE_H
1717

18-
#include"lib/stringinfo.h"
1918
#include"nodes/parsenodes.h"
2019

2120
/* from parser.c */
@@ -24,7 +23,7 @@ extern Oidparam_type(int t);
2423
externintyylex(void);
2524

2625
/* from scan.l */
27-
externvoidscanner_init(StringInfostr);
26+
externvoidscanner_init(constchar*str);
2827
externvoidscanner_finish(void);
2928
externintbase_yylex(void);
3029
externvoidyyerror(constchar*message);

‎src/include/parser/parser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parser.h,v 1.13 2002/06/20 20:29:52 momjian Exp $
10+
* $Id: parser.h,v 1.14 2003/04/27 20:09:44 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndefPARSER_H
1515
#definePARSER_H
1616

17-
#include"lib/stringinfo.h"
1817
#include"parser/parse_node.h"
1918

20-
externList*parser(StringInfostr,Oid*typev,intnargs);
19+
externList*parser(constchar*str,Oid*typev,intnargs);
2120

2221
#endif/* PARSER_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp