Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Communication Packages


Contents

In this section, we will present more complex communication structures – i.e. “communication packages”.

A “communication package” is a sequence of basic data which constitute a logical command send to CUBRID or a response received.

Examples of such packages are:

  • Send request to obtain a broker port to connect to
  • Send SQL command(s) to be executed
  • Receive CAS server information
  • Receive row(s) as a result of executing a SQL query
  • Receive an error information

 

SEND REQUEST packages

 

SEND_BROKER_PORT_REQUEST

 

Packet sent

Packet value

Notes

WRITE_STRING

'CUBRK'

Reserved

WRITE_BYTE

<client type id>

3 = JDBC client type

5 = OLEDB client type

WRITE_BYTE

<client version id>

CAS client/driver version. For 9.x :

 

CAS_PROTO_INDICATOR = 0x40;

CAS_PROTOCOL_VERSION = 0x01;

 

CAS_VER = CAS_PROTO_INDICATOR | CAS_PROTOCOL_VERSION;

WRITE_BYTE

0

Reserved

WRITE_BYTE

0

Reserved

WRITE_BYTE

0

Reserved

Note: The TCP/IP connection is opened using usually these ports:

  • 30000
  • 33000

SEND_OPEN_DATABASE_REQUEST

 

Packet sent

Packet value

Notes

WRITE_FIXED_STRING(32)

<database name>

 

WRITE_FIXED_STRING(32)

<user login id>

 

WRITE_FIXED_STRING(32)

<user login password>

 

WRITE_NULL_ARRAY(512)

 

Used for extended connection info(alternate hosts).

WRITE_NULL_ARRAY(20)

 

Reserved

For the next packages, the following procedure must be followed when sending data through socket:

  • Prepare buffer data:
    • Write content data length (as Integer)
    • Write CAS info (as a 4 bytes array)
    • Write actual data
  • Send/Flush buffer data
  • Clear buffer (optional)

 

SEND_CLOSE_DATABASE_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

1

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_CON_CLOSE

See Function codes

 

SEND_VERSION_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

6

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_GET_DB_VERSION

See Function codes

WRITE_BYTE

1 (= ON)

Or

0 (= OFF)

Auto-commit mode value

 

SEND_COMMIT_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

6

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_END_TRAN

See Function codes

WRITE_BYTE

1 = CCI_TRAN_COMMIT

 

 

SEND_ROLLBACK_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

6

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_END_TRAN

See Function codes

WRITE_BYTE

2 = CCI_TRAN_ROLLBACK

 

 

SEND_AUTO_COMMIT_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

17

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_SET_DB_PARAMETER

See Function codes

WRITE_INT

CCI_PARAM_AUTO_COMMIT

See Database parameters

WRITE_INT

1 (= ON)

Or

0 (= OFF)

 

 

SEND_GET_PARAMETER_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

9

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_GET_DB_PARAMETER

See Function codes

WRITE_INT

<parameter type>

See Database parameters

 

SEND_SET_PARAMETER_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

17

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_SET_DB_PARAMETER

See Function codes

WRITE_INT

<parameter type>

See Database parameters

WRITE_INT

<parameter value>

Integer value

 

SEND_BATCH_EXECUTE_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

<not fixed>

Data length in bytes (without CAS)

 

Note: You need to calculate how many statements are to be executed, as each statement is sent s a WRITE_FIXED_LENGTH_STRING packet.

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_EXECUTE_BATCH

See Function codes

WRITE_BYTE

1 (= ON)

Or

0 (= OFF)

Auto-commit mode value

WRITE_FIXED_LENGTH_STRING

First SQL statement to execute

 

… (repeat)

 

 

WRITE_FIXED_LENGTH_STRING

Last SQL statement to execute

 

Note: Do not use this function for SQL query statements, i.e. statements which return rows.

Use it only for non-query statements – for example: INSERT, UPDATE, ALTER etc.

 

SEND_PREPARE_EXECUTE_QUERY_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

<not fixed>

Data length in bytes (without CAS)

 

Note: You need to calculate the length, considering t SL query statement length.

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_PREPARE_AND_EXECUTE

See Function codes

WRITE_INT

3

Reserved

WRITE_NULL_TERMINATED_STRING

<SQL query statement>

 

WRITE_BYTE

CCI_PREPARE_NORMAL

See Query prepare modes

