view deita/d_query.c @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents 1f9877b637e9
children
line wrap: on
line source

#include "deita_internal.h"
#include <stdio.h>

Deita_Result_Set* Deita_Query_Execute(
  Deita_Connection *p_connection,
  const char *query,
  Dowa_Arena *p_arena)
{
  if (!p_connection || !query)
    return NULL;

  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_query_execute(p_connection, query, p_arena);

  fprintf(stderr, "Deita_Query_Execute: Unsupported database type %d\n", p_connection->database_type);
  return NULL;
}

Deita_Result_Set* Deita_Query_Execute_Prepared(
  Deita_Connection *p_connection,
  const char *query,
  int32 parameter_count,
  const char **parameter_values,
  Dowa_Arena *p_arena)
{
  if (!p_connection || !query)
    return NULL;

  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_query_execute_prepared(p_connection, query, parameter_count, parameter_values, p_arena);

  fprintf(stderr, "Deita_Query_Execute_Prepared: Unsupported database type %d\n", p_connection->database_type);
  return NULL;
}

int32 Deita_Query_Execute_Update(
  Deita_Connection *p_connection,
  const char *query)
{
  if (!p_connection || !query)
    return -1;

  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_query_execute_update(p_connection, query);

  fprintf(stderr, "Deita_Query_Execute_Update: Unsupported database type %d\n", p_connection->database_type);
  return -1;
}

int32 Deita_Query_Execute_Update_Prepared(
  Deita_Connection *p_connection,
  const char *query,
  int32 parameter_count,
  const char **parameter_values)
{
  if (!p_connection || !query)
    return -1;

  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_query_execute_update_prepared(p_connection, query, parameter_count, parameter_values);

  fprintf(stderr, "Deita_Query_Execute_Update_Prepared: Unsupported database type %d\n", p_connection->database_type);
  return -1;
}

boolean Deita_Result_Set_Next(Deita_Result_Set *p_result_set)
{
  if (!p_result_set)
    return FALSE;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_next(p_result_set);

  fprintf(stderr, "Deita_Result_Set_Next: Unsupported database type %d\n", p_result_set->database_type);
  return FALSE;
}

boolean Deita_Result_Set_Has_Error(Deita_Result_Set *p_result_set)
{
  return p_result_set ? p_result_set->has_error : TRUE;
}

int32 Deita_Result_Set_Get_Column_Count(Deita_Result_Set *p_result_set)
{
  if (!p_result_set)
    return 0;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_column_count(p_result_set);

  fprintf(stderr, "Deita_Result_Set_Get_Column_Count: Unsupported database type %d\n", p_result_set->database_type);
  return 0;
}

const char* Deita_Result_Set_Get_Column_Name(
  Deita_Result_Set *p_result_set,
  int32 column_index)
{
  if (!p_result_set)
    return NULL;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_column_name(p_result_set, column_index);

  fprintf(stderr, "Deita_Result_Set_Get_Column_Name: Unsupported database type %d\n", p_result_set->database_type);
  return NULL;
}

Deita_Column_Type Deita_Result_Set_Get_Column_Type(
  Deita_Result_Set *p_result_set,
  int32 column_index)
{
  if (!p_result_set)
    return DEITA_COLUMN_TYPE_NULL;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_column_type(p_result_set, column_index);

  fprintf(stderr, "Deita_Result_Set_Get_Column_Type: Unsupported database type %d\n", p_result_set->database_type);
  return DEITA_COLUMN_TYPE_NULL;
}

const char* Deita_Result_Set_Get_Text(
  Deita_Result_Set *p_result_set,
  int32 column_index)
{
  if (!p_result_set)
    return NULL;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_text(p_result_set, column_index);

  fprintf(stderr, "Deita_Result_Set_Get_Text: Unsupported database type %d\n", p_result_set->database_type);
  return NULL;
}

int64 Deita_Result_Set_Get_Integer(
  Deita_Result_Set *p_result_set,
  int32 column_index)
{
  if (!p_result_set)
    return 0;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_integer(p_result_set, column_index);

  fprintf(stderr, "Deita_Result_Set_Get_Integer: Unsupported database type %d\n", p_result_set->database_type);
  return 0;
}

double Deita_Result_Set_Get_Real(
  Deita_Result_Set *p_result_set,
  int32 column_index)
{
  if (!p_result_set)
    return 0.0;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
    return deita__sqlite_result_set_get_real(p_result_set, column_index);

  fprintf(stderr, "Deita_Result_Set_Get_Real: Unsupported database type %d\n", p_result_set->database_type);
  return 0.0;
}

void Deita_Result_Set_Free(Deita_Result_Set *p_result_set)
{
  if (!p_result_set)
    return;

  if (p_result_set->database_type == DEITA_DATABASE_TYPE_SQLITE3)
  {
    deita__sqlite_result_set_free(p_result_set);
    return;
  }

  fprintf(stderr, "Deita_Result_Set_Free: Unsupported database type %d\n", p_result_set->database_type);
}