403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/django/db/backends/oracle/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/django/db/backends/oracle/__pycache__/creation.cpython-311.pyc
�

�|�e�L��j�ddlZddlmZddlmZddlmZddlmZddl	m
Z
dZGd�d	e��ZdS)
�N)�settings)�
DatabaseError)�BaseDatabaseCreation)�get_random_string)�cached_property�test_c���eZdZed���Zd$d�Zd�Zd�Zd�Zd%d�Z	d&d	�Z
d&d
�Zd�Zd�Z
d&d
�Zd�Zd�Zd'd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Z d!�Z!d"�Z"d#�Z#dS)(�DatabaseCreationc��tj|jj}|�d��p|d}|�d��p|d}i|�||d��}t|j��}|||jj���S)a>
        This is analogous to other backends' `_nodb_connection` property,
        which allows access to an "administrative" connection which can
        be used to manage the test databases.
        For Oracle, the only connection that can be used for that purpose
        is the main (non-test) connection.
        �
SAVED_USER�USER�SAVED_PASSWORD�PASSWORD)r
r)�alias)r�	DATABASES�
connectionr�get�type)�self�
settings_dict�user�password�DatabaseWrappers     �D/usr/lib/python3/dist-packages/django/db/backends/oracle/creation.py�_maindb_connectionz#DatabaseCreation._maindb_connections���!�*�4�?�+@�A�
�� � ��.�.�G�-��2G�� �$�$�%5�6�6�S�-�
�:S��M�=�M�$�H�M�M�M�
��t��/�/����}�D�O�4I�J�J�J�J��Fc	�j�|���}|j���5}|����r	|�||||���n�#t
$�r�}dt
|��vr,|�d|z��tj	d��|std|dz��}|s|dk�rI|dkr"|�d|jjz��	|�
|||��n�#t$r`}d	t
|��vr|�||||��n,|�d
|z��tj	d��Yd}~nFd}~wt
$r6}|�d
|z��tj	d��Yd}~nd}~wwxYw	|�||||��nl#t
$r6}|�d|z��tj	d��Yd}~n1d}~wwxYw|�d��tj	d��Yd}~nd}~wwxYw|����r�|dkr|�d
��	|�||||���nJ#t
$�r<}dt
|��vr,|�d|z��tj	d��|std|dz��}|s|dkr�	|dkr|�d��|�|||��|dkr|�d
��|�||||��nl#t
$r6}|�d|z��tj	d��Yd}~n1d}~wwxYw|�d��tj	d��Yd}~nd}~wwxYwddd��n#1swxYwY|j���|�|��|jjdS)N�	ORA-01543z+Got an error creating the test database: %s�z^It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: r�yesr�.Destroying old test database for alias '%s'...z	ORA-29857z1Got an error destroying the old test database: %sz-Got an error recreating the test database: %szTests cancelled.zCreating test user...�	ORA-01920z'Got an error creating the test user: %szZIt appears the test user, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: �Destroying old test user...z)Got an error recreating the test user: %s�NAME)�_get_test_db_paramsr�cursor�_test_database_create�_execute_test_db_creation�	Exception�str�log�sys�exit�inputrr�_execute_test_db_destructionr�)_handle_objects_preventing_db_destruction�_test_user_create�_create_test_user�_destroy_test_user�close�_switch_to_test_userr)r�	verbosity�autoclobber�keepdb�
parametersr'�e�confirms        r�_create_test_dbz DatabaseCreation._create_test_dbs���-�-�/�/�
�
�
$�
+�
+�
-�
-�A	$���)�)�+�+�#
$�"$��2�2�6�:�y�RX�Y�Y�Y�Y�� � $� $� $�"�#�a�&�&�0�0����!N�QR�!R�S�S�S�������&�a�"'�K�MW�X^�M_�`�#a�#a��#�$�g��&6�&6�$��>�>� �H�H�%U�X\�Xg�Xm�%m�n�n�n�(� �=�=�f�j�R[�\�\�\�\��,�,�,�,�*�c�!�f�f�4�4� $� N� N�v�Wa�OX�Ze�!g�!g�!g�!g�!%���)\�_`�)`� a� a� a� #���������������(�(�(�(� �H�H�%X�[\�%\�]�]�]��H�Q�K�K�K�K�K�K�K�K�����(����(� �:�:�6�:�y�Z`�a�a�a�a��(�(�(�(� �H�H�%T�WX�%X�Y�Y�Y��H�Q�K�K�K�K�K�K�K�K�����(�������!3�4�4�4����������������A $����D�%�%�'�'�
$���>�>��H�H�4�5�5�5�$��*�*�6�:�y�&�Q�Q�Q�Q�� �$�$�$�"�#�a�&�&�0�0����!J�Q�!N�O�O�O�������&�\�"'�F�HR�SY�HZ�[�#\�#\��#�
$�g��&6�&6�	(�(�A�~�~� $���)F� G� G� G� �3�3�F�J�	�R�R�R�(�A�~�~� $���)@� A� A� A� �2�2�6�:�y�RX�Y�Y�Y�Y��(�(�(�(� �H�H�%P�ST�%T�U�U�U��H�Q�K�K�K�K�K�K�K�K�����(�������!3�4�4�4����������������-$����WA	$�A	$�A	$�A	$�A	$�A	$�A	$�A	$�A	$�A	$�A	$����A	$�A	$�A	$�A	$�D	
��%�%�'�'�'��!�!�*�-�-�-���,�V�4�4s��O*�A�O*�I�*BI�3D�
I�
F3�AE0�+I�0
F3�=,F.�)I�.F3�3I�7G�I�
H�,H�I�H�,I�<O*�I�3O*�:J�O*�O�AO�?A%M%�$O�%
N%�/,N �O� N%�%,O�O*�O�O*�*O.�1O.c�~�tj|jj}|jjdx|d<|jjd<|jjdx|d<|jjd<|d}|jjd}|dx|d<x|d<x|d<|jjd<|dx|d<|jjd<dS)	a�
        Switch to the user that's used for creating the test database.

        Oracle doesn't have the concept of separate databases under the same
        user, so a separate user is used; see _create_test_db(). The main user
        is also needed for cleanup when testing is completed, so save its
        credentials in the SAVED_USER/SAVED_PASSWORD key in the settings dict.
        r
rrr�TESTrrN)rrrrr)rr:�
real_settings�real_test_settings�
test_settingss     rr6z%DatabaseCreation._switch_to_test_userfs���!�*�4�?�+@�A�
��O�)�&�1�	2�
�l�#�d�o�&C�L�&Q�
�O�)�*�5�	6�
�&�'�$�/�*G�HX�*Y�*�6�2����5�f�=�
�4>�v�4F�	G��6�"�	G�]�6�%:�	G�]�6�=R��O�)�&�1�PZ�[e�Pf�f�
�j�!�D�O�$A�*�$M�$M�$Mrc�Z�|d|jjd<|d|jjd<dS)z�
        Set this database up to be used in testing as a mirror of a primary
        database whose settings are given.
        r
