[20200211] using DBMS_ SHARED_ POOL.MARKHOT And SQL_ Calculation of id.txt

Time:2021-3-3

[20200211] using DBMS_ SHARED_ POOL.MARKHOT And SQL_ Calculation of id.txt

–//Previously written, using DBMS_ SHARED_ POOL.MARKHOT Tag hot SQL_ ID, so the same SQL statement uses different SQL_ id.
–//Link: http://blog.itpub.net/267265/viewspace-2147197/ =>[20171110] same SQL statement_ Can Id be different
–//I’m curious to know how Oracle calculates SQL in this case_ It’s not.

–//Correction: SQL statement uses DBMS_ SHARED_ POOL.MARKHOT Tag hot SQL_ ID, full_ hash_ Value and SQL_ The calculation of ID is based on the original SQL statement
–//Add. Mod (SID, CPU)_ Count / 2) + 1.
–//If implicit parameters are set_ kgl_ hot_ object_ Copy, change to add. Mod (SID_ kgl_ hot_ object_ Copies) + 1.

1. Environment:
[email protected]> @ &r/ver1
PORT_STRING                    VERSION        BANNER
—————————— ————– ——————————————————————————–
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production

[email protected]> select * from dept where deptno=10;
    DEPTNO DNAME          LOC
———- ————– ————-
        10 ACCOUNTING     NEW YORK
–//sql_ Id =’4xamunv51w9j ‘, which can be executed many times to avoid SQL statement exiting the shared pool

SELECT name
      ,hash_value
      ,full_hash_value
      ,namespace
      ,child_latch
      ,property hot_flag
      ,executions
      ,invalidations
  FROM v$db_object_cache
 WHERE name = ‘select * from dept where deptno=10’;

NAME                                     HASH_VALUE FULL_HASH_VALUE                  NAMESPACE  CHILD_LATCH HOT_FLAG   EXECUTIONS INVALIDATIONS
—————————————- ———- ——————————– ———- ———– ———- ———- ————-
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA             0                     8             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA         61745                     8             0
–//Confirm full_ HASH_ VALUE=’1431c45dbddbb9e74eaa74d53650f131′.

$ echo -e -n  ‘select * from dept where deptno=10\0’ | md5sum | sed ‘s/  -//’ | xxd -r -p | od -t x4 | sed  -n  -e ‘s/^0000000 //’ -e ‘s/ //gp’
1431c45dbddbb9e74eaa74d53650f131
–//The contrast is quite right.

2. Create GDB script
–//Reference link: http://blog.itpub.net/267265/viewspace-2665902/= >[20191127] table full hash value calculation.txt
$ cat md5.gdb
set pagination off

break kggmd5Update
  commands
    printf “Length: %d\n”,$rdx
    x/40xc $rsi
    c
  end

break kglComputeHash
  commands
    c
  end

break kggmd5Process
  commands
    c
  end

break kggmd5Finish
  commands
    c
  end

3. Test analysis:
–//First use DBMS_ SHARED_ POOL.MARKHOT Mark.
[email protected]> exec dbms_shared_pool.markhot( hash=>’1431c45dbddbb9e74eaa74d53650f131′, namespace=>0, global=>true);
PL/SQL procedure successfully completed.

–//Log in as Scott
–//session 1:
[email protected]> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
———- ———- ———————— ——— —— ——- ———- ————————————————–
        58         49 54621                    DEDICATED 54622       28         23 alter system kill session ‘58,49’ immediate;
–//spid=54622
–//session 2:
$ gdb -p 54622 -x md5.gdb

–//session 1:
–//Before testing, you can execute select * from dept where dept no = 10; note that the s uppercase SQL statement is different from the original.
Select * from dept where deptno=10

[email protected]> select * from dept where deptno=10;
    DEPTNO DNAME          LOC
———- ————– ————-
        10 ACCOUNTING     NEW YORK

@ dpc ” ”
–//Output slightly, query SQL_ Id =’7sqgfqarnwk8h ‘, which is different from the original completion.
        
4. Observe the output of GDB

