CUBRID Engine  latest
esql_translate.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "language_support.h"
#include "misc_string.h"
#include "util_func.h"
#include "dbi.h"
#include "esql_translate.h"
#include "memory_alloc.h"
#include "esql_misc.h"
Include dependency graph for esql_translate.c:

Go to the source code of this file.

Classes

struct  when_desc
 

Macros

#define ESQL_FILE_ID_VAR_NAME   "uci_esqlxc_file"
 
#define NOT_FOUND_MACRO_NAME   "SQL_NOT_FOUND"
 
#define WARN_CHAR_MACRO_NAME   "SQL_WARNING_CHAR"
 
#define REPETITIVE_SERIAL_NO   (repetitive_no++)
 
#define FP   c_out_stream
 

Typedefs

typedef struct when_desc WHEN_DESC
 

Enumerations

enum  esql_msg { MSG_BAD_CASE = 1 }
 

Functions

static void emit_start (int leading_brace)
 
static void emit_end (void)
 
static void get_quasi_string (HOST_REF *ref, const char **buf_str, const char **bufsize_str)
 
static void tr_connect (HOST_REF *db_name, HOST_REF *user_name, HOST_REF *passwd)
 
static void tr_disconnect (void)
 
static void tr_commit (void)
 
static void tr_rollback (void)
 
static void tr_static (const char *stmt, int length, bool repeat, int num_in_vars, HOST_REF *in_vars, const char *in_desc_name, int num_out_vars, HOST_REF *out_vars, const char *out_desc_name)
 
static void tr_open_cs (int cs_no, const char *stmt, int length, int stmt_no, bool readonly, int num_in_vars, HOST_REF *in_vars, const char *desc_name)
 
static void tr_fetch_cs (int cs_no, int num_out_vars, HOST_REF *out_vars, const char *desc_name)
 
static void tr_update_cs (int cs_no, const char *text, int length, bool repetitive, int num_in_vars, HOST_REF *in_vars)
 
static void tr_delete_cs (int cs_no)
 
static void tr_close_cs (int cs_no)
 
static void tr_prepare_esql (int stmt_no, HOST_REF *stmt)
 
static void tr_describe (int stmt_no, const char *desc_name)
 
static void tr_execute (int stmt_no, int num_in_vars, HOST_REF *in_vars, const char *in_desc_name, int num_out_vars, HOST_REF *out_vars, const char *out_desc_name)
 
static void tr_execute_immediate (HOST_REF *stmt)
 
static void tr_object_describe (HOST_REF *obj, int num_attrs, const char **attr_names, const char *desc_name)
 
static void tr_object_fetch (HOST_REF *obj, int num_attrs, const char **attr_names, int num_out_vars, HOST_REF *out_vars, const char *desc_name)
 
static void tr_object_update (const char *set_expr, int length, bool repetitive, int num_in_vars, HOST_REF *in_vars)
 
static void tr_whenever (WHEN_CONDITION condition, WHEN_ACTION action, const char *name)
 
static void tr_set_out_stream (FILE *out_stream)
 
static void tr_set_line_terminator (const char *)
 
static void emit_put_db_value (HOST_REF *host)
 
static void emit_get_db_value (int cs_no, HOST_REF *host)
 
static void tr_print_n_string (char *stmt, int length)
 
static void emit_whenever (void)
 
static char * escape_string (const char *, int length, int *counter)
 

Variables

static int repetitive_no = 0
 
static FILE * c_out_stream
 
static const char * NL = " "
 
static WHEN_DESC on_warning = { CONTINUE, (char *) NULL }
 
static WHEN_DESC on_error = { CONTINUE, (char *) NULL }
 
static WHEN_DESC on_not_found = { CONTINUE, (char *) NULL }
 
static const char * c_type_to_db_type_c []
 
ESQL_TRANSLATE_TABLE esql_Translate_table
 

Macro Definition Documentation

#define ESQL_FILE_ID_VAR_NAME   "uci_esqlxc_file"

Definition at line 46 of file esql_translate.c.

Referenced by emit_start().

#define NOT_FOUND_MACRO_NAME   "SQL_NOT_FOUND"

Definition at line 47 of file esql_translate.c.

Referenced by emit_whenever().

#define REPETITIVE_SERIAL_NO   (repetitive_no++)

