F.48. ltfce

F.48.1. Features Compatible with all mode
F.48.2. Functions
F.48.3. Operator type compatibility

ltfce - All mode's compatibility functions and operators.

F.48.1. Features Compatible with all mode

Features compatible with all mode are provided. Functions and operators are created under lt_catalog. The table below lists features that can be used in all mode.

Table F.26. Functions

Item

Overview

DATABASE

Return current schema as current database

LOCATE

Return the position of the substring in the string


Table F.27. Operator type compatibility

Item

LEFTARG:int2 RIGHTARG:text

LEFTARG:int4 RIGHTARG:text

LEFTARG:int8 RIGHTARG:text

LEFTARG:text RIGHTARG:int2

LEFTARG:text RIGHTARG:int4

LEFTARG:text RIGHTARG:int8

LEFTARG:text RIGHTARG:numeric

LEFTARG:numeric RIGHTARG:text


F.48.2. Functions

  • DATABASE

  • LOCATE

F.48.2.1. DATABASE

Description

Synonym for current_schema(). The concept of schema is similar to that of database in MySQL. You can specify the current schema by setting the search_path.

Syntax

database() RETURNS text
    

General rules

  • Returns the name of the schema that is first in the search path (or a null value if the search path is empty).

  • Like mysql,This is the schema that will be used for any tables or other named objects that are created without specifying a target schema.

Example

lightdb@lt_test=# select database();
 database 
----------
 public
(1 row)
    

F.48.2.2. LOCATE

Description

Return the position of the first occurrence of substring.

Syntax

LOCATE(substr TEXT,str TEXT) returns INTEGER
LOCATE(substr TEXT,str TEXT,POS INTEGER) returns INTEGER
    

General rules

  • The first syntax returns the position of the first occurrence of substring substr in string str.

  • The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos.

  • Returns 0 if substr is not in str.

  • Returns NULL if any argument is NULL.

Example

In the following example,position of 'bar' in 'foobarbar', starting at position 5. is returned.

SELECT LOCATE('bar', 'foobarbar', 5);
  locate 
--------
      7
(1 row)
    

F.48.3. Operator type compatibility

Add type overloading between text and Numeric Types(int2, int4, int8, numeric) for operators such as '+', '-', '*', '/', '<', '<=', '>', '>=', '=', '<>' and '%'.

Example

With it, you can directly add '1.1'::text with 1.

lightdb@test=# select '1.1'::text+1;
 ?column? 
----------
      2.1
(1 row)
    

When in Oracle or MySQL compatible type (see lightdb_syntax_compatible_type), base on the rule that 'unknown' can convert to 'text' in some situations (see Chapter 10 for details), you can directly add '1.1' with 1.

lightdb@test=# select '1.1'+1;
 ?column? 
----------
      2.1
(1 row)
    
English|中文