Skip to content

Commit ee05ac9

Browse files
committed
Remove DestDebugJson output
1 parent 5239ee4 commit ee05ac9

File tree

5 files changed

+7
-108
lines changed

5 files changed

+7
-108
lines changed

src/backend/access/common/printtup.c

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
}

src/backend/tcop/dest.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static const DestReceiver debugtupDR = {
7777
DestDebug
7878
};
7979

80-
static const DestReceiver debugtup_jsonDR = {
81-
debugtup_json, debugtup_json_startup, debugtup_json_shutdown, donothingCleanup,
82-
DestDebugJson
83-
};
84-
8580
static const DestReceiver printsimpleDR = {
8681
printsimple, printsimple_startup, donothingCleanup, donothingCleanup,
8782
DestRemoteSimple
@@ -137,9 +132,6 @@ CreateDestReceiver(CommandDest dest)
137132
case DestDebug:
138133
return unconstify(DestReceiver *, &debugtupDR);
139134

140-
case DestDebugJson:
141-
return unconstify(DestReceiver *, &debugtup_jsonDR);
142-
143135
case DestSPI:
144136
return unconstify(DestReceiver *, &spi_printtupDR);
145137

@@ -208,7 +200,6 @@ EndCommand(const QueryCompletion *qc, CommandDest dest, bool force_undecorated_o
208200

209201
case DestNone:
210202
case DestDebug:
211-
case DestDebugJson:
212203
case DestSPI:
213204
case DestTuplestore:
214205
case DestIntoRel:
@@ -254,7 +245,6 @@ NullCommand(CommandDest dest)
254245

255246
case DestNone:
256247
case DestDebug:
257-
case DestDebugJson:
258248
case DestSPI:
259249
case DestTuplestore:
260250
case DestIntoRel:
@@ -298,7 +288,6 @@ ReadyForQuery(CommandDest dest)
298288

299289
case DestNone:
300290
case DestDebug:
301-
case DestDebugJson:
302291
case DestSPI:
303292
case DestTuplestore:
304293
case DestIntoRel:

src/backend/tcop/postgres.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@
9393
const char *debug_query_string; /* client-supplied query string */
9494

9595
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
96-
#ifdef EMSCRIPTEN
97-
CommandDest whereToSendOutput = DestRemote;
98-
#else
9996
CommandDest whereToSendOutput = DestDebug;
100-
#endif
10197

10298
/* flag for logging end of session */
10399
bool Log_disconnections = false;
@@ -525,14 +521,14 @@ ReadCommand(StringInfo inBuf)
525521
{
526522
int result;
527523

524+
if (whereToSendOutput == DestRemote)
528525
#ifdef EMSCRIPTEN
529-
result = EmscriptenBackend(inBuf);
526+
result = EmscriptenBackend(inBuf);
530527
#else
531-
if (whereToSendOutput == DestRemote)
532528
result = SocketBackend(inBuf);
529+
#endif
533530
else
534531
result = InteractiveBackend(inBuf);
535-
#endif
536532
return result;
537533
}
538534

@@ -3748,6 +3744,10 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
37483744
{
37493745
argv++;
37503746
argc--;
3747+
#ifdef EMSCRIPTEN
3748+
/* We want to send output to the client using the wire protocol */
3749+
whereToSendOutput = DestRemote;
3750+
#endif
37513751
}
37523752
}
37533753
else

src/include/access/printtup.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,4 @@ extern void spi_dest_startup(DestReceiver *self, int operation,
3232
TupleDesc typeinfo);
3333
extern bool spi_printtup(TupleTableSlot *slot, DestReceiver *self);
3434

35-
/* print tuples */
36-
37-
extern bool debugtup_json(TupleTableSlot *slot, DestReceiver *self);
38-
39-
extern void debugtup_json_startup(DestReceiver *self, int operation, TupleDesc typeinfo);
40-
41-
extern void debugtup_json_shutdown(DestReceiver *self);
42-
4335
#endif /* PRINTTUP_H */

src/include/tcop/dest.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ typedef enum
8888
{
8989
DestNone, /* results are discarded */
9090
DestDebug, /* results go to debugging output */
91-
DestDebugJson, /* results go to debugging output as jsons */
9291
DestRemote, /* results sent to frontend process */
9392
DestRemoteExecute, /* sent to frontend, in Execute command */
9493
DestRemoteSimple, /* sent to frontend, w/no catalog access */

0 commit comments

Comments
 (0)