001package gudusoft.gsqlparser.nodes;
002
003import gudusoft.gsqlparser.*;
004
005import java.util.HashMap;
006import java.util.Map;
007
008
009/**
010* This class represents SQL Datatype.
011 * call method {@link #toString() toString} will return string  representation of datatype
012 * including type name,length,precision,scale and attributes
013 * <ul>
014 *     <li>typename
015 *     <li>typename(length)
016 *      <ul>
017 *          <li>length: {@link #getLength()}</li>
018 *          </uL>
019 *     </li>
020 *     <li>typename(precision,scale)
021 *      <ul>
022 *          <li>precision: {@link #getPrecision()}</li>
023 *          <li>precision: {@link #getScale()}</li>
024 *          </uL>
025 *     </li>
026 * </ul>
027 *
028 *
029 * <p>datetype attribute
030 * <br> In datatype like this: MEDIUMTEXT [CHARACTER SET cs_name] [COLLATE collation_name],
031 * CHARACTER SET and COLLATE were treated as attribute of the MEDIUMTEXT datatype,those attributes
032 * can be fetched from {@link #getDatatypeAttributeList()}. For more detailed information about
033 * attributes in datatype, please check {@link TDatatypeAttribute}.
034 * <p>
035 * method {@link #getDatatypeAttributeList()} can be used to get datatype attribute
036 * such as FORMAT 'yyyymmdd' of DATE in this fuction: CAST('20120802' AS DATE FORMAT 'yyyymmdd').
037 *
038*
039* <p>BINARY
040 * <ul>
041*   <li>BINARY[(n)]
042 *   <ul>
043 *       <li>{@link EDataType#binary_t}</li>
044 *       <li>n: {@link #getLength()}</li>
045 *       </ul>
046 *  </li>
047*   <li>BINARY LARGE OBJECT</li>
048*   <li>BLOB
049 *   <ul>
050 *       <li>{@link EDataType#blob_t}
051 *           </li>
052 *       </ul>
053 *   </li>
054*   <li>GRAPHIC
055 *   <ul>
056 *       <li>{@link EDataType#graphic_t}
057 *           </li>
058 *       </ul>
059 *   </li>
060*   <li>LONGBLOB
061 *   <ul>
062 *       <li>{@link EDataType#longblob_t}
063 *           </li>
064 *       </ul>
065 *   </li>
066*   <li>LONG RAW
067 *   <ul>
068 *       <li>{@link EDataType#long_raw_t}
069 *           </li>
070 *       </ul>
071 *   </li>
072*   <li>VARBINARY[(n)]
073 *   <ul>
074 *       <li>{@link EDataType#varbinary_t}
075 *           </li>
076 *       <li>n: {@link #getLength()}</li>
077 *       </ul>
078 *   </li>
079*   <li>BYTEA
080 *   <ul>
081 *       <li>{@link EDataType#bytea_t}
082 *           </li>
083 *       </ul>
084 *      </li>
085*   <li>IMAGE(SQL Server) </li>
086*   <li>TINYBLOB(MySQL, SQL Server)
087 *   <ul>
088 *       <li>{@link EDataType#tinyblob_t}
089 *           </li>
090 *       </ul>
091 *      </li>
092*  </ul>
093 *
094* <p>BOOLEAN
095 * <ul>
096*   <li>BOOL
097 *   <ul>
098 *       <li>{@link EDataType#bool_t}
099 *           </li>
100 *       </ul>
101 *      </li>
102*   <li>BOOLEAN
103 *   <ul>
104 *       <li>{@link EDataType#bool_t}
105 *           </li>
106 *       </ul>
107 *      </li>
108* </ul>
109 *
110* <p>CHARACTER STRING
111 * <ul>
112*   <li>CHAR[(n)]/CHARACTER[(n)]
113 *   <ul>
114 *       <li>{@link EDataType#char_t}.
115 *           </li>
116 *           <li>n: {@link #getLength()} </li>
117 *       </ul>
118 *       </li>
119*   <li>CHARACTER VARYING(n)/VARCHAR(n)/CHAR VARYING(n)/VARCHAR2(n) (Oracle)
120 *   <ul>
121 *       <li>{@link EDataType#varchar_t}
122 *           </li>
123 *           <li>n: {@link #getLength()} </li>
124 *       </ul>
125 *      </li>
126*   <li>NATIONAL CHARACTER[(n)]/NATIONAL CHAR[(n)]/NCHAR[(n)]
127 *   <ul>
128 *       <li>{@link EDataType#nchar_t}
129 *           </li>
130 *           <li>n: {@link #getLength()} </li>
131 *       </ul>
132 *      </li>
133*   <li>NATIONAL CHARACTER VARYING(n)/NATIONAL CHAR VARYING(n)/NCHAR VARYING(n)/NVARCHAR/VARGRAPHIC(n)
134 *   <ul>
135 *       <li>{@link EDataType#nvarchar_t}
136 *           </li>
137 *           <li>n: {@link #getLength()} </li>
138 *       </ul>
139 *      </li>
140*   <li>NVARCHAR2(n) (Oracle)
141 *   <ul>
142 *       <li>{@link EDataType#nvarchar2_t}
143 *           </li>
144 *           <li>n: {@link #getLength()} </li>
145 *       </ul>
146 *      </li>
147*   <li>CHARACTER LARGE OBJECT/CLOB
148 *   <ul>
149 *       <li>{@link EDataType#clob_t}
150 *           </li>
151 *       </ul>
152 *      </li>
153*   <li>NATIONAL CHARACTER LARGE OBJECT</li>
154*   <li>NCLOB
155 *   <ul>
156 *       <li>{@link EDataType#nclob_t}
157 *           </li>
158 *       </ul>
159 *      </li>
160*   <li>DBCLOB
161 *   <ul>
162 *       <li>{@link EDataType#dbclob_t}
163 *           </li>
164 *       </ul>
165 *      </li>
166*   <li>NTEXT/NATIONAL TEXT(SQL Server)
167 *   <ul>
168 *       <li>{@link EDataType#ntext_t}
169 *           </li>
170 *       </ul>
171 *      </li>
172*   <li>TEXT
173 *   <ul>
174 *       <li>{@link EDataType#text_t}
175 *           </li>
176 *       </ul>
177 *      </li>
178*   <li>CHAR FOR BIT DATA</li>
179*   <li>VARCHAR FOR BIT DATA</li>
180*   <li>TINYTEXT(MySQL)</li>
181*   </ul>
182*
183* <p>DATALINK
184 * <ul>
185*   <li>DATALINK
186 *   <ul>
187 *       <li>{@link EDataType#datalink_t}
188 *           </li>
189 *       </ul>
190 *      </li>
191*</ul>
192 *
193* <p>INTERVAL
194 * <ul>
195*   <li>INTERVAL
196 *   <ul>
197 *       <li>{@link EDataType#interval_t}
198 *           </li>
199 *       </ul>
200 *      </li>
201*   <li>INTERVAL DAY[(precision)]
202 *   <ul>
203 *       <li>{@link EDataType#interval_day_t}
204 *           </li>
205 *           <li>precision: {@link #getPrecision()}</li>
206 *       </ul>
207 *      </li>
208*   <li>INTERVAL DAY[(precision)] TO SECOND[(second precision)]
209 *   <ul>
210 *       <li>{@link EDataType#interval_day_to_second_t}
211 *           </li>
212 *           <li>precision: {@link #getPrecision()}</li>
213 *           <li>second precision: {@link #getSecondsPrecision()}</li>
214 *       </ul>
215 *          </li>
216*   <li>INTERVAL DAY[(precision)] TO MINUTE
217 *   <ul>
218 *       <li>{@link EDataType#interval_day_to_minute_t}
219 *           </li>
220 *           <li>precision: {@link #getPrecision()}</li>
221 *       </ul>
222 *      </li>
223*   <li>INTERVAL DAY[(precision)] TO HOUR
224 *   <ul>
225 *       <li>{@link EDataType#interval_day_to_hour_t}
226 *           </li>
227 *           <li>precision: {@link #getPrecision()}</li>
228 *       </ul>
229 *      </li>
230*   <li>INTERVAL YEAR[(precision)] TO MONTH
231 *   <ul>
232 *       <li>{@link EDataType#interval_year_to_month_t}
233 *           </li>
234 *           <li>precision: {@link #getPrecision()}</li>
235 *       </ul>
236 *      </li>
237*   <li>TIMESPAN
238 *   <ul>
239 *       <li>{@link EDataType#timespan_t}
240 *           </li>
241 *       </ul>
242 *      </li>
243 *      </ul>
244*
245*<p> COLLECTION
246 * <ul>
247*   <li>ARRAY </li>
248*   <li>MULTISET</li>
249 *   </ul>
250*
251* <p>NUMERIC
252 * <ul>
253*   <li>INTEGER/INT
254 *   <ul>
255 *       <li>{@link EDataType#int_t}
256 *           </li>
257 *       </ul>
258 *      </li>
259*   <li>INT4(PostgreSQL)
260 *   <ul>
261 *       <li>{@link EDataType#int4_t}
262 *           </li>
263 *       </ul>
264 *      </li>
265*   <li>MEDIUMINT(MySQL)
266 *   <ul>
267 *       <li>{@link EDataType#mediumint_t}
268 *           </li>
269 *       </ul>
270 *      </li>
271*   <li>SMALLINT
272 *   <ul>
273 *       <li>{@link EDataType#smallint_t}
274 *           </li>
275 *       </ul>
276 *      </li>
277*   <li>INT2(PostgreSQL)
278 *   <ul>
279 *       <li>{@link EDataType#int2_t}
280 *           </li>
281 *       </ul>
282 *      </li>
283*   <li>BIGINT
284 *   <ul>
285 *       <li>{@link EDataType#bigint_t}
286 *           </li>
287 *       </ul>
288 *      </li>
289*   <li>NUMERIC(p,s)
290 *   <ul>
291 *       <li>{@link EDataType#numeric_t}
292 *           </li>
293 *           <li>p: {@link #getPrecision()}</li>
294 *           <li>s: {@link #getScale()}</li>
295 *       </ul>
296 *      </li>
297*   <li>NUMBER(p,s)
298 *   <ul>
299 *       <li>{@link EDataType#number_t}
300 *           </li>
301 *           <li>p: {@link #getPrecision()}</li>
302 *           <li>s: {@link #getScale()}</li>
303 *       </ul>
304 *      </li>
305*   <li>DEC[IMAL](p,s)
306 *   <ul>
307 *       <li>{@link EDataType#dec_t}
308 *           </li>
309 *           <li>p: {@link #getPrecision()}</li>
310 *           <li>s: {@link #getScale()}</li>
311 *       </ul>
312 *      </li>
313*   <li>FLOAT(p,s)
314 *   <ul>
315 *       <li>{@link EDataType#float_t}
316 *           </li>
317 *           <li>p: {@link #getPrecision()}</li>
318 *           <li>s: {@link #getScale()}</li>
319 *       </ul>
320 *      </li>
321*   <li>FLOAT4(PostgreSQL)
322 *   <ul>
323 *       <li>{@link EDataType#float4_t}
324 *           </li>
325 *       </ul>
326 *      </li>
327*   <li>FLOAT8(PostgreSQL)
328 *   <ul>
329 *       <li>{@link EDataType#float8_t}
330 *           </li>
331 *       </ul>
332 *       </li>
333*   <li>REAL
334 *   <ul>
335 *       <li>{@link EDataType#real_t}
336 *           </li>
337 *       </ul>
338 *       </li>
339*   <li>DOUBLE/DOUBLE PRECISION
340 *   <ul>
341 *       <li>{@link EDataType#double_t}
342 *           </li>
343 *       </ul>
344 *       </li>
345*   <li>BINARY_FLOAT(Oracle)</li>
346*   <li>BINARY_DOUBLE(Oracle)</li>
347*   <li>TINYINT/YEAR(MySQL)</li>
348 *   </ul>
349*
350* <p>TEMPORAL
351 * <ul>
352*   <li>DATE
353 *   <ul>
354 *       <li>{@link EDataType#date_t}
355 *           </li>
356 *       </ul>
357 *       </li>
358*   <li>TIME
359 *   <ul>
360 *       <li>{@link EDataType#time_t}
361 *           </li>
362 *       </ul>
363 *       </li>
364*   <li>TIME WITH TIME ZONE/TIMETZ(PostgreSQL)
365 *   <ul>
366 *       <li>{@link EDataType#time_with_time_zone_t}
367 *           </li>
368 *       </ul>
369 *       </li>
370*   <li>TIMESTAMP [(fractional_seconds)]
371 *   <ul>
372 *       <li>{@link EDataType#timestamp_t}
373 *           </li>
374 *           <li>fractional_seconds: {@link #getPrecision()}</li>
375 *       </ul>
376 *      </li>
377*   <li>TIMESTAMP [(fractional_seconds)] WITH TIME ZONE
378 *   <ul>
379 *       <li>{@link EDataType#timestamp_with_time_zone_t}
380 *           </li>
381 *           <li>fractional_seconds: {@link #getPrecision()}</li>
382 *       </ul>
383 *      </li>
384*   <li>DATETIME
385 *   <ul>
386 *       <li>{@link EDataType#datetime_t}
387 *           </li>
388 *       </ul>
389 *      </li>
390*   <li>SMALLDATETIME
391 *   <ul>
392 *       <li>{@link EDataType#smalldatetime_t}
393 *           </li>
394 *       </ul>
395 *      </li>
396*   <li>DATETIMEOFFSET[ (fractional seconds precision) ]
397 *   <ul>
398 *       <li>{@link EDataType#datetimeoffset_t}
399 *           </li>
400 *           <li>fractional seconds precision: {@link #getPrecision()}</li>
401 *       </ul>
402 *      </li>
403*   <li>DATETIME2[ (fractional seconds precision) ](SQL Server)
404 *   <ul>
405 *       <li>{@link EDataType#datetime2_t}
406 *           </li>
407 *           <li>fractional seconds precision: {@link #getPrecision()}</li>
408 *       </ul>
409 *      </li>
410*   <li>TIMESTAMPTZ</li>
411 *   </ul>
412*
413*
414* <p>XML
415 * <ul>
416*   <li>XML
417 *   <ul>
418 *       <li>{@link EDataType#xml_t}
419 *           </li>
420 *       </ul>
421 *   </li>
422*   <li>XMLTYPE(Oracle)</li>
423 *   </ul>
424*
425* <p>HIVE array
426 * <ul>
427*   <li>array</li>
428 *
429 *       <li>{@link EDataType#listType_t}
430 *           </li>
431 *           <li>T: {@link #getTypeOfList()}</li>
432 *       </ul>
433 *
434*
435 *
436 * <p>OTHERS
437 * <ul>
438*   <li>BFILE(Oracle)</li>
439 *
440 *       <li>{@link EDataType#bfile_t}
441 *           </li>
442 *
443 *
444*   <li>BIT(MySQL,PostgreSQL,SQL Server)</li>
445*   <li>BITVARYING/VARBIT(PostgreSQL)</li>
446*   <li>BOX(PostgreSQL)</li>
447*   <li>CIDR(PostgreSQL)</li>
448*   <li>CIRCLE(PostgreSQL)</li>
449*   <li>CURSOR(SQL Server)</li>
450*   <li>ENUM(MySQL, PostgreSQL)</li>
451*   <li>GEOGRAPHY(SQL Server)</li>
452 *
453 *       <li>{@link EDataType#geography_t}
454 *           </li>
455 *
456 *
457*   <li>GEOMETRY(SQL Server)</li>
458 *       <li>{@link EDataType#geometry_t}
459 *           </li>
460*   <li>HIERARCHYID(SQL Server)</li>
461*   <li>INET(PostgreSQL)</li>
462*   <li>LINE(PostgreSQL)</li>
463*   <li>LONG(Oracle)</li>
464 *       <li>{@link EDataType#long_t}
465 *           </li>
466*   <li>LONG VARCHAR</li>
467*   <li>LONG VARGRAPHIC</li>
468*   <li>LONGTEXT(MySQL)</li>
469*   <li>LSEG(PostgreSQL)</li>
470*   <li>MACADDR(PostgreSQL)</li>
471*   <li>MEDIUMBLOB(MySQL)</li>
472*   <li>MEDIUMTEXT(MySQL)</li>
473*   <li>MONEY(PostgreSQL,SQL Server)</li>
474*   <li>OID(PostgreSQL)</li>
475*   <li>PATH(PostgreSQL)</li>
476*   <li>POINT(PostgreSQL)</li>
477*   <li>POLYGON(PostgreSQL)</li>
478*   <li>RAW(Oracle)</li>
479 *       <li>{@link EDataType#raw_t}
480 *           </li>
481*   <li>ROWID(Oracle)</li>
482*   <li>ROWVERSION(SQL Server)</li>
483*   <li>SERIAL, SERIAL4(MySQL,PostgreSQL)</li>
484*   <li>SERIAL8, BIGSERIAL(PostgreSQL)</li>
485*   <li>SET(MySQL)</li>
486*   <li>SMALLMONEY(SQL Server)</li>
487*   <li>SQL_VARIANT(SQL Server)</li>
488*   <li>TABLE(SQL Server)</li>
489*   <li>UNIQUEIDENTIFIER(SQL Server)</li>
490*   <li>UROWID(Oracle)</li>
491 *   </ul>
492*
493*
494* <p>datatypes optional attributes:
495*  <ul>
496*   <li>NSIGNED (MySQL)</li>
497*   <li>ZEROFILL (MySQL)</li>
498*   <li>CHARACTER SET cs_name (MySQL)</li>
499*   <li>COLLATE collation_name (MySQL)</li>
500* </ul>
501 *
502* @see TDatatypeAttribute
503*
504*/
505public class TTypeName extends TParseTreeNode implements Cloneable {
506
507    private TCharacterDatatypeProperty characterDatatypeProperty;
508
509    public void setCharacterDatatypeProperty(TCharacterDatatypeProperty characterDatatypeProperty) {
510        this.characterDatatypeProperty = characterDatatypeProperty;
511    }
512
513    public TCharacterDatatypeProperty getCharacterDatatypeProperty() {
514        return characterDatatypeProperty;
515    }
516
517    @Override
518    public String toString(){
519        StringBuilder sb = new StringBuilder();
520        TTypeName subType;
521       // tables.append(",\t"+column.getColumnDataType().toString());
522        switch (this.getDataType()){
523            case array_t:
524                subType = this.getTypeOfList();
525
526                if ((subType != null) && (subType.getDataType() == EDataType.struct_t)){
527                    sb.append("array");
528                    sb.append("\n\tstruct");
529                    for(int k=0;k<subType.getColumnDefList().size();k++){
530                        sb.append("\n\t\t\t\t\t\t"+ subType.getColumnDefList().getColumn(k).getColumnName().toString()
531                                +",\t"+ subType.getColumnDefList().getColumn(k).getDatatype().toString());
532                    }
533                }else{
534                    sb.append(super.toString());
535                }
536                break;
537            case struct_t:
538                subType = this;
539                for(int k=0;k<subType.getColumnDefList().size();k++){
540                    sb.append("\n\t\t\t\t\t\t"+ subType.getColumnDefList().getColumn(k).getColumnName().toString()
541                            +",\t"+ subType.getColumnDefList().getColumn(k).getDatatype().toString());
542                }
543                break;
544            default:
545                String s = super.toString();
546                if (s == null) s = this.plainText; // 这个值是在 clone() method 中设置的
547                sb.append(s);
548                break;
549        }
550
551        return sb.toString();
552    }
553    public TTypeName  clone(){
554        TTypeName cloneObject = new TTypeName();
555        cloneObject.dataType = this.dataType;
556        if (this.typeOfList != null){
557            cloneObject.typeOfList = this.typeOfList.clone();
558        }
559
560        if (this.columnDefList != null){
561            cloneObject.columnDefList = new TColumnDefinitionList();
562            for(int i=0;i<this.columnDefList.size();i++){
563                cloneObject.columnDefList.addColumn(this.columnDefList.getColumn(i).clone());
564            }
565        }
566
567        cloneObject.setPlainText(this.toString()); // 下面的两个设置token的操作会导致 原 TTypeName 的内存不能释放,导致内存泄漏,所有用 setPlainText 设置文本信息
568
569//        cloneObject.setStartToken(this.getStartToken());
570//        cloneObject.setEndToken(this.getEndToken());
571
572        return cloneObject;
573    }
574
575    @Override
576    public void setPlainText(String plainText) {
577        this.plainText = plainText;
578    }
579
580    private String plainText;
581
582    public TTypeName(){
583
584    }
585
586    public TTypeName(EDataType dataType){
587        this.dataType = dataType;
588    }
589
590    public TTypeName(EDataType dataType,TConstant length){
591        this(dataType);
592        switch (this.dataType){
593            case time_t:
594            case timetz_t:
595            case timentz_t:
596            case timestamp_with_time_zone_t:
597            case timestamp_with_local_time_zone_t:
598                this.fractionalSecondsPrecision = length;
599                break;
600            case interval_year_to_month_t:
601            case interval_day_to_second_t:
602                this.precision = length;
603                break;
604            default:
605                this.length = length;
606                break;
607        }
608    }
609
610    public TTypeName(EDataType dataType,TConstant precision, TConstant scale){
611        this(dataType);
612        this.precision = precision;
613        switch (this.dataType){
614            case interval_year_to_month_t:
615            case interval_day_to_second_t:
616                this.secondsPrecision = scale;
617                break;
618            default:
619                this.scale = scale;
620                break;
621        }
622
623    }
624
625    private TConstant fractionalSecondsPrecision;
626
627    public void setFractionalSecondsPrecision(TConstant fractionalSecondsPrecision) {
628        this.fractionalSecondsPrecision = fractionalSecondsPrecision;
629    }
630
631    public TConstant getFractionalSecondsPrecision() {
632
633        return fractionalSecondsPrecision;
634    }
635
636    private boolean byteUnit = false;
637
638    public boolean isCharUnit() {
639        return charUnit;
640    }
641
642    public boolean isByteUnit() {
643        return byteUnit;
644    }
645
646    private boolean charUnit = false;
647
648    private boolean varying = false;
649
650    public boolean isVarying() {
651        return varying;
652    }
653
654    private static Map<String, EDataType> dataTypeMap = new HashMap<String, EDataType>( );
655    private static Map<String, EDataType> teradataDataTypeMap = new HashMap<String, EDataType>( );
656
657    public static EDataType searchTeradataTypeByName(String typenameStr){
658
659        if (teradataDataTypeMap.size() == 0){
660            teradataDataTypeMap.put("array",EDataType.array_t);
661            teradataDataTypeMap.put("varray",EDataType.varray_t);
662            teradataDataTypeMap.put("blob",EDataType.blob_t);
663            teradataDataTypeMap.put("byte",EDataType.byte_t);
664            teradataDataTypeMap.put("varbyte",EDataType.varbyte_t);
665            teradataDataTypeMap.put("bigint",EDataType.bigint_t);
666            teradataDataTypeMap.put("byteint",EDataType.byteint_t);
667            teradataDataTypeMap.put("date",EDataType.date_t);
668            teradataDataTypeMap.put("dec",EDataType.dec_t);
669            teradataDataTypeMap.put("decimal",EDataType.decimal_t);
670            teradataDataTypeMap.put("double_precision",EDataType.double_precision_t);
671            teradataDataTypeMap.put("float",EDataType.float_t);
672            teradataDataTypeMap.put("integer",EDataType.int_t);
673            teradataDataTypeMap.put("int",EDataType.int_t);
674            teradataDataTypeMap.put("number",EDataType.number_t);
675            teradataDataTypeMap.put("numeric",EDataType.numeric_t);
676            teradataDataTypeMap.put("real",EDataType.real_t);
677            teradataDataTypeMap.put("smallint",EDataType.smallint_t);
678            teradataDataTypeMap.put("time",EDataType.time_t);
679            teradataDataTypeMap.put("timestamp",EDataType.timestamp_t);
680            teradataDataTypeMap.put("interval",EDataType.interval_t);
681            teradataDataTypeMap.put("char",EDataType.char_t);
682            teradataDataTypeMap.put("character",EDataType.char_t);
683            teradataDataTypeMap.put("clob",EDataType.clob_t);
684            teradataDataTypeMap.put("long",EDataType.long_t);
685            teradataDataTypeMap.put("long_varchar",EDataType.long_varchar_t);
686            teradataDataTypeMap.put("varchar",EDataType.varchar_t);
687            teradataDataTypeMap.put("period",EDataType.period_t);
688            teradataDataTypeMap.put("td_anytype",EDataType.td_anytype_t);
689            teradataDataTypeMap.put("variant_type",EDataType.variant_t);
690            teradataDataTypeMap.put("xml",EDataType.xml_t);
691        }
692
693        return teradataDataTypeMap.get(typenameStr.toLowerCase());
694    }
695
696    public static EDataType searchTypeByName(String typenameStr, EDbVendor dbVendor){
697        if (dbVendor == EDbVendor.dbvteradata) return searchTeradataTypeByName(typenameStr);
698        else return searchTypeByName(typenameStr);
699    }
700
701    public static EDataType searchTypeByName(String typenameStr){
702
703        if (dataTypeMap.size() == 0){
704            dataTypeMap.put("bfile",EDataType.bfile_t);
705            dataTypeMap.put("bigint",EDataType.bigint_t);
706            dataTypeMap.put("bignumeric",EDataType.bignumeric_t);
707            dataTypeMap.put("bigserial",EDataType.bigserial_t);
708            dataTypeMap.put("binary",EDataType.binary_t);
709            dataTypeMap.put("bit",EDataType.bit_t);
710            dataTypeMap.put("blob",EDataType.blob_t);
711            dataTypeMap.put("boolean",EDataType.boolean_t);
712            dataTypeMap.put("byte",EDataType.byte_t);
713            dataTypeMap.put("bytea",EDataType.bytea_t);
714            dataTypeMap.put("byteint",EDataType.byteint_t);
715            dataTypeMap.put("char",EDataType.char_t);
716            dataTypeMap.put("character",EDataType.char_t);
717            dataTypeMap.put("clob",EDataType.clob_t);
718            dataTypeMap.put("date",EDataType.date_t);
719            dataTypeMap.put("datetime",EDataType.datetime_t);
720            dataTypeMap.put("datetime2",EDataType.datetime2_t);
721            dataTypeMap.put("datetimeoffset",EDataType.datetime_t);
722            dataTypeMap.put("dec",EDataType.dec_t);
723            dataTypeMap.put("decimal",EDataType.dec_t);
724            dataTypeMap.put("double",EDataType.double_precision_t);
725            dataTypeMap.put("double_precision",EDataType.double_precision_t);
726            dataTypeMap.put("float",EDataType.float_t);
727            dataTypeMap.put("geometry",EDataType.geometry_t);
728            dataTypeMap.put("geography",EDataType.geography_t);
729            dataTypeMap.put("hierarchyid",EDataType.hierarchyid_t);
730            dataTypeMap.put("int",EDataType.int_t);
731            dataTypeMap.put("int4",EDataType.int4_t);
732            dataTypeMap.put("int64",EDataType.int64_t);
733            dataTypeMap.put("int8",EDataType.int8_t);
734            dataTypeMap.put("integer",EDataType.int_t);
735            dataTypeMap.put("interval",EDataType.interval_t);
736            dataTypeMap.put("image",EDataType.varbinary_t);
737            dataTypeMap.put("long",EDataType.long_t);
738            dataTypeMap.put("long_raw",EDataType.long_raw_t);
739            dataTypeMap.put("money",EDataType.money_t);
740            dataTypeMap.put("nchar",EDataType.nchar_t);
741            dataTypeMap.put("nclob",EDataType.nclob_t);
742            dataTypeMap.put("number",EDataType.number_t);
743            dataTypeMap.put("numeric",EDataType.numeric_t);
744            dataTypeMap.put("ntext",EDataType.nvarchar_t);
745            dataTypeMap.put("nvarchar",EDataType.nvarchar_t);
746            dataTypeMap.put("period",EDataType.period_t);
747            dataTypeMap.put("real",EDataType.real_t);
748            dataTypeMap.put("refcursor",EDataType.refcursor_t);
749            dataTypeMap.put("rowid",EDataType.rowid_t);
750            dataTypeMap.put("serial",EDataType.serial_t);
751            dataTypeMap.put("signtype",EDataType.signtype_t);
752            dataTypeMap.put("simple_integer",EDataType.simple_integer_t);
753            dataTypeMap.put("smalldatetime",EDataType.datetime_t);
754            dataTypeMap.put("smallint",EDataType.smallint_t);
755            dataTypeMap.put("smallmoney",EDataType.smallmoney_t);
756            dataTypeMap.put("sql_variant",EDataType.sql_variant_t);
757            dataTypeMap.put("string",EDataType.string_t);
758            dataTypeMap.put("text",EDataType.text_t);
759            dataTypeMap.put("time",EDataType.time_t);
760            dataTypeMap.put("timestamp",EDataType.timestamp_t);
761            dataTypeMap.put("tinyint",EDataType.tinyint_t);
762            dataTypeMap.put("uniqueidentifier",EDataType.uniqueidentifier_t);
763            dataTypeMap.put("uuid",EDataType.uuid_t);
764            dataTypeMap.put("varbinary",EDataType.varbinary_t);
765            dataTypeMap.put("varbyte",EDataType.varbyte_t);
766            dataTypeMap.put("varchar",EDataType.varchar_t);
767            dataTypeMap.put("xml",EDataType.xml_t);
768            dataTypeMap.put("xmltype",EDataType.xml_t);
769        }
770
771        return dataTypeMap.get(typenameStr.toLowerCase());
772    }
773
774    private String charsetName = null;
775    private String collationName = null;
776    private TColumnDefinitionList columnDefList;
777
778    public void setCharsetAndCollation(TDummy dummy){
779        if (dummy == null) return;
780        if (dummy.int1 == 1){ // character set
781            charsetName = dummy.node1.toString();
782        }else if (dummy.int1 == 2){ // collation
783            collationName = dummy.node1.toString();
784        }else if (dummy.int1 == 3){ // character set and  collation
785            charsetName = dummy.node1.toString();
786            collationName = dummy.node2.toString();
787        }
788//        if (dummy.node1 != null){
789//            charsetName = dummy.node1.toString();
790//        }
791//        if (dummy.st1 != null){
792//            collationName = dummy.node2.toString();
793//        }
794    }
795
796    public void setCharsetNameByToken(TSourceToken st){
797        if (st == null) return;
798        charsetName = st.toString();
799    }
800    public void setCharsetName(String charsetName) {
801        this.charsetName = charsetName;
802    }
803
804    public void setCollationName(String collationName) {
805        this.collationName = collationName;
806    }
807
808    public String getCharsetName() {
809        if (charsetName != null)  return charsetName;
810        if (characterDatatypeProperty != null) return characterDatatypeProperty.getCharacterSetName();
811        return null;
812    }
813
814
815    public String getCollationName() {
816        return collationName;
817    }
818
819    private TTypeName typeOfList;
820    private TTypeName primitiveTypeOfMap;
821    private TTypeName typeOfMap;
822
823    public void setColTypeList(TPTNodeList<TTypeName> colTypeList) {
824        this.colTypeList = colTypeList;
825    }
826
827    public TPTNodeList<TTypeName> getColTypeList() {
828
829        return colTypeList;
830    }
831
832    private TPTNodeList <TTypeName> colTypeList;
833
834    public void setColumnDefList(TColumnDefinitionList columnDefList) {
835        this.columnDefList = columnDefList;
836    }
837
838    /**
839     * Fields in the BigQuery struct &lt;fields&gt;
840     *
841     * @return BigQuery struct &lt;fields&gt;
842     */
843    public TColumnDefinitionList getColumnDefList() {
844
845        return columnDefList;
846    }
847
848    public void setTypeOfMap(TTypeName typeOfMap) {
849        this.typeOfMap = typeOfMap;
850    }
851
852    public void setPrimitiveTypeOfMap(TTypeName primitiveTypeOfMap) {
853
854        this.primitiveTypeOfMap = primitiveTypeOfMap;
855    }
856
857    public TTypeName getTypeOfMap() {
858
859        return typeOfMap;
860    }
861
862    public TTypeName getPrimitiveTypeOfMap() {
863
864        return primitiveTypeOfMap;
865    }
866
867    public void setTypeOfList(TTypeName typeOfList) {
868        this.typeOfList = typeOfList;
869    }
870
871    /**
872     * Type of &lt;T&gt; in Hive, BigQuery Array &lt;T&gt;. BigQuery struct &lt;T&gt;
873     *
874     * @return HIVE, BigQuery element type of Array &lt;T&gt;, struct &lt;T&gt;
875     */
876    public TTypeName getTypeOfList() {
877
878        return typeOfList;
879    }
880
881    public void setDataTypeByObjectName(TObjectName objectName){
882        if (objectName == null) return;
883        dataTypeObjectName = objectName;
884        String tokenText = TBaseType.getTextWithoutQuoted(objectName.toString());
885        EDataType t = searchTypeByName(tokenText);
886        if (t != null){
887            dataType = t;
888        }else if(dataType == EDataType.generic_t){
889            if (dataTypeName == null){
890                dataTypeName = objectName.toString();
891            }
892        }
893    }
894    public void setDataTypeByToken(TSourceToken st){
895        if (st == null) return;
896        String tokenText = st.getTextWithoutQuoted();
897        EDataType t = searchTypeByName(tokenText);
898        if (t != null){
899            dataType = t;
900        }else if(dataType == EDataType.generic_t){
901            if (dataTypeName == null){
902                dataTypeName = st.toString();
903            }
904        }
905    }
906
907    private String dataTypeName = null;
908    private TObjectName dataTypeObjectName = null;
909
910    public TObjectName getDataTypeObjectName() {
911        return dataTypeObjectName;
912    }
913
914    /**
915     * The string representation of the datatype
916     * @return The string representation of the datatype
917     */
918    public String getDataTypeName() {
919        switch (dataType){
920            case double_precision_t:
921                return "double precision";
922            case unsigned_int_t:
923                return "unsigned int";
924            case long_raw_t:
925                return "long raw";
926            case binary_float_t:
927                return "binary float";
928            case binary_double_t:
929                return "binary double";
930            case timestamp_with_time_zone_t:
931            case timestamp_with_local_time_zone_t:
932                return "timestamp";
933            case interval_year_to_month_t:
934                return "interval year";
935            case interval_day_to_second_t:
936                return "interval day";
937            case generic_t:
938                if (dataTypeName != null){
939                    return dataTypeName;
940                }
941                else if (getStartToken() != null){
942                    return getStartToken().toString();
943                }else
944                    return "";
945            case unknown_t:
946                if (dataTypeName != null){
947                    return dataTypeName;
948                }
949                else if (getStartToken() != null){
950                    return getStartToken().toString();
951                }else
952                    return "";
953            default:
954                break;
955        }
956
957        if (dataTypeName != null)  return dataTypeName;
958
959        String ret = getDataType().toString();
960        if (ret.endsWith("_t")){
961            ret = ret.substring(0,ret.length()-2);
962        }
963        return  ret;
964
965    }
966
967    private EDataType dataType = EDataType.unknown_t;
968
969    public void setDataType(EDataType dataType) {
970        this.dataType = dataType;
971    }
972
973    /**
974     *
975     * @return a value of {@link EDataType}
976     *
977     */
978    public EDataType getDataType() {
979
980        return dataType;
981    }
982
983
984
985    private TConstant start; //informix serial (start)
986
987    public void setStart(TConstant start) {
988        this.start = start;
989    }
990
991    public TConstant getStart() {
992
993        return start;
994    }
995
996    private TConstant Max;      //informix nvarchar(max,reserve)
997
998    public void setMax(TConstant max) {
999        Max = max;
1000    }
1001
1002    public void setReserve(TConstant reserve) {
1003        Reserve = reserve;
1004    }
1005
1006    public TConstant getMax() {
1007
1008        return Max;
1009    }
1010
1011    public TConstant getReserve() {
1012        return Reserve;
1013    }
1014
1015    private TConstant Reserve; //informix nvarchar(max,reserve)
1016
1017    private TConstant length;
1018
1019    /**
1020     * mysql display length for integer datatype
1021     * @return constant
1022     */
1023    public TConstant getDisplayLength() {
1024        return displayLength;
1025    }
1026
1027    private TConstant displayLength; // mysql display length for integer, https://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20/3135854#3135854
1028
1029    public void setLength(TConstant length) {
1030        this.length = length;
1031    }
1032
1033    /**
1034     * it's a number, or a max constant.
1035     * @return a value of {@link TConstant}, length of this datatype.
1036     */
1037    public TConstant getLength() {
1038        return length;
1039    }
1040
1041    private TConstant precision;
1042    private TConstant scale;
1043    private TConstant storageFormat;
1044
1045    private TConstant secondsPrecision;
1046
1047    /**
1048     *
1049     * @return a value of {@link TConstant}, typically the second precision value of datatype.
1050     */
1051    public TConstant getSecondsPrecision() {
1052        return secondsPrecision;
1053    }
1054
1055    public void setPrecision(TConstant precision) {
1056        this.precision = precision;
1057    }
1058
1059    /**
1060     *
1061     * @return  a value of {@link TConstant}, scale value of datatypes such as numeric, float.
1062     */
1063    public TConstant getScale() {
1064        return scale;
1065    }
1066
1067    /**
1068     *
1069     * @return a value of {@link TConstant}, precision value of datatypes such as numeric, float.
1070     */
1071    public TConstant getPrecision() {
1072
1073        return precision;
1074    }
1075
1076    public void setScale(TConstant scale) {
1077        this.scale = scale;
1078    }
1079
1080    /**
1081     * For VECTOR type, returns the storage format (DENSE or SPARSE).
1082     *
1083     * @return a value of {@link TConstant}, storage format of VECTOR type.
1084     */
1085    public TConstant getStorageFormat() {
1086        return storageFormat;
1087    }
1088
1089    public void setStorageFormat(TConstant storageFormat) {
1090        this.storageFormat = storageFormat;
1091    }
1092
1093    public void setPrecisionScale(TPrecisionScale precisionScale){
1094        if (precisionScale != null){
1095           precision = precisionScale.getPrecision();
1096           scale = precisionScale.getScale();
1097           storageFormat = precisionScale.getStorageFormat();
1098        }
1099    }
1100
1101    private TPTNodeList <TIndices> arrays;
1102
1103    /**
1104     * index value of datetype in PostgreSQL. like this: SimpleTypename ARRAY [n,...].
1105     *
1106     * @return  a list of {@link TIndices},
1107     */
1108    public TPTNodeList<TIndices> getArrays() {
1109        return arrays;
1110    }
1111
1112    public void setArrays(TPTNodeList<TIndices> arrays) {
1113
1114        this.arrays = arrays;
1115    }
1116
1117    private TPTNodeList <TDatatypeAttribute> datatypeAttributeList;
1118
1119    public void setDatatypeAttributeList(TPTNodeList <TDatatypeAttribute> datatypeAttributeList) {
1120        this.datatypeAttributeList = datatypeAttributeList;
1121    }
1122
1123    /**
1124     * datatype attribute element.
1125     * @return a list of {@link TDatatypeAttribute}
1126     */
1127    public TPTNodeList <TDatatypeAttribute> getDatatypeAttributeList() {
1128
1129        if (datatypeAttributeList == null){
1130            datatypeAttributeList = new TPTNodeList <TDatatypeAttribute> ();
1131        }
1132        return datatypeAttributeList;
1133    }
1134
1135    public void init(Object arg1,Object arg2,Object arg3){
1136        init(arg1,arg2);
1137
1138        if (arg3 != null) {
1139            switch (dataType){
1140                case  interval_year_to_month_t:
1141                    break;
1142                case  interval_day_to_second_t:
1143                case  interval_second_t:
1144                case interval_minute_to_second_t:
1145                case interval_hour_to_second_t:
1146                    this.secondsPrecision = (TConstant)arg3;
1147                    break;
1148                case map_t:
1149                    keyType = (TTypeName) arg2;
1150                    valueType = (TTypeName)arg3;
1151                    break;
1152                case string_t:
1153                    collationName = ((TObjectName)arg3).toString();
1154                    break;
1155                case generic_t:
1156                    if (arg3 instanceof TObjectName) {
1157                        this.dataTypeName = ((TObjectName) arg3).toString();
1158                    }
1159
1160                    break;
1161                default:
1162                    break;
1163            }
1164        }
1165    }
1166
1167    public void setTypeModifiers(TExpressionList exprList){
1168       if (exprList == null) return;
1169        if (exprList.size() == 1){
1170            TExpression e = exprList.getExpression(0);
1171            if (e.getExpressionType() == EExpressionType.simple_constant_t)
1172                precision = e.getConstantOperand();
1173        }else if (exprList.size() == 2){
1174            TExpression e = exprList.getExpression(0);
1175            if (e.getExpressionType() == EExpressionType.simple_constant_t)
1176                precision = e.getConstantOperand();
1177            TExpression e1 = exprList.getExpression(1);
1178            if (e1.getExpressionType() == EExpressionType.simple_constant_t)
1179                scale = e1.getConstantOperand();
1180        }
1181
1182    }
1183
1184    private TTypeName elementType;
1185    private TTypeName keyType;
1186    private TTypeName valueType;
1187
1188    public TTypeName getElementType() {
1189        return elementType;
1190    }
1191
1192    public TTypeName getKeyType() {
1193        return keyType;
1194    }
1195
1196    public TTypeName getValueType() {
1197        return valueType;
1198    }
1199
1200    public void init(Object arg1, Object arg2){
1201        init(arg1);
1202
1203        if ((arg2 != null) ){
1204
1205            switch (dataType){
1206                case interval_day_to_second_t:
1207                case interval_year_to_month_t:
1208                case interval_second_t:
1209                case interval_minute_to_second_t:
1210                case interval_hour_to_second_t:
1211                case interval_hour_to_minute_t:
1212                case interval_hour_t:
1213                case interval_day_to_minute_t:
1214                case interval_day_to_hour_t:
1215                case interval_month_t:
1216                case interval_year_t:
1217                    precision = (TConstant)arg2;
1218                    length = null;
1219                    break;
1220                case binary_t:
1221                case varbinary_t:
1222                case bytea_t:
1223                case raw_t:
1224                case char_t:
1225                case nchar_t:
1226                case varchar_t:
1227                case varchar2_t:
1228                case nvarchar_t:
1229                case nvarchar2_t:
1230                case ntext_t:
1231                case long_varbinary_t:
1232                case long_varchar_t:
1233                case character_t:
1234                case byte_t:
1235                case varbyte_t:
1236                case clob_t:
1237                case blob_t:
1238                    if (arg2 instanceof  TConstant){
1239                        length = (TConstant)arg2;
1240                    }
1241                    else if (arg2 instanceof TDummy){
1242                        length = (TConstant)(((TDummy)arg2).node1);
1243                    }
1244                    break;
1245                case timestamp_t:
1246                    if (arg2 instanceof  TConstant){
1247                        length = (TConstant)arg2;
1248                        scale = length;
1249                    }
1250                    else if (arg2 instanceof TDummy){
1251                        length = (TConstant)(((TDummy)arg2).node1);
1252                        scale = length;
1253                    }
1254                    // if scale > 6, then set length to 11, otherwise, set length to 7
1255                    // https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Data-Types.html#GUID-7B72E154-677A-4342-A1EA-C74C1EA928E6
1256
1257                    if (scale != null){
1258                        Integer tmpi = scale.getIntegerValue();
1259                        if (tmpi != null){
1260                            if (tmpi > 6){
1261                                length = new TConstant();
1262                                length.init(ELiteralType.integer_et,new TSourceToken("11"));
1263                            }else{
1264                                length = new TConstant();
1265                                length.init(ELiteralType.integer_et,new TSourceToken("7"));
1266                            }
1267                        }
1268                    }
1269
1270                    break;
1271                case time_t:
1272                case timetz_t:
1273                case timentz_t:
1274                case timestamp_with_time_zone_t:
1275                case timestamp_with_local_time_zone_t:
1276                    if (arg2 instanceof  TConstant){
1277                        fractionalSecondsPrecision = (TConstant)arg2;
1278                    }
1279                    else if (arg2 instanceof TDummy){
1280                        fractionalSecondsPrecision = (TConstant)(((TDummy)arg2).node1);
1281                    }
1282                    break;
1283                case string_t:
1284                    if (arg2 instanceof TConstant){ //snowflake
1285                        this.length = (TConstant)arg2;
1286//                    }else if (arg2 instanceof TObjectName){  //bigquery
1287//                        collationName = ((TObjectName)arg2).toString();
1288                    } else if (arg2 instanceof TDummy){
1289                        length = (TConstant)(((TDummy)arg2).node1);
1290                    }
1291
1292                    break;
1293                case xml_t:
1294                case xmltype_t:
1295                    this.precision = ((TPrecisionScale)arg2).getPrecision();
1296                    this.scale = ((TPrecisionScale)arg2).getScale();
1297                    break;
1298                case array_t:
1299                case set_t:
1300                    this.elementType = (TTypeName)arg2;
1301                    break;
1302                case vargraphic_t:
1303                    this.length = (TConstant)arg2;
1304                    break;
1305                case int_t:
1306                case int2_t:
1307                case int4_t:
1308                case bigint_t:
1309                    if (arg2 instanceof TDummy){ //mysql display length
1310                        this.displayLength = (TConstant)(((TDummy)arg2).node1);
1311                    }
1312                    break;
1313                case generic_t:
1314                    if (arg2 instanceof TObjectName) {
1315                        this.dataTypeName = ((TObjectName) arg2).toString();
1316                    }
1317                    break;
1318                default:
1319                    if (arg2 instanceof TPrecisionScale){
1320                        this.precision = ((TPrecisionScale)arg2).getPrecision();
1321                        this.scale = ((TPrecisionScale)arg2).getScale();
1322                        this.storageFormat = ((TPrecisionScale)arg2).getStorageFormat();
1323                        if (dataType == EDataType.period_t){
1324                            secondsPrecision = ((TPrecisionScale)arg2).getPrecision();
1325                        }
1326                    }else if (arg2 instanceof TDummy){ //opt_float rule in y file
1327                        this.precision = (TConstant)(((TDummy)arg2).node1);
1328                    }else if (arg2 instanceof TConstant){
1329                        this.length = (TConstant)arg2;
1330                    }
1331                    break;
1332            }
1333        }
1334    }
1335
1336    public void init(Object arg1){
1337        dataType = (EDataType)arg1;
1338    }
1339
1340    public void setByteUnit(boolean byteUnit) {
1341        this.byteUnit = byteUnit;
1342    }
1343
1344    public void setCharUnit(boolean charUnit) {
1345        this.charUnit = charUnit;
1346    }
1347
1348    public void setVarying(boolean varying) {
1349        this.varying = varying;
1350    }
1351
1352    public void setSecondsPrecision(TConstant secondsPrecision) {
1353        this.secondsPrecision = secondsPrecision;
1354    }
1355
1356    public void setCharUnit(TSourceToken st){
1357        if (st == null) return;
1358        if (st.tokencode == TBaseType.rrw_char){
1359            charUnit = true;
1360        }else{
1361            byteUnit = true;
1362        }
1363
1364    }
1365
1366    public void setVarying(TSourceToken st){
1367        if (st != null){
1368            varying = true;
1369            switch (dataType){
1370                case char_t:
1371                    dataType = EDataType.varchar_t;
1372                    break;
1373                case nchar_t:
1374                    dataType = EDataType.nvarchar_t;
1375                    break;
1376                case bit_t:
1377                    dataType = EDataType.varbit_t;
1378                    break;
1379                default:
1380                    break;
1381            }
1382        }
1383    }
1384
1385    /**
1386     * used in y file,  setup dbobject type of all source tokens consist of this datatype.
1387     */
1388    public void setDataTypeInTokens(){
1389        if (this.getStartToken() == null) return;
1390        if (this.getEndToken() == null) return;
1391        TSourceTokenList stlist = this.getStartToken().container;
1392        TSourceToken st = null;
1393        int level = 0;
1394        for(int i= this.getStartToken().posinlist; i<=this.getEndToken().posinlist;i++){
1395            st = stlist.get(i);
1396            if (st.tokentype == ETokenType.ttleftparenthesis){ level++; continue;}
1397            if (st.tokentype == ETokenType.ttrightparenthesis){ level--; continue;}
1398            if (level == 0){
1399                st.setDbObjType(TObjectName.ttobjDatatype);
1400            }
1401        }
1402
1403        if ((this.type == TTypeName.lfdGeneric)||(this.dataType == EDataType.generic_t)){
1404//            st= getStartToken();
1405//            if (st.toString().equalsIgnoreCase("datetime")){
1406//                this.type = lfdDatetime;
1407//                dataType = EDataType.datetime_t;
1408//            }
1409            setDataTypeByToken(getStartToken());
1410        }
1411    }
1412
1413
1414    public void setIntervalType(TDummy dummy){
1415        if (dummy == null) return;
1416        TSourceToken startToken = dummy.getStartToken();
1417        if (startToken == null) return;
1418        TSourceToken endToken = dummy.getEndToken();
1419        if (endToken == null) return;
1420        TSourceTokenList stlist = startToken.container;
1421        
1422        boolean hasYear = false;
1423        boolean hasMonth = false;
1424        boolean hasDay = false;
1425        boolean hasHour = false;
1426        boolean hasMinute = false;
1427        boolean hasSecond = false;
1428        boolean hasTo = false;
1429        
1430        // For better pattern detection, track token positions
1431        int yearPos = -1;
1432        int monthPos = -1;
1433        int dayPos = -1;
1434        int hourPos = -1;
1435        int minutePos = -1;
1436        int secondPos = -1;
1437        int toPos = -1;
1438        
1439        // Scan tokens to determine interval type
1440        for (int i = startToken.posinlist; i <= endToken.posinlist; i++) {
1441            TSourceToken st = stlist.get(i);
1442            String tokenText = st.toString().toLowerCase();
1443            
1444            if (tokenText.equals("year") || tokenText.equals("years")) {
1445                hasYear = true;
1446                yearPos = i;
1447            } else if (tokenText.equals("month") || tokenText.equals("months")) {
1448                hasMonth = true;
1449                monthPos = i;
1450            } else if (tokenText.equals("day") || tokenText.equals("days")) {
1451                hasDay = true;
1452                dayPos = i;
1453            } else if (tokenText.equals("hour") || tokenText.equals("hours")) {
1454                hasHour = true;
1455                hourPos = i;
1456            } else if (tokenText.equals("minute") || tokenText.equals("minutes")) {
1457                hasMinute = true;
1458                minutePos = i;
1459            } else if (tokenText.equals("second") || tokenText.equals("seconds")) {
1460                hasSecond = true;
1461                secondPos = i;
1462            } else if (tokenText.equals("to")) {
1463                hasTo = true;
1464                toPos = i;
1465            }
1466        }
1467        
1468        // Determine interval type based on patterns and token positions
1469        if (hasTo) {
1470            // Check for YEAR TO MONTH pattern
1471            if (hasYear && hasMonth && yearPos < toPos && toPos < monthPos) {
1472                setDataType(EDataType.interval_year_to_month_t);
1473                return;
1474            }
1475            
1476            // Check for DAY TO SECOND pattern
1477            if (hasDay && hasSecond && dayPos < toPos && toPos < secondPos) {
1478                setDataType(EDataType.interval_day_to_second_t);
1479                return;
1480            }
1481            
1482            // Check for DAY TO MINUTE pattern
1483            if (hasDay && hasMinute && dayPos < toPos && toPos < minutePos) {
1484                setDataType(EDataType.interval_day_to_minute_t);
1485                return;
1486            }
1487            
1488            // Check for DAY TO HOUR pattern
1489            if (hasDay && hasHour && dayPos < toPos && toPos < hourPos) {
1490                setDataType(EDataType.interval_day_to_hour_t);
1491                return;
1492            }
1493            
1494            // Check for HOUR TO SECOND pattern
1495            if (hasHour && hasSecond && hourPos < toPos && toPos < secondPos) {
1496                setDataType(EDataType.interval_hour_to_second_t);
1497                return;
1498            }
1499            
1500            // Check for HOUR TO MINUTE pattern
1501            if (hasHour && hasMinute && hourPos < toPos && toPos < minutePos) {
1502                setDataType(EDataType.interval_hour_to_minute_t);
1503                return;
1504            }
1505            
1506            // Check for MINUTE TO SECOND pattern
1507            if (hasMinute && hasSecond && minutePos < toPos && toPos < secondPos) {
1508                setDataType(EDataType.interval_minute_to_second_t);
1509                return;
1510            }
1511        }
1512        
1513        // Single-unit interval types (no TO keyword or not a recognized pattern)
1514        if (hasYear) {
1515            setDataType(EDataType.interval_year_t);
1516        } else if (hasMonth) {
1517            setDataType(EDataType.interval_month_t);
1518        } else if (hasDay) {
1519            setDataType(EDataType.interval_day_t);
1520        } else if (hasHour) {
1521            setDataType(EDataType.interval_hour_t);
1522        } else if (hasMinute) {
1523            setDataType(EDataType.interval_minute_t);
1524        } else if (hasSecond) {
1525            setDataType(EDataType.interval_second_t);
1526        } else {
1527            // Default to generic interval type if specific type can't be determined
1528            setDataType(EDataType.interval_t);
1529        }
1530    }
1531
1532    public void accept(TParseTreeVisitor v){
1533        v.preVisit(this);
1534        v.postVisit(this);
1535    }
1536
1537    public void acceptChildren(TParseTreeVisitor v){
1538        v.preVisit(this);
1539        v.postVisit(this);
1540    }
1541
1542
1543    
1544
1545// following datatype const was deprecated  since v1.4.3.0.
1546// DON'T use those const, use EDataType instead.
1547
1548    public void setType(int type) {
1549        this.type = type;
1550//        switch (type){
1551//            case lfdGeneric:
1552//                this.dataType = EDataType.generic_t;
1553//                break;
1554//            case lfdFloat:
1555//                this.dataType = EDataType.float_t;
1556//                break;
1557//            case lfdDoublePrecision:
1558//                this.dataType = EDataType.double_t;
1559//                break;
1560//            case lfdDecimal:
1561//            case lfdDec:
1562//                this.dataType = EDataType.dec_t;
1563//                break;
1564//            case lfdNumeric:
1565//                this.dataType = EDataType.numeric_t;
1566//                break;
1567//            case lfdnumber:
1568//            case lfdNum:
1569//                this.dataType = EDataType.number_t;
1570//                break;
1571//            case lfdInteger:
1572//            case lfdInt:
1573//                this.dataType = EDataType.int_t;
1574//                break;
1575//            case lfdBit:
1576//                this.dataType = EDataType.bit_t;
1577//                break;
1578//            case lfdBoolean:
1579//                this.dataType = EDataType.bool_t;
1580//                break;
1581//            case lfdVarbinary:
1582//                this.dataType = EDataType.varbinary_t;
1583//                break;
1584//            case lfdBinary:
1585//                this.dataType = EDataType.binary_t;
1586//                break;
1587//            case lfdSmallint:
1588//                dataType = EDataType.smallint_t;
1589//                break;
1590//            case lfdReal:
1591//                dataType = EDataType.real_t;
1592//                break;
1593//            case lfdTinyInt:
1594//                dataType = EDataType.tinyint_t;
1595//                break;
1596//            case lfdBigInt:
1597//                dataType = EDataType.bigint_t;
1598//                break;
1599//            case lfdCharacter:
1600//            case lfdChar:
1601//                dataType = EDataType.char_t;
1602//                break;
1603//            case lfdVarchar:
1604//            case lfdCharVar:
1605//            case lfdCharacterVar:
1606//            case lfdCharacterVarying:
1607//            case lfdCharVarying:
1608//                dataType = EDataType.varchar_t;
1609//                break;
1610//            case lfdVarchar2:
1611//                dataType = EDataType.varchar2_t;
1612//                break;
1613//            case lfdNvarchar2:
1614//                dataType = EDataType.nvarchar2_t;
1615//                break;
1616//            case lfdNationalCharacter:
1617//            case lfdNationalChar:
1618//            case lfdNchar:
1619//                dataType = EDataType.nchar_t;
1620//                break;
1621//            case lfdNVarchar:
1622//            case lfdNationalCharVarying:
1623//            case lfdNcharVarying:
1624//                dataType = EDataType.nvarchar_t;
1625//                break;
1626//            case lfdLongvarchar:
1627//                dataType = EDataType.long_varchar_t;
1628//                break;
1629//            case lfdLongvarbinary:
1630//                dataType = EDataType.long_varbinary_t;
1631//                break;
1632//            case lfdYear:
1633//                dataType = EDataType.year_t;
1634//                break;
1635//            case lfdDate:
1636//                dataType = EDataType.date_t;
1637//                break;
1638//            case lfdTimestamp:
1639//                dataType = EDataType.timestamp_t;
1640//                break;
1641//            case lfdTimeStampWithTZ:
1642//                dataType = EDataType.timestamp_with_time_zone_t;
1643//                break;
1644//            case lfdTimeStampWithLTZ:
1645//                dataType = EDataType.timestamp_with_local_time_zone_t;
1646//                break;
1647//            case lfdTime:
1648//                dataType = EDataType.time_t;
1649//                break;
1650//            case lfdDatetime:
1651//                dataType = EDataType.datetime_t;
1652//                break;
1653//            case lfdIntervalYTM:
1654//            case lfdIntervalYearToMonth:
1655//                dataType = EDataType.interval_year_to_month_t;
1656//                break;
1657//            case lfdIntervalDTS:
1658//            case lfdIntervalDayToSecond:
1659//                dataType = EDataType.interval_day_to_second_t;
1660//                break;
1661//            case lfdLong:
1662//                dataType = EDataType.long_t;
1663//                break;
1664//            case lfdRaw:
1665//                dataType = EDataType.raw_t;
1666//                break;
1667//            case lfdLongRaw:
1668//                dataType = EDataType.long_raw_t;
1669//                break;
1670//            case lfdBlob:
1671//                dataType = EDataType.blob_t;
1672//                break;
1673//            case lfdClob:
1674//                dataType = EDataType.clob_t;
1675//                break;
1676//            case lfdNClob:
1677//                dataType = EDataType.nclob_t;
1678//                break;
1679//            case lfdBfile:
1680//                dataType = EDataType.bfile_t;
1681//                break;
1682//            case lfdTinyblob:
1683//                dataType = EDataType.tinyblob_t;
1684//                break;
1685//            case lfdMediumblob:
1686//                dataType = EDataType.mediumblob_t;
1687//                break;
1688//            case lfdLongblob:
1689//                dataType = EDataType.longblob_t;
1690//                break;
1691//            case lfdTinytext:
1692//                dataType = EDataType.tinytext_t;
1693//                break;
1694//            case lfdText:
1695//                dataType = EDataType.text_t;
1696//                break;
1697//            case lfdntext:
1698//                dataType = EDataType.ntext_t;
1699//                break;
1700//            case lfdMediumtext:
1701//                dataType = EDataType.mediumtext_t;
1702//                break;
1703//            case lfdLongtext:
1704//                dataType = EDataType.longtext_t;
1705//                break;
1706//            case lfdURowid:
1707//                dataType= EDataType.urowid_t;
1708//                break;
1709//            case lfdEnum:
1710//                dataType = EDataType.enum_t;
1711//                break;
1712//            case lfdBinaryLargeObject:
1713//                dataType = EDataType.binary_large_object_t;
1714//                break;
1715//            case lfdGraphic:
1716//                dataType = EDataType.graphic_t;
1717//                break;
1718//            case lfdVarGraphic:
1719//                dataType = EDataType.vargraphic_t;
1720//                break;
1721//            case lfdLongVarGraphic:
1722//                dataType = EDataType.long_vargraphic_t;
1723//                break;
1724//            case lfdDatalink:
1725//                dataType = EDataType.datalink_t;
1726//                break;
1727//            case lfdBinaryInteger:
1728//                dataType = EDataType.binary_integer_t;
1729//                break;
1730//            case lfdPlsInteger:
1731//                dataType = EDataType.pls_integer_t;
1732//                break;
1733//            case lfdByteint:
1734//                dataType = EDataType.byteint_t;
1735//                break;
1736//            case lfdTimeWithTZ:
1737//                dataType = EDataType.timetz_t;
1738//                break;
1739//            case lfdIntervalYear:
1740//                dataType = EDataType.interval_year_t;
1741//                break;
1742//            case lfdIntervalMonth:
1743//                dataType = EDataType.interval_month_t;
1744//                break;
1745//            case lfdIntervalDay:
1746//                dataType = EDataType.interval_day_t;
1747//                break;
1748//            case lfdIntervalDayToHour:
1749//                dataType = EDataType.interval_day_to_hour_t;
1750//                break;
1751//            case lfdIntervalDayToMinute:
1752//                dataType = EDataType.interval_day_to_minute_t;
1753//                break;
1754//            case lfdIntervalHour:
1755//                dataType = EDataType.interval_hour_t;
1756//                break;
1757//            case lfdIntervalHourToMinute:
1758//                dataType = EDataType.interval_hour_to_minute_t;
1759//                break;
1760//            case lfdIntervalHourToSecond:
1761//                dataType = EDataType.interval_hour_to_second_t;
1762//                break;
1763//            case lfdIntervalMinute:
1764//                dataType = EDataType.interval_minute_t;
1765//                break;
1766//            case lfdIntervalMinuteToSecond:
1767//                dataType = EDataType.interval_minute_to_second_t;
1768//                break;
1769//            case lfdIntervalSecond:
1770//                dataType = EDataType.interval_second_t;
1771//                break;
1772//            case lfdByte:
1773//                dataType = EDataType.byte_t;
1774//                break;
1775//            case lfdVarByte:
1776//                dataType = EDataType.varbyte_t;
1777//                break;
1778//            case lfdPeriod:
1779//                dataType = EDataType.period_t;
1780//                break;
1781//            case lfdCharacterLargeObject:
1782//            case lfdCharLargeObject:
1783//                dataType = EDataType.char_large_object_t;
1784//                break;
1785//            case lfdGeoMetry:
1786//                dataType = EDataType.geometry_t;
1787//                break;
1788//            case lfdGeoGraphy:
1789//                dataType = EDataType.geography_t;
1790//                break;
1791//            case lfdSet:
1792//                dataType = EDataType.set_t;
1793//                break;
1794//            case lfdDBClob:
1795//                dataType = EDataType.dbclob_t;
1796//                break;
1797//            case lfdInterval:
1798//                dataType = EDataType.interval_t;
1799//                break;
1800//            default:
1801//                break;
1802//        }
1803    }
1804
1805    public int getType() {
1806
1807        return type;
1808    }
1809
1810    private int type = lfdUnknown;
1811
1812    /**
1813     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#unknown_t}
1814     */
1815public final static int lfdUnknown = 2;
1816    /**
1817     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#generic_t}
1818     */
1819public final static int lfdGeneric  = 3;
1820    /**
1821     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#float_t}
1822     */
1823public final static int lfdFloat  = 4;
1824    /**
1825     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#double_t}
1826     */
1827public final static int lfdDoublePrecision  = 8;
1828    /**
1829     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#dec_t}
1830     */
1831public final static int lfdDecimal = 9;
1832    /**
1833     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#dec_t}
1834     */
1835public final static int lfdDec  = 10;
1836    /**
1837     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#numeric_t}
1838     */
1839public final static int lfdNumeric  = 11;
1840    /**
1841     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#number_t}
1842     */
1843public final static int lfdnumber  = 12;
1844    /**
1845     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#number_t}
1846     */
1847public final static int lfdNum  = 13;
1848    /**
1849     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#int_t}
1850     */
1851public final static int lfdInteger  = 14;
1852    /**
1853     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#bit_t}
1854     */
1855public final static int lfdBit  = 22;
1856    /**
1857     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#bool_t}
1858     */
1859public final static int lfdBoolean  = 23;
1860    /**
1861     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varbinary_t}
1862     */
1863public final static int lfdVarbinary = 33;
1864    /**
1865     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#binary_t}
1866     */
1867public final static int lfdBinary = 34;
1868    /**
1869     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#int_t}
1870     */
1871public final static int lfdInt  = 40;
1872    /**
1873     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#smallint_t}
1874     */
1875public final static int lfdSmallint  = 41;
1876    /**
1877     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#real_t}
1878     */
1879public final static int lfdReal  = 42;
1880    /**
1881     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#tinyint_t}
1882     */
1883public final static int lfdTinyInt  = 43;
1884//        public final static int lfdMediumInt  = 44;
1885/**
1886 * @deprecated As of v1.4.3.0, replaced by {@link EDataType#bigint_t}
1887 */
1888public final static int lfdBigInt  = 45;
1889    /**
1890     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#char_t}
1891     */
1892public final static int lfdCharacter  = 46;
1893    /**
1894     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#char_t}
1895     */
1896public final static int lfdChar  = 47;
1897    /**
1898     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varchar_t}
1899     */
1900public final static int lfdVarchar  = 48;
1901    /**
1902     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varchar2_t}
1903     */
1904public final static int lfdVarchar2  = 49;
1905//        public final static int lfdbinaryVar  = 55;
1906    /**
1907     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#long_varchar_t}
1908     */
1909public final static int lfdLongvarchar = 56;
1910    /**
1911     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#long_varbinary_t}
1912     */
1913public final static int lfdLongvarbinary = 57;
1914//        public final static int lfdMySQLSet  = 58;
1915    /**
1916     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#year_t}
1917     */
1918public final static int lfdYear  = 59;
1919//        public final static int lfdDouble  = 60;
1920    /**
1921     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#nchar_t}
1922     */
1923public final static int lfdNationalChar  = 61;
1924    /**
1925     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#nchar_t}
1926     */
1927public final static int lfdNchar  = 62;
1928    /**
1929     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#date_t}
1930     */
1931public final static int lfdDate  = 63;
1932    /**
1933     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#timestamp_t}
1934     */
1935public final static int lfdTimestamp = 64;
1936    /**
1937     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#timestamp_with_time_zone_t}
1938     */
1939public final static int lfdTimeStampWithTZ  = 65;
1940    /**
1941     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#timestamp_with_local_time_zone_t}
1942     */
1943public final static int lfdTimeStampWithLTZ  = 66;
1944//        public final static int lfdDateWithFmt  = 67;
1945    /**
1946     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#time_t}
1947     */
1948public final static int lfdTime  = 68;
1949    /**
1950     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#datetime_t}
1951     */
1952public final static int lfdDatetime  = 69;
1953//        public final static int lfdsmalldatetime  = 70;
1954    /**
1955     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_year_to_month_t}
1956     */
1957public final static int lfdIntervalYTM  = 71;
1958    /**
1959     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_day_to_second_t}
1960     */
1961public final static int lfdIntervalDTS  = 72;
1962    /**
1963     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#long_t}
1964     */
1965public final static int lfdLong  = 73;
1966    /**
1967     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#raw_t}
1968     */
1969public final static int lfdRaw  = 74;
1970    /**
1971     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#long_raw_t}
1972     */
1973public final static int lfdLongRaw  = 75;
1974    /**
1975     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#blob_t}
1976     */
1977public final static int lfdBlob  = 76;
1978    /**
1979     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#clob_t}
1980     */
1981public final static int lfdClob  = 77;
1982    /**
1983     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#nclob_t}
1984     */
1985public final static int lfdNClob  = 78;
1986    /**
1987     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#bfile_t}
1988     */
1989public final static int lfdBfile  = 79;
1990//        public final static int lfddbclob  = 80;
1991    /**
1992     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#tinyblob_t}
1993     */
1994public final static int lfdTinyblob = 81;
1995    /**
1996     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#mediumblob_t}
1997     */
1998public final static int lfdMediumblob = 82;
1999    /**
2000     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#longblob_t}
2001     */
2002public final static int lfdLongblob = 83;
2003    /**
2004     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#tinytext_t}
2005     */
2006public final static int lfdTinytext = 84;
2007    /**
2008     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#text_t}
2009     */
2010public final static int lfdText = 85;
2011    /**
2012     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#ntext_t}
2013     */
2014public final static int lfdntext  = 86;
2015//        public final static int lfdimage  = 87;
2016    /**
2017     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#mediumtext_t}
2018     */
2019public final static int lfdMediumtext = 88;
2020    /**
2021     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#longtext_t}
2022     */
2023public final static int lfdLongtext = 89;
2024    /**
2025     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#urowid_t}
2026     */
2027public final static int lfdURowid  = 90;
2028    /**
2029     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#enum_t}
2030     */
2031public final static int lfdEnum  = 91;
2032    /**
2033     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#binary_large_object_t}
2034     */
2035public final static int lfdBinaryLargeObject = 102;
2036    /**
2037     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#graphic_t}
2038     */
2039public final static int lfdGraphic  = 103;
2040    /**
2041     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#vargraphic_t}
2042     */
2043public final static int lfdVarGraphic  = 104;
2044    /**
2045     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#long_vargraphic_t}
2046     */
2047public final static int lfdLongVarGraphic  = 105;
2048    /**
2049     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#datalink_t}
2050     */
2051public final static int lfdDatalink  = 106;
2052    /**
2053     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#binary_integer_t}
2054     */
2055public final static int lfdBinaryInteger  = 107; // plsql
2056    /**
2057     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#pls_integer_t}
2058     */
2059public final static int lfdPlsInteger  = 108; // plsql
2060    /**
2061     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#byteint_t}
2062     */
2063public final static int lfdByteint  = 120; // teradata
2064    /**
2065     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#time_with_time_zone_t}
2066     */
2067public final static int lfdTimeWithTZ  = 121; //teradata
2068    /**
2069     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_year_t}
2070     */
2071public final static int lfdIntervalYear  = 130; //teradata
2072    /**
2073     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_year_to_month_t}
2074     */
2075public final static int lfdIntervalYearToMonth  = 131; //teradata
2076    /**
2077     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_month_t}
2078     */
2079public final static int lfdIntervalMonth  = 132; //teradata
2080    /**
2081     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_day_t}
2082     */
2083public final static int lfdIntervalDay  = 133; //teradata
2084    /**
2085     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_day_to_hour_t}
2086     */
2087public final static int lfdIntervalDayToHour  = 134; //teradata
2088    /**
2089     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_day_to_minute_t}
2090     */
2091public final static int lfdIntervalDayToMinute  = 135; //teradata
2092    /**
2093     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_day_to_second_t}
2094     */
2095public final static int lfdIntervalDayToSecond  = 136; //teradata
2096    /**
2097     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_hour_t}
2098     */
2099public final static int lfdIntervalHour  = 137; //teradata
2100    /**
2101     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_hour_to_minute_t}
2102     */
2103public final static int lfdIntervalHourToMinute  = 138; //teradata
2104    /**
2105     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_hour_to_second_t}
2106     */
2107public final static int lfdIntervalHourToSecond  = 139; //teradata
2108    /**
2109     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_minute_t}
2110     */
2111public final static int lfdIntervalMinute  = 140; //teradata
2112    /**
2113     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_minute_to_second_t}
2114     */
2115public final static int lfdIntervalMinuteToSecond  = 141; //teradata
2116    /**
2117     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_second_t}
2118     */
2119public final static int lfdIntervalSecond  = 142; //teradata
2120    /**
2121     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#byte_t}
2122     */
2123public final static int lfdByte  = 143; //teradata
2124    /**
2125     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varbyte_t}
2126     */
2127public final static int lfdVarByte  = 144; //teradata
2128    /**
2129     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varchar_t}
2130     */
2131public final static int lfdCharacterVarying  = 145; //teradata
2132    /**
2133     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#varchar_t}
2134     */
2135public final static int lfdCharVarying  = 146; //teradata
2136    /**
2137     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#period_t}
2138     */
2139public final static int lfdPeriod  = 147; //teradata
2140    /**
2141     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#char_large_object_t}
2142     */
2143public final static int lfdCharacterLargeObject  = 148; //teradata
2144    /**
2145     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#geometry_t}
2146     */
2147public final static int  lfdGeoMetry = 150;//sql srever 2008
2148    /**
2149     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#geography_t}
2150     */
2151public final static int  lfdGeoGraphy = 151;//sql srever 2008
2152
2153//public final static int  lfdSigned = 160;//mysql
2154//public final static int  lfdUnSigned = 161;//mysql
2155    /**
2156     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#nvarchar_t}
2157     */
2158public final static int  lfdNationalCharVarying = 162;//mysql
2159    /**
2160     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#nvarchar_t}
2161     */
2162public final static int  lfdNcharVarying = 163;//mysql
2163    /**
2164     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#set_t}
2165     */
2166public final static int  lfdSet = 164;//mysql
2167
2168    /**
2169     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#char_large_object_t}
2170     */
2171public final static int  lfdCharLargeObject = 171;//db2
2172    /**
2173     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#dbclob_t}
2174     */
2175public final static int  lfdDBClob = 172;
2176    /**
2177     * @deprecated As of v1.4.3.0, replaced by {@link EDataType#interval_t}
2178     */
2179public final static int  lfdInterval = 181; //postgresql
2180
2181
2182/**
2183 * plsql type atribute
2184 * @deprecated As of v1.4.3.0, replaced by {@link TDatatypeAttribute}
2185 */
2186public final static int lfdTypeAtribute  = 107;
2187
2188/**
2189 * plsql rowtype atribute
2190 * @deprecated As of v1.4.3.0, replaced by {@link TDatatypeAttribute}
2191 */
2192public final static int lfdRowTypeAtribute  = 108;
2193
2194}