1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent.

By project convention, these names should include "P" when dealing with a
pointer type; that is, if the result of a GETARG macro is of type FOO *,
it should be called PG_GETARG_FOO_P not just PG_GETARG_FOO.  Some newer
types such as JSONB and ranges had not followed the convention, and a
number of contrib modules hadn't gotten that memo either.  Rename the
offending macros to improve consistency.

In passing, fix a few places that thought PG_DETOAST_DATUM() returns
a Datum; it does not, it returns "struct varlena *".  Applying
DatumGetPointer to that happens not to cause any bad effects today,
but it's formally wrong.  Also, adjust an ltree macro that was designed
without any thought for what pgindent would do with it.

This is all cosmetic and shouldn't have any impact on generated code.

Mark Dilger, some further tweaks by me

Discussion: https://postgr.es/m/EA5676F4-766F-4F38-8348-ECC7DB427C6A@gmail.com
This commit is contained in:
Tom Lane
2017-09-18 15:21:23 -04:00
parent 3e1683d37e
commit 4bd1994650
38 changed files with 471 additions and 461 deletions

View File

@ -21,7 +21,7 @@
Datum
jsonb_exists(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
Jsonb *jb = PG_GETARG_JSONB_P(0);
text *key = PG_GETARG_TEXT_PP(1);
JsonbValue kval;
JsonbValue *v = NULL;
@ -46,7 +46,7 @@ jsonb_exists(PG_FUNCTION_ARGS)
Datum
jsonb_exists_any(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
Jsonb *jb = PG_GETARG_JSONB_P(0);
ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int i;
Datum *key_datums;
@ -79,7 +79,7 @@ jsonb_exists_any(PG_FUNCTION_ARGS)
Datum
jsonb_exists_all(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
Jsonb *jb = PG_GETARG_JSONB_P(0);
ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int i;
Datum *key_datums;
@ -112,8 +112,8 @@ jsonb_exists_all(PG_FUNCTION_ARGS)
Datum
jsonb_contains(PG_FUNCTION_ARGS)
{
Jsonb *val = PG_GETARG_JSONB(0);
Jsonb *tmpl = PG_GETARG_JSONB(1);
Jsonb *val = PG_GETARG_JSONB_P(0);
Jsonb *tmpl = PG_GETARG_JSONB_P(1);
JsonbIterator *it1,
*it2;
@ -131,8 +131,8 @@ Datum
jsonb_contained(PG_FUNCTION_ARGS)
{
/* Commutator of "contains" */
Jsonb *tmpl = PG_GETARG_JSONB(0);
Jsonb *val = PG_GETARG_JSONB(1);
Jsonb *tmpl = PG_GETARG_JSONB_P(0);
Jsonb *val = PG_GETARG_JSONB_P(1);
JsonbIterator *it1,
*it2;
@ -149,8 +149,8 @@ jsonb_contained(PG_FUNCTION_ARGS)
Datum
jsonb_ne(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) != 0);
@ -166,8 +166,8 @@ jsonb_ne(PG_FUNCTION_ARGS)
Datum
jsonb_lt(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) < 0);
@ -180,8 +180,8 @@ jsonb_lt(PG_FUNCTION_ARGS)
Datum
jsonb_gt(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) > 0);
@ -194,8 +194,8 @@ jsonb_gt(PG_FUNCTION_ARGS)
Datum
jsonb_le(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) <= 0);
@ -208,8 +208,8 @@ jsonb_le(PG_FUNCTION_ARGS)
Datum
jsonb_ge(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) >= 0);
@ -222,8 +222,8 @@ jsonb_ge(PG_FUNCTION_ARGS)
Datum
jsonb_eq(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) == 0);
@ -236,8 +236,8 @@ jsonb_eq(PG_FUNCTION_ARGS)
Datum
jsonb_cmp(PG_FUNCTION_ARGS)
{
Jsonb *jba = PG_GETARG_JSONB(0);
Jsonb *jbb = PG_GETARG_JSONB(1);
Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB_P(1);
int res;
res = compareJsonbContainers(&jba->root, &jbb->root);
@ -253,7 +253,7 @@ jsonb_cmp(PG_FUNCTION_ARGS)
Datum
jsonb_hash(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
Jsonb *jb = PG_GETARG_JSONB_P(0);
JsonbIterator *it;
JsonbValue v;
JsonbIteratorToken r;
@ -295,7 +295,7 @@ jsonb_hash(PG_FUNCTION_ARGS)
Datum
jsonb_hash_extended(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
Jsonb *jb = PG_GETARG_JSONB_P(0);
uint64 seed = PG_GETARG_INT64(1);
JsonbIterator *it;
JsonbValue v;
@ -311,7 +311,7 @@ jsonb_hash_extended(PG_FUNCTION_ARGS)
{
switch (r)
{
/* Rotation is left to JsonbHashScalarValueExtended() */
/* Rotation is left to JsonbHashScalarValueExtended() */
case WJB_BEGIN_ARRAY:
hash ^= ((uint64) JB_FARRAY) << 32 | JB_FARRAY;
break;