Skip to content

Commit

Permalink
Fix formatting to comply with pgindent
Browse files Browse the repository at this point in the history
This PR fixes all the formatting to be inline with the latest version of
pgindent. Since pgindent does not like variables named `type`, those
have been appropriately renamed.
  • Loading branch information
cevian committed Jul 11, 2018
1 parent 4f2f1a6 commit 2ec065b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
44 changes: 22 additions & 22 deletions src/agg_bookend.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TS_FUNCTION_INFO_V1(bookend_deserializefunc);
/* A PolyDatum represents a polymorphic datum */
typedef struct PolyDatum
{
Oid type;
Oid type_oid;
bool is_null;
Datum datum;
} PolyDatum;
Expand All @@ -37,7 +37,7 @@ typedef struct PolyDatum
/* PolyDatumIOState is internal state used by polydatum_serialize and polydatum_deserialize */
typedef struct PolyDatumIOState
{
Oid type;
Oid type_oid;
FmgrInfo proc;
Oid typeioparam;
} PolyDatumIOState;
Expand All @@ -47,7 +47,7 @@ polydatum_from_arg(int argno, FunctionCallInfo fcinfo)
{
PolyDatum value;

value.type = get_fn_expr_argtype(fcinfo->flinfo, argno);
value.type_oid = get_fn_expr_argtype(fcinfo->flinfo, argno);
value.is_null = PG_ARGISNULL(argno);
if (!value.is_null)
{
Expand All @@ -66,7 +66,7 @@ polydatum_serialize(PolyDatum *pd, StringInfo buf, PolyDatumIOState *state, Func
{
bytea *outputbytes;

pq_sendint(buf, pd->type, sizeof(Oid));
pq_sendint(buf, pd->type_oid, sizeof(Oid));

if (pd->is_null)
{
Expand All @@ -75,17 +75,17 @@ polydatum_serialize(PolyDatum *pd, StringInfo buf, PolyDatumIOState *state, Func
return;
}

if (state->type != pd->type)
if (state->type_oid != pd->type_oid)
{
Oid func;
bool is_varlena;

getTypeBinaryOutputInfo(pd->type,
getTypeBinaryOutputInfo(pd->type_oid,
&func,
&is_varlena);
fmgr_info_cxt(func, &state->proc,
fcinfo->flinfo->fn_mcxt);
state->type = pd->type;
state->type_oid = pd->type_oid;
}
outputbytes = SendFunctionCall(&state->proc, pd->datum);
pq_sendint(buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
Expand All @@ -110,7 +110,7 @@ polydatum_deserialize(PolyDatum *result, StringInfo buf, PolyDatumIOState *state
result = palloc(sizeof(PolyDatum));
}

result->type = pq_getmsgint(buf, sizeof(Oid));
result->type_oid = pq_getmsgint(buf, sizeof(Oid));

/* Following is copied/adapted from record_recv in core postgres */

Expand Down Expand Up @@ -151,16 +151,16 @@ polydatum_deserialize(PolyDatum *result, StringInfo buf, PolyDatumIOState *state
}

/* Now call the column's receiveproc */
if (state->type != result->type)
if (state->type_oid != result->type_oid)
{
Oid func;

getTypeBinaryInputInfo(result->type,
getTypeBinaryInputInfo(result->type_oid,
&func,
&state->typeioparam);
fmgr_info_cxt(func, &state->proc,
fcinfo->flinfo->fn_mcxt);
state->type = result->type;
state->type_oid = result->type_oid;
}

result->datum = ReceiveFunctionCall(&state->proc,
Expand Down Expand Up @@ -197,24 +197,24 @@ typedef struct InternalCmpAggStoreIOState

typedef struct TypeInfoCache
{
Oid type;
Oid type_oid;
int16 typelen;
bool typebyval;
} TypeInfoCache;

inline static void
typeinfocache_init(TypeInfoCache *tic)
{
tic->type = InvalidOid;
tic->type_oid = InvalidOid;
}

inline static void
typeinfocache_polydatumcopy(TypeInfoCache *tic, PolyDatum input, PolyDatum *output)
{
if (tic->type != input.type)
if (tic->type_oid != input.type_oid)
{
tic->type = input.type;
get_typlenbyval(tic->type, &tic->typelen, &tic->typebyval);
tic->type_oid = input.type_oid;
get_typlenbyval(tic->type_oid, &tic->typelen, &tic->typebyval);
}
*output = input;
if (!input.is_null)
Expand All @@ -239,22 +239,22 @@ cmpfunccache_init(CmpFuncCache *cache)
inline static bool
cmpfunccache_cmp(CmpFuncCache *cache, FunctionCallInfo fcinfo, char *opname, PolyDatum left, PolyDatum right)
{
Assert(left.type == right.type);
Assert(left.type_oid == right.type_oid);
Assert(opname[1] == '\0');

if (cache->cmp_type != left.type || cache->op != opname[0])
if (cache->cmp_type != left.type_oid || cache->op != opname[0])
{
Oid cmp_op,
cmp_regproc;

if (!OidIsValid(left.type))
if (!OidIsValid(left.type_oid))
elog(ERROR, "could not determine the type of the comparison_element");
cmp_op = OpernameGetOprid(list_make1(makeString(opname)), left.type, left.type);
cmp_op = OpernameGetOprid(list_make1(makeString(opname)), left.type_oid, left.type_oid);
if (!OidIsValid(cmp_op))
elog(ERROR, "could not find a %s operator for type %d", opname, left.type);
elog(ERROR, "could not find a %s operator for type %d", opname, left.type_oid);
cmp_regproc = get_opcode(cmp_op);
if (!OidIsValid(cmp_regproc))
elog(ERROR, "could not find the procedure for the %s operator for type %d", opname, left.type);
elog(ERROR, "could not find the procedure for the %s operator for type %d", opname, left.type_oid);
fmgr_info_cxt(cmp_regproc, &cache->proc,
fcinfo->flinfo->fn_mcxt);
}
Expand Down
6 changes: 3 additions & 3 deletions src/sort_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ sort_transform_ec(PlannerInfo *root, EquivalenceClass *orig)
if (transformed_expr != ec_mem->em_expr)
{
EquivalenceMember *em;
Oid type = exprType((Node *) transformed_expr);
Oid type_oid = exprType((Node *) transformed_expr);
List *opfamilies = list_copy(orig->ec_opfamilies);

/*
Expand All @@ -293,7 +293,7 @@ sort_transform_ec(PlannerInfo *root, EquivalenceClass *orig)
*/
EquivalenceClass *exist =
get_eclass_for_sort_expr(root, transformed_expr, ec_mem->em_nullable_relids,
opfamilies, type,
opfamilies, type_oid,
orig->ec_collation, orig->ec_sortref,
ec_mem->em_relids, false);

Expand All @@ -309,7 +309,7 @@ sort_transform_ec(PlannerInfo *root, EquivalenceClass *orig)
em->em_nullable_relids = bms_copy(ec_mem->em_nullable_relids);
em->em_is_const = ec_mem->em_is_const;
em->em_is_child = ec_mem->em_is_child;
em->em_datatype = type;
em->em_datatype = type_oid;

if (newec == NULL)
{
Expand Down
14 changes: 8 additions & 6 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ time_to_internal(PG_FUNCTION_ARGS)
int64
time_value_to_internal(Datum time_val, Oid type_oid, bool failure_ok)
{
Datum res, tz;
Datum res,
tz;

switch(type_oid)
switch (type_oid)
{
case INT8OID:
return DatumGetInt64(time_val);
Expand All @@ -178,10 +179,11 @@ time_value_to_internal(Datum time_val, Oid type_oid, bool failure_ok)
case INT2OID:
return (int64) DatumGetInt16(time_val);
case TIMESTAMPOID:

/*
* for timestamps, ignore timezones, make believe the timestamp is at
* UTC
*/
* for timestamps, ignore timezones, make believe the timestamp is
* at UTC
*/
res = DirectFunctionCall1(pg_timestamp_to_unix_microseconds, time_val);

return DatumGetInt64(res);
Expand Down Expand Up @@ -425,7 +427,7 @@ date_trunc_interval_period_approx(text *units)
case DTK_YEAR:
return 1 * DAYS_PER_YEAR * USECS_PER_DAY;
case DTK_QUARTER:
return DAYS_PER_QUARTER * USECS_PER_DAY;
return DAYS_PER_QUARTER * USECS_PER_DAY;
case DTK_MONTH:
return DAYS_PER_MONTH * USECS_PER_DAY;
case DTK_DAY:
Expand Down

0 comments on commit 2ec065b

Please sign in to comment.