Definition at line 53 of file esql_translate.c.

Referenced by tr_object_update(), tr_static(), and tr_update_cs().

#define WARN_CHAR_MACRO_NAME   "SQL_WARNING_CHAR"

Definition at line 48 of file esql_translate.c.

Referenced by emit_whenever().

Typedef Documentation

typedef struct when_desc WHEN_DESC

Enumeration Type Documentation

enum esql_msg
Enumerator
MSG_BAD_CASE 

Definition at line 140 of file esql_translate.c.

Function Documentation

static void emit_get_db_value ( int  cs_no,
HOST_REF host 
)
static
static void emit_whenever ( void  )
static

Definition at line 1415 of file esql_translate.c.

References when_desc::action, CALL, CONTINUE, emit_line_directive(), FP, GOTO, when_desc::name, NL, NOT_FOUND_MACRO_NAME, pp_enable_uci_trace, STOP, and WARN_CHAR_MACRO_NAME.

Referenced by emit_end().

Here is the caller graph for this function:

static char * escape_string ( const char *  in_str,
int  length,
int *  counter 
)
static

Definition at line 1518 of file esql_translate.c.

References NULL, and pp_malloc().

Referenced by tr_object_update(), tr_open_cs(), and tr_static().

Here is the caller graph for this function:

static void get_quasi_string ( HOST_REF ref,
const char **  buf_str,
const char **  bufsize_str 
)
static
static void tr_close_cs ( int  cs_no)
static

Definition at line 696 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, NL, and pp_enable_uci_trace.

static void tr_commit ( void  )
static

Definition at line 337 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, NL, and pp_enable_uci_trace.

static void tr_connect ( HOST_REF db_name,
HOST_REF user_name,
HOST_REF passwd 
)
static
static void tr_delete_cs ( int  cs_no)
static

Definition at line 674 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, NL, and pp_enable_uci_trace.

static void tr_describe ( int  stmt_no,
const char *  desc_name 
)
static

Definition at line 753 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, and NL.

static void tr_disconnect ( void  )
static

Definition at line 324 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, and NL.

static void tr_execute ( int  stmt_no,
int  num_in_vars,
HOST_REF in_vars,
const char *  in_desc_name,
int  num_out_vars,
HOST_REF out_vars,
const char *  out_desc_name 
)
static
static void tr_execute_immediate ( HOST_REF stmt)
static
static void tr_fetch_cs ( int  cs_no,
int  num_out_vars,
HOST_REF out_vars,
const char *  desc_name 
)
static
static void tr_object_describe ( HOST_REF obj,
int  num_attrs,
const char **  attr_names,
const char *  desc_name 
)
static

Definition at line 884 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, i, NL, and pp_get_expr().

static void tr_object_fetch ( HOST_REF obj,
int  num_attrs,
const char **  attr_names,
int  num_out_vars,
HOST_REF out_vars,
const char *  desc_name 
)
static
static void tr_object_update ( const char *  set_expr,
int  length,
bool  repetitive,
int  num_in_vars,
HOST_REF in_vars 
)
static
static void tr_open_cs ( int  cs_no,
const char *  stmt,
int  length,
int  stmt_no,
bool  readonly,
int  num_in_vars,
HOST_REF in_vars,
const char *  desc_name 
)
static
static void tr_prepare_esql ( int  stmt_no,
HOST_REF stmt 
)
static
static void tr_print_n_string ( char *  stmt,
int  length 
)
static

Definition at line 448 of file esql_translate.c.

References emit_line_directive(), FP, and NULL.

Referenced by tr_object_update(), tr_open_cs(), tr_static(), and tr_update_cs().

Here is the caller graph for this function:

static void tr_rollback ( void  )
static

Definition at line 354 of file esql_translate.c.

References emit_end(), emit_line_directive(), emit_start(), FP, NL, and pp_enable_uci_trace.

static void tr_set_line_terminator ( const char *  terminator)
static

Definition at line 1109 of file esql_translate.c.

References NL.

static void tr_set_out_stream ( FILE *  out_stream)
static

Definition at line 1098 of file esql_translate.c.

References c_out_stream.

