MCPcopy Create free account
hub / github.com/apache/cloudberry / dbms_sql_debug_cursor

Function dbms_sql_debug_cursor

gpcontrib/orafce/dbms_sql.c:304–358  ·  view source on GitHub ↗

* Print state of cursor - just for debug purposes */

Source from the content-addressed store, hash-verified

302 * Print state of cursor - just for debug purposes
303 */
304Datum
305dbms_sql_debug_cursor(PG_FUNCTION_ARGS)
306{
307 CursorData *c;
308 ListCell *lc;
309
310 c = get_cursor(fcinfo, false);
311
312 if (c->assigned)
313 {
314 if (c->original_query)
315 elog(NOTICE, "orig query: \"%s\"", c->original_query);
316
317 if (c->parsed_query)
318 elog(NOTICE, "parsed query: \"%s\"", c->parsed_query);
319
320 }
321 else
322 elog(NOTICE, "cursor is not assigned");
323
324 foreach(lc, c->variables)
325 {
326 VariableData *var = (VariableData *) lfirst(lc);
327
328 if (var->typoid != InvalidOid)
329 {
330 if (!var->isnull)
331 {
332 Oid typOutput;
333 bool isVarlena;
334 char *str;
335
336 getTypeOutputInfo(var->typoid, &typOutput, &isVarlena);
337 str = OidOutputFunctionCall(typOutput, var->value);
338
339 elog(NOTICE, "variable \"%s\" is assigned to \"%s\"", var->refname, str);
340 }
341 else
342 elog(NOTICE, "variable \"%s\" is NULL", var->refname);
343 }
344 else
345 elog(NOTICE, "variable \"%s\" is not assigned", var->refname);
346 }
347
348 foreach(lc, c->columns)
349 {
350 ColumnData *col = (ColumnData *) lfirst(lc);
351
352 elog(NOTICE, "column definition for position %d is %s",
353 col->position,
354 format_type_with_typemod(col->typoid, col->typmod));
355 }
356
357 return (Datum) 0;
358}
359
360/*
361 * Search a variable in cursor's variable list

Callers

nothing calls this directly

Calls 5

get_cursorFunction · 0.85
getTypeOutputInfoFunction · 0.85
OidOutputFunctionCallFunction · 0.85
format_type_with_typemodFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected