1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Make backend header files C++ safe

This alters various incidental uses of C++ key words to use other similar
identifiers, so that a C++ compiler won't choke outright.  You still
(probably) need extern "C" { }; around the inclusion of backend headers.

based on a patch by Kurt Harriman <harriman@acm.org>

Also add a script cpluspluscheck to check for C++ compatibility in the
future.  As of right now, this passes without error for me.
This commit is contained in:
Peter Eisentraut
2009-07-16 06:33:46 +00:00
parent 4ef8dc7a75
commit de160e2c00
52 changed files with 392 additions and 359 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.302 2009/07/14 20:24:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.303 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -5910,14 +5910,14 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
if (!j->isNatural)
{
if (j->using)
if (j->usingClause)
{
ListCell *col;
appendStringInfo(buf, " USING (");
foreach(col, j->using)
foreach(col, j->usingClause)
{
if (col != list_head(j->using))
if (col != list_head(j->usingClause))
appendStringInfo(buf, ", ");
appendStringInfoString(buf,
quote_identifier(strVal(lfirst(col))));
@@ -6251,18 +6251,18 @@ quote_identifier(const char *ident)
/*
* quote_qualified_identifier - Quote a possibly-qualified identifier
*
* Return a name of the form namespace.ident, or just ident if namespace
* Return a name of the form qualifier.ident, or just ident if qualifier
* is NULL, quoting each component if necessary. The result is palloc'd.
*/
char *
quote_qualified_identifier(const char *namespace,
quote_qualified_identifier(const char *qualifier,
const char *ident)
{
StringInfoData buf;
initStringInfo(&buf);
if (namespace)
appendStringInfo(&buf, "%s.", quote_identifier(namespace));
if (qualifier)
appendStringInfo(&buf, "%s.", quote_identifier(qualifier));
appendStringInfoString(&buf, quote_identifier(ident));
return buf.data;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.16 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.17 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -142,7 +142,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
if (item[i].type == QI_VAL)
{
text *txt;
QueryOperand *val = &item[i].operand;
QueryOperand *val = &item[i].qoperand;
txt = cstring_to_text_with_len(GETOPERAND(query) + val->distance,
val->length);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.20 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.21 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -419,15 +419,15 @@ findoprnd_recurse(QueryItem *ptr, uint32 *pos, int nnodes)
{
Assert(ptr[*pos].type == QI_OPR);
if (ptr[*pos].operator.oper == OP_NOT)
if (ptr[*pos].qoperator.oper == OP_NOT)
{
ptr[*pos].operator.left = 1;
ptr[*pos].qoperator.left = 1;
(*pos)++;
findoprnd_recurse(ptr, pos, nnodes);
}
else
{
QueryOperator *curitem = &ptr[*pos].operator;
QueryOperator *curitem = &ptr[*pos].qoperator;
int tmp = *pos;
Assert(curitem->oper == OP_AND || curitem->oper == OP_OR);
@@ -611,7 +611,7 @@ infix(INFIX *in, bool first)
if (in->curpol->type == QI_VAL)
{
QueryOperand *curpol = &in->curpol->operand;
QueryOperand *curpol = &in->curpol->qoperand;
char *op = in->op + curpol->distance;
int clen;
@@ -671,7 +671,7 @@ infix(INFIX *in, bool first)
*(in->cur) = '\0';
in->curpol++;
}
else if (in->curpol->operator.oper == OP_NOT)
else if (in->curpol->qoperator.oper == OP_NOT)
{
bool isopr = false;
@@ -699,7 +699,7 @@ infix(INFIX *in, bool first)
}
else
{
int8 op = in->curpol->operator.oper;
int8 op = in->curpol->qoperator.oper;
INFIX nrm;
in->curpol++;
@@ -808,12 +808,12 @@ tsquerysend(PG_FUNCTION_ARGS)
switch (item->type)
{
case QI_VAL:
pq_sendint(&buf, item->operand.weight, sizeof(uint8));
pq_sendint(&buf, item->operand.prefix, sizeof(uint8));
pq_sendstring(&buf, GETOPERAND(query) + item->operand.distance);
pq_sendint(&buf, item->qoperand.weight, sizeof(uint8));
pq_sendint(&buf, item->qoperand.prefix, sizeof(uint8));
pq_sendstring(&buf, GETOPERAND(query) + item->qoperand.distance);
break;
case QI_OPR:
pq_sendint(&buf, item->operator.oper, sizeof(item->operator.oper));
pq_sendint(&buf, item->qoperator.oper, sizeof(item->qoperator.oper));
break;
default:
elog(ERROR, "unrecognized tsquery node type: %d", item->type);
@@ -887,11 +887,11 @@ tsqueryrecv(PG_FUNCTION_ARGS)
COMP_CRC32(valcrc, val, val_len);
FIN_CRC32(valcrc);
item->operand.weight = weight;
item->operand.prefix = (prefix) ? true : false;
item->operand.valcrc = (int32) valcrc;
item->operand.length = val_len;
item->operand.distance = datalen;
item->qoperand.weight = weight;
item->qoperand.prefix = (prefix) ? true : false;
item->qoperand.valcrc = (int32) valcrc;
item->qoperand.length = val_len;
item->qoperand.distance = datalen;
/*
* Operand strings are copied to the final struct after this loop;
@@ -912,7 +912,7 @@ tsqueryrecv(PG_FUNCTION_ARGS)
if (i == size - 1)
elog(ERROR, "invalid pointer to right operand");
item->operator.oper = oper;
item->qoperator.oper = oper;
}
else
elog(ERROR, "unrecognized tsquery node type: %d", item->type);
@@ -936,8 +936,8 @@ tsqueryrecv(PG_FUNCTION_ARGS)
{
if (item->type == QI_VAL)
{
memcpy(ptr, operands[i], item->operand.length + 1);
ptr += item->operand.length + 1;
memcpy(ptr, operands[i], item->qoperand.length + 1);
ptr += item->qoperand.length + 1;
}
item++;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_cleanup.c,v 1.11 2009/01/01 17:23:50 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_cleanup.c,v 1.12 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,8 +39,8 @@ maketree(QueryItem *in)
if (in->type == QI_OPR)
{
node->right = maketree(in + 1);
if (in->operator.oper != OP_NOT)
node->left = maketree(in + in->operator.left);
if (in->qoperator.oper != OP_NOT)
node->left = maketree(in + in->qoperator.left);
}
return node;
}
@@ -69,9 +69,9 @@ plainnode(PLAINTREE *state, NODE *node)
memcpy((void *) &(state->ptr[state->cur]), (void *) node->valnode, sizeof(QueryItem));
if (node->valnode->type == QI_VAL)
state->cur++;
else if (node->valnode->operator.oper == OP_NOT)
else if (node->valnode->qoperator.oper == OP_NOT)
{
state->ptr[state->cur].operator.left = 1;
state->ptr[state->cur].qoperator.left = 1;
state->cur++;
plainnode(state, node->right);
}
@@ -81,7 +81,7 @@ plainnode(PLAINTREE *state, NODE *node)
state->cur++;
plainnode(state, node->right);
state->ptr[cur].operator.left = state->cur - cur;
state->ptr[cur].qoperator.left = state->cur - cur;
plainnode(state, node->left);
}
pfree(node);
@@ -138,14 +138,14 @@ clean_NOT_intree(NODE *node)
if (node->valnode->type == QI_VAL)
return node;
if (node->valnode->operator.oper == OP_NOT)
if (node->valnode->qoperator.oper == OP_NOT)
{
freetree(node);
return NULL;
}
/* operator & or | */
if (node->valnode->operator.oper == OP_OR)
if (node->valnode->qoperator.oper == OP_OR)
{
if ((node->left = clean_NOT_intree(node->left)) == NULL ||
(node->right = clean_NOT_intree(node->right)) == NULL)
@@ -158,7 +158,7 @@ clean_NOT_intree(NODE *node)
{
NODE *res = node;
Assert(node->valnode->operator.oper == OP_AND);
Assert(node->valnode->qoperator.oper == OP_AND);
node->left = clean_NOT_intree(node->left);
node->right = clean_NOT_intree(node->right);
@@ -233,7 +233,7 @@ clean_fakeval_intree(NODE *node, char *result)
Assert(node->valnode->type == QI_OPR);
if (node->valnode->operator.oper == OP_NOT)
if (node->valnode->qoperator.oper == OP_NOT)
{
node->right = clean_fakeval_intree(node->right, &rresult);
if (!node->right)

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.6 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.7 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,7 +38,7 @@ join_tsqueries(TSQuery a, TSQuery b, int8 operator)
res->valnode = (QueryItem *) palloc0(sizeof(QueryItem));
res->valnode->type = QI_OPR;
res->valnode->operator.oper = operator;
res->valnode->qoperator.oper = operator;
res->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
res->child[0] = QT2QTN(GETQUERY(b), GETOPERAND(b));
@@ -124,7 +124,7 @@ tsquery_not(PG_FUNCTION_ARGS)
res->valnode = (QueryItem *) palloc0(sizeof(QueryItem));
res->valnode->type = QI_OPR;
res->valnode->operator.oper = OP_NOT;
res->valnode->qoperator.oper = OP_NOT;
res->child = (QTNode **) palloc0(sizeof(QTNode *));
res->child[0] = QT2QTN(GETQUERY(a), GETOPERAND(a));
@@ -209,7 +209,7 @@ makeTSQuerySign(TSQuery a)
for (i = 0; i < a->size; i++)
{
if (ptr->type == QI_VAL)
sign |= ((TSQuerySign) 1) << (ptr->operand.valcrc % TSQS_SIGLEN);
sign |= ((TSQuerySign) 1) << (ptr->qoperand.valcrc % TSQS_SIGLEN);
ptr++;
}
@@ -255,7 +255,7 @@ tsq_mcontains(PG_FUNCTION_ARGS)
if (ie[i].type != QI_VAL)
continue;
for (j = 0; j < query->size; j++)
if (iq[j].type == QI_VAL && ie[i].operand.valcrc == iq[j].operand.valcrc)
if (iq[j].type == QI_VAL && ie[i].qoperand.valcrc == iq[j].qoperand.valcrc)
{
j = query->size + 1;
break;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.14 2009/01/07 13:44:36 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.15 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,7 +57,7 @@ findeq(QTNode *node, QTNode *ex, QTNode *subs, bool *isfind)
if (node->valnode->type == QI_OPR)
{
if (node->valnode->operator.oper != ex->valnode->operator.oper)
if (node->valnode->qoperator.oper != ex->valnode->qoperator.oper)
return node;
if (node->nchild == ex->nchild)
@@ -154,7 +154,7 @@ findeq(QTNode *node, QTNode *ex, QTNode *subs, bool *isfind)
{
Assert(node->valnode->type == QI_VAL);
if (node->valnode->operand.valcrc != ex->valnode->operand.valcrc)
if (node->valnode->qoperand.valcrc != ex->valnode->qoperand.valcrc)
return node;
else if (QTNEq(node, ex))
{
@@ -217,7 +217,7 @@ dropvoidsubtree(QTNode *root)
root->nchild = j;
if (root->valnode->operator.oper == OP_NOT && root->nchild == 0)
if (root->valnode->qoperator.oper == OP_NOT && root->nchild == 0)
{
QTNFree(root);
root = NULL;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.11 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.12 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,19 +33,19 @@ QT2QTN(QueryItem *in, char *operand)
node->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
node->child[0] = QT2QTN(in + 1, operand);
node->sign = node->child[0]->sign;
if (in->operator.oper == OP_NOT)
if (in->qoperator.oper == OP_NOT)
node->nchild = 1;
else
{
node->nchild = 2;
node->child[1] = QT2QTN(in + in->operator.left, operand);
node->child[1] = QT2QTN(in + in->qoperator.left, operand);
node->sign |= node->child[1]->sign;
}
}
else if (operand)
{
node->word = operand + in->operand.distance;
node->sign = 1 << (in->operand.valcrc % 32);
node->word = operand + in->qoperand.distance;
node->sign = 1 << (in->qoperand.valcrc % 32);
}
return node;
@@ -94,8 +94,8 @@ QTNodeCompare(QTNode *an, QTNode *bn)
if (an->valnode->type == QI_OPR)
{
QueryOperator *ao = &an->valnode->operator;
QueryOperator *bo = &bn->valnode->operator;
QueryOperator *ao = &an->valnode->qoperator;
QueryOperator *bo = &bn->valnode->qoperator;
if (ao->oper != bo->oper)
return (ao->oper > bo->oper) ? -1 : 1;
@@ -115,8 +115,8 @@ QTNodeCompare(QTNode *an, QTNode *bn)
}
else
{
QueryOperand *ao = &an->valnode->operand;
QueryOperand *bo = &bn->valnode->operand;
QueryOperand *ao = &an->valnode->qoperand;
QueryOperand *bo = &bn->valnode->qoperand;
Assert(an->valnode->type == QI_VAL);
@@ -188,7 +188,7 @@ QTNTernary(QTNode *in)
{
QTNode *cc = in->child[i];
if (cc->valnode->type == QI_OPR && in->valnode->operator.oper == cc->valnode->operator.oper)
if (cc->valnode->type == QI_OPR && in->valnode->qoperator.oper == cc->valnode->qoperator.oper)
{
int oldnchild = in->nchild;
@@ -245,7 +245,7 @@ QTNBinary(QTNode *in)
nn->sign = nn->child[0]->sign | nn->child[1]->sign;
nn->valnode->type = in->valnode->type;
nn->valnode->operator.oper = in->valnode->operator.oper;
nn->valnode->qoperator.oper = in->valnode->qoperator.oper;
in->child[0] = nn;
in->child[1] = in->child[in->nchild - 1];
@@ -273,7 +273,7 @@ cntsize(QTNode *in, int *sumlen, int *nnode)
}
else
{
*sumlen += in->valnode->operand.length + 1;
*sumlen += in->valnode->qoperand.length + 1;
}
}
@@ -294,10 +294,10 @@ fillQT(QTN2QTState *state, QTNode *in)
{
memcpy(state->curitem, in->valnode, sizeof(QueryOperand));
memcpy(state->curoperand, in->word, in->valnode->operand.length);
state->curitem->operand.distance = state->curoperand - state->operand;
state->curoperand[in->valnode->operand.length] = '\0';
state->curoperand += in->valnode->operand.length + 1;
memcpy(state->curoperand, in->word, in->valnode->qoperand.length);
state->curitem->qoperand.distance = state->curoperand - state->operand;
state->curoperand[in->valnode->qoperand.length] = '\0';
state->curoperand += in->valnode->qoperand.length + 1;
state->curitem++;
}
else
@@ -315,7 +315,7 @@ fillQT(QTN2QTState *state, QTNode *in)
if (in->nchild == 2)
{
curitem->operator.left = state->curitem - curitem;
curitem->qoperator.left = state->curitem - curitem;
fillQT(state, in->child[1]);
}
}
@@ -361,9 +361,9 @@ QTNCopy(QTNode *in)
if (in->valnode->type == QI_VAL)
{
out->word = palloc(in->valnode->operand.length + 1);
memcpy(out->word, in->word, in->valnode->operand.length);
out->word[in->valnode->operand.length] = '\0';
out->word = palloc(in->valnode->qoperand.length + 1);
memcpy(out->word, in->word, in->valnode->qoperand.length);
out->word[in->valnode->qoperand.length] = '\0';
out->flags |= QTN_WORDFREE;
}
else

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.15 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsrank.c,v 1.16 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -358,7 +358,7 @@ calc_rank(float *w, TSVector t, TSQuery q, int4 method)
return 0.0;
/* XXX: What about NOT? */
res = (item->type == QI_OPR && item->operator.oper == OP_AND) ?
res = (item->type == QI_OPR && item->qoperator.oper == OP_AND) ?
calc_rank_and(w, t, q) : calc_rank_or(w, t, q);
if (res < 0)
@@ -641,7 +641,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
if (item[i].type != QI_VAL)
continue;
curoperand = &item[i].operand;
curoperand = &item[i].qoperand;
if (QR_GET_OPERAND_EXISTS(qr, &item[i]))
continue;
@@ -680,8 +680,8 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
for (k = 0; k < qr->query->size; k++)
{
QueryOperand *kptr = &item[k].operand;
QueryOperand *iptr = &item[i].operand;
QueryOperand *kptr = &item[k].qoperand;
QueryOperand *iptr = &item[i].qoperand;
if (k == i ||
(item[k].type == QI_VAL &&

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.23 2009/06/11 14:49:04 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.24 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -668,7 +668,7 @@ TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
if (curitem->type == QI_VAL)
return chkcond(checkval, (QueryOperand *) curitem);
switch (curitem->operator.oper)
switch (curitem->qoperator.oper)
{
case OP_NOT:
if (calcnot)
@@ -676,19 +676,19 @@ TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
else
return true;
case OP_AND:
if (TS_execute(curitem + curitem->operator.left, checkval, calcnot, chkcond))
if (TS_execute(curitem + curitem->qoperator.left, checkval, calcnot, chkcond))
return TS_execute(curitem + 1, checkval, calcnot, chkcond);
else
return false;
case OP_OR:
if (TS_execute(curitem + curitem->operator.left, checkval, calcnot, chkcond))
if (TS_execute(curitem + curitem->qoperator.left, checkval, calcnot, chkcond))
return true;
else
return TS_execute(curitem + 1, checkval, calcnot, chkcond);
default:
elog(ERROR, "unrecognized operator: %d", curitem->operator.oper);
elog(ERROR, "unrecognized operator: %d", curitem->qoperator.oper);
}
/* not reachable, but keep compiler quiet */

View File

@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.506 2009/07/12 17:12:34 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.507 2009/07/16 06:33:44 petere Exp $
*
*--------------------------------------------------------------------
*/
@@ -5331,7 +5331,7 @@ flatten_set_variable_args(const char *name, List *args)
{
Node *arg = (Node *) lfirst(l);
char *val;
TypeName *typename = NULL;
TypeName *typeName = NULL;
A_Const *con;
if (l != list_head(args))
@@ -5342,7 +5342,7 @@ flatten_set_variable_args(const char *name, List *args)
TypeCast *tc = (TypeCast *) arg;
arg = tc->arg;
typename = tc->typename;
typeName = tc->typeName;
}
if (!IsA(arg, A_Const))
@@ -5360,7 +5360,7 @@ flatten_set_variable_args(const char *name, List *args)
break;
case T_String:
val = strVal(&con->val);
if (typename != NULL)
if (typeName != NULL)
{
/*
* Must be a ConstInterval argument for TIME ZONE. Coerce
@@ -5372,7 +5372,7 @@ flatten_set_variable_args(const char *name, List *args)
Datum interval;
char *intervalout;
typoid = typenameTypeId(NULL, typename, &typmod);
typoid = typenameTypeId(NULL, typeName, &typmod);
Assert(typoid == INTERVALOID);
interval =

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.66 2009/01/01 17:23:53 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.67 2009/07/16 06:33:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -193,7 +193,7 @@ MemoryContextDelete(MemoryContext context)
}
}
}
(*context->methods->delete) (context);
(*context->methods->delete_context) (context);
pfree(context);
}