static void tr_static ( const char *  stmt,
int  length,
bool  repeat,
int  num_in_vars,
HOST_REF in_vars,
const char *  in_desc_name,
int  num_out_vars,
HOST_REF out_vars,
const char *  out_desc_name 
)
static
static void tr_update_cs ( int  cs_no,
const char *  text,
int  length,
bool  repetitive,
int  num_in_vars,
HOST_REF in_vars 
)
static
static void tr_whenever ( WHEN_CONDITION  condition,
WHEN_ACTION  action,
const char *  name 
)
static

Variable Documentation

FILE* c_out_stream
static

Definition at line 66 of file esql_translate.c.

Referenced by tr_set_out_stream().

const char* c_type_to_db_type_c[]
static
Initial value:
= {
"DB_TYPE_C_SHORT",
"DB_TYPE_C_INT",
"DB_TYPE_C_LONG",
"DB_TYPE_C_FLOAT",
"DB_TYPE_C_DOUBLE",
"DB_TYPE_C_CHAR",
"DB_TYPE_C_CHAR",
"DB_TYPE_C_OBJECT",
"DB_TYPE_C_SET",
"DB_TYPE_C_SET",
"DB_TYPE_C_SET",
"DB_TYPE_C_SET",
"DB_TYPE_C_TIME",
"DB_TYPE_C_TIMESTAMP",
"DB_TYPE_C_DATE",
"DB_TYPE_C_MONETARY",
"",
"DB_TYPE_C_VARCHAR",
"DB_TYPE_C_BIT",
"DB_TYPE_C_VARBIT",
"DB_TYPE_C_NCHAR",
"DB_TYPE_C_VARNCHAR",
"DB_TYPE_C_STRING_CONST",
"DB_TYPE_C_SQLDA",
"DB_TYPE_C_BIGINT",
""
}

Definition at line 111 of file esql_translate.c.

Referenced by emit_get_db_value().

ESQL_TRANSLATE_TABLE esql_Translate_table
Initial value:
= {
}
static void tr_delete_cs(int cs_no)
static void tr_static(const char *stmt, int length, bool repeat, int num_in_vars, HOST_REF *in_vars, const char *in_desc_name, int num_out_vars, HOST_REF *out_vars, const char *out_desc_name)
static void tr_set_line_terminator(const char *)
static void tr_execute_immediate(HOST_REF *stmt)
static void tr_object_update(const char *set_expr, int length, bool repetitive, int num_in_vars, HOST_REF *in_vars)
static void tr_rollback(void)
static void tr_disconnect(void)
static void tr_object_fetch(HOST_REF *obj, int num_attrs, const char **attr_names, int num_out_vars, HOST_REF *out_vars, const char *desc_name)
static void tr_connect(HOST_REF *db_name, HOST_REF *user_name, HOST_REF *passwd)
static void tr_describe(int stmt_no, const char *desc_name)
static void tr_commit(void)
static void tr_execute(int stmt_no, int num_in_vars, HOST_REF *in_vars, const char *in_desc_name, int num_out_vars, HOST_REF *out_vars, const char *out_desc_name)
static void tr_open_cs(int cs_no, const char *stmt, int length, int stmt_no, bool readonly, int num_in_vars, HOST_REF *in_vars, const char *desc_name)
static void tr_whenever(WHEN_CONDITION condition, WHEN_ACTION action, const char *name)
static void tr_prepare_esql(int stmt_no, HOST_REF *stmt)
static void tr_update_cs(int cs_no, const char *text, int length, bool repetitive, int num_in_vars, HOST_REF *in_vars)
static void tr_object_describe(HOST_REF *obj, int num_attrs, const char **attr_names, const char *desc_name)
static void tr_close_cs(int cs_no)
static void tr_set_out_stream(FILE *out_stream)
static void tr_fetch_cs(int cs_no, int num_out_vars, HOST_REF *out_vars, const char *desc_name)

Definition at line 145 of file esql_translate.c.

Referenced by pp_add_whenever_to_scope(), pp_finish_whenever_scope(), and pp_startup().

WHEN_DESC on_not_found = { CONTINUE, (char *) NULL }
static

Definition at line 74 of file esql_translate.c.

Referenced by tr_whenever().

WHEN_DESC on_warning = { CONTINUE, (char *) NULL }
static

Definition at line 72 of file esql_translate.c.

Referenced by tr_whenever().

int repetitive_no = 0
static

Definition at line 63 of file esql_translate.c.