@@ -487,84 +487,3 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
487487
488488 return true;
489489}
490-
491- /* ----------------------------------------------------------------
492- * printtup json
493- * ----------------------------------------------------------------
494- */
495-
496- StringInfoData json_result ;
497-
498- #ifdef EMSCRIPTEN
499- EM_JS (void , dispatch_result , (char * res ), {
500- // Dispatch the result to JS land
501- var query_result = UTF8ToString (res );
502- var event = new Module .Event ("result" , {
503- detail : { result : query_result },
504- });
505- Module .eventTarget .dispatchEvent (event );
506- });
507- #endif
508-
509- void
510- debugtup_json_startup (DestReceiver * self , int operation , TupleDesc typeinfo )
511- {
512- MemoryContext oldcxt = MemoryContextSwitchTo (TopMemoryContext );
513-
514- if (!json_result .data )
515- initStringInfo (& json_result );
516- else
517- resetStringInfo (& json_result );
518-
519- appendStringInfoChar (& json_result , '[' );
520-
521- MemoryContextSwitchTo (oldcxt );
522- }
523-
524- bool
525- debugtup_json (TupleTableSlot * slot , DestReceiver * self )
526- {
527- TupleDesc tupdesc = slot -> tts_tupleDescriptor ;
528- int i ;
529- bool needsep = false;
530-
531- /* without tuples json_result contain only '[', so len is 1 */
532- if (json_result .len > 1 )
533- appendStringInfoChar (& json_result , ',' );
534-
535- appendStringInfoChar (& json_result , '{' );
536-
537- for (i = 0 ; i < tupdesc -> natts ; i ++ )
538- {
539- Datum val ;
540- bool isnull ;
541- char * attname ;
542- Form_pg_attribute att = TupleDescAttr (tupdesc , i );
543-
544- if (att -> attisdropped )
545- continue ;
546-
547- if (needsep )
548- appendStringInfoString (& json_result , "," );
549- needsep = true;
550-
551- attname = NameStr (att -> attname );
552- escape_json (& json_result , attname );
553- appendStringInfoChar (& json_result , ':' );
554-
555- val = slot_getattr (slot , i + 1 , & isnull );
556- add_json (val , isnull , & json_result , att -> atttypid , false);
557- }
558-
559- appendStringInfoChar (& json_result , '}' );
560-
561- return true;
562- }
563-
564- void
565- debugtup_json_shutdown (DestReceiver * self )
566- {
567- appendStringInfoChar (& json_result , ']' );
568- appendStringInfoChar (& json_result , '\0' );
569- dispatch_result (json_result .data );
570- }
0 commit comments