rN�rr)r�primary_settings_dicts  r�set_as_test_mirrorz#DatabaseCreation.set_as_test_mirrorzs3��
1F�f�0M���%�f�-�4I�*�4U���%�j�1�1�1rc�|�|�d��|����rJ|std|dz��}|s|dkr�	|dkr|�d��|�|||��nC#t$r6}|�d|z��tjd��Yd}~nd}~wwxYw	|dkr"|�d	|jjz��|�	|||��dS#t$r7}|�d
|z��tjd��Yd}~dSd}~wwxYw|�d��tjd��dS|�d|dz��|�d��tjd��dS)
Na
There are objects in the old test database which prevent its destruction.
If they belong to the test user, deleting the user will allow the test database to be recreated.
Otherwise, you will need to find and remove each of these objects, or use a different tablespace.
zType 'yes' to delete user %s: rr!rr$z)Got an error destroying the test user: %sr r"z-Got an error destroying the test database: %sz5Tests cancelled -- test database cannot be recreated.z[Django is configured to use pre-existing test user '%s', and will not attempt to delete it.)
r,r2r/r4r*r-r.rrr0)rr'r:r7r8r<r;s       rr1z:DatabaseCreation._handle_objects_preventing_db_destruction�s��	
���
/�	
�	
�	
��!�!�#�#�	��
W�� @�:�f�CU� U�V�V���
�g��.�.� � �A�~�~����!>�?�?�?��+�+�F�J�	�J�J�J�J�� � � � ��H�H�H�1�L�M�M�M��H�Q�K�K�K�K�K�K�K�K����� ���� � �A�~�~����!Q�TX�Tc�Ti�!i�j�j�j��5�5�f�j�)�T�T�T�T�T�� � � � ��H�H�L�q�P�Q�Q�Q��H�Q�K�K�K�K�K�K�K�K�K����� �������P�Q�Q�Q����������H�H�;�=G��=O�P�
Q�
Q�
Q��H�H�L�M�M�M��H�Q�K�K�K�K�Ks0�2B�
C�,B<�<C�?D�
E�,E�Ec��|jjd|jjd<|jjd|jjd<|j���|���}|j���5}|���r2|dkr|�d��|�|||��|�	��r2|dkr|�d��|�
|||��ddd��n#1swxYwY|j���dS)	z�
        Destroy a test database, prompting the user for confirmation if the
        database already exists. Return the name of the test database created.
        rr
