@@ -342,60 +342,59 @@ static bool
342
342
build_index_scan_key (ScanKey skey , Relation rel , Relation idxrel , TupleData * tup )
343
343
{
344
344
int attoff ;
345
- Datum indclassDatum ;
346
- Datum indkeyDatum ;
347
345
bool isnull ;
346
+ Datum indclassDatum ;
348
347
oidvector * opclass ;
349
- int2vector * indkey ;
348
+ int2vector * indkey = & idxrel -> rd_index -> indkey ;
350
349
bool hasnulls = false;
351
350
351
+ Assert (RelationGetReplicaIndex (rel ) == RelationGetRelid (idxrel ));
352
+
352
353
indclassDatum = SysCacheGetAttr (INDEXRELID , idxrel -> rd_indextuple ,
353
354
Anum_pg_index_indclass , & isnull );
354
355
Assert (!isnull );
355
356
opclass = (oidvector * ) DatumGetPointer (indclassDatum );
356
357
357
- indkeyDatum = SysCacheGetAttr (INDEXRELID , idxrel -> rd_indextuple ,
358
- Anum_pg_index_indkey , & isnull );
359
- Assert (!isnull );
360
- indkey = (int2vector * ) DatumGetPointer (indkeyDatum );
361
-
362
-
358
+ /* Build scankey for every attribute in the index. */
363
359
for (attoff = 0 ; attoff < IndexRelationGetNumberOfKeyAttributes (idxrel ); attoff ++ )
364
360
{
365
361
Oid operator ;
366
362
Oid opfamily ;
367
363
RegProcedure regop ;
368
364
int pkattno = attoff + 1 ;
369
365
int mainattno = indkey -> values [attoff ];
370
- Oid atttype = attnumTypeId (rel , mainattno );
371
366
Oid optype = get_opclass_input_type (opclass -> values [attoff ]);
372
367
368
+ /*
369
+ * Load the operator info. We need this to get the equality operator
370
+ * function for the scan key.
371
+ */
373
372
opfamily = get_opclass_family (opclass -> values [attoff ]);
374
373
375
374
operator = get_opfamily_member (opfamily , optype ,
376
375
optype ,
377
376
BTEqualStrategyNumber );
378
-
379
377
if (!OidIsValid (operator ))
380
- mtm_log (ERROR ,
381
- "could not lookup equality operator for type %u, optype %u in opfamily %u" ,
382
- atttype , optype , opfamily );
378
+ elog (ERROR , "missing operator %d(%u,%u) in opfamily %u" ,
379
+ BTEqualStrategyNumber , optype , optype , opfamily );
383
380
384
381
regop = get_opcode (operator );
385
382
386
- /* FIXME: convert type? */
383
+ /* Initialize the scankey. */
387
384
ScanKeyInit (& skey [attoff ],
388
385
pkattno ,
389
386
BTEqualStrategyNumber ,
390
387
regop ,
391
388
tup -> values [mainattno - 1 ]);
392
389
390
+ /* Check for null value. */
393
391
if (tup -> isnull [mainattno - 1 ])
394
392
{
395
393
hasnulls = true;
396
394
skey [attoff ].sk_flags |= SK_ISNULL ;
397
395
}
398
396
}
397
+
399
398
return hasnulls ;
400
399
}
401
400
@@ -742,7 +741,7 @@ read_tuple_parts(StringInfo s, Relation rel, TupleData *tup)
742
741
case 'u' : /* unchanged column */
743
742
tup -> isnull [i ] = true;
744
743
tup -> changed [i ] = false;
745
- tup -> values [i ] = 0xdeadbeef ; /* make bad usage more obvious */
744
+ tup -> values [i ] = NULL ;
746
745
break ;
747
746
748
747
case 'b' : /* binary format */
@@ -1240,10 +1239,8 @@ process_remote_update(StringInfo s, Relation rel)
1240
1239
action );
1241
1240
1242
1241
estate = create_rel_estate (rel );
1243
- oldslot = ExecInitExtraTupleSlot (estate , NULL );
1244
- ExecSetSlotDescriptor (oldslot , tupDesc );
1245
- newslot = ExecInitExtraTupleSlot (estate , NULL );
1246
- ExecSetSlotDescriptor (newslot , tupDesc );
1242
+ oldslot = ExecInitExtraTupleSlot (estate , tupDesc );
1243
+ newslot = ExecInitExtraTupleSlot (estate , tupDesc );
1247
1244
1248
1245
if (action == 'K' )
1249
1246
{
0 commit comments