–//session 3:
[email protected]> select sql_id,sql_text,executions,length(sql_text),ora_hash(sql_text) from v$sqlarea where sql_text = ‘select * from dept where deptno=10’ ;
SQL_ID        SQL_TEXT                            EXECUTIONS LENGTH(SQL_TEXT) ORA_HASH(SQL_TEXT)
————- ———————————– ———- —————- ——————
7sqgfqarnwk8h select * from dept where deptno=10           3               34          156172166
4xamnunv51w9j select * from dept where deptno=10           8               34          156172166
–//sql_id=7sqgfqarnwk8h.

SELECT name
      ,hash_value
      ,full_hash_value
      ,namespace
      ,child_latch
      ,property hot_flag
      ,executions
      ,invalidations
  FROM v$db_object_cache
 WHERE name = ‘select * from dept where deptno=10’;

NAME                                     HASH_VALUE FULL_HASH_VALUE                  NAMESPACE  CHILD_LATCH HOT_FLAG   EXECUTIONS INVALIDATIONS
—————————————- ———- ——————————– ———- ———– ———- ———- ————-
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA             0 HOTCOPY11           3             0
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA         18704 HOTCOPY11           3             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA             0 HOT                 8             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA         61745 HOT                 8             0
–//You can find the new SQL statement full_ HASH_ Value = 5196d0b7fe72e5ea7c59eeb2af4e4910, pay attention to the hot_ FLAG=’HOTCOPY11′.
–//0x4910  = 18704

–//session 2:
(gdb) c
Continuing.

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 35
0x7fffff1de9d8: 115 ‘s’ 101 ‘e’ 108 ‘l’ 101 ‘e’ 99 ‘c’  116 ‘t’ 32 ‘ ‘  42 ‘*’
0x7fffff1de9e0: 32 ‘ ‘  102 ‘f’ 114 ‘r’ 111 ‘o’ 109 ‘m’ 32 ‘ ‘  100 ‘d’ 101 ‘e’
0x7fffff1de9e8: 112 ‘p’ 116 ‘t’ 32 ‘ ‘  119 ‘w’ 104 ‘h’ 101 ‘e’ 114 ‘r’ 101 ‘e’
0x7fffff1de9f0: 32 ‘ ‘  100 ‘d’ 101 ‘e’ 112 ‘p’ 116 ‘t’ 110 ‘n’ 111 ‘o’ 61 ‘=’
0x7fffff1de9f8: 49 ‘1’  48 ‘0’  0 ‘\000’        -13 ‘? 108 ‘l’ 92 ‘\\’ 107 ‘k’ -64 ‘?
–//Put together, select * from dept where dept no = 10 / 0;

Breakpoint 4, 0x00000000097f0830 in kggmd5Finish ()

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 21
0xbefbe20 :    -128 ‘\200’     0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe28 :  0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe30 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe38 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe40 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 8
0x7fffff1dc910: 24 ‘\030’       1 ‘\001’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc918: -40 ‘? -23 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
0x7fffff1dc920: 32 ‘ ‘  -51 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
0x7fffff1dc928: -40 ‘? -23 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
0x7fffff1dc930: -64 ‘? -55 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’