rrrzDestroying test user...z"Destroying test database tables...N)rrr5r&rr'r2r,r4r(r0)r�test_database_namer7r:r's     r�_destroy_test_dbz!DatabaseCreation._destroy_test_db�s���
15��0M�l�0[���%�f�-�48�O�4Q�Rb�4c���%�j�1���������-�-�/�/�
�
�
$�
+�
+�
-�
-�	Q���%�%�'�'�
G���>�>��H�H�6�7�7�7��'�'��
�I�F�F�F��)�)�+�+�
Q���>�>��H�H�A�B�B�B��1�1�&�*�i�P�P�P�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q����	Q�	Q�	Q�	Q�	
��%�%�'�'�'�'�'s�B
D�D"�%D"c���|dkr|�d|dz��|���rddg}nddg}|rdnd}|�|||||��dS)	Nr z_create_test_db(): dbname = %srz�
                CREATE TABLESPACE %(tblspace)s
                DATAFILE SIZE %(size)s
                AUTOEXTEND ON NEXT %(extsize)s MAXSIZE %(maxsize)s
                z�
                CREATE TEMPORARY TABLESPACE %(tblspace_temp)s
                TEMPFILE SIZE %(size_tmp)s
                AUTOEXTEND ON NEXT %(extsize_tmp)s MAXSIZE %(maxsize_tmp)s
                z�
                CREATE TABLESPACE %(tblspace)s
                DATAFILE '%(datafile)s' SIZE %(size)s REUSE
                AUTOEXTEND ON NEXT %(extsize)s MAXSIZE %(maxsize)s
                z�
                CREATE TEMPORARY TABLESPACE %(tblspace_temp)s
                TEMPFILE '%(datafile_tmp)s' SIZE %(size_tmp)s REUSE
                AUTOEXTEND ON NEXT %(extsize_tmp)s MAXSIZE %(maxsize_tmp)s
                r)r,�#_test_database_oracle_managed_files�_execute_allow_fail_statements)rr'r:r7r9�
statements�acceptable_ora_errs       rr)z*DatabaseCreation._execute_test_db_creation�s�����>�>��H�H�5�
�6�8J�J�K�K�K��3�3�5�5�	��
�
�J�J��
�
�J�-3�<�[�[����+�+�F�J�
�I�Wi�j�j�j�j�jrc��|dkr|�d|dz��ddg}|rdnd}|�|||||��}|s0|�d���d}|�||g||��d	D]C}	d
}
|	|d<|�||
g||d��}|s|dkr|�d
|	z���DdS)Nr z"_create_test_user(): username = %srz�CREATE USER %(user)s
               IDENTIFIED BY "%(password)s"
               DEFAULT TABLESPACE %(tblspace)s
               TEMPORARY TABLESPACE %(tblspace_temp)s
               QUOTA UNLIMITED ON %(tblspace)s
            z�GRANT CREATE SESSION,
                     CREATE TABLE,
                     CREATE SEQUENCE,
                     CREATE PROCEDURE,
                     CREATE TRIGGER
               TO %(user)sr#rz0ALTER USER %(user)s IDENTIFIED BY "%(password)s")�VIEWzMATERIALIZED VIEWz(GRANT CREATE %(object_type)s TO %(user)s�object_typez	ORA-01031zBFailed to grant CREATE %s permission to test user. This may be ok.)r,rM�_test_settings_get�_execute_statements)rr'r:r7r9rNrO�success�set_passwordrR�extras           rr3z"DatabaseCreation._create_test_user�s����>�>��H�H�9�J�v�<N�N�O�O�O�
�
�

