sqlgettypeinfo.c
来自「这个是内存数据库的客户端」· C语言 代码 · 共 1,091 行 · 第 1/3 页
C
1,091 行
/* * The contents of this file are subject to the MonetDB Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the MonetDB Database System. * * The Initial Developer of the Original Code is CWI. * Portions created by CWI are Copyright (C) 1997-2007 CWI. * All Rights Reserved. *//* * This code was created by Peter Harvey (mostly during Christmas 98/99). * This code is LGPL. Please ensure that this message remains in future * distributions and uses of this code (thats about all I get out of it). * - Peter Harvey pharvey@codebydesign.com * * This file has been modified for the MonetDB project. See the file * Copyright in this directory for more information. *//********************************************************************** * SQLGetTypeInfo() * CLI Compliance: ISO 92 * * Author: Martin van Dinther * Date : 30 aug 2002 * **********************************************************************/#include "ODBCGlobal.h"#include "ODBCStmt.h"#include <float.h>#define NCOLUMNS 19/* column names of result set */static const char *columnnames[NCOLUMNS] = { "type_name", "data_type", "column_size", "literal_prefix", "literal_suffix", "create_params", "nullable", "case_sensitive", "searchable", "unsigned_attribute", "fixed_prec_scale", "auto_unique_value", "local_type_name", "minimum_scale", "maximum_scale", "sql_data_type", "sql_datetime_sub", "num_prec_radix", "interval_precision"};/* column types of result set */static const char *columntypes[NCOLUMNS] = { "varchar", "smallint", "int", "varchar", "varchar", "varchar", "smallint", "smallint", "smallint", "smallint", "smallint", "smallint", "varchar", "smallint", "smallint", "smallint", "smallint", "int", "smallint"};/* column lengths of result set */static const int columnlengths[NCOLUMNS] = { 128, 5, 10, 128, 128, 128, 5, 5, 5, 5, 5, 5, 128, 5, 5, 5, 5, 10, 5};static struct types { const char *type_name; const int data_type; /* concise type */ const int column_size; const char *literal_prefix; const char *literal_suffix; const char *create_params; const int nullable; /* NO_NULLS, NULLABLE, NULLABLE_UNKNOWN */ const int case_sensitive; /* SQL_FALSE, SQL_TRUE */ const int searchable; /* PRED_NONE, PRED_CHAR, PRED_BASIC, SEARCHABLE */ const int unsigned_attribute; /* SQL_FALSE, SQL_TRUE, NULL */ const int fixed_prec_scale; /* SQL_FALSE, SQL_TRUE */ const int auto_unique_value; /* SQL_FALSE, SQL_TRUE, NULL */ const char *local_type_name; const int minimum_scale; const int maximum_scale; const int sql_data_type; const int sql_datetime_sub; const int num_prec_radix; const int interval_precision; const char **tuple;} types[] = { /* this table is sorted on the value of data_type */ { "boolean", /* type_name */ SQL_BIT, /* data_type */ 1, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ NULL, /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_TRUE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ -1, /* minimum_scale */ -1, /* maximum_scale */ SQL_BIT, /* sql_data_type */ -1, /* sql_datetime_sub */ -1, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "tinyint", /* type_name */ SQL_TINYINT, /* data_type */ 2, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 0, /* maximum_scale */ SQL_TINYINT, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "bigint", /* type_name */ SQL_BIGINT, /* data_type */ 19, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 0, /* maximum_scale */ SQL_BIGINT, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, /* longvarbinary */ /* varbinary */ /* binary */ /* longvarchar */ { "character", /* type_name */ SQL_CHAR, /* data_type */ 1000000, /* column_size */ "'", /* literal_prefix */ "'", /* literal_suffix */ "length", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_TRUE, /* case_sensitive */ SQL_SEARCHABLE, /* searchable */ -1, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ -1, /* minimum_scale */ -1, /* maximum_scale */ SQL_CHAR, /* sql_data_type */ -1, /* sql_datetime_sub */ -1, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "char", /* type_name */ SQL_CHAR, /* data_type */ 1000000, /* column_size */ "'", /* literal_prefix */ "'", /* literal_suffix */ "length", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_TRUE, /* case_sensitive */ SQL_SEARCHABLE, /* searchable */ -1, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ -1, /* minimum_scale */ -1, /* maximum_scale */ SQL_CHAR, /* sql_data_type */ -1, /* sql_datetime_sub */ -1, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "numeric", /* type_name */ SQL_NUMERIC, /* data_type */ 19, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision,scale", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 19, /* maximum_scale */ SQL_NUMERIC, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "decimal", /* type_name */ SQL_DECIMAL, /* data_type */ 19, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision,scale", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 19, /* maximum_scale */ SQL_DECIMAL, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "int", /* type_name */ SQL_INTEGER, /* data_type */ 9, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 0, /* maximum_scale */ SQL_INTEGER, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "integer", /* type_name */ SQL_INTEGER, /* data_type */ 9, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 0, /* maximum_scale */ SQL_INTEGER, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "mediumint", /* type_name */ SQL_INTEGER, /* data_type */ 9, /* column_size */ NULL, /* literal_prefix */ NULL, /* literal_suffix */ "precision", /* create_params */ SQL_NULLABLE, /* nullable */ SQL_FALSE, /* case_sensitive */ SQL_PRED_BASIC, /* searchable */ SQL_FALSE, /* unsigned_attribute */ SQL_FALSE, /* fixed_prec_scale */ SQL_FALSE, /* auto_unique_value */ NULL, /* local_type_name */ 0, /* minimum_scale */ 0, /* maximum_scale */ SQL_INTEGER, /* sql_data_type */ -1, /* sql_datetime_sub */ 10, /* num_prec_radix */ -1, /* interval_precision */ NULL /* tuple */ }, { "smallint", /* type_name */ SQL_SMALLINT, /* data_type */ 4, /* column_size */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?