WRITE_BYTE

1 (= ON)

Or

0 (= OFF)

Auto-commit mode value

WRITE_BYTE

0x02 (=CCI_EXEC_QUERY_ALL)

 

WRITE_INT

0

Reserved (Max. col. size)

WRITE_INT

0

Reserved (Max. row. size)

WRITE_NULL

 

Reserved

WRITE_CACHE_TIME

<0, 0>

Reserved

 

Seconds = 0

Milliseconds = 0

WRITE_INT

<query timeout>

Usually to be set to 0

 

Compatibility: 8.4.1+

SEND_CLOSE_QUERY_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

14

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_CLOSE_REQ_HANDLE

See Function codes

WRITE_INT

<query handle>

 

WRITE_BYTE

1 (= ON)

Or

0 (= OFF)

Auto-commit mode value

 

SEND_FETCH_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

38

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_FETCH

See Function codes

WRITE_INT

<query handle>

 

WRITE_INT

Start position

= Current cursor position + 1

WRITE_INT

Fetch size

Default value is 0

Usually set to 100

WRITE_BYTE

Case sensitive?

1 (= ON) or0 (= OFF)

WRITE_INT

0

Reserved

 

SEND_SCHEMA_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

<not fixed>

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_SCHEMA_INFO

See Function codes

WRITE_INT

Schema type

See Schema types

WRITE_NULL_TERMINATED_STRING

Table name pattern

If no pattern given, write empty string, null-terminated

WRITE_INT

0

Reserved

WRITE_BYTE

Pattern match mode

0: CCI_CLASS_NAME_PATTERN_MATCH

1:  CCI_ATTR_NAME_PATTERN_MATCH

 

SEND_LOB_NEW_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

5

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_LOB_NEW

See Function codes

WRITE_INT

<LOB type>

23 = BLOB

24 = CLOB

 

Compatibility: 8.3.1+

SEND_LOB_READ_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

<not fixed>

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_LOB_READ

See Function codes

WRITE_BYTES_ARRAY(N)

<LOB handle>

N = LOB handle size

WRITE_LONG

Start position from which to read

 

WRITE_INT

Number of bytes to read

 

 

Compatibility: 8.3.1+

SEND_LOB_WRITE_REQUEST

 

Packet sent

Packet value

Notes

WRITE_INT

<not fixed>

Data length in bytes (without CAS)

WRITE_CAS

<CAS info>

CAS info = [0x00, 0xFF, 0xFF, 0xFF]

WRITE_FUNCTION_CODE

CAS_FC_LOB_WRITE

See Function codes

WRITE_BYTES_ARRAY(N)

<LOB handle>

N = LOB handle size

WRITE_LONG

Start position from which to write data

 

WRITE_BYTES_ARRAY(N)

<data>

N = Length of data to be written

 

Compatibility: 8.3.1+

 


 

GET RESPONSE packages

 

GET_BROKER_PORT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

(TCP/IP) Port value

Port to use further by the client to send/receive data.

 

Note: If the new port is not >0, then the initial port should be used further (this is typically the Linux behavior).

 

For the next packages, the following procedure must be followed when reading data:

  • Read int (4 bytes) = the response data length
  • Read CAS info (as 4 bytes)
  • Read actual data

 

GET_OPEN_DATABASE_RESPONSE

 

Packet received

Value meaning

Notes

READ_BROKER_INFO

Broker information

See READ_BROKER_INFO

READ_INT

Session Id

Unique session id

 

GET_RESPONSE_CODE

 

Packet received

Value meaning

Notes

READ_INT

Response length

Response data length, in bytes.

READ_CAS

CAS

See CAS 

READ_INT

Response code

When a response is received by the client, after a previous request, the client receives a response code:

  • If >=0 means there is no error
  • If<0 it means that there is an error

 

GET_ERROR_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Error code

See CUBRID error codes 

READ_NULL_TERMINATED_STRING

Error message

See Communication sequences section for information regarding the length of the error message string

 

GET_VERSION_RESPONSE

 

Packet received

Value meaning

Notes

READ_NULL_TERMINATED_STRING

Database version

 

 

GET_GET_PARAMETER_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Parameter value

 

 

GET_BATCH_EXECUTE_COUNT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

No. of SQL statements executed

 

 

GET_BATCH_EXECUTE_HEADER_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTE

 

