CUBRID Engine  latest
csql_result.c File Reference
#include "config.h"
#include <assert.h>
#include <float.h>
#include <setjmp.h>
#include <signal.h>
#include "csql.h"
#include "dbtran_def.h"
#include "dbtype.h"
#include "memory_alloc.h"
#include "object_primitive.h"
#include "porting.h"
#include "transaction_cl.h"
Include dependency graph for csql_result.c:

Go to the source code of this file.

Classes

struct  CUR_RESULT_INFO
 
struct  CSQL_CMD_STRING_TABLE
 

Macros

#define MAX_SHORT_DISPLAY_LENGTH   6
 
#define MAX_INTEGER_DISPLAY_LENGTH   11
 
#define MAX_BIGINT_DISPLAY_LENGTH   20
 
#define MAX_FLOAT_DISPLAY_LENGTH   (FLT_DIG + 7)
 
#define MAX_DOUBLE_DISPLAY_LENGTH   (DBL_DIG + 9)
 
#define MAX_TIME_DISPLAY_LENGTH   11
 
#define MAX_TIMEZONE_DISPLAY_LENGTH   18
 
#define MAX_UTIME_DISPLAY_LENGTH   25
 
#define MAX_TIMESTAMPTZ_DISPLAY_LENGTH   (MAX_UTIME_DISPLAY_LENGTH + MAX_TIMEZONE_DISPLAY_LENGTH)
 
#define MAX_DATETIME_DISPLAY_LENGTH   29
 
#define MAX_DATETIMETZ_DISPLAY_LENGTH   (MAX_DATETIME_DISPLAY_LENGTH + MAX_TIMEZONE_DISPLAY_LENGTH)
 
#define MAX_DATE_DISPLAY_LENGTH   10
 
#define MAX_MONETARY_DISPLAY_LENGTH   20
 
#define MAX_DEFAULT_DISPLAY_LENGTH   20
 
#define STRING_TYPE_PREFIX_SUFFIX_LENGTH   2
 
#define NSTRING_TYPE_PREFIX_SUFFIX_LENGTH   3
 
#define BIT_TYPE_PREFIX_SUFFIX_LENGTH   3
 

Functions

static const char * csql_cmd_string (CUBRID_STMT_TYPE stmt_type, const char *default_string)
 
static void display_empty_result (int stmt_type, int line_no)
 
static char ** get_current_result (int **len, const CUR_RESULT_INFO *result_info, bool plain_output, bool query_output, bool loaddb_output, char column_enclosure)
 
static int write_results_to_stream (const CSQL_ARGUMENT *csql_arg, FILE *fp, const CUR_RESULT_INFO *result_info)
 
static char * uncontrol_strdup (const char *from)
 
static char * uncontrol_strndup (const char *from, int length)
 
static int calculate_width (int column_width, int string_width, int origin_width, DB_TYPE attr_type, bool is_null)
 
static bool is_string_type (DB_TYPE type)
 
static bool is_nstring_type (DB_TYPE type)
 
static bool is_bit_type (DB_TYPE type)
 
static bool is_cuttable_type_by_string_width (DB_TYPE type)
 
static bool is_type_that_has_suffix (DB_TYPE type)
 
void csql_results (const CSQL_ARGUMENT *csql_arg, DB_QUERY_RESULT *result, DB_QUERY_TYPE *attr_spec, int line_no, CUBRID_STMT_TYPE stmt_type)
 
static void csql_pipe_handler (int sig_no)
 

Variables

static CSQL_CMD_STRING_TABLE csql_Cmd_string_table []
 
static const char * csql_Isolation_level_string []
 
static jmp_buf csql_Jmp_buf
 
static void(* csql_pipe_save )(int sig)
 

Macro Definition Documentation

#define BIT_TYPE_PREFIX_SUFFIX_LENGTH   3

Definition at line 66 of file csql_result.c.

Referenced by calculate_width().

#define MAX_BIGINT_DISPLAY_LENGTH   20

Definition at line 50 of file csql_result.c.

Referenced by csql_results().

#define MAX_DATE_DISPLAY_LENGTH   10

Definition at line 61 of file csql_result.c.

Referenced by csql_results().

#define MAX_DATETIME_DISPLAY_LENGTH   29

Definition at line 58 of file csql_result.c.

