functions/WRITE_MESSAGE_TO_TABLE.pg_sql
Functions
WRITE_MESSAGE_TO_TABLE |
---|
Write given parameters into the logging table. It is meant to be called in an autonomous transaction to and best done in a separate process to reduce impact on main transaction as much as possible.
- Private
- Just used internally.
- Syntax:
WRITE_MESSAGE_TO_TABLE (I_FUNCTION, I_MESSAGE, I_LEVEL, I_PRESENT_USER, I_SESSION_USER, I_TRANSACTION_TIMESTAMP, I_TRANSACTION_ID, I_SERVER_PID, I_REMOTE_ADDRESS, I_REMOTE_PORT)
- Parameters:
Parameter | In/Out | Data Type | Description |
---|
I_FUNCTION | IN | TEXT | Value for LOG.FUNCTION. | I_MESSAGE | IN | TEXT | Value for LOG.MESSAGE. | I_LEVEL | IN | TEXT | Value for LOG.LEVEL. | I_PRESENT_USER | IN | NAME | Value for LOG.PRESENT_USER. | I_SESSION_USER | IN | NAME | Value for LOG.SESS_USER. | I_TRANSACTION_TIMESTAMP | IN | TIMESTAMP_WITH_TIMEZONE | Value for LOG.TRANSACTION_TIMESTAMP. | I_TRANSACTION_ID | IN | BIGINT | Value for LOG.TRANSACTION_ID. | I_SERVER_PID | IN | BIGINT | Value for LOG.SERVER_PID. | I_REMOTE_ADDRESS | IN | INET | Value for LOG.REMOTE_ADDRESS. | I_REMOTE_PORT | IN | INT | Value for LOG.REMOTE_PORT. |
- Return values:
- Copyright:
- Thiemo Kellner, 2018 -
- Webpage:
- https://www.sourceforge.net/projects/pglogger
- Version Info:
- $Id: WRITE_MESSAGE_TO_TABLE.pg_sql 19 2018-06-15 20:24:38Z thiemo $
- Additional Info:
- This function is meant to be private. Its use outside pglogger is very limited at most. That's why it is marked as private eventhough it is visible to the outside. All of this is due to the fact that PostgreSQL 10 and earlier does not support packages.
- License LGPLv3
- TODO:
- Once PostgreSQL supports packages, integrate this function into one. For the time being, it should get installed within a schema on its own and no execution grants should be given on it.
- Once HyperSQL supports a license tag, convert the corresponding info tag into one.
|
Source
0001: \echo Start functions/WRITE_MESSAGE_TO_TABLE.pg_sql
0002:
0003: 0004: 0005: 0006: 0007: 0008: 0009: 0010: 0011: 0012: 0013: 0014: 0015: 0016: 0017: 0018: 0019: 0020: 0021: 0022: 0023: 0024: 0025: 0026: 0027: 0028: 0029: 0030: 0031: 0032: 0033: 0034:
0035: create or replace function WRITE_MESSAGE_TO_TABLE(
0036: I_FUNCTION text,
0037: I_MESSAGE text,
0038: I_LEVEL text,
0039: I_PRESENT_USER name,
0040: I_SESSION_USER name,
0041: I_TRANSACTION_TIMESTAMP timestamp with time zone,
0042: I_TRANSACTION_ID bigint,
0043: I_SERVER_PID bigint,
0044: I_REMOTE_ADDRESS inet,
0045: I_REMOTE_PORT int
0046: )
0047: returns void
0048: language plpgsql
0049: volatile
0050: 0051: 0052: 0053: set search_path = :SCHEMA_NAME, public
0054: as
0055: $body$
0056: begin
0057: insert into LOG(
0058: FUNCTION,
0059: MESSAGE,
0060: LEVEL,
0061: PRESENT_USER,
0062: SESS_USER,
0063: TRANSACTION_TIMESTAMP,
0064: TRANSACTION_ID,
0065: SERVER_PID,
0066: REMOTE_ADDRESS,
0067: REMOTE_PORT
0068: ) values (
0069: I_FUNCTION,
0070: I_MESSAGE,
0071: I_LEVEL,
0072: I_PRESENT_USER,
0073: I_SESSION_USER,
0074: I_TRANSACTION_TIMESTAMP,
0075: I_TRANSACTION_ID,
0076: I_SERVER_PID,
0077: I_REMOTE_ADDRESS,
0078: I_REMOTE_PORT
0079: );
0080: end;
0081: $body$;
0082:
0083:
0084: comment on function WRITE_MESSAGE_TO_TABLE(
0085: I_FUNCTION text,
0086: I_MESSAGE text,
0087: I_LEVEL text,
0088: I_PRESENT_USER name,
0089: I_SESSION_USER name,
0090: I_TRANSACTION_TIMESTAMP timestamp with time zone,
0091: I_TRANSACTION_ID bigint,
0092: I_SERVER_PID bigint,
0093: I_REMOTE_ADDRESS inet,
0094: I_REMOTE_PORT int
0095: ) is
0096: 'Write given parameters into the logging table. It is meant to be called in an autonomous transaction to and best done in a separate process to reduce impact on main transaction as much as possible.
0097: As colateral the ID of written record is returned.
0098: $Header: svn+ssh://thiemo@svn.code.sf.net/p/pglogger/code/functions/WRITE_MESSAGE_TO_TABLE.pg_sql 19 2018-06-15 20:24:38Z thiemo $';
0099:
0100:
0101: commit; 0102:
0103: \echo End functions/WRITE_MESSAGE_TO_TABLE.pg_sql
Generated by
HyperSQL v3.9.8 at Wed Jul 4 07:48:47 2018