Breakpoint 2, 0x000000000984457c in kglComputeHash ()

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 35
0x7fffff1de9d8: 115 ‘s’ 101 ‘e’ 108 ‘l’ 101 ‘e’ 99 ‘c’  116 ‘t’ 32 ‘ ‘  42 ‘*’
0x7fffff1de9e0: 32 ‘ ‘  102 ‘f’ 114 ‘r’ 111 ‘o’ 109 ‘m’ 32 ‘ ‘  100 ‘d’ 101 ‘e’
0x7fffff1de9e8: 112 ‘p’ 116 ‘t’ 32 ‘ ‘  119 ‘w’ 104 ‘h’ 101 ‘e’ 114 ‘r’ 101 ‘e’
0x7fffff1de9f0: 32 ‘ ‘  100 ‘d’ 101 ‘e’ 112 ‘p’ 116 ‘t’ 110 ‘n’ 111 ‘o’ 61 ‘=’
0x7fffff1de9f8: 49 ‘1’  48 ‘0’  0 ‘\000’        -13 ‘? 108 ‘l’ 92 ‘\\’ 107 ‘k’ -64 ‘?
–//Put together, select * from dept where dept no = 10 / 0;

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 1
0x9e79fec :    46 ‘.’  0 ‘\000’        0 ‘\000’        0 ‘\000’        107 ‘k’ 116 ‘t’ 99 ‘c’  110 ‘n’
0x9e79ff4 : 46 ‘.’  99 ‘c’  64 ‘@’  49 ‘1’  50 ‘2’  54 ‘6’  49 ‘1’  55 ‘7’
0x9e79ffc :        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        37 ‘%’  42 ‘*’  115 ‘s’ 102 ‘f’
0x9e7a004 : 108 ‘l’ 103 ‘g’ 115 ‘s’ 58 ‘:’  32 ‘ ‘  48 ‘0’  120 ‘x’ 37 ‘%’
0x9e7a00c :        48 ‘0’  56 ‘8’  120 ‘x’ 32 ‘ ‘  0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
–//Length = 1 corresponds to ‘

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 2
0x7fffff1dc460: 49 ‘1’  49 ‘1’  0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc468: 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc470: -128 ‘\200’     -57 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
0x7fffff1dc478: 49 ‘1’  41 ‘)’  -125 ‘\203’     9 ‘\t’  0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc480: -80 ‘? -55 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
–//Notice here, length: 2, the character is exactly ’11’

Breakpoint 4, 0x00000000097f0830 in kggmd5Finish ()

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 18
0xbefbe20 :    -128 ‘\200’     0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe28 :  0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe30 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe38 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0xbefbe40 : 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’