Referenced by csql_results().

#define MAX_DATETIMETZ_DISPLAY_LENGTH   (MAX_DATETIME_DISPLAY_LENGTH + MAX_TIMEZONE_DISPLAY_LENGTH)

Definition at line 59 of file csql_result.c.

Referenced by csql_results().

#define MAX_DEFAULT_DISPLAY_LENGTH   20

Definition at line 63 of file csql_result.c.

Referenced by csql_results().

#define MAX_DOUBLE_DISPLAY_LENGTH   (DBL_DIG + 9)

Definition at line 52 of file csql_result.c.

Referenced by csql_results().

#define MAX_FLOAT_DISPLAY_LENGTH   (FLT_DIG + 7)

Definition at line 51 of file csql_result.c.

Referenced by csql_results().

#define MAX_INTEGER_DISPLAY_LENGTH   11

Definition at line 49 of file csql_result.c.

Referenced by csql_results().

#define MAX_MONETARY_DISPLAY_LENGTH   20

Definition at line 62 of file csql_result.c.

Referenced by csql_results().

#define MAX_SHORT_DISPLAY_LENGTH   6

Definition at line 48 of file csql_result.c.

Referenced by csql_results().

#define MAX_TIME_DISPLAY_LENGTH   11

Definition at line 53 of file csql_result.c.

Referenced by csql_results().

#define MAX_TIMESTAMPTZ_DISPLAY_LENGTH   (MAX_UTIME_DISPLAY_LENGTH + MAX_TIMEZONE_DISPLAY_LENGTH)

Definition at line 56 of file csql_result.c.

Referenced by csql_results().

#define MAX_TIMEZONE_DISPLAY_LENGTH   18

Definition at line 54 of file csql_result.c.

#define MAX_UTIME_DISPLAY_LENGTH   25

Definition at line 55 of file csql_result.c.

Referenced by csql_results().

#define NSTRING_TYPE_PREFIX_SUFFIX_LENGTH   3

Definition at line 65 of file csql_result.c.

Referenced by calculate_width().

#define STRING_TYPE_PREFIX_SUFFIX_LENGTH   2

Definition at line 64 of file csql_result.c.

Referenced by calculate_width().

Function Documentation

int calculate_width ( int  column_width,
int  string_width,
int  origin_width,
DB_TYPE  attr_type,
bool  is_null 
)
static
static const char * csql_cmd_string ( CUBRID_STMT_TYPE  stmt_type,
const char *  default_string 
)
static

Definition at line 437 of file csql_result.c.

References i.

Referenced by display_empty_result(), and write_results_to_stream().

Here is the caller graph for this function:

static void csql_pipe_handler ( int  sig_no)
static

Definition at line 705 of file csql_result.c.

References csql_Jmp_buf.

Referenced by write_results_to_stream().

Here is the caller graph for this function:

void csql_results ( const CSQL_ARGUMENT csql_arg,
DB_QUERY_RESULT result,
DB_QUERY_TYPE attr_spec,
int  line_no,
CUBRID_STMT_TYPE  stmt_type 
)

Definition at line 185 of file csql_result.c.