�
�-3�<�[�[����5�5�f�j�*�V_�as�t�t���	T�4�2�2�:�>�>�F�M�L��$�$�V�l�^�Z��S�S�S�9�	m�	m�K�>�E�(3�J�}�%��9�9�&�5�'�:�W`�bm�n�n�G��
m�y�A�~�~����]�`k�k�l�l�l��	m�	mrc��|dkr|�d|dz��ddg}|�||||��dS)Nr z)_execute_test_db_destruction(): dbname=%srzQDROP TABLESPACE %(tblspace)s INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTSzVDROP TABLESPACE %(tblspace_temp)s INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS�r,rT�rr'r:r7rNs     rr0z-DatabaseCreation._execute_test_db_destruction�sW����>�>��H�H�@�:�f�CU�U�V�V�V�_�d�
�
�	
� � ���Z��K�K�K�K�Krc��|dkr3|�d|dz��|�d��dg}|�||||��dS)Nr z_destroy_test_user(): user=%srz&Be patient. This can take some time...zDROP USER %(user)s CASCADErYrZs     rr4z#DatabaseCreation._destroy_test_usersg����>�>��H�H�4�z�&�7I�I�J�J�J��H�H�=�>�>�>�(�
�
�	
� � ���Z��K�K�K�K�Krc���|D]e}||z}|dkrt|��	|�|���3#t$r&}|r|dkr|�d|z���d}~wwxYwdS)Nr zFailed (%s))�print�executer*r,)	rr'rNr:r7�allow_quiet_fail�template�stmt�errs	         rrTz$DatabaseCreation._execute_statementss���"�		�		�H��j�(�D��A�~�~��d����
����t�$�$�$�$���
�
�
�(�4�Y�!�^�^��H�H�]�c�2�3�3�3������
����
		�		s�6�
A&�!A!�!A&c���	|duot|��dk}|�|||||���dS#t$r!}t|��}|�||vr�Yd}~dSd}~wwxYw)z�
        Execute statements which are allowed to fail silently if the Oracle
        error code given by `acceptable_ora_err` is raised. Return True if the
        statements execute without an exception, or False otherwise.
        Nr)r_TF)�lenrTrr+)	rr'rNr:r7rOr_rb�descriptions	         rrMz/DatabaseCreation._execute_allow_fail_statementss���		�1��=�]�#�FX�BY�BY�\]�B]���$�$�V�Z��Y�aq�$�r�r�r��4���	�	�	��c�(�(�K�!�)�-?�{�-R�-R���5�5�5�5�5�����		���s�15�
A �A�A c��|���|���|���|���|���|���|���|���|���|�	��|�
��|���|���d�
S)N)
�dbnamerr�tblspace�
tblspace_temp�datafile�datafile_tmp�maxsize�maxsize_tmp�size�size_tmp�extsize�extsize_tmp)
�_test_database_name�_test_database_user�_test_database_passwd�_test_database_tblspace�_test_database_tblspace_tmp� _test_database_tblspace_datafile�$_test_database_tblspace_tmp_datafile�_test_database_tblspace_maxsize�#_test_database_tblspace_tmp_maxsize�_test_database_tblspace_size� _test_database_tblspace_tmp_size�_test_database_tblspace_extsize�#_test_database_tblspace_tmp_extsize�rs rr&z$DatabaseCreation._get_test_db_params,s����.�.�0�0��,�,�.�.��2�2�4�4��4�4�6�6�!�=�=�?�?��=�=�?�?� �E�E�G�G��;�;�=�=��C�C�E�E��5�5�7�7��=�=�?�?��;�;�=�=��C�C�E�E�
�
�	
rNc�~�|jj}|d�||��}|�|rt||z}|S)z�
        Return a value from the test settings dict, or a given default, or a
        prefixed entry from the main settings dict.
        r?�rrr�TEST_DATABASE_PREFIX)r�key�default�prefixedr�vals      rrSz#DatabaseCreation._test_settings_get=sE��
��5�
��F�#�'�'��W�5�5���;�8�;�&��x�)@�@�C��
rc�0�|�dd���S)Nr%�r��rSrs rrrz$DatabaseCreation._test_database_nameH����&�&�v��&�?�?�?rc�0�|�dd���S)N�	CREATE_DBT�r�r�rs rr(z&DatabaseCreation._test_database_createKs���&�&�{�D�&�A�A�Arc�0�|�dd���S)N�CREATE_USERTr�r�rs rr2z"DatabaseCreation._test_user_createNs���&�&�}�d�&�C�C�Crc�0�|�dd���S)Nr
r�r�rs rrsz$DatabaseCreation._test_database_userQr�rc�z�|�d��}|�#|���rtd��}|S)Nr�)rSr2r)rrs  rrtz&DatabaseCreation._test_database_passwdTs>���*�*�:�6�6����� 6� 6� 8� 8��(��,�,�H��rc�0�|�dd���S)N�TBLSPACEr
r�r�rs rruz(DatabaseCreation._test_database_tblspace[s���&�&�z�F�&�C�C�Crc�t�|jj}|d�dt|dzdz��S)Nr?�TBLSPACE_TMPr
�_tempr��rrs  rrvz,DatabaseCreation._test_database_tblspace_tmp^sA����5�
��V�$�(�(��)=�
�f�@U�)U�X_�)_�a�a�	arc�^�d|���z}|�d|���S)N�%s.dbf�DATAFILEr�)rurS�rrhs  rrwz1DatabaseCreation._test_database_tblspace_datafilecs1���d�:�:�<�<�<���&�&�z�8�&�D�D�Drc�^�d|���z}|�d|���S)Nr��DATAFILE_TMPr�)rvrSr�s  rrxz5DatabaseCreation._test_database_tblspace_tmp_datafilegs1���d�>�>�@�@�@���&�&�~�x�&�H�H�Hrc�0�|�dd���S)N�DATAFILE_MAXSIZE�500Mr�r�rs rryz0DatabaseCreation._test_database_tblspace_maxsizeks���&�&�'9�6�&�J�J�Jrc�0�|�dd���S)N�DATAFILE_TMP_MAXSIZEr�r�r�rs rrzz4DatabaseCreation._test_database_tblspace_tmp_maxsizens���&�&�'=�v�&�N�N�Nrc�0�|�dd���S)N�
DATAFILE_SIZE�50Mr�r�rs rr{z-DatabaseCreation._test_database_tblspace_sizeqs���&�&���&�F�F�Frc�0�|�dd���S)N�DATAFILE_TMP_SIZEr�r�r�rs rr|z1DatabaseCreation._test_database_tblspace_tmp_sizets���&�&�':�E�&�J�J�Jrc�0�|�dd���S)N�DATAFILE_EXTSIZE�25Mr�r�rs rr}z0DatabaseCreation._test_database_tblspace_extsizews���&�&�'9�5�&�I�I�Irc�0�|�dd���S)N�DATAFILE_TMP_EXTSIZEr�r�r�rs rr~z4DatabaseCreation._test_database_tblspace_tmp_extsizez����&�&�'=�u�&�M�M�Mrc�0�|�dd���S)N�ORACLE_MANAGED_FILESFr�r�rs rrLz4DatabaseCreation._test_database_oracle_managed_files}r�rc�&�|jjdS)z�
        Return the 'production' DB name to get the test DB creation machinery
        to work. This isn't a great deal in this case because DB names as
        handled by Django don't have real counterparts in Oracle.
        r%rDrs r�_get_test_db_namez"DatabaseCreation._get_test_db_name�s����,�V�4�4rc�|�|jj}|d|d|d|d|���fS)N�HOST�PORT�ENGINEr%)rrrsr�s  r�test_db_signaturez"DatabaseCreation.test_db_signature�sE����5�
��&�!��&�!��(�#��&�!��$�$�&�&�
�	
r)rFF)r)F)NN)$�__name__�
__module__�__qualname__rrr=r6rFr1rJr)r3r0r4rTrMr&rSrrr(r2rsrtrurvrwrxryrzr{r|r}r~rLr�r��rrr
r
sh�������
K�
K��_�
K�F5�F5�F5�F5�Pg�g�g�(V�V�V�#�#�#�J(�(�(�(�(k�k�k�k�Bm�m�m�m�BL�L�L�L�L�L�
�
�
�
����"
�
�
�"	�	�	�	�@�@�@�B�B�B�D�D�D�@�@�@����D�D�D�a�a�a�
E�E�E�I�I�I�K�K�K�O�O�O�G�G�G�K�K�K�J�J�J�N�N�N�N�N�N�5�5�5�
�
�
�
�
rr
)
r-�django.confr�	django.dbr� django.db.backends.base.creationr�django.utils.cryptor�django.utils.functionalrr�r
r�rr�<module>r�s���
�
�
�
� � � � � � �#�#�#�#�#�#�A�A�A�A�A�A�1�1�1�1�1�1�3�3�3�3�3�3���D
�D
�D
�D
�D
�+�D
�D
�D
�D
�D
r

Youez - 2016 - github.com/yon3zu
LinuXploit