* ExecBuildSlotValueDescription -- construct a string representing a tuple * * This is intentionally very similar to BuildIndexValueDescription, but * unlike that function, we truncate long field values (to at most maxfieldlen * bytes). That seems necessary here since heap field values could be very * long, whereas index entries typically aren't so wide. * * Also, unlike the case with inde
| 3363 | * columns they are. |
| 3364 | */ |
| 3365 | static char * |
| 3366 | ExecBuildSlotValueDescription(Oid reloid, |
| 3367 | TupleTableSlot *slot, |
| 3368 | TupleDesc tupdesc, |
| 3369 | Bitmapset *modifiedCols, |
| 3370 | int maxfieldlen) |
| 3371 | { |
| 3372 | StringInfoData buf; |
| 3373 | StringInfoData collist; |
| 3374 | bool write_comma = false; |
| 3375 | bool write_comma_collist = false; |
| 3376 | int i; |
| 3377 | AclResult aclresult; |
| 3378 | bool table_perm = false; |
| 3379 | bool any_perm = false; |
| 3380 | |
| 3381 | /* |
| 3382 | * Check if RLS is enabled and should be active for the relation; if so, |
| 3383 | * then don't return anything. Otherwise, go through normal permission |
| 3384 | * checks. |
| 3385 | */ |
| 3386 | if (check_enable_rls(reloid, InvalidOid, true) == RLS_ENABLED) |
| 3387 | return NULL; |
| 3388 | |
| 3389 | initStringInfo(&buf); |
| 3390 | |
| 3391 | appendStringInfoChar(&buf, '('); |
| 3392 | |
| 3393 | /* |
| 3394 | * Check if the user has permissions to see the row. Table-level SELECT |
| 3395 | * allows access to all columns. If the user does not have table-level |
| 3396 | * SELECT then we check each column and include those the user has SELECT |
| 3397 | * rights on. Additionally, we always include columns the user provided |
| 3398 | * data for. |
| 3399 | */ |
| 3400 | aclresult = pg_class_aclcheck(reloid, GetUserId(), ACL_SELECT); |
| 3401 | if (aclresult != ACLCHECK_OK) |
| 3402 | { |
| 3403 | /* Set up the buffer for the column list */ |
| 3404 | initStringInfo(&collist); |
| 3405 | appendStringInfoChar(&collist, '('); |
| 3406 | } |
| 3407 | else |
| 3408 | table_perm = any_perm = true; |
| 3409 | |
| 3410 | /* Make sure the tuple is fully deconstructed */ |
| 3411 | slot_getallattrs(slot); |
| 3412 | |
| 3413 | for (i = 0; i < tupdesc->natts; i++) |
| 3414 | { |
| 3415 | bool column_perm = false; |
| 3416 | char *val; |
| 3417 | int vallen; |
| 3418 | Form_pg_attribute att = TupleDescAttr(tupdesc, i); |
| 3419 | |
| 3420 | /* ignore dropped columns */ |
| 3421 | if (att->attisdropped) |
| 3422 | continue; |
no test coverage detected