@@ -53,7 +53,6 @@ static void GetForeignRelSize(PlannerInfo *root,
5353 * min & max will call GetForeignRelSize & GetForeignPaths multiple times,
5454 * we should open & close db multiple times.
5555 */
56- printf ("\n-----------------%s open----------------------\n" , __func__ );
5756 ptr = OpenRequest (foreignTableId , ptr );
5857
5958 /* TODO better estimation */
@@ -190,26 +189,28 @@ static void GetKeyRangeQual(Plan *plan,
190189 continue ;
191190 }
192191
193- HeapTuple opertup = SearchSysCache1 (OPEROID , ObjectIdGetDatum (op -> opno ));
192+ HeapTuple opertup = SearchSysCache1 (OPEROID ,
193+ ObjectIdGetDatum (op -> opno ));
194194 if (!HeapTupleIsValid (opertup )) {
195- ereport (ERROR , (errmsg ("cache lookup failed for operator %u" , op -> opno )));
195+ ereport (ERROR , (errmsg ("cache lookup failed for operator %u" ,
196+ op -> opno )));
196197 }
197198 Form_pg_operator operform = (Form_pg_operator ) GETSTRUCT (opertup );
198199 char * oprname = NameStr (operform -> oprname );
199200 if (strncmp (oprname , ">=" , NAMEDATALEN ) == 0 ) {
200201 startFlag = true;
201202 Const * constNode = ((Const * ) right );
202203 Datum datum = constNode -> constvalue ;
203- TypeCacheEntry * typeEntry = lookup_type_cache (constNode -> consttype , 0 );
204- datum = ShortVarlena (datum , typeEntry -> typlen , typeEntry -> typstorage );
204+ TypeCacheEntry * type = lookup_type_cache (constNode -> consttype , 0 );
205+ datum = ShortVarlena (datum , type -> typlen , type -> typstorage );
205206 SerializeAttribute (tupleDescriptor , varattno - 1 , datum , startInfo );
206207 ReleaseSysCache (opertup );
207208 }else if (strncmp (oprname , "<=" , NAMEDATALEN ) == 0 ) {
208209 limitFlag = true;
209210 Const * constNode = ((Const * ) right );
210211 Datum datum = constNode -> constvalue ;
211- TypeCacheEntry * typeEntry = lookup_type_cache (constNode -> consttype , 0 );
212- datum = ShortVarlena (datum , typeEntry -> typlen , typeEntry -> typstorage );
212+ TypeCacheEntry * type = lookup_type_cache (constNode -> consttype , 0 );
213+ datum = ShortVarlena (datum , type -> typlen , type -> typstorage );
213214 SerializeAttribute (tupleDescriptor , varattno - 1 , datum , limitInfo );
214215 ReleaseSysCache (opertup );
215216 }else {
@@ -258,7 +259,8 @@ static void GetKeyBasedQual(Node *node,
258259 /* get the name of the operator according to PG_OPERATOR OID */
259260 HeapTuple opertup = SearchSysCache1 (OPEROID , ObjectIdGetDatum (op -> opno ));
260261 if (!HeapTupleIsValid (opertup )) {
261- ereport (ERROR , (errmsg ("cache lookup failed for operator %u" , op -> opno )));
262+ ereport (ERROR , (errmsg ("cache lookup failed for operator %u" ,
263+ op -> opno )));
262264 }
263265 Form_pg_operator operform = (Form_pg_operator ) GETSTRUCT (opertup );
264266 char * oprname = NameStr (operform -> oprname );
@@ -324,13 +326,9 @@ static void BeginForeignScan(ForeignScanState *scanState, int executorFlags) {
324326 return ;
325327 }
326328
327- //printf("\n-----------------Plan Type: %d----------------------\n", scanState->ss.ps.plan->type);
328-
329329 ListCell * lc ;
330330 foreach (lc , scanState -> ss .ps .plan -> qual ) {
331331 Expr * state = lfirst (lc );
332- //printf("\n-----------------Qual Type: %d----------------------\n", state->type);
333-
334332 GetKeyBasedQual ((Node * ) state ,
335333 scanState -> ss .ss_currentRelation -> rd_att ,
336334 readState );
@@ -346,18 +344,13 @@ static void BeginForeignScan(ForeignScanState *scanState, int executorFlags) {
346344 scanState -> ss .ss_currentRelation -> rd_att ,
347345 readState );
348346 #endif
349- //if(readState->isRangeQueryUsed) {
350-
351- //}else
352- //{
353- Oid relationId = RelationGetRelid (scanState -> ss .ss_currentRelation );
354- GetIterRequest (relationId , ptr );
355- //}
347+ Oid relationId = RelationGetRelid (scanState -> ss .ss_currentRelation );
348+ GetIterRequest (relationId , ptr );
356349 }
357350}
358351
359352static void DeserializeTuple (StringInfo key ,
360- StringInfo value ,
353+ StringInfo val ,
361354 TupleTableSlot * tupleSlot ) {
362355
363356 Datum * values = tupleSlot -> tts_values ;
@@ -376,7 +369,7 @@ static void DeserializeTuple(StringInfo key,
376369 enlargeStringInfo (buffer , bufLen );
377370 buffer -> len = bufLen ;
378371
379- memcpy (buffer -> data , value -> data , bufLen );
372+ memcpy (buffer -> data , val -> data , bufLen );
380373
381374 for (uint32 index = 1 ; index < count ; index ++ ) {
382375
@@ -407,7 +400,7 @@ static void DeserializeTuple(StringInfo key,
407400 if (index == 0 ) {
408401 offset = bufLen ;
409402 }
410- current = value -> data + offset ;
403+ current = val -> data + offset ;
411404 }
412405}
413406
@@ -455,20 +448,18 @@ static TupleTableSlot *IterateForeignScan(ForeignScanState *scanState) {
455448 found = GetRequest (relationId , ptr , k , kLen , & v , & vLen );
456449 readState -> done = true;
457450 }
458- /*} else if (readState->isRangeQueryUsed)
459- {*/
460-
451+ /*} else if (readState->isRangeQueryUsed) {*/
461452 } else {
462453 found = NextRequest (relationId , ptr , & k , & kLen , & v , & vLen );
463454 }
464455
465456 if (found ) {
466457 StringInfo key = makeStringInfo ();
467458 appendBinaryStringInfo (key , k , kLen );
468- StringInfo value = makeStringInfo ();
469- appendBinaryStringInfo (value , v , vLen );
459+ StringInfo val = makeStringInfo ();
460+ appendBinaryStringInfo (val , v , vLen );
470461
471- DeserializeTuple (key , value , tupleSlot );
462+ DeserializeTuple (key , val , tupleSlot );
472463
473464 ExecStoreVirtualTuple (tupleSlot );
474465 }
@@ -665,7 +656,7 @@ static void BeginForeignModify(ModifyTableState *modifyTableState,
665656}
666657
667658static void SerializeTuple (StringInfo key ,
668- StringInfo value ,
659+ StringInfo val ,
669660 TupleTableSlot * tupleSlot ) {
670661
671662 TupleDesc tupleDescriptor = tupleSlot -> tts_tupleDescriptor ;
@@ -679,7 +670,7 @@ static void SerializeTuple(StringInfo key,
679670 nulls -> len = nullsLen ;
680671 memset (nulls -> data , 0 , nullsLen );
681672
682- value -> len += nullsLen ;
673+ val -> len += nullsLen ;
683674
684675 for (uint32 index = 0 ; index < count ; index ++ ) {
685676
@@ -695,10 +686,10 @@ static void SerializeTuple(StringInfo key,
695686 }
696687
697688 Datum datum = tupleSlot -> tts_values [index ];
698- SerializeAttribute (tupleDescriptor , index , datum , index == 0 ? key : value );
689+ SerializeAttribute (tupleDescriptor , index , datum , index == 0 ? key : val );
699690 }
700691
701- memcpy (value -> data , nulls -> data , nullsLen );
692+ memcpy (val -> data , nulls -> data , nullsLen );
702693}
703694
704695static TupleTableSlot * ExecForeignInsert (EState * executorState ,
@@ -744,13 +735,13 @@ static TupleTableSlot *ExecForeignInsert(EState *executorState,
744735 slot_getallattrs (tupleSlot );
745736
746737 StringInfo key = makeStringInfo ();
747- StringInfo value = makeStringInfo ();
738+ StringInfo val = makeStringInfo ();
748739
749- SerializeTuple (key , value , tupleSlot );
740+ SerializeTuple (key , val , tupleSlot );
750741
751742 Relation relation = relationInfo -> ri_RelationDesc ;
752743 Oid foreignTableId = RelationGetRelid (relation );
753- PutRequest (foreignTableId , ptr , key -> data , key -> len , value -> data , value -> len );
744+ PutRequest (foreignTableId , ptr , key -> data , key -> len , val -> data , val -> len );
754745
755746 return tupleSlot ;
756747}
@@ -798,13 +789,13 @@ static TupleTableSlot *ExecForeignUpdate(EState *executorState,
798789 slot_getallattrs (tupleSlot );
799790
800791 StringInfo key = makeStringInfo ();
801- StringInfo value = makeStringInfo ();
792+ StringInfo val = makeStringInfo ();
802793
803- SerializeTuple (key , value , tupleSlot );
794+ SerializeTuple (key , val , tupleSlot );
804795
805796 Relation relation = relationInfo -> ri_RelationDesc ;
806797 Oid foreignTableId = RelationGetRelid (relation );
807- PutRequest (foreignTableId , ptr , key -> data , key -> len , value -> data , value -> len );
798+ PutRequest (foreignTableId , ptr , key -> data , key -> len , val -> data , val -> len );
808799
809800 return tupleSlot ;
810801}
@@ -851,9 +842,9 @@ static TupleTableSlot *ExecForeignDelete(EState *executorState,
851842 slot_getallattrs (planSlot );
852843
853844 StringInfo key = makeStringInfo ();
854- StringInfo value = makeStringInfo ();
845+ StringInfo val = makeStringInfo ();
855846
856- SerializeTuple (key , value , planSlot );
847+ SerializeTuple (key , val , planSlot );
857848
858849 Relation relation = relationInfo -> ri_RelationDesc ;
859850 Oid foreignTableId = RelationGetRelid (relation );
@@ -862,7 +853,8 @@ static TupleTableSlot *ExecForeignDelete(EState *executorState,
862853 return tupleSlot ;
863854}
864855
865- static void EndForeignModify (EState * executorState , ResultRelInfo * relationInfo ) {
856+ static void EndForeignModify (EState * executorState ,
857+ ResultRelInfo * relationInfo ) {
866858 printf ("\n-----------------%s----------------------\n" , __func__ );
867859 /*
868860 * End the table update and release resources. It is normally not
0 commit comments