Breakpoint 1, 0x00000000097f09a8 in kggmd5Update ()
Length: 8
0x7fffff1dc2a0: 48 ‘0’  1 ‘\001’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc2a8: 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc2b0: 32 ‘ ‘  -53 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’
0x7fffff1dc2b8: 0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’        0 ‘\000’
0x7fffff1dc2c0: 96 ‘`’  -61 ‘? 29 ‘\035’       -1 ‘’  -1 ‘’  127 ‘\177’      0 ‘\000’        0 ‘\000’

$ echo -e -n  ‘select * from dept where deptno=10\0.11’ | md5sum | sed ‘s/  -//’ | xxd -r -p | od -t x4 | sed  -n  -e ‘s/^0000000 //’ -e ‘s/ //gp’
5196d0b7fe72e5ea7c59eeb2af4e4910
–//^_ ^, which is right on top.

SELECT name
      ,hash_value
      ,full_hash_value
      ,namespace
      ,child_latch
      ,property hot_flag
      ,executions
      ,invalidations
  FROM v$db_object_cache
 WHERE name = ‘select * from dept where deptno=10’;

NAME                                     HASH_VALUE FULL_HASH_VALUE                  NAMESPACE  CHILD_LATCH HOT_FLAG   EXECUTIONS INVALIDATIONS
—————————————- ———- ——————————– ———- ———– ———- ———- ————-
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA             0 HOTCOPY11           3             0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA         18704 HOTCOPY11           3             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA             0 HOT                 8             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA         61745 HOT                 8             0

–//That is, the statement generates full_ HASH_ The value calculation is the original SQL statement (note that Oracle will do some formatting operations), followed by the addition of 0. V $dB_ object_ cache.HOT_ The number after the flag field.
–//A little more popular is to add. V $dB on the original basis_ object_ cache.HOT_ The number after the flag field.

–//Use the script I wrote to test (be careful to install Zsh):
$ ./sql_id.zsh ‘select * from dept where deptno=10\0.11’
sql_text = select * from dept where deptno=10.11
full_hash_value(16) = 5196D0B7FE72E5EA7C59EEB2AF4E4910
hash_value(10) = 2941143312
sql_id(32) = 7sqgfqarnwk8h
sql_id(32) = 7sqgfqarnwk8h
–//sql_ Id = 7sqgfqarnwk8h, which is also consistent with the previous query result of V $sqlarea view.

4. Continue to explore. As for why 11 is added later, it is estimated that it is related to conversation Sid (guess).
–//Exit GBD program and continue analysis.
–//First of all, I try to log out and then log in. My test environment Sid will remain unchanged and serial # will change. I execute select * from dept where dept no = 10 to query
–//v$db_ object_ Cache does not generate new SQL_ id.

[email protected]> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
———- ———- ———————— ——— —— ——- ———- ————————————————–
        58         49 54621                    DEDICATED 54622       28         23 alter system kill session ‘58,49’ immediate;

[email protected]> show parameter cpu_count
NAME      TYPE    VALUE
——— ——- —–
cpu_count integer 24

[email protected]> select mod(58,24),mod(58,16) from dual ;
MOD(58,24) MOD(58,16)
———- ———-
        10         10
–//Is this Sid and a parameter modulo 10 + 1, because we haven’t seen hot_ At least I haven’t seen the situation of flag =’hotcopy0 ‘.
–//To create a new session:
–//session 4:
[email protected]> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
———- ———- ———————— ——— —— ——- ———- ————————————————–
        30        115 55199                    DEDICATED 55200       26         44 alter system kill session ‘30,115’ immediate;

[email protected]> select mod(30,24),mod(30,16) from dual ;
MOD(30,24) MOD(30,16)
———- ———-
         6         14

[email protected]> select * from dept where deptno=10;
    DEPTNO DNAME          LOC
———- ————– ————-
        10 ACCOUNTING     NEW YORK

–//session 3:
SELECT name
      ,hash_value
      ,full_hash_value
      ,namespace
      ,child_latch
      ,property hot_flag
      ,executions
      ,invalidations
  FROM v$db_object_cache
 WHERE name = ‘select * from dept where deptno=10’;

[email protected]> /
NAME                                     HASH_VALUE FULL_HASH_VALUE                  NAMESPACE  CHILD_LATCH HOT_FLAG   EXECUTIONS INVALIDATIONS
—————————————- ———- ——————————– ———- ———– ———- ———- ————-
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA             0 HOTCOPY11           3             0
select * from dept where deptno=10       2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA         18704 HOTCOPY11           3             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA             0 HOT                 8             0
select * from dept where deptno=10        911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA         61745 HOT                 8             0
select * from dept where deptno=10       3106222595 642c74f9bf38538acec7e363b9253203 SQL AREA             0 HOTCOPY7            1             0
select * from dept where deptno=10       3106222595 642c74f9bf38538acec7e363b9253203 SQL AREA         78339 HOTCOPY7            1             0
6 rows selected.
–//Generate new hot_ Flag = hotcopy7. It’s just mod (SID, CPU)_ count)+1.

[email protected]> select sql_id,sql_text,executions,length(sql_text),ora_hash(sql_text) from v$sqlarea where sql_text = ‘select * from dept where deptno=10’ ;
SQL_ID        SQL_TEXT                                                     EXECUTIONS LENGTH(SQL_TEXT) ORA_HASH(SQL_TEXT)
————- ———————————————————— ———- —————- ——————
7sqgfqarnwk8h select * from dept where deptno=10                                    3               34          156172166
4xamnunv51w9j select * from dept where deptno=10                                    8               34          156172166
cxjz3cfwkach3 select * from dept where deptno=10                                    1               34          156172166
~~~~~~~~~~~~~
–//sql_id=cxjz3cfwkach3,HOT_FLAG=’HOTCOPY7′

$ echo -e -n  ‘select * from dept where deptno=10\0.7’ | md5sum | sed ‘s/  -//’ | xxd -r -p | od -t x4 | sed  -n  -e ‘s/^0000000 //’ -e ‘s/ //gp’
642c74f9bf38538acec7e363b9253203

$ ./sql_id.zsh ‘select * from dept where deptno=10\0.7’
v1=642C74F9BF38538ACEC7E363B9253203 v2=CEC7E363B9253203 v3=3106222595
sql_text = select * from dept where deptno=10.7
full_hash_value(16) = 642C74F9BF38538ACEC7E363B9253203
hash_value(10) = 3106222595
./sql_id.zsh:1: number truncated after 15 digits: CEC7E363B9253203
sql_id(32) = 0tv3y6sxt4nt0
sql_id(32) =  tv3y6sxt4nt0
–//It seems that the first character C in the V2 variable is not a number. In my memory, it seems that I used the Zsh version of the server to test it at home at night.
–//Use another SQL_ id.sh Script test:

$ ./sql_id.sh ‘select * from dept where deptno=10\0.7’
v1=642C74F9BF38538ACEC7E363B9253203 v2=CEC7E363B9253203 v3=B9253203
sql_text = select * from dept where deptno=10\0.7
full_hash_value(16) = 642C74F9BF38538ACEC7E363B9253203
hash_value(10) = 3106222595
sql_id(32) = cxjz3cfwkach3
sql_id(32) = cxjz3cfwkach3
sql_id(32) = cxjz3cfwkach3
–//That’s right. You can open a new session test to make sure that the SQL statement is based on the original. Mod (SID, CPU)_ Count) + 1.

Conclusion:
–//Work is too quiet and boring to explore this problem.
–//SQL statement using DBMS_ SHARED_ POOL.MARKHOT Tag hot SQL_ ID, full_ hash_ Value and SQL_ The calculation of ID is to add the
–// . mod(sid,cpu_ Count) + 1.
–//Using DBMS_ SHARED_ POOL.MARKHOT Marking hot SQL statements, in fact, is the use of space for time practice, scattered. But there may be too much contention in my morning test
–//On the contrary, it is slower to use and has the opportunity to test more sessions.
–//Maybe it’s because. Mod (SID, CPU)_ The string of count + 1 may have too many conflicts, but it is slower.

–//Attach SQL_ id.sh Script, which contains several from full_ hash_ Value computing SQL_ Method of ID:
$ cat sql_id.sh
#! /bin/bash
# calcucate sql_text of full_hash_value(16),hash_value(10),sql_id(32).
odebug=${ODEBUG:-0}

#sql_text=${1}’\0′
sql_text=${1}
v1=$(echo -e -n “$sql_text” | md5sum | sed ‘s/  -//’ | xxd -r -p | od -t x4 |  sed   -n  -e ‘s/^0\+ //’ -e ‘s/ //gp’ | tr ‘a-z’ ‘A-Z’)
v2=${v1:(-16):16}
v3=${v2:(-8):8}
# v2=$(echo “obase=16;ibase=16; $v1 % 10000000000000000” | bc| tr -d ‘\\\r\n’)
# v3=$(echo “obase=10;ibase=16; $v1 % 100000000” | bc| tr -d ‘\\\r\n’)

if [ $odebug -eq 1 ] ; then
        echo v1=$v1 v2=$v2 v3=$v3
fi

echo “sql_text = $sql_text”
echo “full_hash_value(16) = $v1 “
echo “hash_value(10) = $(( 16#$v3 )) “

BASE32=($(echo {0..9} {a..z} | tr -d ‘eilo’))
res=”
for i in $(echo “obase=32;ibase=16; $v2” | bc| tr -d ‘\\\r\n’)
do
        res=${res}${BASE32[$(( 10#$i ))]}
done
echo “sql_id(32) = $(printf “%13s” $res | tr ‘ ‘ ‘0’)”
echo “sql_id(32) = $(printf “%013s” $res)”

res1=$(eval $(echo “obase=32;ibase=16; $v2″ | bc| tr -d ‘\\\r\n’ | awk ‘BEGIN{RS=” +”; printf “echo ” }/./{printf “${BASE32[$(( 10#%02d))]} “, $1}’ ))
res1=$(tr -d ” ” <<< $res1)
echo “sql_id(32) = $(printf “%013s” $res1)”

Recommended Today

Practice analysis of rust built-in trait: partialeq and EQ

Abstract:Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. This article is shared from Huawei cloud community《Analysis of rust built-in trait: partialeq and EQ》Author: debugzhang Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. Some traits can be automatically […]