aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/postgres.c58
-rw-r--r--src/backend/tcop/pquery.c25
-rw-r--r--src/backend/tcop/utility.c22
3 files changed, 54 insertions, 51 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 604dd9819eb..7a4390538b6 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.414 2004/05/23 03:50:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.415 2004/05/26 04:41:35 neilc Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -428,7 +428,7 @@ pg_parse_and_rewrite(const char *query_string, /* string to execute */
{
List *raw_parsetree_list;
List *querytree_list;
- List *list_item;
+ ListCell *list_item;
/*
* (1) parse the request string into a list of raw parse trees.
@@ -443,7 +443,7 @@ pg_parse_and_rewrite(const char *query_string, /* string to execute */
{
Node *parsetree = (Node *) lfirst(list_item);
- querytree_list = nconc(querytree_list,
+ querytree_list = list_concat(querytree_list,
pg_analyze_and_rewrite(parsetree,
paramTypes,
numParams));
@@ -468,8 +468,8 @@ pg_parse_and_rewrite(const char *query_string, /* string to execute */
List *
pg_parse_query(const char *query_string)
{
- List *raw_parsetree_list,
- *parsetree_item;
+ List *raw_parsetree_list;
+ ListCell *parsetree_item;
if (log_statement == LOGSTMT_ALL)
ereport(LOG,
@@ -571,7 +571,7 @@ List *
pg_rewrite_queries(List *querytree_list)
{
List *new_list = NIL;
- List *list_item;
+ ListCell *list_item;
if (log_parser_stats)
ResetUsage();
@@ -598,7 +598,7 @@ pg_rewrite_queries(List *querytree_list)
/* rewrite regular queries */
List *rewritten = QueryRewrite(querytree);
- new_list = nconc(new_list, rewritten);
+ new_list = list_concat(new_list, rewritten);
}
}
@@ -691,7 +691,7 @@ List *
pg_plan_queries(List *querytrees, bool needSnapshot)
{
List *plan_list = NIL;
- List *query_list;
+ ListCell *query_list;
foreach(query_list, querytrees)
{
@@ -730,8 +730,8 @@ exec_simple_query(const char *query_string)
{
CommandDest dest = whereToSendOutput;
MemoryContext oldcontext;
- List *parsetree_list,
- *parsetree_item;
+ List *parsetree_list;
+ ListCell *parsetree_item;
struct timeval start_t,
stop_t;
bool save_log_duration = log_duration;
@@ -946,7 +946,7 @@ exec_simple_query(const char *query_string)
*/
finish_xact_command();
}
- else if (lnext(parsetree_item) == NIL)
+ else if (lnext(parsetree_item) == NULL)
{
/*
* If this is the last parsetree of the query string, close
@@ -1129,14 +1129,14 @@ exec_parse_message(const char *query_string, /* string to execute */
* is mainly to keep the protocol simple --- otherwise we'd need to
* worry about multiple result tupdescs and things like that.
*/
- if (length(parsetree_list) > 1)
+ if (list_length(parsetree_list) > 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot insert multiple commands into a prepared statement")));
if (parsetree_list != NIL)
{
- Node *parsetree = (Node *) lfirst(parsetree_list);
+ Node *parsetree = (Node *) linitial(parsetree_list);
int i;
/*
@@ -1198,7 +1198,7 @@ exec_parse_message(const char *query_string, /* string to execute */
(errcode(ERRCODE_INDETERMINATE_DATATYPE),
errmsg("could not determine data type of parameter $%d",
i + 1)));
- param_list = lappendo(param_list, ptype);
+ param_list = lappend_oid(param_list, ptype);
}
if (log_parser_stats)
@@ -1342,11 +1342,11 @@ exec_bind_message(StringInfo input_message)
errmsg("unnamed prepared statement does not exist")));
}
- if (numParams != length(pstmt->argtype_list))
+ if (numParams != list_length(pstmt->argtype_list))
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
- numParams, stmt_name, length(pstmt->argtype_list))));
+ numParams, stmt_name, list_length(pstmt->argtype_list))));
/*
* Create the portal. Allow silent replacement of an existing portal
@@ -1374,7 +1374,7 @@ exec_bind_message(StringInfo input_message)
if (numParams > 0)
{
bool isaborted = IsAbortedTransactionBlockState();
- List *l;
+ ListCell *l;
MemoryContext oldContext;
oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
@@ -1385,7 +1385,7 @@ exec_bind_message(StringInfo input_message)
i = 0;
foreach(l, pstmt->argtype_list)
{
- Oid ptype = lfirsto(l);
+ Oid ptype = lfirst_oid(l);
int32 plength;
bool isNull;
@@ -1587,9 +1587,9 @@ exec_execute_message(const char *portal_name, long max_rows)
BeginCommand(portal->commandTag, dest);
/* Check for transaction-control commands */
- if (length(portal->parseTrees) == 1)
+ if (list_length(portal->parseTrees) == 1)
{
- Query *query = (Query *) lfirst(portal->parseTrees);
+ Query *query = (Query *) linitial(portal->parseTrees);
if (query->commandType == CMD_UTILITY &&
query->utilityStmt != NULL &&
@@ -1690,7 +1690,7 @@ exec_describe_statement_message(const char *stmt_name)
{
PreparedStatement *pstmt;
TupleDesc tupdesc;
- List *l;
+ ListCell *l;
StringInfoData buf;
/* Find prepared statement */
@@ -1713,11 +1713,11 @@ exec_describe_statement_message(const char *stmt_name)
* First describe the parameters...
*/
pq_beginmessage(&buf, 't'); /* parameter description message type */
- pq_sendint(&buf, length(pstmt->argtype_list), 2);
+ pq_sendint(&buf, list_length(pstmt->argtype_list), 2);
foreach(l, pstmt->argtype_list)
{
- Oid ptype = lfirsto(l);
+ Oid ptype = lfirst_oid(l);
pq_sendint(&buf, (int) ptype, 4);
}
@@ -1732,7 +1732,7 @@ exec_describe_statement_message(const char *stmt_name)
List *targetlist;
if (ChoosePortalStrategy(pstmt->query_list) == PORTAL_ONE_SELECT)
- targetlist = ((Query *) lfirst(pstmt->query_list))->targetList;
+ targetlist = ((Query *) linitial(pstmt->query_list))->targetList;
else
targetlist = NIL;
SendRowDescriptionMessage(tupdesc, targetlist, NULL);
@@ -1766,7 +1766,7 @@ exec_describe_portal_message(const char *portal_name)
List *targetlist;
if (portal->strategy == PORTAL_ONE_SELECT)
- targetlist = ((Query *) lfirst(portal->parseTrees))->targetList;
+ targetlist = ((Query *) linitial(portal->parseTrees))->targetList;
else
targetlist = NIL;
SendRowDescriptionMessage(portal->tupDesc, targetlist,
@@ -2524,17 +2524,19 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
if (MyProcPort != NULL)
{
- List *gucopts = MyProcPort->guc_options;
+ ListCell *gucopts = list_head(MyProcPort->guc_options);
while (gucopts)
{
- char *name,
- *value;
+ char *name;
+ char *value;
name = lfirst(gucopts);
gucopts = lnext(gucopts);
+
value = lfirst(gucopts);
gucopts = lnext(gucopts);
+
SetConfigOption(name, value, PGC_BACKEND, PGC_S_CLIENT);
}
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index c213182ad1f..2608588234c 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -8,10 +8,11 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.77 2004/03/21 22:29:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.78 2004/05/26 04:41:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
+
#include "postgres.h"
#include "executor/executor.h"
@@ -200,9 +201,9 @@ ChoosePortalStrategy(List *parseTrees)
strategy = PORTAL_MULTI_QUERY; /* default assumption */
- if (length(parseTrees) == 1)
+ if (list_length(parseTrees) == 1)
{
- Query *query = (Query *) lfirst(parseTrees);
+ Query *query = (Query *) linitial(parseTrees);
if (query->commandType == CMD_SELECT &&
query->canSetTag &&
@@ -267,8 +268,8 @@ PortalStart(Portal portal, ParamListInfo params)
* Create QueryDesc in portal's context; for the moment, set
* the destination to None.
*/
- queryDesc = CreateQueryDesc((Query *) lfirst(portal->parseTrees),
- (Plan *) lfirst(portal->planTrees),
+ queryDesc = CreateQueryDesc((Query *) linitial(portal->parseTrees),
+ (Plan *) linitial(portal->planTrees),
None_Receiver,
params,
false);
@@ -304,7 +305,7 @@ PortalStart(Portal portal, ParamListInfo params)
* will take care of it.
*/
portal->tupDesc =
- UtilityTupleDescriptor(((Query *) lfirst(portal->parseTrees))->utilityStmt);
+ UtilityTupleDescriptor(((Query *) linitial(portal->parseTrees))->utilityStmt);
/*
* Reset cursor position data to "start of query"
@@ -473,7 +474,7 @@ PortalRun(Portal portal, long count,
PortalCreateHoldStore(portal);
treceiver = CreateDestReceiver(Tuplestore, portal);
- PortalRunUtility(portal, lfirst(portal->parseTrees),
+ PortalRunUtility(portal, linitial(portal->parseTrees),
treceiver, NULL);
(*treceiver->rDestroy) (treceiver);
portal->portalUtilReady = true;
@@ -800,8 +801,8 @@ PortalRunMulti(Portal portal,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag)
{
- List *plantree_list = portal->planTrees;
- List *querylist_item;
+ ListCell *planlist_item = list_head(portal->planTrees);
+ ListCell *querylist_item;
/*
* If the destination is RemoteExecute, change to None. The reason is
@@ -825,9 +826,9 @@ PortalRunMulti(Portal portal,
foreach(querylist_item, portal->parseTrees)
{
Query *query = (Query *) lfirst(querylist_item);
- Plan *plan = (Plan *) lfirst(plantree_list);
+ Plan *plan = (Plan *) lfirst(planlist_item);
- plantree_list = lnext(plantree_list);
+ planlist_item = lnext(planlist_item);
/*
* If we got a cancel signal in prior command, quit
@@ -885,7 +886,7 @@ PortalRunMulti(Portal portal,
* Increment command counter between queries, but not after the
* last one.
*/
- if (plantree_list != NIL)
+ if (planlist_item != NULL)
CommandCounterIncrement();
/*
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index bcf071ea8a0..fd9427c203d 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.215 2004/05/07 19:12:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.216 2004/05/26 04:41:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -331,7 +331,7 @@ ProcessUtility(Node *parsetree,
if (stmt->options)
{
- List *head;
+ ListCell *head;
foreach(head, stmt->options)
{
@@ -339,10 +339,10 @@ ProcessUtility(Node *parsetree,
if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("transaction_isolation",
- makeList1(item->arg), false);
+ list_make1(item->arg), false);
else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("transaction_read_only",
- makeList1(item->arg), false);
+ list_make1(item->arg), false);
}
}
}
@@ -405,7 +405,7 @@ ProcessUtility(Node *parsetree,
case T_DropStmt:
{
DropStmt *stmt = (DropStmt *) parsetree;
- List *arg;
+ ListCell *arg;
foreach(arg, stmt->objects)
{
@@ -743,7 +743,7 @@ ProcessUtility(Node *parsetree,
*/
if (strcmp(n->name, "TRANSACTION") == 0)
{
- List *head;
+ ListCell *head;
foreach(head, n->args)
{
@@ -751,15 +751,15 @@ ProcessUtility(Node *parsetree,
if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("transaction_isolation",
- makeList1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("transaction_read_only",
- makeList1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
}
}
else if (strcmp(n->name, "SESSION CHARACTERISTICS") == 0)
{
- List *head;
+ ListCell *head;
foreach(head, n->args)
{
@@ -767,10 +767,10 @@ ProcessUtility(Node *parsetree,
if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("default_transaction_isolation",
- makeList1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("default_transaction_read_only",
- makeList1(item->arg), n->is_local);
+ list_make1(item->arg), n->is_local);
}
}
else