References assert, CUR_RESULT_INFO::attr_lengths, CUR_RESULT_INFO::attr_names, CUR_RESULT_INFO::attr_types, csql_check_server_down(), csql_display_csql_err(), CSQL_ERR_NO_MORE_MEMORY, CSQL_ERR_SQL_ERROR, csql_Error_code, CSQL_FAILURE, csql_Num_failures, csql_Output_fp, csql_Scratch_text, csql_text_utf8_to_console, CUR_RESULT_INFO::curr_stmt_line_no, CUR_RESULT_INFO::curr_stmt_type, DB_CURSOR_END, db_query_first_tuple(), db_query_format_name(), db_query_format_next(), db_query_format_type(), DB_TYPE_BIGINT, DB_TYPE_DATE, DB_TYPE_DATETIME, DB_TYPE_DATETIMELTZ, DB_TYPE_DATETIMETZ, DB_TYPE_DOUBLE, DB_TYPE_FLOAT, DB_TYPE_INTEGER, DB_TYPE_MONETARY, DB_TYPE_SHORT, DB_TYPE_TIME, DB_TYPE_TIMESTAMP, DB_TYPE_TIMESTAMPLTZ, DB_TYPE_TIMESTAMPTZ, display_empty_result(), err, error(), free_and_init, i, LC_FETCH_CURRENT_VERSION, CSQL_ARGUMENT::loaddb_output, CUR_RESULT_INFO::max_attr_name_length, MAX_BIGINT_DISPLAY_LENGTH, MAX_DATE_DISPLAY_LENGTH, MAX_DATETIME_DISPLAY_LENGTH, MAX_DATETIMETZ_DISPLAY_LENGTH, MAX_DEFAULT_DISPLAY_LENGTH, MAX_DOUBLE_DISPLAY_LENGTH, MAX_FLOAT_DISPLAY_LENGTH, MAX_INTEGER_DISPLAY_LENGTH, MAX_MONETARY_DISPLAY_LENGTH, MAX_SHORT_DISPLAY_LENGTH, MAX_TIME_DISPLAY_LENGTH, MAX_TIMESTAMPTZ_DISPLAY_LENGTH, MAX_UTIME_DISPLAY_LENGTH, NO_ERROR, nonscr_display_error(), NULL, CUR_RESULT_INFO::num_attrs, CSQL_ARGUMENT::plain_output, CSQL_ARGUMENT::query_output, CUR_RESULT_INFO::query_result, SCRATCH_TEXT_LEN, strlen, TM_TRAN_READ_FETCH_VERSION, uncontrol_strdup(), and write_results_to_stream().

Referenced by csql_execute_statements().

Here is the caller graph for this function:

static void display_empty_result ( int  stmt_type,
int  line_no 
)
static
static bool is_bit_type ( DB_TYPE  type)
static

Definition at line 1139 of file csql_result.c.

References DB_TYPE_BIT, and DB_TYPE_VARBIT.

Referenced by calculate_width(), is_cuttable_type_by_string_width(), and is_type_that_has_suffix().

Here is the caller graph for this function:

static bool is_cuttable_type_by_string_width ( DB_TYPE  type)
static

Definition at line 1159 of file csql_result.c.

References is_bit_type(), is_nstring_type(), and is_string_type().

Referenced by calculate_width().

Here is the caller graph for this function:

static bool is_nstring_type ( DB_TYPE  type)
static

Definition at line 1119 of file csql_result.c.

References DB_TYPE_NCHAR, and DB_TYPE_VARNCHAR.

Referenced by calculate_width(), is_cuttable_type_by_string_width(), and is_type_that_has_suffix().

Here is the caller graph for this function:

static bool is_string_type ( DB_TYPE  type)
static

Definition at line 1099 of file csql_result.c.

References DB_TYPE_CHAR, and DB_TYPE_STRING.

Referenced by calculate_width(), is_cuttable_type_by_string_width(), and is_type_that_has_suffix().

Here is the caller graph for this function:

static bool is_type_that_has_suffix ( DB_TYPE  type)
static

Definition at line 1170 of file csql_result.c.

References is_bit_type(), is_nstring_type(), and is_string_type().

Referenced by write_results_to_stream().

Here is the caller graph for this function:

static char * uncontrol_strdup ( const char *  from)
static

Definition at line 1206 of file csql_result.c.

References strlen, and uncontrol_strndup().

Referenced by csql_results().

Here is the caller graph for this function:

static char * uncontrol_strndup ( const char *  from,
int  length 
)
static

Definition at line 1182 of file csql_result.c.

References CSQL_ERR_NO_MORE_MEMORY, csql_Error_code, and NULL.

Referenced by uncontrol_strdup().

Here is the caller graph for this function:

Variable Documentation

CSQL_CMD_STRING_TABLE csql_Cmd_string_table[]
static

Definition at line 87 of file csql_result.c.

const char* csql_Isolation_level_string[]
static
Initial value:
= {
"UNKNOWN",
"UNKNOWN",
"UNKNOWN",
"UNKNOWN",
"READ COMMITTED",
"REPEATABLE READ",
"SERIALIZABLE"
}

Definition at line 147 of file csql_result.c.

Referenced by get_current_result().

jmp_buf csql_Jmp_buf
static

Definition at line 157 of file csql_result.c.

Referenced by csql_pipe_handler(), and write_results_to_stream().

void(* csql_pipe_save) (int sig)
static