Reserved

READ_INT

Execution result code

 

 

GET_BATCH_EXECUTE_STATEMENT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

 

Reserved

READ_SHORT

 

Reserved

READ_SHORT

 

Reserved

 

GET_PREPARE_EXECUTE_QUERY_HEADER_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Cache Lifetime

 

READ_BYTE

Statement type

 

READ_ INT

Bind count

 

READ_BYTE

Is updateable?

 

READ_ INT

Query result columns count

 

Compatibility: 8.4.1+

GET_PREPARE_EXECUTE_QUERY_COLUMN_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTE

Column type

 

READ_SHORT

Scale

 

READ_INT

Precision

 

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

Column real name length

 

READ_NULL_TERMINATED_STRING(N)

Column real name

N = Column real name length

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_BYTE

Nullable?

1 = True, 0 = False

READ_INT

Default value length

 

READ_NULL_TERMINATED_STRING(N)

Default value

N = Default value length

READ_BYTE

Auto-increment?

1 = True, 0 = False

READ_BYTE

Unique key?

1 = True, 0 = False

READ_BYTE

Primary key?

1 = True, 0 = False

READ_BYTE

Reverse index?

1 = True, 0 = False

READ_BYTE

Reverse unique?

1 = True, 0 = False

READ_BYTE

Foreign key?

1 = True, 0 = False

READ_BYTE

Shared?

1 = True, 0 = False

Compatibility: 8.4.1+

GET_PREPARE_EXECUTE_QUERY_COUNT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Tuples count

 

READ_BYTE

Cache reusable

1 = True, 0 = False

READ_INT

Result count

 

Compatibility: 8.4.1+

GET_PREPARE_EXECUTE_QUERY_RESULT_INFO_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTE

Statement type

 

READ_INT

Result count

 

READ_OID

OID

 

READ_INT

Cache time seconds

 

READ_INT

Cache time milliseconds

 

Compatibility: 8.4.1+

GET_PREPARE_EXECUTE_QUERY_RESULT_INFO_SELECT_RESPONSE

 

Packet received

Value meaning

Notes

READ_ INT

Fetch code

 

READ_INT

Tuple count

1 = True, 0 = False

Compatibility: 8.4.1+

 

GET_PREPARE_EXECUTE_QUERY_TUPLE_OID_RESPONSE

 

Packet received

Value meaning

Notes

READ_ INT

Column index

 

READ_OID

 

 

 

Compatibility: 8.4.1+

GET_PREPARE_EXECUTE_QUERY_COLUMN_VALUE_RESPONSE

 

Packet received

Value meaning

Notes

READ_ INT

Size

See data types

READ_BYTE

Data type

 

READ_xxx

Value

Depending on the data type, the appropriate READ_xxx command is executed.

Compatibility: 8.4.1+

GET_FETCH_TUPLES_COUNT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Tuples count

 

Compatibility: 8.4.1+

GET_SCHEMA_HEADER_RESPONSE

 

Packet received

Value meaning

Notes

READ_ INT

Result tuple

 

READ_INT

Number of columns

 

 

GET_SCHEMA_COLUMN_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTE

Data type

See data types

READ_SHORT

Scale

 

READ_INT

Precision

 

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

 

GET_SCHEMA_COLUMNS_COUNT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Columns count

 

 

GET_SCHEMA_FETCH_TUPLE_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Index

 

READ_OID

 

 

 

GET_SCHEMA_FETCH_TUPLE_TABLE_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_INT

2

Indicates that Table type is a short value

READ_SHORT

Table type

0 : system class
1 : vclass
2 : class
3 : proxy

 

GET_SCHEMA_FETCH_TUPLE_VIEW_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

View name length

 

READ_NULL_TERMINATED_STRING(N)

View name

N = View name length

READ_INT

View type length

 

READ_SHORT

View type

1 : vclass
3 : proxy

 

GET_SCHEMA_FETCH_TUPLE_COLUMN_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

Domain value length

 

READ_SHORT

Domain value

 

READ_INT

Scale value length

 

READ_SHORT

Scale value

 

READ_INT

Precision value length

 

READ_INT

Precision value

 

READ_INT

Indexed value length

 

READ_SHORT

Indexed value

 

READ_INT

Not Null value length

 

READ_SHORT

Not Null value

 

READ_INT

