MCPcopy Create free account
hub / github.com/MariaDB/server / MYSQLtoPLG

Function MYSQLtoPLG

storage/connect/myutil.cpp:35–105  ·  view source on GitHub ↗

/ Convert from MySQL type name to PlugDB type number */ /

Source from the content-addressed store, hash-verified

33/* Convert from MySQL type name to PlugDB type number */
34/************************************************************************/
35int MYSQLtoPLG(char *typname, char *var)
36 {
37 int type;
38 TYPCONV xconv = GetTypeConv();
39
40 if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") ||
41 !stricmp(typname, "integer"))
42 type = TYPE_INT;
43 else if (!stricmp(typname, "smallint"))
44 type = TYPE_SHORT;
45 else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
46 !stricmp(typname, "enum") || !stricmp(typname, "set"))
47 type = TYPE_STRING;
48 else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
49 !stricmp(typname, "real"))
50 type = TYPE_DOUBLE;
51 else if (!stricmp(typname, "decimal") || !stricmp(typname, "numeric"))
52 type = TYPE_DECIM;
53 else if (!stricmp(typname, "date") || !stricmp(typname, "datetime") ||
54 !stricmp(typname, "time") || !stricmp(typname, "timestamp") ||
55 !stricmp(typname, "year"))
56 type = TYPE_DATE;
57 else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong"))
58 type = TYPE_BIGINT;
59 else if (!stricmp(typname, "tinyint"))
60 type = TYPE_TINY;
61 else if (!stricmp(typname, "text") && var) {
62 switch (xconv) {
63 case TPC_YES:
64 type = TYPE_STRING;
65 *var = 'X';
66 break;
67 case TPC_SKIP:
68 *var = 'K';
69 /* falls through */
70 default: // TPC_NO
71 type = TYPE_ERROR;
72 } // endswitch xconv
73
74 return type;
75 } else
76 type = TYPE_ERROR;
77
78 if (var) {
79 if (type == TYPE_DATE) {
80 // This is to make the difference between temporal values
81 if (!stricmp(typname, "date"))
82 *var = 'D';
83 else if (!stricmp(typname, "datetime"))
84 *var = 'A';
85 else if (!stricmp(typname, "timestamp"))
86 *var = 'S';
87 else if (!stricmp(typname, "time"))
88 *var = 'T';
89 else if (!stricmp(typname, "year"))
90 *var = 'Y';
91
92 } else if (type == TYPE_STRING) {

Callers 5

TabColumnsFunction · 0.85
MyColumnsFunction · 0.85
GetResultMethod · 0.85
GetColumnOptionMethod · 0.85
MYSQLCOLMethod · 0.85

Calls 1

GetTypeConvFunction · 0.85

Tested by

no test coverage detected