이 페이지는 기계 번역되었습니다. 영어 원본을 읽어보세요. English

IBSurgeon 라이브러리

Firebird 아키텍처를 SQL 쿼리로 확인하는 방법은 무엇인가요?

Firebird 금요일 농담 #8 (https://t.me/firebirdsql에서)

아래 스크립트는 SQL로 Firebird 서버의 현재 아키텍처를 실행 중인 상태에서 결정합니다.

일반적으로 아키텍처를 이해하려면 구성 파일 firebird.conf 또는 Firebird 서비스 설정을 살펴봐야 합니다.

그러나 고도로 자동화된 테스트 환경에서는 순수 SQL로 아키텍처를 확인해야 할 필요가 있습니다.

이 방법의 작성자는 Firebird QA 및 IBSurgeon 수석 관리자인 Pavel Zotov입니다.

간단히 하기 위해 코드는 execute block으로 선언되었지만, 저장 프로시저로 쉽게 전환할 수 있습니다.

아래 스크립트는 isql.exe에서 사용할 준비가 되어 있습니다.

`set list on; set term ^; –create or alter procedure sys_get_fb_arch ( – a_connect_with_usr varchar(31) default ‘SYSDBA’ – ,a_connect_with_pwd varchar(31) default ‘masterkey’ –) returns( – fb_arch varchar(50) –) as execute block returns( fb_arch varchar(50) ) as declare a_connect_with_usr varchar(31) default ‘SYSDBA’; declare a_connect_with_pwd varchar(31) default ‘masterkey’; declare cur_server_pid int; declare ext_server_pid int; declare att_protocol varchar(255); declare v_test_sttm varchar(255); declare v_fetches_beg bigint; declare v_fetches_end bigint; begin

-- FB 아키텍처 감지를 위한 보조 SP.

select a.mon$server_pid, a.mon$remote_protocol
from mon$attachments a
where a.mon$attachment_id = current_connection
into cur_server_pid, att_protocol;

if ( att_protocol is null ) then
    fb_arch = 'Embedded';
else if ( upper(current_user) = upper('SYSDBA')
          and rdb$get_context('SYSTEM','ENGINE_VERSION') NOT starting with '2.5'
          and exists(select * from mon$attachments a
                     where a.mon$remote_protocol is null
                           and upper(a.mon$user) in ( upper('Cache Writer'), upper('Garbage Collector'))
                    )
        ) then
    fb_arch = 'SuperServer';
else
    begin
        v_test_sttm =
            'select a.mon$server_pid + 0*(select 1 from rdb$database)'
            ||' from mon$attachments a '
            ||' where a.mon$attachment_id = current_connection';

        select i.mon$page_fetches
        from mon$io_stats i
        where i.mon$stat_group = 0  -- db_level
        into v_fetches_beg;

        execute statement v_test_sttm
        on external
             'localhost:' || rdb$get_context('SYSTEM', 'DB_NAME')
        as
             user a_connect_with_usr
             password a_connect_with_pwd
             role left('R' || replace(uuid_to_char(gen_uuid()),'-',''),31)
        into ext_server_pid;

        in autonomous transaction do
        select i.mon$page_fetches
        from mon$io_stats i
        where i.mon$stat_group = 0  -- db_level
        into v_fetches_end;

        fb_arch = iif( cur_server_pid is distinct from ext_server_pid,
                       'Classic',
                       iif( v_fetches_beg is not distinct from v_fetches_end,
                            'SuperClassic',
                            'SuperServer'
                          )
                     );
    end

fb_arch = trim(fb_arch) || ' ' || rdb$get_context('SYSTEM','ENGINE_VERSION');

suspend;

end

^ – sys_get_fb_arch set term ;^ commit;`