Shared value length

 

READ_SHORT

Shared value

 

READ_INT

Unique value length

 

READ_SHORT

Unique value

 

READ_INT

Default value length

 

READ_NULL_TERMINATED_STRING(N)

Default value

N = Default value length

READ_INT

Column order value length

 

READ_INT

Column order value

 

READ_INT

Class/Table name value length

 

READ_NULL_TERMINATED_STRING(N)

Class/Table name value

N = Class/Table name value length

READ_INT

Source Class/Table name value length

 

READ_NULL_TERMINATED_STRING(N)

Source Class/Table name value

N = Source Class/Table name value length

READ_INT

Is Key value length

 

READ_SHORT

Is Key value

 

 

GET_SCHEMA_FETCH_TUPLE_CONSTRAINT_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Constraint type length

 

READ_SHORT

Constraint type value

0 : unique
1 : index
2 : reverse unique
3 : reverse index

READ_INT

Constraint name length

 

READ_NULL_TERMINATED_STRING(N)

Constraint name

N = Constraint name length

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

Pages type length

 

READ_SHORT

Pages value

 

READ_INT

Keys type length

 

READ_ SHORT

Keys value

 

READ_INT

Primary key type length

 

READ_ SHORT

Primary key value

 

READ_INT

Order type length

 

READ_ SHORT

Order value

 

 

GET_SCHEMA_FETCH_TUPLE_EXPORTED_KEYS_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

FK Table name length

 

READ_NULL_TERMINATED_STRING(N)

FK Table name

N = FK Table name length

READ_INT

FK Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = FK Column name length

READ_INT

Sequence type length

 

READ_SHORT

Sequence value

 

READ_INT

Updateaction length

 

READ_ SHORT

Update action value

 

READ_INT

Delete action length

 

READ_ SHORT

Delete actionvalue

 

READ_INT

FK name length

 

READ_NULL_TERMINATED_STRING(N)

FK name

N = FK name length

READ_INT

PK name length

 

READ_NULL_TERMINATED_STRING(N)

PK name

N = PK name length

Compatibility: 8.3.1+

GET_SCHEMA_FETCH_TUPLE_IMPORTED_KEYS_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

FK Table name length

 

READ_NULL_TERMINATED_STRING(N)

FK Table name

N = FK Table name length

READ_INT

FK Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = FK Column name length

READ_INT

Sequence type length

 

READ_SHORT

Sequence value

 

READ_INT

Update action length

 

READ_ SHORT

Update action value

 

READ_INT

Delete action length

 

READ_ SHORT

Delete action value

 

READ_INT

FK name length

 

READ_NULL_TERMINATED_STRING(N)

FK name

N = FK name length

READ_INT

PK name length

 

READ_NULL_TERMINATED_STRING(N)

PK name

N = PK name length

Compatibility: 8.4.1+

GET_SCHEMA_FETCH_TUPLE_PRIMARY_KEYS_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_INT

Column name length

 

READ_NULL_TERMINATED_STRING(N)

Column name

N = Column name length

READ_INT

Sequence type length

 

READ_SHORT

Sequence value

 

READ_INT

PK name length

 

READ_NULL_TERMINATED_STRING(N)

PK name

N = PK name length

 

GET_SCHEMA_FETCH_TUPLE_PRIVILEGE_RESPONSE

 

Packet received

Value meaning

Notes

READ_INT

Table name length

 

READ_NULL_TERMINATED_STRING(N)

Table name

N = Table name length

READ_INT

Privilege name length

 

READ_NULL_TERMINATED_STRING(N)

Privilege name

N = Privilege name length

READ_INT

Grantable type length

 

READ_NULL_TERMINATED_STRING(N)

Grantable

N = Grantable type length

‘YES’ or ‘NO'

Compatibility: 8.3.1+

GET_LOB_NEW_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTES_ARRAY(N)

LOB handle

N = Response length

Compatibility: 8.3.1+

GET_LOB_READ_RESPONSE

 

Packet received

Value meaning

Notes

READ_BYTES_ARRAY(N)

 

N = Response length

 

Note: Depending on the LOB type, data will be interpreted as binary or as string.

Compatibility: 8.3.1+

comments powered by Disqus
Page info
viewed 1631 times
translations en
Author
posted last year by
CUBRID
Contributors
updated last year by
View revisions
tagged
Share this article