�����JFIF��XX����������    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222�����"����4���������������������������� ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu������������������������������������#ډb���_�N��?�����������wQ���5-�~�I���8���������������������������������TK<5o�Iv-������������������k�_U_������������������������������~b�M��d��������Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�����?_�'ϔ��_�Ջt������������������������=||I �����6�έ"�����D���/[�k�9����Y�8������ds|\���Ҿp6�Ҵ���]��.����6���z<�v��@]�i%������������������������$j��~����g��J>��no����pM[me�i$[�����������s�o�ᘨ�˸ nɜG-�ĨU�ycP���3.DB�li�;���������������������hj���x����7Z^�N�h��������N3u{�:j�����x�힞��#M��&��jL P@��_���� P�������������������&��o8��������9������@Sz���6�t7#O�ߋ �����s}Yf�T������lmr����Z)'N��k�۞p�����w\�T���������������ȯ?�8`���O��i{wﭹW�[�r�� ��Q4F�׊������3m&L�=��h3�������z~��#����\�l :�F,j@�� ʱ�wQT����8�"kJO����6�֚l������������������}����R�>ډK���]��y����&����p�}b������;N�1�m�r$����|��7�>e�@���B�TM*-i�H��g�D�)� E�m�|�ؘbҗ�a���Ҿ����������������t4�����o���G��*oCN�rP���Q��@z,|?W[0���������:�n,j���WiE��W������$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S���������������VN;���}�s?.����� w��9��˟<���Mq4�Wv'������{)0�1mB����V����W[��������8�/<� �%���wT^�5���b��)iM� p�g�N�&ݝ������������VO~��q���u���9��� ����!��J27�����$����O-���! �:���%H��� ـ�������y�ΠM=t{!S�� �oK8�������t<����è��������:a��������[������ա�H���~��w��Qz`�p����o�^ ������Q��n����� �,uu�C��$ ^���,�������8�#��:�6��e�|~�����������!�3��3.�\0�����q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<�����Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y���|�y��� ~�6�@c��1vOp��������Ig�����4��l�OD�����L����� R���c���j�_�uX�6��3?nk��Wy�f;^*B� ��@���~a�`��Eu�������+�����6�L��.ü>��}y���}_�O�6�͐�:�Yr���G�X��kG������l^w����������~㒶sy���Iu�!���� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT����G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2������#I/�׍qz��^t�̔���������b�Yz4x����t�){ OH�����+(E��A&�N�������XT��o��"�XC����'���)}�J�z�p� ����~5�}�^����+�6����w��c��Q�|�Lp�d�H��}�(�.|����k��c4^�����"�����Z?ȕ ��a<�������L�!0�39C� �Eu�����C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf����M}7����]�������s2tcS{�\icTx;�\��7K���P������ʇ Z O-��~�������c>"��?��������P�����E��O�8��@�8��G��Q�g�a�Վ���󁶠��䧘��_%#r�>�����1�z�a���eb��qcP��ѵ��n���#L��� =��׀t� L�7�`�����V����A{�C:�g���e@�����w1 Xp�3�c3�ġ�������p��M"'-�@n4���fG���B3�DJ�8[Jo�ߐ���gK)ƛ��$���� �������8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`�������?��K�����QK�d���������B`�s}�>���`������*�>��,*@J�d�oF*�����弝��O}�k��s��]��y�ߘ�������c1G�V���<=�7��7����6��q�PT��tXԀ�!9*4�4Tހ���3XΛex�46�������Y��D ����� ����BdemDa����\�_l,����G�/���֌7���Y�](�xTt^%�GE�����4�}bT����ڹ�����;��Y)���B�Q��u��>J/J ���⮶.�XԄ��j�ݳ������+E��d ���r�5�_D�����1 ���o�� �B�x�΢�#����<��W�����8���R6�@���g�M�.��� dr�D��>(otU��@�x=��~v���2� ӣ�d�oBd�����3�eO�6�㣷����������ݜ�6��6Y��Qz`����S��{���\P��~z m5{J/L��1������<�e�ͅPu���b�]�ϔ��������'�������f�b� Zpw��c`"��i���BD@:)ִ�:�]��h���v�E��w���T�l�������P����"Ju�}��وV ��J��G6��. J/�Qgl߭�e�����@�z�Zev2u����)]կ���������7x�������s�M�-<ɯ�c��r��v�����@��$�ޮ}lk���a����'����>x��O\�Z������Fu>������ck#��&:��`�$��ai�>2Δ����l���oF[h�������lE�ܺ�Π���k:)���`������� $[6�����9�����kOw�\|�����8}������ބ:��񶐕��������I�A1/���=�2[�,�!��.}gN#�u����b���� ~���������݊��}34q�����d�E��L��������c��$���"�[q�U�硬g^��%B ��z���r�p�������J�ru%v\h�����1Y�ne`������ǥ:g����pQM~�^��Xi� ��`S�:V2������9.�P���V������?B�k�� ��������AEvw%�_�9C�Q����wKekP�ؠ�\������;Io d�{ ߞo�c1eP�����\� `����E=���@K<�Y��������eڼ�J����w����{av�F�'�M�@��������������/J��+9p����|]���������Iw &`���8���&�M�hg���[�{�������Xj���%��Ӓ�������������������$��(�����ʹN�������<>�I���RY�����K2�NPlL�ɀ�)��&e��������B+ь����(������������������� � �JTx����_?EZ� }@���� 6�U���뙢ط�z��dWI��n` D����噥�[��uV��"�G&�����Ú����2�g�}&m���������������������?ċ���"����Om#�������������������������� ��{���������������������ON��"S�X���Ne��ysQ���@�������������Fn��Vg�����dX�~nj����������������������]J�<�K]:����FW���b�������62����������=��5f����JKw����bf�X������������������������55��~J �%^�������:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v�������g�8�1��f2�������������������������4;�V���ǔ�)�������������������9���1\������������������������������c��v�/'Ƞ�w������������������$�4�R-��t����������������������������������� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃�������������������������������������������A��20�c#���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������@���� 0!1@AP"#2Q`$3V�%45a6�FRUq����� ������^7ׅ,$n��������+��F�`��2X'��0vM��p�L=�������5��8������u�p~���.�`r�����\����O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;�������S�T���1���i[U�ɵz�]��U)V�S6���3$K{��ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u��!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ����D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v������멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$��JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4��[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ��dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il���d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J���oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.����3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R�=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N������#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%����JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$�I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$����L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)��H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>��dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\��y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~�������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7���ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz���)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)�'��8Ϣ�ٔ���ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'��L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(�}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3��������QT��a�����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3��,#c�co��q�a)*P�t����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O����������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l��O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m����PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q��������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~��|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@�l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`�7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ�����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i�����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0���Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q���nxҍ!U�f�!eh�i�2�m����`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{�/ �?�͟��|1�:�#g��W�>$����d��J��d�B���=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H�����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l�����l�cGs�ځ�������y�Ac������\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6�����N6�q��������N� ���! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td���� ?�����N����a��3��m���C���w��������xA�m�q�m����m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4����r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0�������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ�����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G������Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q��(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9���3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M�����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#y�w��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa�����Q�#� WeF��ŮNj�p�J* mQ�N�����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]���陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv�:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WP�w���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*�� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp��BGv[]�u�Ov����0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND���.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J ��4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R���� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(��>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG���{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/���*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>�e]�����Q�r�:����g�,i"�����ԩA��*M�<�G��b�if��l^M��5�� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f������֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ����˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)���h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������� G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W��I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��B�S�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c����]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪��\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W������6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}������6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@��P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6������m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw��k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ�����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e���R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1�[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN���ĕ���0������� !01@Q"2AaPq3BR�������?�����@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j��ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^����ԯ̾9Z��F��������n��1��� ��]�[��)�'�������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ���&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0���;_���3������� !01"@AQa2Pq#3BR�������?����ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q�� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6�����������4B>��o��](��$B���m�����a�!=���?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{�E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)�����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a��84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b���$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7���k�� 403WebShell
403Webshell
Server IP : 93.127.173.124  /  Your IP : 216.73.216.150
Web Server : LiteSpeed
System : Linux in-mum-web1874.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User : u862839997 ( 862839997)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyc
�
1��fcg@sgdZddlmZddlZddlZddlmZddl	m
Zddl	mZddl	m
Zdd	l	mZdd
l	mZddl	mZdd
l	mZddl	mZddl	mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlmZ!ddl"m#Z#ddl$m%Z%ddl$m&Z&ddl$m'Z'ddl$m(Z(ddl$m)Z)ddl$m*Z*dd l$m+Z+dd!l$m,Z,dd"l$m-Z-dd#l$m.Z.dd$l$m/Z/ej0d%ej1�Z2ej0d&ej1ej3B�Z4e5d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�gf�Z6d�d�fZ7d�d�d�d�fZ8d�d�d�d�d�d�d�fZ9d�e j:fd���YZ;d�e j<fd���YZ=d�e j>fd���YZ?e?Z@d�e j>fd���YZAeAZBd�e j>fd���YZCeCZDd�e j>fd���YZEeEZFd�e j>fd���YZGd�e j>fd���YZHd�e j>fd���YZId�e jJfd���YZJd�e jKfd���YZKd�e jLe jMfd���YZNeNZOd�e j>fd���YZPePZQd�e j>fd���YZeZRd�e j>fd���YZSd�e jLe jTfd���YZUd�ejVfd���YZWiejXe jX6eNe jY6eUe jT6ejZe j[jZ6ej[e j[6Z\i+ejXd�6ej]d�6ej[d�6ej^d�6ej_d�6ej`d�6ejad�6ejbd�6ejcd�6ejdd�6e*d�6e%d�6e-d�6e/d�6e'd�6e jed�6e jed�6e.d�6e+d�6e)d�6e,d�6e?d�6eAd�6ed�6ePd�6ePd�6eCd�6eEd�6eGd�6eHd�6eId�6e=d�6eJd�6eJd�6eJd�6eKd�6eKd�6e(d�6eKd�6e;d�6e&d�6eNd�6eSd�6Zfd�ejgfd���YZhd�ejifd���YZjd�ejkfd���YZld�ejmfd���YZnd�ejofd���YZpd�ejqfd���YZrd�ejqfd���YZsd�ejtfd���YZud�ejvfd���YZwd�ejvfd���YZxd�ejyfd���YZzdS(�sc�
.. dialect:: postgresql
    :name: PostgreSQL
    :full_support: 12, 13, 14, 15
    :normal_support: 9.6+
    :best_effort: 8+

.. _postgresql_sequences:

Sequences/SERIAL/IDENTITY
-------------------------

PostgreSQL supports sequences, and SQLAlchemy uses these as the default means
of creating new primary key values for integer-based primary key columns. When
creating tables, SQLAlchemy will issue the ``SERIAL`` datatype for
integer-based primary key columns, which generates a sequence and server side
default corresponding to the column.

To specify a specific named sequence to be used for primary key generation,
use the :func:`~sqlalchemy.schema.Sequence` construct::

    Table('sometable', metadata,
            Column('id', Integer, Sequence('some_id_seq'), primary_key=True)
        )

When SQLAlchemy issues a single INSERT statement, to fulfill the contract of
having the "last insert identifier" available, a RETURNING clause is added to
the INSERT statement which specifies the primary key columns should be
returned after the statement completes. The RETURNING functionality only takes
place if PostgreSQL 8.2 or later is in use. As a fallback approach, the
sequence, whether specified explicitly or implicitly via ``SERIAL``, is
executed independently beforehand, the returned value to be used in the
subsequent insert. Note that when an
:func:`~sqlalchemy.sql.expression.insert()` construct is executed using
"executemany" semantics, the "last inserted identifier" functionality does not
apply; no RETURNING clause is emitted nor is the sequence pre-executed in this
case.

To force the usage of RETURNING by default off, specify the flag
``implicit_returning=False`` to :func:`_sa.create_engine`.

PostgreSQL 10 and above IDENTITY columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PostgreSQL 10 and above have a new IDENTITY feature that supersedes the use
of SERIAL. The :class:`_schema.Identity` construct in a
:class:`_schema.Column` can be used to control its behavior::

    from sqlalchemy import Table, Column, MetaData, Integer, Computed

    metadata = MetaData()

    data = Table(
        "data",
        metadata,
        Column(
            'id', Integer, Identity(start=42, cycle=True), primary_key=True
        ),
        Column('data', String)
    )

The CREATE TABLE for the above :class:`_schema.Table` object would be:

.. sourcecode:: sql

    CREATE TABLE data (
        id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 42 CYCLE),
        data VARCHAR,
        PRIMARY KEY (id)
    )

.. versionchanged::  1.4   Added :class:`_schema.Identity` construct
   in a :class:`_schema.Column` to specify the option of an autoincrementing
   column.

.. note::

   Previous versions of SQLAlchemy did not have built-in support for rendering
   of IDENTITY, and could use the following compilation hook to replace
   occurrences of SERIAL with IDENTITY::

       from sqlalchemy.schema import CreateColumn
       from sqlalchemy.ext.compiler import compiles


       @compiles(CreateColumn, 'postgresql')
       def use_identity(element, compiler, **kw):
           text = compiler.visit_create_column(element, **kw)
           text = text.replace(
               "SERIAL", "INT GENERATED BY DEFAULT AS IDENTITY"
            )
           return text

   Using the above, a table such as::

       t = Table(
           't', m,
           Column('id', Integer, primary_key=True),
           Column('data', String)
       )

   Will generate on the backing database as::

       CREATE TABLE t (
           id INT GENERATED BY DEFAULT AS IDENTITY,
           data VARCHAR,
           PRIMARY KEY (id)
       )

.. _postgresql_ss_cursors:

Server Side Cursors
-------------------

Server-side cursor support is available for the psycopg2, asyncpg
dialects and may also be available in others.

Server side cursors are enabled on a per-statement basis by using the
:paramref:`.Connection.execution_options.stream_results` connection execution
option::

    with engine.connect() as conn:
        result = conn.execution_options(stream_results=True).execute(text("select * from table"))

Note that some kinds of SQL statements may not be supported with
server side cursors; generally, only SQL statements that return rows should be
used with this option.

.. deprecated:: 1.4  The dialect-level server_side_cursors flag is deprecated
   and will be removed in a future release.  Please use the
   :paramref:`_engine.Connection.stream_results` execution option for
   unbuffered cursor support.

.. seealso::

    :ref:`engine_stream_results`

.. _postgresql_isolation_level:

Transaction Isolation Level
---------------------------

Most SQLAlchemy dialects support setting of transaction isolation level
using the :paramref:`_sa.create_engine.isolation_level` parameter
at the :func:`_sa.create_engine` level, and at the :class:`_engine.Connection`
level via the :paramref:`.Connection.execution_options.isolation_level`
parameter.

For PostgreSQL dialects, this feature works either by making use of the
DBAPI-specific features, such as psycopg2's isolation level flags which will
embed the isolation level setting inline with the ``"BEGIN"`` statement, or for
DBAPIs with no direct support by emitting ``SET SESSION CHARACTERISTICS AS
TRANSACTION ISOLATION LEVEL <level>`` ahead of the ``"BEGIN"`` statement
emitted by the DBAPI.   For the special AUTOCOMMIT isolation level,
DBAPI-specific techniques are used which is typically an ``.autocommit``
flag on the DBAPI connection object.

To set isolation level using :func:`_sa.create_engine`::

    engine = create_engine(
        "postgresql+pg8000://scott:tiger@localhost/test",
        isolation_level = "REPEATABLE READ"
    )

To set using per-connection execution options::

    with engine.connect() as conn:
        conn = conn.execution_options(
            isolation_level="REPEATABLE READ"
        )
        with conn.begin():
            # ... work with transaction

There are also more options for isolation level configurations, such as
"sub-engine" objects linked to a main :class:`_engine.Engine` which each apply
different isolation level settings.  See the discussion at
:ref:`dbapi_autocommit` for background.

Valid values for ``isolation_level`` on most PostgreSQL dialects include:

* ``READ COMMITTED``
* ``READ UNCOMMITTED``
* ``REPEATABLE READ``
* ``SERIALIZABLE``
* ``AUTOCOMMIT``

.. seealso::

    :ref:`dbapi_autocommit`

    :ref:`postgresql_readonly_deferrable`

    :ref:`psycopg2_isolation_level`

    :ref:`pg8000_isolation_level`

.. _postgresql_readonly_deferrable:

Setting READ ONLY / DEFERRABLE
------------------------------

Most PostgreSQL dialects support setting the "READ ONLY" and "DEFERRABLE"
characteristics of the transaction, which is in addition to the isolation level
setting. These two attributes can be established either in conjunction with or
independently of the isolation level by passing the ``postgresql_readonly`` and
``postgresql_deferrable`` flags with
:meth:`_engine.Connection.execution_options`.  The example below illustrates
passing the ``"SERIALIZABLE"`` isolation level at the same time as setting
"READ ONLY" and "DEFERRABLE"::

    with engine.connect() as conn:
        conn = conn.execution_options(
            isolation_level="SERIALIZABLE",
            postgresql_readonly=True,
            postgresql_deferrable=True
        )
        with conn.begin():
            #  ... work with transaction

Note that some DBAPIs such as asyncpg only support "readonly" with
SERIALIZABLE isolation.

.. versionadded:: 1.4 added support for the ``postgresql_readonly``
   and ``postgresql_deferrable`` execution options.

.. _postgresql_reset_on_return:

Temporary Table / Resource Reset for Connection Pooling
-------------------------------------------------------

The :class:`.QueuePool` connection pool implementation used
by the SQLAlchemy :class:`_sa.Engine` object includes
:ref:`reset on return <pool_reset_on_return>` behavior that will invoke
the DBAPI ``.rollback()`` method when connections are returned to the pool.
While this rollback will clear out the immediate state used by the previous
transaction, it does not cover a wider range of session-level state, including
temporary tables as well as other server state such as prepared statement
handles and statement caches.   The PostgreSQL database includes a variety
of commands which may be used to reset this state, including
``DISCARD``, ``RESET``, ``DEALLOCATE``, and ``UNLISTEN``.


To install
one or more of these commands as the means of performing reset-on-return,
the :meth:`.PoolEvents.reset` event hook may be used, as demonstrated
in the example below (**requires SQLAlchemy 1.4.43 or greater**). The implementation
will end transactions in progress as well as discard temporary tables
using the ``CLOSE``, ``RESET`` and ``DISCARD`` commands; see the PostgreSQL
documentation for background on what each of these statements do.

The :paramref:`_sa.create_engine.pool_reset_on_return` parameter
is set to ``None`` so that the custom scheme can replace the default behavior
completely.   The custom hook implementation calls ``.rollback()`` in any case,
as it's usually important that the DBAPI's own tracking of commit/rollback
will remain consistent with the state of the transaction::


    from sqlalchemy import create_engine
    from sqlalchemy import event

    postgresql_engine = create_engine(
        "postgresql+pyscopg2://scott:tiger@hostname/dbname",

        # disable default reset-on-return scheme
        pool_reset_on_return=None,
    )


    @event.listens_for(postgresql_engine, "reset")
    def _reset_postgresql(dbapi_connection, connection_record, reset_state):
        dbapi_connection.execute("CLOSE ALL")
        dbapi_connection.execute("RESET ALL")
        dbapi_connection.execute("DISCARD TEMP")

        # so that the DBAPI itself knows that the connection has been
        # reset
        dbapi_connection.rollback()

.. versionchanged:: 1.4.43  Ensured the :meth:`.PoolEvents.reset` event
   is invoked for all "reset" occurrences, so that it's appropriate
   as a place for custom "reset" handlers.   Previous schemes which
   use the :meth:`.PoolEvents.checkin` handler remain usable as well.

.. seealso::

    :ref:`pool_reset_on_return` - in the :ref:`pooling_toplevel` documentation

.. _postgresql_alternate_search_path:

Setting Alternate Search Paths on Connect
------------------------------------------

The PostgreSQL ``search_path`` variable refers to the list of schema names
that will be implicitly referred towards when a particular table or other
object is referenced in a SQL statement.  As detailed in the next section
:ref:`postgresql_schema_reflection`, SQLAlchemy is generally organized around
the concept of keeping this variable at its default value of ``public``,
however, in order to have it set to any arbitrary name or names when connections
are used automatically, the "SET SESSION search_path" command may be invoked
for all connections in a pool using the following event handler, as discussed
at :ref:`schema_set_default_connections`::

    from sqlalchemy import event
    from sqlalchemy import create_engine

    engine = create_engine("postgresql+psycopg2://scott:tiger@host/dbname")

    @event.listens_for(engine, "connect", insert=True)
    def set_search_path(dbapi_connection, connection_record):
        existing_autocommit = dbapi_connection.autocommit
        dbapi_connection.autocommit = True
        cursor = dbapi_connection.cursor()
        cursor.execute("SET SESSION search_path='%s'" % schema_name)
        cursor.close()
        dbapi_connection.autocommit = existing_autocommit

The reason the recipe is complicated by use of the ``.autocommit`` DBAPI
attribute is so that when the ``SET SESSION search_path`` directive is invoked,
it is invoked outside of the scope of any transaction and therefore will not
be reverted when the DBAPI connection has a rollback.

.. seealso::

  :ref:`schema_set_default_connections` - in the :ref:`metadata_toplevel` documentation




.. _postgresql_schema_reflection:

Remote-Schema Table Introspection and PostgreSQL search_path
------------------------------------------------------------

.. admonition:: Section Best Practices Summarized

    keep the ``search_path`` variable set to its default of ``public``, without
    any other schema names. Ensure the username used to connect **does not**
    match remote schemas, or ensure the ``"$user"`` token is **removed** from
    ``search_path``.  For other schema names, name these explicitly
    within :class:`_schema.Table` definitions. Alternatively, the
    ``postgresql_ignore_search_path`` option will cause all reflected
    :class:`_schema.Table` objects to have a :attr:`_schema.Table.schema`
    attribute set up.

The PostgreSQL dialect can reflect tables from any schema, as outlined in
:ref:`metadata_reflection_schemas`.

In all cases, the first thing SQLAlchemy does when reflecting tables is
to **determine the default schema for the current database connection**.
It does this using the PostgreSQL ``current_schema()``
function, illustated below using a PostgreSQL client session (i.e. using
the ``psql`` tool)::

    test=> select current_schema();
    current_schema
    ----------------
    public
    (1 row)

Above we see that on a plain install of PostgreSQL, the default schema name
is the name ``public``.

However, if your database username **matches the name of a schema**, PostgreSQL's
default is to then **use that name as the default schema**.  Below, we log in
using the username ``scott``.  When we create a schema named ``scott``, **it
implicitly changes the default schema**::

    test=> select current_schema();
    current_schema
    ----------------
    public
    (1 row)

    test=> create schema scott;
    CREATE SCHEMA
    test=> select current_schema();
    current_schema
    ----------------
    scott
    (1 row)

The behavior of ``current_schema()`` is derived from the
`PostgreSQL search path
<https://www.postgresql.org/docs/current/static/ddl-schemas.html#DDL-SCHEMAS-PATH>`_
variable ``search_path``, which in modern PostgreSQL versions defaults to this::

    test=> show search_path;
    search_path
    -----------------
    "$user", public
    (1 row)

Where above, the ``"$user"`` variable will inject the current username as the
default schema, if one exists.   Otherwise, ``public`` is used.

When a :class:`_schema.Table` object is reflected, if it is present in the
schema indicated by the ``current_schema()`` function, **the schema name assigned
to the ".schema" attribute of the Table is the Python "None" value**.  Otherwise, the
".schema" attribute will be assigned the string name of that schema.

With regards to tables which these :class:`_schema.Table`
objects refer to via foreign key constraint, a decision must be made as to how
the ``.schema`` is represented in those remote tables, in the case where that
remote schema name is also a member of the current ``search_path``.

By default, the PostgreSQL dialect mimics the behavior encouraged by
PostgreSQL's own ``pg_get_constraintdef()`` builtin procedure.  This function
returns a sample definition for a particular foreign key constraint,
omitting the referenced schema name from that definition when the name is
also in the PostgreSQL schema search path.  The interaction below
illustrates this behavior::

    test=> CREATE TABLE test_schema.referred(id INTEGER PRIMARY KEY);
    CREATE TABLE
    test=> CREATE TABLE referring(
    test(>         id INTEGER PRIMARY KEY,
    test(>         referred_id INTEGER REFERENCES test_schema.referred(id));
    CREATE TABLE
    test=> SET search_path TO public, test_schema;
    test=> SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM
    test-> pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n
    test-> ON n.oid = c.relnamespace
    test-> JOIN pg_catalog.pg_constraint r  ON c.oid = r.conrelid
    test-> WHERE c.relname='referring' AND r.contype = 'f'
    test-> ;
                   pg_get_constraintdef
    ---------------------------------------------------
     FOREIGN KEY (referred_id) REFERENCES referred(id)
    (1 row)

Above, we created a table ``referred`` as a member of the remote schema
``test_schema``, however when we added ``test_schema`` to the
PG ``search_path`` and then asked ``pg_get_constraintdef()`` for the
``FOREIGN KEY`` syntax, ``test_schema`` was not included in the output of
the function.

On the other hand, if we set the search path back to the typical default
of ``public``::

    test=> SET search_path TO public;
    SET

The same query against ``pg_get_constraintdef()`` now returns the fully
schema-qualified name for us::

    test=> SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM
    test-> pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n
    test-> ON n.oid = c.relnamespace
    test-> JOIN pg_catalog.pg_constraint r  ON c.oid = r.conrelid
    test-> WHERE c.relname='referring' AND r.contype = 'f';
                         pg_get_constraintdef
    ---------------------------------------------------------------
     FOREIGN KEY (referred_id) REFERENCES test_schema.referred(id)
    (1 row)

SQLAlchemy will by default use the return value of ``pg_get_constraintdef()``
in order to determine the remote schema name.  That is, if our ``search_path``
were set to include ``test_schema``, and we invoked a table
reflection process as follows::

    >>> from sqlalchemy import Table, MetaData, create_engine, text
    >>> engine = create_engine("postgresql://scott:tiger@localhost/test")
    >>> with engine.connect() as conn:
    ...     conn.execute(text("SET search_path TO test_schema, public"))
    ...     metadata_obj = MetaData()
    ...     referring = Table('referring', metadata_obj,
    ...                       autoload_with=conn)
    ...
    <sqlalchemy.engine.result.CursorResult object at 0x101612ed0>

The above process would deliver to the :attr:`_schema.MetaData.tables`
collection
``referred`` table named **without** the schema::

    >>> metadata_obj.tables['referred'].schema is None
    True

To alter the behavior of reflection such that the referred schema is
maintained regardless of the ``search_path`` setting, use the
``postgresql_ignore_search_path`` option, which can be specified as a
dialect-specific argument to both :class:`_schema.Table` as well as
:meth:`_schema.MetaData.reflect`::

    >>> with engine.connect() as conn:
    ...     conn.execute(text("SET search_path TO test_schema, public"))
    ...     metadata_obj = MetaData()
    ...     referring = Table('referring', metadata_obj,
    ...                       autoload_with=conn,
    ...                       postgresql_ignore_search_path=True)
    ...
    <sqlalchemy.engine.result.CursorResult object at 0x1016126d0>

We will now have ``test_schema.referred`` stored as schema-qualified::

    >>> metadata_obj.tables['test_schema.referred'].schema
    'test_schema'

.. sidebar:: Best Practices for PostgreSQL Schema reflection

    The description of PostgreSQL schema reflection behavior is complex, and
    is the product of many years of dealing with widely varied use cases and
    user preferences. But in fact, there's no need to understand any of it if
    you just stick to the simplest use pattern: leave the ``search_path`` set
    to its default of ``public`` only, never refer to the name ``public`` as
    an explicit schema name otherwise, and refer to all other schema names
    explicitly when building up a :class:`_schema.Table` object.  The options
    described here are only for those users who can't, or prefer not to, stay
    within these guidelines.

.. seealso::

    :ref:`reflection_schema_qualified_interaction` - discussion of the issue
    from a backend-agnostic perspective

    `The Schema Search Path
    <https://www.postgresql.org/docs/current/static/ddl-schemas.html#DDL-SCHEMAS-PATH>`_
    - on the PostgreSQL website.

INSERT/UPDATE...RETURNING
-------------------------

The dialect supports PG 8.2's ``INSERT..RETURNING``, ``UPDATE..RETURNING`` and
``DELETE..RETURNING`` syntaxes.   ``INSERT..RETURNING`` is used by default
for single-row INSERT statements in order to fetch newly generated
primary key identifiers.   To specify an explicit ``RETURNING`` clause,
use the :meth:`._UpdateBase.returning` method on a per-statement basis::

    # INSERT..RETURNING
    result = table.insert().returning(table.c.col1, table.c.col2).\
        values(name='foo')
    print(result.fetchall())

    # UPDATE..RETURNING
    result = table.update().returning(table.c.col1, table.c.col2).\
        where(table.c.name=='foo').values(name='bar')
    print(result.fetchall())

    # DELETE..RETURNING
    result = table.delete().returning(table.c.col1, table.c.col2).\
        where(table.c.name=='foo')
    print(result.fetchall())

.. _postgresql_insert_on_conflict:

INSERT...ON CONFLICT (Upsert)
------------------------------

Starting with version 9.5, PostgreSQL allows "upserts" (update or insert) of
rows into a table via the ``ON CONFLICT`` clause of the ``INSERT`` statement. A
candidate row will only be inserted if that row does not violate any unique
constraints.  In the case of a unique constraint violation, a secondary action
can occur which can be either "DO UPDATE", indicating that the data in the
target row should be updated, or "DO NOTHING", which indicates to silently skip
this row.

Conflicts are determined using existing unique constraints and indexes.  These
constraints may be identified either using their name as stated in DDL,
or they may be inferred by stating the columns and conditions that comprise
the indexes.

SQLAlchemy provides ``ON CONFLICT`` support via the PostgreSQL-specific
:func:`_postgresql.insert()` function, which provides
the generative methods :meth:`_postgresql.Insert.on_conflict_do_update`
and :meth:`~.postgresql.Insert.on_conflict_do_nothing`:

.. sourcecode:: pycon+sql

    >>> from sqlalchemy.dialects.postgresql import insert
    >>> insert_stmt = insert(my_table).values(
    ...     id='some_existing_id',
    ...     data='inserted value')
    >>> do_nothing_stmt = insert_stmt.on_conflict_do_nothing(
    ...     index_elements=['id']
    ... )
    >>> print(do_nothing_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO NOTHING
    {stop}

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     constraint='pk_my_table',
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT ON CONSTRAINT pk_my_table DO UPDATE SET data = %(param_1)s

.. versionadded:: 1.1

.. seealso::

    `INSERT .. ON CONFLICT
    <https://www.postgresql.org/docs/current/static/sql-insert.html#SQL-ON-CONFLICT>`_
    - in the PostgreSQL documentation.

Specifying the Target
^^^^^^^^^^^^^^^^^^^^^

Both methods supply the "target" of the conflict using either the
named constraint or by column inference:

* The :paramref:`_postgresql.Insert.on_conflict_do_update.index_elements` argument
  specifies a sequence containing string column names, :class:`_schema.Column`
  objects, and/or SQL expression elements, which would identify a unique
  index:

  .. sourcecode:: pycon+sql

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     index_elements=['id'],
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s
    {stop}

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     index_elements=[my_table.c.id],
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s

* When using :paramref:`_postgresql.Insert.on_conflict_do_update.index_elements` to
  infer an index, a partial index can be inferred by also specifying the
  use the :paramref:`_postgresql.Insert.on_conflict_do_update.index_where` parameter:

  .. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(user_email='a@b.com', data='inserted data')
    >>> stmt = stmt.on_conflict_do_update(
    ...     index_elements=[my_table.c.user_email],
    ...     index_where=my_table.c.user_email.like('%@gmail.com'),
    ...     set_=dict(data=stmt.excluded.data)
    ... )
    >>> print(stmt)
    {opensql}INSERT INTO my_table (data, user_email)
    VALUES (%(data)s, %(user_email)s) ON CONFLICT (user_email)
    WHERE user_email LIKE %(user_email_1)s DO UPDATE SET data = excluded.data

* The :paramref:`_postgresql.Insert.on_conflict_do_update.constraint` argument is
  used to specify an index directly rather than inferring it.  This can be
  the name of a UNIQUE constraint, a PRIMARY KEY constraint, or an INDEX:

  .. sourcecode:: pycon+sql

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     constraint='my_table_idx_1',
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT ON CONSTRAINT my_table_idx_1 DO UPDATE SET data = %(param_1)s
    {stop}

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     constraint='my_table_pk',
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT ON CONSTRAINT my_table_pk DO UPDATE SET data = %(param_1)s
    {stop}

* The :paramref:`_postgresql.Insert.on_conflict_do_update.constraint` argument may
  also refer to a SQLAlchemy construct representing a constraint,
  e.g. :class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`,
  :class:`.Index`, or :class:`.ExcludeConstraint`.   In this use,
  if the constraint has a name, it is used directly.  Otherwise, if the
  constraint is unnamed, then inference will be used, where the expressions
  and optional WHERE clause of the constraint will be spelled out in the
  construct.  This use is especially convenient
  to refer to the named or unnamed primary key of a :class:`_schema.Table`
  using the
  :attr:`_schema.Table.primary_key` attribute:

  .. sourcecode:: pycon+sql

    >>> do_update_stmt = insert_stmt.on_conflict_do_update(
    ...     constraint=my_table.primary_key,
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s

The SET Clause
^^^^^^^^^^^^^^^

``ON CONFLICT...DO UPDATE`` is used to perform an update of the already
existing row, using any combination of new values as well as values
from the proposed insertion.   These values are specified using the
:paramref:`_postgresql.Insert.on_conflict_do_update.set_` parameter.  This
parameter accepts a dictionary which consists of direct values
for UPDATE:

.. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(id='some_id', data='inserted value')
    >>> do_update_stmt = stmt.on_conflict_do_update(
    ...     index_elements=['id'],
    ...     set_=dict(data='updated value')
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s

.. warning::

    The :meth:`_expression.Insert.on_conflict_do_update`
    method does **not** take into
    account Python-side default UPDATE values or generation functions, e.g.
    those specified using :paramref:`_schema.Column.onupdate`.
    These values will not be exercised for an ON CONFLICT style of UPDATE,
    unless they are manually specified in the
    :paramref:`_postgresql.Insert.on_conflict_do_update.set_` dictionary.

Updating using the Excluded INSERT Values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In order to refer to the proposed insertion row, the special alias
:attr:`~.postgresql.Insert.excluded` is available as an attribute on
the :class:`_postgresql.Insert` object; this object is a
:class:`_expression.ColumnCollection`
which alias contains all columns of the target
table:

.. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(
    ...     id='some_id',
    ...     data='inserted value',
    ...     author='jlh'
    ... )
    >>> do_update_stmt = stmt.on_conflict_do_update(
    ...     index_elements=['id'],
    ...     set_=dict(data='updated value', author=stmt.excluded.author)
    ... )
    >>> print(do_update_stmt)
    {opensql}INSERT INTO my_table (id, data, author)
    VALUES (%(id)s, %(data)s, %(author)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s, author = excluded.author

Additional WHERE Criteria
^^^^^^^^^^^^^^^^^^^^^^^^^

The :meth:`_expression.Insert.on_conflict_do_update` method also accepts
a WHERE clause using the :paramref:`_postgresql.Insert.on_conflict_do_update.where`
parameter, which will limit those rows which receive an UPDATE:

.. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(
    ...     id='some_id',
    ...     data='inserted value',
    ...     author='jlh'
    ... )
    >>> on_update_stmt = stmt.on_conflict_do_update(
    ...     index_elements=['id'],
    ...     set_=dict(data='updated value', author=stmt.excluded.author),
    ...     where=(my_table.c.status == 2)
    ... )
    >>> print(on_update_stmt)
    {opensql}INSERT INTO my_table (id, data, author)
    VALUES (%(id)s, %(data)s, %(author)s)
    ON CONFLICT (id) DO UPDATE SET data = %(param_1)s, author = excluded.author
    WHERE my_table.status = %(status_1)s

Skipping Rows with DO NOTHING
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``ON CONFLICT`` may be used to skip inserting a row entirely
if any conflict with a unique or exclusion constraint occurs; below
this is illustrated using the
:meth:`~.postgresql.Insert.on_conflict_do_nothing` method:

.. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(id='some_id', data='inserted value')
    >>> stmt = stmt.on_conflict_do_nothing(index_elements=['id'])
    >>> print(stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT (id) DO NOTHING

If ``DO NOTHING`` is used without specifying any columns or constraint,
it has the effect of skipping the INSERT for any unique or exclusion
constraint violation which occurs:

.. sourcecode:: pycon+sql

    >>> stmt = insert(my_table).values(id='some_id', data='inserted value')
    >>> stmt = stmt.on_conflict_do_nothing()
    >>> print(stmt)
    {opensql}INSERT INTO my_table (id, data) VALUES (%(id)s, %(data)s)
    ON CONFLICT DO NOTHING

.. _postgresql_match:

Full Text Search
----------------

SQLAlchemy makes available the PostgreSQL ``@@`` operator via the
:meth:`_expression.ColumnElement.match` method on any textual column expression.

On the PostgreSQL dialect, an expression like the following::

    select(sometable.c.text.match("search string"))

will emit to the database::

    SELECT text @@ to_tsquery('search string') FROM table

Various other PostgreSQL text search functions such as ``to_tsquery()``,
``to_tsvector()``, and ``plainto_tsquery()`` are available by explicitly using
the standard SQLAlchemy :data:`.func` construct.

For example::

    select(func.to_tsvector('fat cats ate rats').match('cat & rat'))

Emits the equivalent of::

    SELECT to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')

The :class:`_postgresql.TSVECTOR` type can provide for explicit CAST::

    from sqlalchemy.dialects.postgresql import TSVECTOR
    from sqlalchemy import select, cast
    select(cast("some text", TSVECTOR))

produces a statement equivalent to::

    SELECT CAST('some text' AS TSVECTOR) AS anon_1

.. tip::

    It's important to remember that text searching in PostgreSQL is powerful but complicated,
    and SQLAlchemy users are advised to reference the PostgreSQL documentation
    regarding
    `Full Text Search <https://www.postgresql.org/docs/current/textsearch-controls.html>`_.

    There are important differences between ``to_tsquery`` and
    ``plainto_tsquery``, the most significant of which is that ``to_tsquery``
    expects specially formatted "querytext" that is written to PostgreSQL's own
    specification, while ``plainto_tsquery`` expects unformatted text that is
    transformed into ``to_tsquery`` compatible querytext. This means the input to
    ``.match()`` under PostgreSQL may be incompatible with the input to
    ``.match()`` under another database backend. SQLAlchemy users who support
    multiple backends are advised to carefully implement their usage of
    ``.match()`` to work around these constraints.

Full Text Searches in PostgreSQL are influenced by a combination of: the
PostgreSQL setting of ``default_text_search_config``, the ``regconfig`` used
to build the GIN/GiST indexes, and the ``regconfig`` optionally passed in
during a query.

When performing a Full Text Search against a column that has a GIN or
GiST index that is already pre-computed (which is common on full text
searches) one may need to explicitly pass in a particular PostgreSQL
``regconfig`` value to ensure the query-planner utilizes the index and does
not re-compute the column on demand.

In order to provide for this explicit query planning, or to use different
search strategies, the ``match`` method accepts a ``postgresql_regconfig``
keyword argument::

    select(mytable.c.id).where(
        mytable.c.title.match('somestring', postgresql_regconfig='english')
    )

Emits the equivalent of::

    SELECT mytable.id FROM mytable
    WHERE mytable.title @@ to_tsquery('english', 'somestring')

One can also specifically pass in a `'regconfig'` value to the
``to_tsvector()`` command as the initial argument::

    select(mytable.c.id).where(
            func.to_tsvector('english', mytable.c.title )\
            .match('somestring', postgresql_regconfig='english')
        )

produces a statement equivalent to::

    SELECT mytable.id FROM mytable
    WHERE to_tsvector('english', mytable.title) @@
        to_tsquery('english', 'somestring')

It is recommended that you use the ``EXPLAIN ANALYZE...`` tool from
PostgreSQL to ensure that you are generating queries with SQLAlchemy that
take full advantage of any indexes you may have created for full text search.

.. seealso::

    `Full Text Search <https://www.postgresql.org/docs/current/textsearch-controls.html>`_ - in the PostgreSQL documentation


FROM ONLY ...
-------------

The dialect supports PostgreSQL's ONLY keyword for targeting only a particular
table in an inheritance hierarchy. This can be used to produce the
``SELECT ... FROM ONLY``, ``UPDATE ONLY ...``, and ``DELETE FROM ONLY ...``
syntaxes. It uses SQLAlchemy's hints mechanism::

    # SELECT ... FROM ONLY ...
    result = table.select().with_hint(table, 'ONLY', 'postgresql')
    print(result.fetchall())

    # UPDATE ONLY ...
    table.update(values=dict(foo='bar')).with_hint('ONLY',
                                                   dialect_name='postgresql')

    # DELETE FROM ONLY ...
    table.delete().with_hint('ONLY', dialect_name='postgresql')


.. _postgresql_indexes:

PostgreSQL-Specific Index Options
---------------------------------

Several extensions to the :class:`.Index` construct are available, specific
to the PostgreSQL dialect.

Covering Indexes
^^^^^^^^^^^^^^^^

The ``postgresql_include`` option renders INCLUDE(colname) for the given
string names::

    Index("my_index", table.c.x, postgresql_include=['y'])

would render the index as ``CREATE INDEX my_index ON table (x) INCLUDE (y)``

Note that this feature requires PostgreSQL 11 or later.

.. versionadded:: 1.4

.. _postgresql_partial_indexes:

Partial Indexes
^^^^^^^^^^^^^^^

Partial indexes add criterion to the index definition so that the index is
applied to a subset of rows.   These can be specified on :class:`.Index`
using the ``postgresql_where`` keyword argument::

  Index('my_index', my_table.c.id, postgresql_where=my_table.c.value > 10)

.. _postgresql_operator_classes:

Operator Classes
^^^^^^^^^^^^^^^^

PostgreSQL allows the specification of an *operator class* for each column of
an index (see
https://www.postgresql.org/docs/current/interactive/indexes-opclass.html).
The :class:`.Index` construct allows these to be specified via the
``postgresql_ops`` keyword argument::

    Index(
        'my_index', my_table.c.id, my_table.c.data,
        postgresql_ops={
            'data': 'text_pattern_ops',
            'id': 'int4_ops'
        })

Note that the keys in the ``postgresql_ops`` dictionaries are the
"key" name of the :class:`_schema.Column`, i.e. the name used to access it from
the ``.c`` collection of :class:`_schema.Table`, which can be configured to be
different than the actual name of the column as expressed in the database.

If ``postgresql_ops`` is to be used against a complex SQL expression such
as a function call, then to apply to the column it must be given a label
that is identified in the dictionary by name, e.g.::

    Index(
        'my_index', my_table.c.id,
        func.lower(my_table.c.data).label('data_lower'),
        postgresql_ops={
            'data_lower': 'text_pattern_ops',
            'id': 'int4_ops'
        })

Operator classes are also supported by the
:class:`_postgresql.ExcludeConstraint` construct using the
:paramref:`_postgresql.ExcludeConstraint.ops` parameter. See that parameter for
details.

.. versionadded:: 1.3.21 added support for operator classes with
   :class:`_postgresql.ExcludeConstraint`.


Index Types
^^^^^^^^^^^

PostgreSQL provides several index types: B-Tree, Hash, GiST, and GIN, as well
as the ability for users to create their own (see
https://www.postgresql.org/docs/current/static/indexes-types.html). These can be
specified on :class:`.Index` using the ``postgresql_using`` keyword argument::

    Index('my_index', my_table.c.data, postgresql_using='gin')

The value passed to the keyword argument will be simply passed through to the
underlying CREATE INDEX command, so it *must* be a valid index type for your
version of PostgreSQL.

.. _postgresql_index_storage:

Index Storage Parameters
^^^^^^^^^^^^^^^^^^^^^^^^

PostgreSQL allows storage parameters to be set on indexes. The storage
parameters available depend on the index method used by the index. Storage
parameters can be specified on :class:`.Index` using the ``postgresql_with``
keyword argument::

    Index('my_index', my_table.c.data, postgresql_with={"fillfactor": 50})

.. versionadded:: 1.0.6

PostgreSQL allows to define the tablespace in which to create the index.
The tablespace can be specified on :class:`.Index` using the
``postgresql_tablespace`` keyword argument::

    Index('my_index', my_table.c.data, postgresql_tablespace='my_tablespace')

.. versionadded:: 1.1

Note that the same option is available on :class:`_schema.Table` as well.

.. _postgresql_index_concurrently:

Indexes with CONCURRENTLY
^^^^^^^^^^^^^^^^^^^^^^^^^

The PostgreSQL index option CONCURRENTLY is supported by passing the
flag ``postgresql_concurrently`` to the :class:`.Index` construct::

    tbl = Table('testtbl', m, Column('data', Integer))

    idx1 = Index('test_idx1', tbl.c.data, postgresql_concurrently=True)

The above index construct will render DDL for CREATE INDEX, assuming
PostgreSQL 8.2 or higher is detected or for a connection-less dialect, as::

    CREATE INDEX CONCURRENTLY test_idx1 ON testtbl (data)

For DROP INDEX, assuming PostgreSQL 9.2 or higher is detected or for
a connection-less dialect, it will emit::

    DROP INDEX CONCURRENTLY test_idx1

.. versionadded:: 1.1 support for CONCURRENTLY on DROP INDEX.  The
   CONCURRENTLY keyword is now only emitted if a high enough version
   of PostgreSQL is detected on the connection (or for a connection-less
   dialect).

When using CONCURRENTLY, the PostgreSQL database requires that the statement
be invoked outside of a transaction block.   The Python DBAPI enforces that
even for a single statement, a transaction is present, so to use this
construct, the DBAPI's "autocommit" mode must be used::

    metadata = MetaData()
    table = Table(
        "foo", metadata,
        Column("id", String))
    index = Index(
        "foo_idx", table.c.id, postgresql_concurrently=True)

    with engine.connect() as conn:
        with conn.execution_options(isolation_level='AUTOCOMMIT'):
            table.create(conn)

.. seealso::

    :ref:`postgresql_isolation_level`

.. _postgresql_index_reflection:

PostgreSQL Index Reflection
---------------------------

The PostgreSQL database creates a UNIQUE INDEX implicitly whenever the
UNIQUE CONSTRAINT construct is used.   When inspecting a table using
:class:`_reflection.Inspector`, the :meth:`_reflection.Inspector.get_indexes`
and the :meth:`_reflection.Inspector.get_unique_constraints`
will report on these
two constructs distinctly; in the case of the index, the key
``duplicates_constraint`` will be present in the index entry if it is
detected as mirroring a constraint.   When performing reflection using
``Table(..., autoload_with=engine)``, the UNIQUE INDEX is **not** returned
in :attr:`_schema.Table.indexes` when it is detected as mirroring a
:class:`.UniqueConstraint` in the :attr:`_schema.Table.constraints` collection
.

.. versionchanged:: 1.0.0 - :class:`_schema.Table` reflection now includes
   :class:`.UniqueConstraint` objects present in the
   :attr:`_schema.Table.constraints`
   collection; the PostgreSQL backend will no longer include a "mirrored"
   :class:`.Index` construct in :attr:`_schema.Table.indexes`
   if it is detected
   as corresponding to a unique constraint.

Special Reflection Options
--------------------------

The :class:`_reflection.Inspector`
used for the PostgreSQL backend is an instance
of :class:`.PGInspector`, which offers additional methods::

    from sqlalchemy import create_engine, inspect

    engine = create_engine("postgresql+psycopg2://localhost/test")
    insp = inspect(engine)  # will be a PGInspector

    print(insp.get_enums())

.. autoclass:: PGInspector
    :members:

.. _postgresql_table_options:

PostgreSQL Table Options
------------------------

Several options for CREATE TABLE are supported directly by the PostgreSQL
dialect in conjunction with the :class:`_schema.Table` construct:

* ``TABLESPACE``::

    Table("some_table", metadata, ..., postgresql_tablespace='some_tablespace')

  The above option is also available on the :class:`.Index` construct.

* ``ON COMMIT``::

    Table("some_table", metadata, ..., postgresql_on_commit='PRESERVE ROWS')

* ``WITH OIDS``::

    Table("some_table", metadata, ..., postgresql_with_oids=True)

* ``WITHOUT OIDS``::

    Table("some_table", metadata, ..., postgresql_with_oids=False)

* ``INHERITS``::

    Table("some_table", metadata, ..., postgresql_inherits="some_supertable")

    Table("some_table", metadata, ..., postgresql_inherits=("t1", "t2", ...))

    .. versionadded:: 1.0.0

* ``PARTITION BY``::

    Table("some_table", metadata, ...,
          postgresql_partition_by='LIST (part_column)')

    .. versionadded:: 1.2.6

.. seealso::

    `PostgreSQL CREATE TABLE options
    <https://www.postgresql.org/docs/current/static/sql-createtable.html>`_ -
    in the PostgreSQL documentation.

.. _postgresql_constraint_options:

PostgreSQL Constraint Options
-----------------------------

The following option(s) are supported by the PostgreSQL dialect in conjunction
with selected constraint constructs:

* ``NOT VALID``:  This option applies towards CHECK and FOREIGN KEY constraints
  when the constraint is being added to an existing table via ALTER TABLE,
  and has the effect that existing rows are not scanned during the ALTER
  operation against the constraint being added.

  When using a SQL migration tool such as `Alembic <https://alembic.sqlalchemy.org>`_
  that renders ALTER TABLE constructs, the ``postgresql_not_valid`` argument
  may be specified as an additional keyword argument within the operation
  that creates the constraint, as in the following Alembic example::

        def update():
            op.create_foreign_key(
                "fk_user_address",
                "address",
                "user",
                ["user_id"],
                ["id"],
                postgresql_not_valid=True
            )

  The keyword is ultimately accepted directly by the
  :class:`_schema.CheckConstraint`, :class:`_schema.ForeignKeyConstraint`
  and :class:`_schema.ForeignKey` constructs; when using a tool like
  Alembic, dialect-specific keyword arguments are passed through to
  these constructs from the migration operation directives::

       CheckConstraint("some_field IS NOT NULL", postgresql_not_valid=True)

       ForeignKeyConstraint(["some_id"], ["some_table.some_id"], postgresql_not_valid=True)

  .. versionadded:: 1.4.32

  .. seealso::

      `PostgreSQL ALTER TABLE options
      <https://www.postgresql.org/docs/current/static/sql-altertable.html>`_ -
      in the PostgreSQL documentation.

.. _postgresql_table_valued_overview:

Table values, Table and Column valued functions, Row and Tuple objects
-----------------------------------------------------------------------

PostgreSQL makes great use of modern SQL forms such as table-valued functions,
tables and rows as values.   These constructs are commonly used as part
of PostgreSQL's support for complex datatypes such as JSON, ARRAY, and other
datatypes.  SQLAlchemy's SQL expression language has native support for
most table-valued and row-valued forms.

.. _postgresql_table_valued:

Table-Valued Functions
^^^^^^^^^^^^^^^^^^^^^^^

Many PostgreSQL built-in functions are intended to be used in the FROM clause
of a SELECT statement, and are capable of returning table rows or sets of table
rows. A large portion of PostgreSQL's JSON functions for example such as
``json_array_elements()``, ``json_object_keys()``, ``json_each_text()``,
``json_each()``, ``json_to_record()``, ``json_populate_recordset()`` use such
forms. These classes of SQL function calling forms in SQLAlchemy are available
using the :meth:`_functions.FunctionElement.table_valued` method in conjunction
with :class:`_functions.Function` objects generated from the :data:`_sql.func`
namespace.

Examples from PostgreSQL's reference documentation follow below:

* ``json_each()``::

    >>> from sqlalchemy import select, func
    >>> stmt = select(func.json_each('{"a":"foo", "b":"bar"}').table_valued("key", "value"))
    >>> print(stmt)
    SELECT anon_1.key, anon_1.value
    FROM json_each(:json_each_1) AS anon_1

* ``json_populate_record()``::

    >>> from sqlalchemy import select, func, literal_column
    >>> stmt = select(
    ...     func.json_populate_record(
    ...         literal_column("null::myrowtype"),
    ...         '{"a":1,"b":2}'
    ...     ).table_valued("a", "b", name="x")
    ... )
    >>> print(stmt)
    SELECT x.a, x.b
    FROM json_populate_record(null::myrowtype, :json_populate_record_1) AS x

* ``json_to_record()`` - this form uses a PostgreSQL specific form of derived
  columns in the alias, where we may make use of :func:`_sql.column` elements with
  types to produce them.  The :meth:`_functions.FunctionElement.table_valued`
  method produces  a :class:`_sql.TableValuedAlias` construct, and the method
  :meth:`_sql.TableValuedAlias.render_derived` method sets up the derived
  columns specification::

    >>> from sqlalchemy import select, func, column, Integer, Text
    >>> stmt = select(
    ...     func.json_to_record('{"a":1,"b":[1,2,3],"c":"bar"}').table_valued(
    ...         column("a", Integer), column("b", Text), column("d", Text),
    ...     ).render_derived(name="x", with_types=True)
    ... )
    >>> print(stmt)
    SELECT x.a, x.b, x.d
    FROM json_to_record(:json_to_record_1) AS x(a INTEGER, b TEXT, d TEXT)

* ``WITH ORDINALITY`` - part of the SQL standard, ``WITH ORDINALITY`` adds an
  ordinal counter to the output of a function and is accepted by a limited set
  of PostgreSQL functions including ``unnest()`` and ``generate_series()``. The
  :meth:`_functions.FunctionElement.table_valued` method accepts a keyword
  parameter ``with_ordinality`` for this purpose, which accepts the string name
  that will be applied to the "ordinality" column::

    >>> from sqlalchemy import select, func
    >>> stmt = select(
    ...     func.generate_series(4, 1, -1).
    ...     table_valued("value", with_ordinality="ordinality").
    ...     render_derived()
    ... )
    >>> print(stmt)
    SELECT anon_1.value, anon_1.ordinality
    FROM generate_series(:generate_series_1, :generate_series_2, :generate_series_3)
    WITH ORDINALITY AS anon_1(value, ordinality)

.. versionadded:: 1.4.0b2

.. seealso::

    :ref:`tutorial_functions_table_valued` - in the :ref:`unified_tutorial`

.. _postgresql_column_valued:

Column Valued Functions
^^^^^^^^^^^^^^^^^^^^^^^

Similar to the table valued function, a column valued function is present
in the FROM clause, but delivers itself to the columns clause as a single
scalar value.  PostgreSQL functions such as ``json_array_elements()``,
``unnest()`` and ``generate_series()`` may use this form. Column valued functions are available using the
:meth:`_functions.FunctionElement.column_valued` method of :class:`_functions.FunctionElement`:

* ``json_array_elements()``::

    >>> from sqlalchemy import select, func
    >>> stmt = select(func.json_array_elements('["one", "two"]').column_valued("x"))
    >>> print(stmt)
    SELECT x
    FROM json_array_elements(:json_array_elements_1) AS x

* ``unnest()`` - in order to generate a PostgreSQL ARRAY literal, the
  :func:`_postgresql.array` construct may be used::


    >>> from sqlalchemy.dialects.postgresql import array
    >>> from sqlalchemy import select, func
    >>> stmt = select(func.unnest(array([1, 2])).column_valued())
    >>> print(stmt)
    SELECT anon_1
    FROM unnest(ARRAY[%(param_1)s, %(param_2)s]) AS anon_1

  The function can of course be used against an existing table-bound column
  that's of type :class:`_types.ARRAY`::

    >>> from sqlalchemy import table, column, ARRAY, Integer
    >>> from sqlalchemy import select, func
    >>> t = table("t", column('value', ARRAY(Integer)))
    >>> stmt = select(func.unnest(t.c.value).column_valued("unnested_value"))
    >>> print(stmt)
    SELECT unnested_value
    FROM unnest(t.value) AS unnested_value

.. seealso::

    :ref:`tutorial_functions_column_valued` - in the :ref:`unified_tutorial`


Row Types
^^^^^^^^^

Built-in support for rendering a ``ROW`` may be approximated using
``func.ROW`` with the :attr:`_sa.func` namespace, or by using the
:func:`_sql.tuple_` construct::

    >>> from sqlalchemy import table, column, func, tuple_
    >>> t = table("t", column("id"), column("fk"))
    >>> stmt = t.select().where(
    ...     tuple_(t.c.id, t.c.fk) > (1,2)
    ... ).where(
    ...     func.ROW(t.c.id, t.c.fk) < func.ROW(3, 7)
    ... )
    >>> print(stmt)
    SELECT t.id, t.fk
    FROM t
    WHERE (t.id, t.fk) > (:param_1, :param_2) AND ROW(t.id, t.fk) < ROW(:ROW_1, :ROW_2)

.. seealso::

    `PostgreSQL Row Constructors
    <https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS>`_

    `PostgreSQL Row Constructor Comparison
    <https://www.postgresql.org/docs/current/functions-comparisons.html#ROW-WISE-COMPARISON>`_

Table Types passed to Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PostgreSQL supports passing a table as an argument to a function, which it
refers towards as a "record" type. SQLAlchemy :class:`_sql.FromClause` objects
such as :class:`_schema.Table` support this special form using the
:meth:`_sql.FromClause.table_valued` method, which is comparable to the
:meth:`_functions.FunctionElement.table_valued` method except that the collection
of columns is already established by that of the :class:`_sql.FromClause`
itself::


    >>> from sqlalchemy import table, column, func, select
    >>> a = table( "a", column("id"), column("x"), column("y"))
    >>> stmt = select(func.row_to_json(a.table_valued()))
    >>> print(stmt)
    SELECT row_to_json(a) AS row_to_json_1
    FROM a

.. versionadded:: 1.4.0b2


ARRAY Types
-----------

The PostgreSQL dialect supports arrays, both as multidimensional column types
as well as array literals:

* :class:`_postgresql.ARRAY` - ARRAY datatype

* :class:`_postgresql.array` - array literal

* :func:`_postgresql.array_agg` - ARRAY_AGG SQL function

* :class:`_postgresql.aggregate_order_by` - helper for PG's ORDER BY aggregate
  function syntax.

JSON Types
----------

The PostgreSQL dialect supports both JSON and JSONB datatypes, including
psycopg2's native support and support for all of PostgreSQL's special
operators:

* :class:`_postgresql.JSON`

* :class:`_postgresql.JSONB`

HSTORE Type
-----------

The PostgreSQL HSTORE type as well as hstore literals are supported:

* :class:`_postgresql.HSTORE` - HSTORE datatype

* :class:`_postgresql.hstore` - hstore literal

ENUM Types
----------

PostgreSQL has an independently creatable TYPE structure which is used
to implement an enumerated type.   This approach introduces significant
complexity on the SQLAlchemy side in terms of when this type should be
CREATED and DROPPED.   The type object is also an independently reflectable
entity.   The following sections should be consulted:

* :class:`_postgresql.ENUM` - DDL and typing support for ENUM.

* :meth:`.PGInspector.get_enums` - retrieve a listing of current ENUM types

* :meth:`.postgresql.ENUM.create` , :meth:`.postgresql.ENUM.drop` - individual
  CREATE and DROP commands for ENUM.

.. _postgresql_array_of_enum:

Using ENUM with ARRAY
^^^^^^^^^^^^^^^^^^^^^

The combination of ENUM and ARRAY is not directly supported by backend
DBAPIs at this time.   Prior to SQLAlchemy 1.3.17, a special workaround
was needed in order to allow this combination to work, described below.

.. versionchanged:: 1.3.17 The combination of ENUM and ARRAY is now directly
   handled by SQLAlchemy's implementation without any workarounds needed.

.. sourcecode:: python

    from sqlalchemy import TypeDecorator
    from sqlalchemy.dialects.postgresql import ARRAY

    class ArrayOfEnum(TypeDecorator):
        impl = ARRAY

        def bind_expression(self, bindvalue):
            return sa.cast(bindvalue, self)

        def result_processor(self, dialect, coltype):
            super_rp = super(ArrayOfEnum, self).result_processor(
                dialect, coltype)

            def handle_raw_string(value):
                inner = re.match(r"^{(.*)}$", value).group(1)
                return inner.split(",") if inner else []

            def process(value):
                if value is None:
                    return None
                return super_rp(handle_raw_string(value))
            return process

E.g.::

    Table(
        'mydata', metadata,
        Column('id', Integer, primary_key=True),
        Column('data', ArrayOfEnum(ENUM('a', 'b, 'c', name='myenum')))

    )

This type is not included as a built-in type as it would be incompatible
with a DBAPI that suddenly decides to support ARRAY of ENUM directly in
a new version.

.. _postgresql_array_of_json:

Using JSON/JSONB with ARRAY
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Similar to using ENUM, prior to SQLAlchemy 1.3.17, for an ARRAY of JSON/JSONB
we need to render the appropriate CAST.   Current psycopg2 drivers accommodate
the result set correctly without any special steps.

.. versionchanged:: 1.3.17 The combination of JSON/JSONB and ARRAY is now
   directly handled by SQLAlchemy's implementation without any workarounds
   needed.

.. sourcecode:: python

    class CastingArray(ARRAY):
        def bind_expression(self, bindvalue):
            return sa.cast(bindvalue, self)

E.g.::

    Table(
        'mydata', metadata,
        Column('id', Integer, primary_key=True),
        Column('data', CastingArray(JSONB))
    )


i����(tdefaultdictN(tUUIDi(tarray(tdml(thstore(tjson(trangesi(texc(tschema(tsql(tutil(tcharacteristics(tdefault(t
reflection(t	coercions(tcompiler(telements(t
expression(troles(tsqltypes(tDDLBase(tBIGINT(tBOOLEAN(tCHAR(tDATE(tFLOAT(tINTEGER(tNUMERIC(tREAL(tSMALLINT(tTEXT(tVARCHARs ^(?:btree|hash|gist|gin|[\w_]+)$ss\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|GRANT|REVOKE|IMPORT FOREIGN SCHEMA|REFRESH MATERIALIZED VIEW|TRUNCATE)talltanalysetanalyzetandtanyRtastasct
asymmetrictbothtcasetcasttchecktcollatetcolumnt
constrainttcreatetcurrent_catalogtcurrent_datetcurrent_roletcurrent_timetcurrent_timestamptcurrent_userRt
deferrabletdesctdistincttdotelsetendtexcepttfalsetfetchtfortforeigntfromtgranttgroupthavingtint	initiallyt	intersecttintotleadingtlimitt	localtimetlocaltimestamptnewtnottnulltoftofftoffsettoldtontonlytortordertplacingtprimaryt
referencest	returningtselecttsession_usertsomet	symmetricttabletthenttottrailingttruetuniontuniquetusertusingtvariadictwhentwheretwindowtwitht
authorizationtbetweentbinarytcrosstcurrent_schematfreezetfulltiliketinnertistisnulltjointlefttliketnaturaltnotnulltoutertovertoverlapstrighttsimilartverbosei�i�i�i�i�i�iiiii�i�i�tBYTEAcBseZdZRS(R�(t__name__t
__module__t__visit_name__(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stDOUBLE_PRECISIONcBseZdZRS(R�(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stINETcBseZdZRS(R�(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stCIDRcBseZdZRS(R�(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stMACADDRcBseZdZRS(R�(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stMACADDR8cBseZdZRS(R�(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stMONEYcBseZdZdZRS(s�Provide the PostgreSQL MONEY type.

    Depending on driver, result rows using this type may return a
    string value which includes currency symbols.

    For this reason, it may be preferable to provide conversion to a
    numerically-based currency datatype using :class:`_types.TypeDecorator`::

        import re
        import decimal
        from sqlalchemy import TypeDecorator

        class NumericMoney(TypeDecorator):
            impl = MONEY

            def process_result_value(self, value: Any, dialect: Any) -> None:
                if value is not None:
                    # adjust this for the currency and numeric
                    m = re.match(r"\$([\d.]+)", value)
                    if m:
                        value = decimal.Decimal(m.group(1))
                return value

    Alternatively, the conversion may be applied as a CAST using
    the :meth:`_types.TypeDecorator.column_expression` method as follows::

        import decimal
        from sqlalchemy import cast
        from sqlalchemy import TypeDecorator

        class NumericMoney(TypeDecorator):
            impl = MONEY

            def column_expression(self, column: Any):
                return cast(column, Numeric())

    .. versionadded:: 1.2

    R�(R�R�t__doc__R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s(tOIDcBseZdZdZRS(sCProvide the PostgreSQL OID type.

    .. versionadded:: 0.9.5

    R�(R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stREGCLASScBseZdZdZRS(sHProvide the PostgreSQL REGCLASS type.

    .. versionadded:: 1.2.7

    R�(R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��st	TIMESTAMPcBs#eZdZdZedd�ZRS(s&Provide the PostgreSQL TIMESTAMP type.R�cCs&tt|�jd|�||_dS(s�Construct a TIMESTAMP.

        :param timezone: boolean value if timezone present, default False
        :param precision: optional integer precision value

         .. versionadded:: 1.4

        ttimezoneN(tsuperR�t__init__t	precision(tselfR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�s	N(R�R�R�R�tFalsetNoneR�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�
stTIMEcBs#eZdZdZedd�ZRS(sPostgreSQL TIME type.R�cCs&tt|�jd|�||_dS(s�Construct a TIME.

        :param timezone: boolean value if timezone present, default False
        :param precision: optional integer precision value

         .. versionadded:: 1.4

        R�N(R�R�R�R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�#s	N(R�R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�stINTERVALcBskeZdZdZeZddd�Zed��Z	e
d��Zed�Z
e
d��Zd�ZRS(	sPostgreSQL INTERVAL type.R�cCs||_||_dS(s Construct an INTERVAL.

        :param precision: optional integer precision value
        :param fields: string fields specifier.  allows storage of fields
         to be limited, such as ``"YEAR"``, ``"MONTH"``, ``"DAY TO HOUR"``,
         etc.

         .. versionadded:: 1.2

        N(R�tfields(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�7s	cKstd|j�S(NR�(R�tsecond_precision(tclstintervaltkw((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytadapt_emulated_to_nativeEscCstjS(N(RtInterval(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_type_affinityIscCstjdtd|j�S(NtnativeR�(RR�tTrueR�(R�tallow_nulltype((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
as_genericMscCstjS(N(tdtt	timedelta(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytpython_typePscCs|S(N((R�toptvalue((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytcoerce_compared_valueTsN(R�R�R�R�R�R�R�R�tclassmethodR�tpropertyR�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�0stBITcBseZdZded�ZRS(R�cCs.|s|pd|_n	||_||_dS(Ni(tlengthtvarying(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�^s	N(R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�[sRcBsSeZdZdZed�Zd�Zd�Zd�Zd�Z	e
d��ZRS(szPostgreSQL UUID type.

    Represents the UUID column type, interpreting
    data either as natively returned by the DBAPI
    or as Python uuid objects.

    The UUID type is currently known to work within the prominent DBAPI
    drivers supported by SQLAlchemy including psycopg2, pg8000 and
    asyncpg. Support for other DBAPI drivers may be incomplete or non-present.

    RcCs
||_dS(s�Construct a UUID type.


        :param as_uuid=False: if True, values will be interpreted
         as Python uuid objects, converting to/from string via the
         DBAPI.

        N(tas_uuid(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�{s	cCs3t|tj�r|Stt|�j||�SdS(s@See :meth:`.TypeEngine.coerce_compared_value` for a description.N(t
isinstanceR
tstring_typesR�RR�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��scCs|jrd�}|SdSdS(NcSs"|dk	rtj|�}n|S(N(R�R
t	text_type(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytprocess�s(R�R�(R�tdialectR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytbind_processor�s		cCs|jrd�}|SdSdS(NcSs|dk	rt|�}n|S(N(R�t_python_UUID(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s(R�R�(R�R�tcoltypeR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytresult_processor�s		cCs'|jrd�}|Sd�}|SdS(NcSs|dk	rd|}n|S(Ns
'%s'::UUID(R�(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s
cSs|dk	rd|}n|S(Ns'%s'(R�(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s
(R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytliteral_processor�s
			cCs|jr
tStS(N(R�R�tstr(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s(R�R�R�R�R�R�R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRks				tTSVECTORcBseZdZdZRS(sThe :class:`_postgresql.TSVECTOR` type implements the PostgreSQL
    text search type TSVECTOR.

    It can be used to do full text queries on natural language
    documents.

    .. versionadded:: 0.9.0

    .. seealso::

        :ref:`postgresql_match`

    R�(R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stENUMcBs�eZdZeZd�Zed��Zded�Z	ded�Z
defd��YZdefd��YZ
d	�Zed
�Zed�Zed�Zed
�ZRS(s�PostgreSQL ENUM type.

    This is a subclass of :class:`_types.Enum` which includes
    support for PG's ``CREATE TYPE`` and ``DROP TYPE``.

    When the builtin type :class:`_types.Enum` is used and the
    :paramref:`.Enum.native_enum` flag is left at its default of
    True, the PostgreSQL backend will use a :class:`_postgresql.ENUM`
    type as the implementation, so the special create/drop rules
    will be used.

    The create/drop behavior of ENUM is necessarily intricate, due to the
    awkward relationship the ENUM type has in relationship to the
    parent table, in that it may be "owned" by just a single table, or
    may be shared among many tables.

    When using :class:`_types.Enum` or :class:`_postgresql.ENUM`
    in an "inline" fashion, the ``CREATE TYPE`` and ``DROP TYPE`` is emitted
    corresponding to when the :meth:`_schema.Table.create` and
    :meth:`_schema.Table.drop`
    methods are called::

        table = Table('sometable', metadata,
            Column('some_enum', ENUM('a', 'b', 'c', name='myenum'))
        )

        table.create(engine)  # will emit CREATE ENUM and CREATE TABLE
        table.drop(engine)  # will emit DROP TABLE and DROP ENUM

    To use a common enumerated type between multiple tables, the best
    practice is to declare the :class:`_types.Enum` or
    :class:`_postgresql.ENUM` independently, and associate it with the
    :class:`_schema.MetaData` object itself::

        my_enum = ENUM('a', 'b', 'c', name='myenum', metadata=metadata)

        t1 = Table('sometable_one', metadata,
            Column('some_enum', myenum)
        )

        t2 = Table('sometable_two', metadata,
            Column('some_enum', myenum)
        )

    When this pattern is used, care must still be taken at the level
    of individual table creates.  Emitting CREATE TABLE without also
    specifying ``checkfirst=True`` will still cause issues::

        t1.create(engine) # will fail: no such type 'myenum'

    If we specify ``checkfirst=True``, the individual table-level create
    operation will check for the ``ENUM`` and create if not exists::

        # will check if enum exists, and emit CREATE TYPE if not
        t1.create(engine, checkfirst=True)

    When using a metadata-level ENUM type, the type will always be created
    and dropped if either the metadata-wide create/drop is called::

        metadata.create_all(engine)  # will emit CREATE TYPE
        metadata.drop_all(engine)  # will emit DROP TYPE

    The type can also be created and dropped directly::

        my_enum.create(engine)
        my_enum.drop(engine)

    .. versionchanged:: 1.0.0 The PostgreSQL :class:`_postgresql.ENUM` type
       now behaves more strictly with regards to CREATE/DROP.  A metadata-level
       ENUM type will only be created and dropped at the metadata level,
       not the table level, with the exception of
       ``table.create(checkfirst=True)``.
       The ``table.drop()`` call will now emit a DROP TYPE for a table-level
       enumerated type.

    cOs`|jdd�}|tkr.tjd�n|jdt�|_tt|�j	||�dS(sConstruct an :class:`_postgresql.ENUM`.

        Arguments are the same as that of
        :class:`_types.Enum`, but also including
        the following parameters.

        :param create_type: Defaults to True.
         Indicates that ``CREATE TYPE`` should be
         emitted, after optionally checking for the
         presence of the type, when the parent
         table is being created; and additionally
         that ``DROP TYPE`` is called when the table
         is dropped.    When ``False``, no check
         will be performed and no ``CREATE TYPE``
         or ``DROP TYPE`` is emitted, unless
         :meth:`~.postgresql.ENUM.create`
         or :meth:`~.postgresql.ENUM.drop`
         are called directly.
         Setting to ``False`` is helpful
         when invoking a creation scheme to a SQL file
         without access to the actual database -
         the :meth:`~.postgresql.ENUM.create` and
         :meth:`~.postgresql.ENUM.drop` methods can
         be used to emit SQL to a target bind.

        tnative_enums�the native_enum flag does not apply to the sqlalchemy.dialects.postgresql.ENUM datatype; this type always refers to ENUM.   Use sqlalchemy.types.Enum for non-native enum.tcreate_typeN(
tpopR�R�R
twarnR�R�R�R�R�(R�tenumsR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�$s
cKs�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�|jdt�|jd|j�|jd|j�||�S(	sbProduce a PostgreSQL native :class:`_postgresql.ENUM` from plain
        :class:`.Enum`.

        tvalidate_stringstnameRtinherit_schematmetadatat_create_eventstvalues_callabletomit_aliases(	t
setdefaultR�R�RR�R�R�R�t
_omit_aliases(R�timplR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�JscCs-|jjsdS|j|j|d|�dS(s�Emit ``CREATE TYPE`` for this
        :class:`_postgresql.ENUM`.

        If the underlying dialect does not support
        PostgreSQL CREATE TYPE, no action is taken.

        :param bind: a connectable :class:`_engine.Engine`,
         :class:`_engine.Connection`, or similar object to emit
         SQL.
        :param checkfirst: if ``True``, a query against
         the PG catalog will be first performed to see
         if the type does not exist already before
         creating.

        Nt
checkfirst(R�tsupports_native_enumt_run_ddl_visitort
EnumGenerator(R�tbindR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR/ZscCs-|jjsdS|j|j|d|�dS(s�Emit ``DROP TYPE`` for this
        :class:`_postgresql.ENUM`.

        If the underlying dialect does not support
        PostgreSQL DROP TYPE, no action is taken.

        :param bind: a connectable :class:`_engine.Engine`,
         :class:`_engine.Connection`, or similar object to emit
         SQL.
        :param checkfirst: if ``True``, a query against
         the PG catalog will be first performed to see
         if the type actually exists before dropping.

        NR�(R�R�R�tEnumDropper(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdroposR�cBs&eZed�Zd�Zd�ZRS(cKs)ttj|�j||�||_dS(N(R�R�R�R�R�(R�R�t
connectionR�tkwargs((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��scCsB|js
tS|jj|�}|jjj|j|jd|�S(NR(R�R�R�tschema_for_objectR�thas_typeR�(R�tenumteffective_schema((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_can_create_enum�s
	cCs-|j|�sdS|jjt|��dS(N(R�R�texecutetCreateEnumType(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_enum�s(R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s	
R�cBs&eZed�Zd�Zd�ZRS(cKs)ttj|�j||�||_dS(N(R�R�R�R�R�(R�R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��scCsA|js
tS|jj|�}|jjj|j|jd|�S(NR(R�R�R�R�R�R�R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_can_drop_enum�s
	cCs-|j|�sdS|jjt|��dS(N(R�R�R�tDropEnumType(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s(R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s	
cCs�|js
tSd|kr�|d}d|jkrB|jd}nt�}|jd<|j|jf|k}|j|j|jf�|StSdS(sLook in the 'ddl runner' for 'memos', then
        note our name in that collection.

        This to ensure a particular named enum is operated
        upon only once within any kind of create/drop
        sequence without relying upon "checkfirst".

        t_ddl_runnert	_pg_enumsN(R�R�tmemotsetRR�taddR�(R�R�R�t
ddl_runnertpg_enumstpresent((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_check_for_name_in_memos�s		
cKsS|s#|jrO|jdt�rO|j||�rO|jd|d|�ndS(Nt_is_metadata_operationR�R�(R�tgetR�R�R/(R�ttargetR�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_on_table_create�s

cKsM|jrI|jdt�rI|j||�rI|jd|d|�ndS(NR�R�R�(R�R�R�R�R�(R�R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_on_table_drop�s
cKs/|j||�s+|jd|d|�ndS(NR�R�(R�R/(R�R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_on_metadata_create�scKs/|j||�s+|jd|d|�ndS(NR�R�(R�R�(R�R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_on_metadata_drop�sN(R�R�R�R�R�R�R�R�R�R/R�RR�R�R�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��sM	&	
t
_ColonCastcBseZdZd�ZRS(t
colon_castcCs(||_||_tj|�|_dS(N(ttypetclauseRt
TypeClauset
typeclause(R�Rttype_((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s		(R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��st_arrayRRtjsonbt	int4ranget	int8rangetnumranget	daterangettsranget	tstzrangetintegertbiginttsmallintscharacter varyingt	characters"char"R�ttexttnumerictfloattrealtinettcidrtuuidtbitsbit varyingtmacaddrtmacaddr8tmoneytoidtregclasssdouble precisiont	timestampstimestamp with time zonestimestamp without time zonestime with time zonestime without time zonetdatettimetbyteatbooleanR�ttsvectort
PGCompilercBs%eZd�Zd�Zd�Zed�Zed�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejd��Zd�Zd�Zd�Z d�Z!d�Z"RS(cKs,d|jj||�|jj||�fS(Ns%s::%s(R�t_compiler_dispatchR�(R�telementR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_colon_cast!	scKsd|j||�S(Ns	ARRAY[%s](tvisit_clauselist(R�RR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_array'	scKs,d|j|j|�|j|j|�fS(Ns%s:%s(R�tstarttstop(R�RR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_slice*	scKsn|rE|jjtjk	rEt|d<|jtj||j�|�St|d<|j||sddnd|�S(Nt
_cast_appliedteager_groupings -> s ->> (	R�R�RtJSONR�R�R	R*t_generate_generic_binary(R�RptoperatorR!R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_json_getitem_op_binary0	s

cKsn|rE|jjtjk	rEt|d<|jtj||j�|�St|d<|j||sddnd|�S(NR!R"s #> s #>> (	R�R�RR#R�R�R	R*R$(R�RpR%R!R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt!visit_json_path_getitem_op_binary@	s

cKs,d|j|j|�|j|j|�fS(Ns%s[%s](R�RzR�(R�RpR%R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_getitem_binaryO	scKs,d|j|j|�|j|j|�fS(Ns%s ORDER BY %s(R�R�torder_by(R�RR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_aggregate_order_byU	scKs�d|jkrc|j|jdtj�}|rcd|j|j|�||j|j|�fSnd|j|j|�|j|j|�fS(Ntpostgresql_regconfigs%s @@ to_tsquery(%s, %s)s%s @@ to_tsquery(%s)(t	modifierstrender_literal_valueRt
STRINGTYPER�RzR�(R�RpR%R�t	regconfig((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_match_op_binary[	scKsd|jjdd�}d|j|j|�|j|j|�f|r_d|j|tj�ndS(Ntescapes%s ILIKE %ss ESCAPE t(	R,R�R�R�RzR�R-RR.(R�RpR%R�R1((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_ilike_op_binaryk	scKsd|jjdd�}d|j|j|�|j|j|�f|r_d|j|tj�ndS(NR1s%s NOT ILIKE %ss ESCAPE R2(	R,R�R�R�RzR�R-RR.(R�RpR%R�R1((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_not_ilike_op_binaryw	scCs�|jd}|dkr0|j|d||�S|dkrS|j|d||�Sd|j|j|�||j|tj�|j|j|�fS(Ntflagss %s tis %s* s%s %s CONCAT('(?', %s, ')', %s)(	R,R�R$R�RzR-RR.R�(R�tbase_opRpR%R�R5((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
_regexp_match�	s
cKs|jd|||�S(Nt~(R8(R�RpR%R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_regexp_match_op_binary�	scKs|jd|||�S(Ns!~(R8(R�RpR%R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt visit_not_regexp_match_op_binary�	scKsu|j|j|�}|j|j|�}|jd}|dkrQd||fSd|||j|tj�fSdS(NR5sREGEXP_REPLACE(%s, %s)sREGEXP_REPLACE(%s, %s, %s)(R�RzR�R,R�R-RR.(R�RpR%R�tstringtpattern_replaceR5((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_regexp_replace_op_binary�	s
cs0ddj�fd�|p$t�gD��fS(NsSELECT %s WHERE 1!=1s, c3s:|]0}d�jjj|jr*t�n|�VqdS(sCAST(NULL AS %s)N(R�t
type_compilerR�t_isnullR(t.0R�(R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�	s(RyR(R�t
element_types((R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_empty_set_expr�	scCs@tt|�j||�}|jjr<|jdd�}n|S(Ns\s\\(R�RR-R�t_backslash_escapestreplace(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR-�	scKsd|jj|�S(Ns
nextval('%s')(tpreparertformat_sequence(R�tseqR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_sequence�	scKs�d}|jdk	r5|d|j|j|�7}n|jdk	r�|jdkr`|d7}n|d|j|j|�7}n|S(NR2s	 
 LIMIT s
 LIMIT ALLs OFFSET (t
_limit_clauseR�R�t_offset_clause(R�R\R�R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytlimit_clause�	s 
 cCs0|j�dkr(tjd|��nd|S(NtONLYsUnrecognized hint: %rsONLY (tupperRtCompileError(R�tsqltextR`thinttiscrud((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytformat_from_hint_text�	scKsa|js|jrY|jrRddjg|jD]}|j||�^q.�dSdSndSdS(Ns
DISTINCT ON (s, s) s	DISTINCT R2(t	_distinctt_distinct_onRyR�(R�R\R�tcol((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_select_precolumns�	s
		7cs�|jjr*|jjr!d}qEd}n|jjr?d}nd}|jjr�tj�}x*|jjD]}|jtj|��qjW|ddj	��fd�|D��7}n|jj
r�|d7}n|jjr�|d	7}n|S(
Ns FOR KEY SHAREs
 FOR SHAREs FOR NO KEY UPDATEs FOR UPDATEs OF s, c3s-|]#}�j|dtdt��VqdS(tashintt
use_schemaN(R�R�R�(RAR`(R�R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�	ss NOWAITs SKIP LOCKED(t_for_update_argtreadt	key_shareRPR
t
OrderedSettupdatetsql_utiltsurface_selectables_onlyRytnowaittskip_locked(R�R\R�ttmpttablestc((R�R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytfor_update_clause�	s&			

cCsHgtj|�D]!}|j||d|j�^q}ddj|�S(Ntfallback_label_names
RETURNING s, (Rt_select_iterablest_label_returning_columnt_non_anon_labelRy(R�tstmttreturning_colsRetcolumns((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytreturning_clause
s4cKs�|j|jjd|�}|j|jjd|�}t|jj�dkr}|j|jjd|�}d|||fSd||fSdS(NiiisSUBSTRING(%s FROM %s FOR %s)sSUBSTRING(%s FROM %s)(R�tclausestlen(R�tfuncR�tsRR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_substring_func
scs�|jdk	r+d�jj|j�}nv|jdk	r�ddj�fd�|jD��}|jdk	r�|d�j|jdtdt�7}q�nd}|S(	NsON CONSTRAINT %ss(%s)s, c3sN|]D}t|tj�r-�jj|�n�j|dtdt�VqdS(t
include_tableRYN(R�R
R�RFtquoteR�R�(RARe(R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>&
ss	 WHERE %sRtRYR2(	tconstraint_targetR�RFt#truncate_and_render_constraint_nametinferred_target_elementsRytinferred_target_whereclauseR�R�(R�R�R�ttarget_text((R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_on_conflict_target
s			cCs7|jdk	o6|jjdkp6t|jjtj�S(N(tinsert_single_values_exprR�t	statementt_post_values_clauseR�RtOnConflictDoNothing(R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt&_is_safe_for_fast_insert_values_helper8
scKs(|j||�}|r d|SdSdS(NsON CONFLICT %s DO NOTHINGsON CONFLICT DO NOTHING(R{(R�ton_conflictR�Rz((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_on_conflict_do_nothingJ
scKsr|}|j||�}g}t|j�}|jdd}|jj}x|D]�}	|	j}
|
|kr~|j|
�}n!|	|krQ|j|	�}nqQtj	|�r�t
jd|d|	j
�}n9t|t
j�r|j
jr|j�}|	j
|_
n|j|j�dt�}|jj|	j�}
|jd|
|f�qQW|rtjd|jjjdjd�|D��f�x�|j�D]�\}}t|tj�r�|jj|�n|j|dt�}
|jtjtj |�dt�}|jd|
|f�q�Wndj|�}|j!dk	rd|d	|j|j!d
t"dt�7}nd||fS(Ni����t
selectableR�RYs%s = %ssFAdditional column names not matching any column keys in table '%s': %ss, css|]}d|VqdS(s'%s'N((RARe((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�
ss	 WHERE %sRtsON CONFLICT %s DO UPDATE SET %s(#R{tdicttupdate_values_to_settstackR`RetkeyR�Rt_is_literalRt
BindParameterR�R�R�R@t_cloneR�t
self_groupR�RFRuR�tappendR
R�tcurrent_executableRytitemsR�texpectRtExpressionElementRoletupdate_whereclauseR�(R�R�R�R�Rztaction_set_opstset_parameterstinsert_statementtcolsRetcol_keyR�t
value_texttkey_texttktvtaction_text((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_on_conflict_do_updateS
sN
	$	cs1t�d<ddj���fd�|D��S(NtasfromsFROM s, c3s'|]}|j�d���VqdS(t	fromhintsN(R(RAtt(t
from_hintsR�R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�
s(R�Ry(R�tupdate_stmtt
from_tabletextra_fromsR�R�((R�R�R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytupdate_from_clause�
s
	cs1t�d<ddj���fd�|D��S(s9Render the DELETE .. USING clause specific to PostgreSQL.R�sUSING s, c3s'|]}|j�d���VqdS(R�N(R(RAR�(R�R�R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�
s(R�Ry(R�tdelete_stmtR�R�R�R�((R�R�R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdelete_extra_from_clause�
s
	cKs�d}|jdk	r5|d|j|j|�7}n|jdk	r�|d|j|j|�|jdrodnd|jdr�dndf7}n|S(	NR2s
 OFFSET (%s) ROWSs
 FETCH FIRST (%s)%s ROWS %stpercents PERCENTt	with_tiess	WITH TIESRM(RKR�R�t
_fetch_clauset_fetch_clause_options(R�R\R�R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytfetch_clause�
s(#R�R�RRR R�R&R'R(R*R0R3R4R8R:R;R>RCR-RIRLRSRWRfRnRsR{R
tmemoized_propertyR�R�R�R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR 	s<																
							"			D			
t
PGDDLCompilercBs}eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
cKs|jj|�}|jj|j�}t|tj�rE|j}n|j	dk	o]|jj}|jr||j
jkr|jjs�t|tj�r|r|jdks�t|jtj�r|jjrt|tj�r�|d7}qwt|tj�r|d7}qw|d7}n[|d|jjj|jd|d|j�7}|j|�}|dk	rw|d|7}n|jdk	r�|d|j|j�7}n|r�|d|j|j	�7}n|jr�|r�|d7}n|jr|r|d	7}n|S(
Ns
 BIGSERIALs SMALLSERIALs SERIALt ttype_expressiontidentifier_preparers	 DEFAULT s	 NOT NULLs NULL(RFt
format_columnR�tdialect_implR�R�Rt
TypeDecoratorR�tidentityR�tsupports_identity_columnstprimary_keyR`t_autoincrement_columntsupports_smallserialtSmallIntegerRRtSequencetoptionalt
BigIntegerR?R�tget_column_default_stringtcomputedtnullable(R�R-R�tcolspect	impl_typethas_identityR((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_column_specification�
sF	


	

cCs|jdd}|rdSdS(Nt
postgresqlt	not_valids
 NOT VALIDR2(tdialect_options(R�R.R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_define_constraint_validity�
scCs�|jrht|j�dj}t|tj�rht|jtj�rh|jj	rht
jd��qhntt
|�j|�}||j|�7}|S(Nis�PostgreSQL dialect cannot produce the CHECK constraint for ARRAY of non-native ENUM; please specify create_constraint=False on this Enum datatype.(t_type_boundtlistRmR�R�RtARRAYt	item_typetEnumR�RROR�R�tvisit_check_constraintR�(R�R.ttypR((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��
s	
cCs/tt|�j|�}||j|�7}|S(N(R�R�tvisit_foreign_key_constraintR�(R�R.R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�s	cCsd|jj|j�S(NsCOMMENT ON TABLE %s IS NULL(RFtformat_tableR(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_drop_table_commentscs?|j}d�jj|�dj�fd�|jD��fS(NsCREATE TYPE %s AS ENUM (%s)s, c3s0|]&}�jjtj|�dt�VqdS(t
literal_bindsN(tsql_compilerR�R	tliteralR�(RAte(R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>s(RRFtformat_typeRyR�(R�R/R�((R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_create_enum_types	cCs|j}d|jj|�S(NsDROP TYPE %s(RRFR�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_drop_enum_type#s	cCs|j}|j}|j|�d}|jr;|d7}n|d7}|jjrx|jdd}|rx|d7}qxn|jr�|d7}n|d|j|d	t	�|j
|j�f7}|jdd
}|r�|d|jj|t
�j�7}n|jdd}|d
djg|jD]u}|jjt|tj�sN|j�n|dt	dt�t|d�r�|j|kr�d||jnd^q!�7}|jdd}	|	r,g|	D].}
t|
tj�r�|jj|
n|
^q�}|ddjg|D]}|j|j�^q�7}n|jdd}
|
rz|ddjg|
j�D]}d|^q\�7}n|jdd}|r�|d|j|�7}n|jdd}|dk	rt!j"t#j$|�}|jj|dt	dt�}|d|7}n|S(NsCREATE sUNIQUE sINDEX R�tconcurrentlys
CONCURRENTLY sIF NOT EXISTS s	%s ON %s tinclude_schemaRhs	USING %s topss(%s)s, RtR�R�R�R2tincludes
 INCLUDE (%s)Rms
 WITH (%s)s%s = %st
tablespaces TABLESPACE %sRks WHERE (%RFRt_verify_index_tableRfR�t#_supports_create_index_concurrentlyR�t
if_not_existst_prepared_index_nameR�R�R`tvalidate_sql_phraset	IDX_USINGtlowerRytexpressionsR�R�R�RtColumnClauseR�R�thasattrR�R
R�ReRuR�R�R�RR�RtDDLExpressionRole(R�R/RFtindexRR�RhR�texprt
includeclauseRVt
inclusionsRet
withclausetstorage_parameterttablespace_nametwhereclausetwhere_compiled((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_create_index(sb		
	

	
 �8-(	cCsu|j}d}|jjrB|jdd}|rB|d7}qBn|jrX|d7}n||j|dt�7}|S(Ns
DROP INDEX R�R�s
CONCURRENTLY s
IF EXISTS R�(RR�t!_supports_drop_index_concurrentlyR�t	if_existsR�R�(R�R�R�RR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_drop_index�s		
c	KsEd}|jdk	r2|d|jj|�7}ng}x�|jD]~\}}}t|d<|jj||�t|d�r�|j	|j
kr�d|j
|j	nd}|jd||f�qBW|d|jj|j
t�j�dj|�f7}|jdk	r.|d	|jj|jd
t�7}n||j|�7}|S(NR2sCONSTRAINT %s RtR�R�s
%s WITH %ssEXCLUDE USING %s (%s)s, s WHERE (%s)R�(R�R�RFtformat_constraintt
_render_exprsR�R�R�R�R�R�R�R�RhR�R�RyRkR�tdefine_constraint_deferrability(	R�R.R�RRR�R�R�texclude_element((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_exclude_constraint�s(
5	cs]g}|jd}|jd�}|dk	r�t|ttf�sO|f}n|jddj�fd�|D��d�n|dr�|jd|d�n|d	tkr�|jd
�n |d	t	kr�|jd�n|dr|dj
d
d�j�}|jd|�n|drP|d}|jd�jj
|��ndj|�S(NR�tinheritss

 INHERITS ( s, c3s!|]}�jj|�VqdS(N(RFRu(RAR�(R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�ss )tpartition_bys
 PARTITION BY %st	with_oidss
 WITH OIDSs
 WITHOUT OIDSt	on_committ_R�s
 ON COMMIT %sR�s
 TABLESPACE %sR2(R�R�R�R�R�ttupleR�RyR�R�RERNRFRu(R�R`t
table_optstpg_optsR�ton_commit_optionsR�((R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytpost_create_table�s,
+



cCsD|jtkr!tjd��nd|jj|jdtdt�S(Ns�PostrgreSQL computed columns do not support 'virtual' persistence; set the 'persisted' flag to None or True for PostgreSQL support.sGENERATED ALWAYS AS (%s) STOREDRtR�(t	persistedR�RROR�R�RPR�(R�t	generated((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_computed_column�s
cKsVd}|jjdk	r7d|jj|jj�}ntt|�j|d||�S(Ns AS %stprefix(R�Rt	data_typeR?R�R�R�tvisit_create_sequence(R�R/R�R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR
�s(R�R�R�R�R�R�R�R�R�R�R�R�RRR
(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��
s	7							Z			"	tPGTypeCompilercBs"eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!RS( cKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_TSVECTOR�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_INET�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_CIDR�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_MACADDR�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_MACADDR8�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_MONEY�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt	visit_OID�scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_REGCLASS�scKs#|js
dSdi|jd6SdS(NRsFLOAT(%(precision)s)R�(R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_FLOATs	cKsdS(NsDOUBLE PRECISION((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_DOUBLE_PRECISIONscKsdS(NR((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_BIGINTscKsdS(NtHSTORE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_HSTOREscKsdS(NR#((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_JSONscKsdS(NtJSONB((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_JSONBscKsdS(Nt	INT4RANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_INT4RANGEscKsdS(Nt	INT8RANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_INT8RANGEscKsdS(NtNUMRANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_NUMRANGEscKsdS(Nt	DATERANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_DATERANGE scKsdS(NtTSRANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_TSRANGE#scKsdS(Nt	TSTZRANGE((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_TSTZRANGE&scKs|j||�S(N(tvisit_TIMESTAMP(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_datetime)scKsD|js|jjr0tt|�j||�S|j||�SdS(N(R�R�R�R�RR�t
visit_ENUM(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�,scKs(|dkr|jj}n|j|�S(N(R�R�R�R�(R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR*2scKsFdt|dd�dk	r(d|jnd|jr:dp=ddfS(NsTIMESTAMP%s %sR�s(%d)R2tWITHtWITHOUTs
 TIME ZONE(tgetattrR�R�R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR(7s%cKsFdt|dd�dk	r(d|jnd|jr:dp=ddfS(Ns	TIME%s %sR�s(%d)R2R+R,s
 TIME ZONE(R-R�R�R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_TIME?s%cKsPd}|jdk	r)|d|j7}n|jdk	rL|d|j7}n|S(NR�R�s (%d)(R�R�R�(R�R�R�R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_INTERVALGscKsF|jr5d}|jdk	rB|d|j7}qBn
d|j}|S(NsBIT VARYINGs(%d)sBIT(%d)(R�R�R�(R�R�R�tcompiled((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt	visit_BITOs	
cKsdS(NR((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
visit_UUIDXscKs|j||�S(N(tvisit_BYTEA(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_large_binary[scKsdS(NR�((R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR3^scKsN|j|j|�}tjddd|jdk	r<|jnd|dd�S(Ns((?: COLLATE.*)?)$s%s\1s[]itcount(R�R�tretsubt
dimensionsR�(R�R�R�Rv((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytvisit_ARRAYasN("R�R�RR
RRRRRRRRRRRRRRR!R#R%R'R)R�R�R*R(R.R/R1R2R4R3R9(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�s>																														tPGIdentifierPreparercBs#eZeZd�Zed�ZRS(cCs9|d|jkr5|dd!j|j|j�}n|S(Niii����(t
initial_quoteREtescape_to_quotetescape_quote(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_unquote_identifiervs
cCsv|jstjd��n|j|j�}|j|�}|jrr|rr|dk	rr|j|�d|}n|S(Ns%PostgreSQL ENUM type requires a name.t.(R�RRORuR�tomit_schemaR�tquote_schema(R�R�RYR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�}s	
(R�R�tRESERVED_WORDStreserved_wordsR>R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR:rs	tPGInspectorcBs;eZdd�Zdd�Zdd�Zddd�ZRS(c
Cs8|j��&}|jj|||d|j�SWdQXdS(s(Return the OID for the given table name.t
info_cacheN(t_operation_contextR�t
get_table_oidRE(R�t
table_nameRtconn((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRG�s	cCs;|p|j}|j��}|jj||�SWdQXdS(sKReturn a list of ENUM objects.

        Each member is a dictionary containing these fields:

            * name - name of the enum
            * schema - the schema name for the enum.
            * visible - boolean, whether or not this enum is visible
              in the default search path.
            * labels - a list of string labels that apply to the enum.

        :param schema: schema name.  If None, the default schema
         (typically 'public') is used.  May also be set to '*' to
         indicate load enums for all schemas.

        .. versionadded:: 1.0.0

        N(tdefault_schema_nameRFR�t_load_enums(R�RRI((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt	get_enums�scCs;|p|j}|j��}|jj||�SWdQXdS(sReturn a list of FOREIGN TABLE names.

        Behavior is similar to that of
        :meth:`_reflection.Inspector.get_table_names`,
        except that the list is limited to those tables that report a
        ``relkind`` value of ``f``.

        .. versionadded:: 1.0.0

        N(RJRFR�t_get_foreign_table_names(R�RRI((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_foreign_table_names�stplaintmaterializedcCs;|j��)}|jj||d|jd|�SWdQXdS(s�Return all view names in `schema`.

        :param schema: Optional, retrieve names from a non-default schema.
         For special quoting, use :class:`.quoted_name`.

        :param include: specify which types of views to return.  Passed
         as a string value (for a single type) or a tuple (for any number
         of types).  Defaults to ``('plain', 'materialized')``.

         .. versionadded:: 1.1

        RER�N(RFR�tget_view_namesRE(R�RR�RI((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRQ�s	N(RORP(R�R�R�RGRLRNRQ(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRD�sR�cBseZdZRS(tcreate_enum_type(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��sR�cBseZdZRS(tdrop_enum_type(R�R�R�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��stPGExecutionContextcBs#eZd�Zd�Zd�ZRS(cCs |jd|jj|�|�S(Nsselect nextval('%s')(t_execute_scalarR�RG(R�RHR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
fire_sequence�scCs�|jr~||jjkr~|jrM|jjrM|jd|jj|j�S|jdkst|jj
r~|jjr~y
|j}Wn�t
k
r|jj}|j}|ddtddt|��!}|ddtddt|��!}d||f}||_}nX|jdk	r6|jj|j�}nd}|dk	r[d||f}n
d|f}|j||j�Sntt|�j|�S(Ns	select %siis	%s_%s_seqsselect nextval('"%s"."%s"')sselect nextval('"%s"')(R�R`R�tserver_defaultthas_argumentRUtargR�RR�tis_sequenceR�t_postgresql_seq_nametAttributeErrorR�tmaxRpR�R�R�RTtget_insert_default(R�R-tseq_namettabRVR�R�R((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR^�s4

	$$	

cCs
tj|�S(N(tAUTOCOMMIT_REGEXPtmatch(R�R}((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytshould_autocommit_text
s(R�R�RVR^Rc(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRT�s			-t"PGReadOnlyConnectionCharacteristiccBs)eZeZd�Zd�Zd�ZRS(cCs|j|t�dS(N(tset_readonlyR�(R�R�t
dbapi_conn((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytreset_characteristic
scCs|j||�dS(N(Re(R�R�RfR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytset_characteristic
scCs
|j|�S(N(tget_readonly(R�R�Rf((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_characteristic
s(R�R�R�t
transactionalRgRhRj(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRd
s		t$PGDeferrableConnectionCharacteristiccBs)eZeZd�Zd�Zd�ZRS(cCs|j|t�dS(N(tset_deferrableR�(R�R�Rf((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRg&
scCs|j||�dS(N(Rm(R�R�RfR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRh)
scCs
|j|�S(N(tget_deferrable(R�R�Rf((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRj,
s(R�R�R�RkRgRhRj(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRl!
s		t	PGDialectcBs�eZdZeZeZdZeZeZeZ	eZ
eZeZeZ
eZeZeZeZeZeZeZdZeZeZeZeZeZeZ e!Z"e#Z$d?Z&eZ'eZ(e)j*j+Z+e+j,ie-�d6e.�d6�Z+e/j0ied6d?d6d?d6id6ed	6id
6d?d6fe/j1ied6d?d6d?d
6d?d6d?d6d?d6fe/j2ied6fe/j3ied6fgZ4d@Z5eZ6eZ7eZ8d?d?d?d�Z9d�Z:d�Z;e<ddddg�Z=d�Z>d�Z?d�Z@d�ZAd�ZBd�ZCd �ZDd!�ZEeed"�ZFeed#�ZGd$�ZHd%�ZId&�ZJd?d'�ZKd?d(�ZLd?d)�ZMd*�ZNeOjPd?d+��ZQeOjPd,��ZReOjPd?d-��ZSeOjPd?d.��ZTeOjPd?dAd1��ZUeOjPd?d2��ZVeOjPd?d3��ZWeOjPd?d4��ZXd5�ZYeOjPd?d6��ZZeOjPd?ed7��Z[d8�Z\eOjPd9��Z]eOjPd?d:��Z^eOjPd?d;��Z_eOjPd?d<��Z`d?d=�Zad>�ZbRS(BR�i?tpyformattpostgresql_readonlytpostgresql_deferrableRhR�RkR�R�RmR�tignore_search_pathR�R�R�R�R�tpostgresql_ignore_search_pathcKs2tjj||�||_||_||_dS(N(RtDefaultDialectR�tisolation_levelt_json_deserializert_json_serializer(R�Rvtjson_serializertjson_deserializerR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��
s		cCstt|�j|�|jdkr8t|_|_n|jd	k|_|js�|jj	�|_|jj
tjd�|jj
td�n|jd
k|_|jdkr�t|_n$|jd�j�}|dk|_|jdk|_|jd
k|_|jdk|_dS(Niiii	s show standard_conforming_stringsRQi
(ii(ii(i	i(ii(ii(i	i(i
(R�Rot
initializetserver_version_infoR�tfull_returningtimplicit_returningR�tcolspecstcopyR�RR�R�R�R�RDtexec_driver_sqltscalarR�R�R�(R�R�t
std_string((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR{�
s&	cs*�jdk	r"�fd�}|SdSdS(Ncs�j|�j�dS(N(tset_isolation_levelRv(RI(R�(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytconnect�
s(RvR�(R�R�((R�sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
on_connect�
stSERIALIZABLEsREAD UNCOMMITTEDsREAD COMMITTEDsREPEATABLE READcCs�|jdd�}||jkrOtjd||jdj|j�f��n|j�}|jd|�|jd�|j�dS(NR�R�sLInvalid value '%s' for isolation_level. Valid isolation levels for %s are %ss, s=SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL %stCOMMIT(	REt_isolation_lookupRt
ArgumentErrorR�RytcursorR�tclose(R�R�tlevelR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��
s%
cCs=|j�}|jd�|j�d}|j�|j�S(Ns show transaction isolation leveli(R�R�tfetchoneR�RN(R�R�R�tval((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_isolation_level�
s


cCs
t��dS(N(tNotImplementedError(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRe�
scCs
t��dS(N(R�(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRi�
scCs
t��dS(N(R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRm�
scCs
t��dS(N(R�(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRn�
scCs|j|j�dS(N(tdo_beginR�(R�R�txid((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdo_begin_twophase�
scCs|jd|�dS(NsPREPARE TRANSACTION '%s'(R�(R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdo_prepare_twophase�
scCsa|rM|r|jd�n|jd|�|jd�|j|j�n|j|j�dS(NtROLLBACKsROLLBACK PREPARED '%s'tBEGIN(R�tdo_rollbackR�(R�R�R�tis_preparedtrecover((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdo_rollback_twophase�
s
cCsa|rM|r|jd�n|jd|�|jd�|j|j�n|j|j�dS(NR�sCOMMIT PREPARED '%s'R�(R�R�R�t	do_commit(R�R�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdo_commit_twophases
cCs3|jtjd��}g|D]}|d^qS(Ns!SELECT gid FROM pg_prepared_xactsi(R�R	R(R�R�t	resultsettrow((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytdo_recover_twophasescCs|jd�j�S(Nsselect current_schema()(R�R�(R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_get_default_schema_name scCs[d}|jtj|�jtjdtj|j��dtj	���}t
|j��S(Ns=select nspname from pg_namespace where lower(nspname)=:schemaRR�(R�R	Rt
bindparamst	bindparamR
R�R�RtUnicodetbooltfirst(R�R�RtqueryR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt
has_schema#scCs�|j|�|dkr[|jtjd�jtjdtj|�dt	j
���}n`|jtjd�jtjdtj|�dt	j
�tjdtj|�dt	j
���}t|j��S(Ns�select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname=:nameR�R�stselect relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=:schema and relname=:nameR(
t_ensure_has_table_connectionR�R�R	RR�R�R
R�RR�R�R�(R�R�RHRR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt	has_table3s*
			cCs�|dkr|j}n|jtjd�jtjdtj|�dt	j
�tjdtj|�dt	j
���}t|j��S(Ns�SELECT relname FROM pg_class c join pg_namespace n on n.oid=c.relnamespace where relkind='S' and n.nspname=:schema and relname=:nameR�R�R(
R�RJR�R	RR�R�R
R�RR�R�R�(R�R�t
sequence_nameRR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pythas_sequenceZs		cCs�|dk	r$d}tj|�}nd}tj|�}|jtjdtj|�dtj��}|dk	r�|jtjdtj|�dtj��}n|j	|�}t
|j��S(Ns
            SELECT EXISTS (
                SELECT * FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n
                WHERE t.typnamespace = n.oid
                AND t.typname = :typname
                AND n.nspname = :nspname
                )
                s�
            SELECT EXISTS (
                SELECT * FROM pg_catalog.pg_type t
                WHERE t.typname = :typname
                AND pg_type_is_visible(t.oid)
                )
                ttypnameR�tnspname(R�R	RR�R�R
R�RR�R�R�R�(R�R�t	type_nameRR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�rs!$cCs~|jd�j�}tjd|�}|s@td|��ntg|jddd�D]}|dk	rYt|�^qY�S(Nsselect pg_catalog.version()sQ.*(?:PostgreSQL|EnterpriseDB) (\d+)\.?(\d+)?(?:\.(\d+))?(?:\.\d+)?(?:devel|beta)?s,Could not determine version from string '%s'iii(	R�R�R6RbtAssertionErrorRRCR�tint(R�R�R�tmtx((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_get_server_version_info�s	c
Ksd}|dk	rd}nd}d|}tj|�}|dk	rXtj|�}ntj|�jdtj�}|jdtj	�}|r�|jtj
ddtj��}n|j|td|d|��}	|	j
�}|dkrtj|��n|S(	s�Fetch the oid for schema.table_name.

        Several reflection methods require the table oid.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        sn.nspname = :schemas%pg_catalog.pg_table_is_visible(c.oid)s	
            SELECT c.oid
            FROM pg_catalog.pg_class c
            LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
            WHERE (%s)
            AND c.relname = :table_name AND c.relkind in
            ('r', 'v', 'm', 'f', 'p')
        RHRRR�N(R�R
R�R	RR�RR�RmtIntegerR�R�R�R�RtNoSuchTableError(
R�R�RHRR�t	table_oidtschema_where_clauseR�RrRe((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRG�s$			$!cKsA|jtjd�jdtj��}g|D]\}|^q.S(NsOSELECT nspname FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' ORDER BY nspnameR�(R�R	RRmRR�(R�R�R�tresultR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_schema_names�s
cKsb|jtjd�jdtj�td|dk	r9|n|j��}g|D]\}|^qOS(Ns�SELECT c.relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = :schema AND c.relkind in ('r', 'p')trelnameR(	R�R	RRmRR�R�R�RJ(R�R�RR�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_table_names�s	cKsb|jtjd�jdtj�td|dk	r9|n|j��}g|D]\}|^qOS(Ns|SELECT c.relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = :schema AND c.relkind = 'f'R�R(	R�R	RRmRR�R�R�RJ(R�R�RR�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRM�s	RORPc
Ks�idd6dd6}y*gtj|�D]}||^q'}Wn$tk
rdtd|f��nX|sztd��n|jtjddjd	�|D���jd
t	j
�td|dk	r�|n|j
��}g|D]\}	|	^q�S(NR�ROR�RPs_include %r unknown, needs to be a sequence containing one or both of 'plain' and 'materialized'sZempty include, needs to be a sequence containing one or both of 'plain' and 'materialized's~SELECT c.relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = :schema AND c.relkind IN (%s)s, css|]}d|VqdS(s'%s'N((RAtelem((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>sR�R(R
tto_listtKeyErrort
ValueErrorR�R	RRyRmRR�R�R�RJ(
R�R�RR�R�tinclude_kindR6tkindsR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRQ�s&*
 	cKsl|s|j}n|jtjd�jtjdtj|�dtj	���}g|D]}|d^qXS(NsrSELECT relname FROM pg_class c join pg_namespace n on n.oid=c.relnamespace where relkind='S' and n.nspname=:schemaRR�i(
RJR�R	RR�R�R
R�RR�(R�R�RR�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_sequence_namess	cKsR|jtjd�jdtj�td|dk	r9|n|jd|��}|S(Ns�SELECT pg_get_viewdef(c.oid) view_def FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = :schema AND c.relname = :view_name AND c.relkind IN ('v', 'm')tview_defRt	view_name(	R�R	RRmRR�R�R�RJ(R�R�R�RR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_view_definition)s		cKst|j|||d|jd��}|jdkr9dnd}|jdkrWd}nd}d||f}tj|�jtjd	d
tj��j	dtj
dtj
�}	|j|	td	|��}
|
j
�}|j|�}td
�|j|dd�D��}
g}x]|D]U\}}}}}}}}|j||||||
||||�
}|j|�qW|S(NREisa.attgenerated as generatedsNULL as generatedi
s�                (SELECT json_build_object(
                    'always', a.attidentity = 'a',
                    'start', s.seqstart,
                    'increment', s.seqincrement,
                    'minvalue', s.seqmin,
                    'maxvalue', s.seqmax,
                    'cache', s.seqcache,
                    'cycle', s.seqcycle)
                FROM pg_catalog.pg_sequence s
                JOIN pg_catalog.pg_class c on s.seqrelid = c."oid"
                WHERE c.relkind = 'S'
                AND a.attidentity != ''
                AND s.seqrelid = pg_catalog.pg_get_serial_sequence(
                    a.attrelid::regclass::text, a.attname
                )::regclass::oid
                ) as identity_options                sNULL as identity_optionss
            SELECT a.attname,
              pg_catalog.format_type(a.atttypid, a.atttypmod),
              (
                SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid)
                FROM pg_catalog.pg_attrdef d
                WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum
                AND a.atthasdef
              ) AS DEFAULT,
              a.attnotnull,
              a.attrelid as table_oid,
              pgd.description as comment,
              %s,
              %s
            FROM pg_catalog.pg_attribute a
            LEFT JOIN pg_catalog.pg_description pgd ON (
                pgd.objoid = a.attrelid AND pgd.objsubid = a.attnum)
            WHERE a.attrelid = :table_oid
            AND a.attnum > 0 AND NOT a.attisdropped
            ORDER BY a.attnum
        R�R�tattnameRcssF|]<}|dr&|df|fn|d|df|fVqdS(tvisibleR�RN((RAtrec((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�sRt*(i(i
(RGR�R|R	RR�R�RR�RmR�R�R�tfetchallt
_load_domainsRKt_get_column_infoR�(R�R�RHRR�R�RR�tSQL_COLSRrRetrowstdomainsR�RmR�R�tdefault_R}tcommenttcolumn_info((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_columns;sF	
	"	c
Csqd�}|dkr.t}d}
}t}n-t}tjdd|�}
||
�\}
}ttj|
��}|}tjd|�}|r�|j	d�}ntjd|�}|r�|j	d�r�ttj
d|j	d���}nd2}i}|
d	krC|r:|j
d
�\}}t|�t|�f}q�d3}nT|
dkrXd4}n?|
d
krmd5}n*|
d6kr�t|d<|r�t|�|d<nd7}n�|
d8kr�t|d<|r�t|�|d<nd9}n�|
dkrt|d<|rt|�f}q�d:}n�|
jd�rtj
d|
tj�}|rTt|�|d<n|rp|j	d�|d<nd}
d;}n|r�t|�f}nxtr�|
|jkr�|j|
}Pq�||kr||}t}|d|d<|ds|d|d<nt|d�}Pq�||kr�||}|d}
||
�\}
}ttj|
��}|om|d}|d r�|r�|d }q�q�q�d}Pq�W|r�|||�}|r|jd!|�}qnF|r�tjd"|f�tj}n tjd#|
|f�tj}|	d<krItd%|d&|	d=k�}d}nd}t}|dk	rtjd(|�}|dk	rt|jtj�r�t}n|}d)|j	d*�kr�|dk	r�|j	d�d+|d)|j	d*�|j	d,�}q�qntd|d-|d|d |d.|p/|
dk	d/|�}|dk	rT||d0<n|
dk	rm|
|d1<n|S(>NcSs"tjdd|�|jd�fS(Ns\[\]$R2s[](R6R7tendswith(tattype((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt_handle_array_type�ssno format_type()s\(.*\)R2s\(([\d,]+)\)is\((.*)\)s\s*,\s*Rt,sdouble precisioni5Rstimestamp with time zonestime with time zoneR�R�stimestamp without time zonestime without time zoneRsbit varyingR�R�s
interval (.+)R�R�R�RtlabelsR�R�RR�s6PostgreSQL format_type() returned NULL for column '%s's*Did not recognize type '%s' of column '%s'sRPRRrs(nextval\(')([^']+)('.*$)R?is"%s"iR�t
autoincrementR�R�R�(((i5((stimestamp with time zonestime with time zone((stimestamp without time zonestime without time zoneR((((NR2s(RrRr(R�R�R�R6R7RR
tquoted_token_parsertsearchRCtsplitR�t
startswithRbtIt
ischema_namesR�R�RtNULLTYPER�t
issubclassR�R�(R�R�R�RR}R�R�RR�RR�R�tno_format_typeR�tis_arraytenum_or_domain_keyR�tcharlentargsR�tprectscaletfield_matchR�R�tdomainR�R�RbtschR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s�
	
	$			
		
	
			





			!	>	

c
Ks|j|||d|jd��}|jdkrLd|jdd�}nd}tj|�jdtj�}|j	|t
d	|��}g|j�D]}	|	d
^q�}
d}tj|�jdtj�}|j	|t
d	|��}|j�}i|
d
6|d6S(NREiisq
                SELECT a.attname
                FROM
                    pg_class t
                    join pg_index ix on t.oid = ix.indrelid
                    join pg_attribute a
                        on t.oid=a.attrelid AND %s
                 WHERE
                  t.oid = :table_oid and ix.indisprimary = 't'
                ORDER BY a.attnum
            sa.attnums	ix.indkeys�
                SELECT a.attname
                FROM pg_attribute a JOIN (
                    SELECT unnest(ix.indkey) attnum,
                           generate_subscripts(ix.indkey, 1) ord
                    FROM pg_index ix
                    WHERE ix.indrelid = :table_oid AND ix.indisprimary
                    ) k ON a.attnum=k.attnum
                WHERE a.attrelid = :table_oid
                ORDER BY k.ord
            R�R�is�
        SELECT conname
           FROM  pg_catalog.pg_constraint r
           WHERE r.conrelid = :table_oid AND r.contype = 'p'
           ORDER BY 1
        tconnametconstrained_columnsR�(ii(
RGR�R|t
_pg_index_anyR	RRmRR�R�R�R�R�(
R�R�RHRR�R�tPK_SQLR�RetrR�tPK_CONS_SQLR�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_pk_constraint_s	#cKs_|j}|j|||d|jd��}d}tjd�}	tj|�jdtj	dtj	�}
|j
|
td|��}g}x�|j�D]�\}
}}tj
|	|�j�}|\
}}}}}}}}}}}}}|dk	r|dkr	tnt}ngtjd|�D]}|j|�^q%}|rg||jkr^|}q�|}n9|r|j|�}n!|dk	r�||kr�|}n|j|�}gtjd	|�D]}|j|�^q�}d
�d|fd|fd
|fd|fd|fgD�}i|
d6|d6|d6|d6|d6|d6}|j|�q�W|S(NREs�
          SELECT r.conname,
                pg_catalog.pg_get_constraintdef(r.oid, true) as condef,
                n.nspname as conschema
          FROM  pg_catalog.pg_constraint r,
                pg_namespace n,
                pg_class c

          WHERE r.conrelid = :table AND
                r.contype = 'f' AND
                c.oid = confrelid AND
                n.oid = c.relnamespace
          ORDER BY 1
        s/FOREIGN KEY \((.*?)\) REFERENCES (?:(.*?)\.)?(.*?)\((.*?)\)[\s]?(MATCH (FULL|PARTIAL|SIMPLE)+)?[\s]?(ON UPDATE (CASCADE|RESTRICT|NO ACTION|SET NULL|SET DEFAULT)+)?[\s]?(ON DELETE (CASCADE|RESTRICT|NO ACTION|SET NULL|SET DEFAULT)+)?[\s]?(DEFERRABLE|NOT DEFERRABLE)?[\s]?(INITIALLY (DEFERRED|IMMEDIATE)+)?R�tcondefR`t
DEFERRABLEs\s*,\s*s\s*,\scSs7i|]-\}}|dk	r|dkr||�qS(s	NO ACTIONN(R�(RAR�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys
<dictcomp>�s		tonupdatetondeleteRFR6RbR�R�treferred_schematreferred_tabletreferred_columnstoptions(R�RGR�R6tcompileR	RRmRR�R�R�R�R�tgroupsR�R�R�R�R>RJR�(R�R�RHRRtR�RFR�tFK_SQLtFK_REGEXR�RetfkeysR�R�t	conschemaR�R�R�R�R�R�RbR�R�R6RFR�R�tfkey_d((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_foreign_keys�sV			
-+			+				
csN|jd	kr<ddj��fd�tdd�D��Sd��fSdS(
Niis(%s)s OR c3s"|]}d�|�fVqdS(s%s[%d] = %sN((RAtind(RVt
compare_to(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>sii
s%s = ANY(%s)(ii(R|Rytrange(R�RVR((RVRsV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR�s	$c&
s-|j|||d|jd��}|jd/kr�d|jd0krKdnd|jd1krcdnd	|jd2kr{dnd	|jdd
�f}n"d|jd3kr�dnd	f}tj|�jdtjdtj�}|j	|t
d|��}td��}	d}
xs|j
�D]e}|\}}
}}}}}}}}}}|r||
krstjd|�n|}
qn||	k}|	|}|dk	r�||d|<n|s|j�}|r�||r�||}|| }ng}g|D]}t|j��^q�|d<g|D]}t|j��^q!|d<i}x�t|pXdj��D]|\}}t|j��}d4} |d@r�| d57} |d
@s�| d67} q�n|d
@r�| d77} n| rb| ||<qbqbW|r�||d<n|
|d<|dk	r||d <n|rMt
g|D]}!|!jd!�^q(�|d"<n|rl|d#krl||d$<n|r�||d%<q�qqWg}"x�|	j�D]�\}#�i|#d&6�dd6g�dD]}$�d|$^q�d'6}%|jd8krg�dD]}$�d|$^q�|%d(<nd �kr;�d |%d <nd�krtt
�fd)��dj�D��|%d*<nd(|%kr�|%d(|%jd+i�d,<nd"�kr��d"|%jd+i�d-<nd$�kr��d$|%jd+i�d.<nd%�kr�d%|%jd+i�d%<n|"j|%�q�W|"S(9NREiis�
              SELECT
                  i.relname as relname,
                  ix.indisunique, ix.indexprs, ix.indpred,
                  a.attname, a.attnum, NULL, ix.indkey%s,
                  %s, %s, am.amname,
                  NULL as indnkeyatts
              FROM
                  pg_class t
                        join pg_index ix on t.oid = ix.indrelid
                        join pg_class i on i.oid = ix.indexrelid
                        left outer join
                            pg_attribute a
                            on t.oid = a.attrelid and %s
                        left outer join
                            pg_am am
                            on i.relam = am.oid
              WHERE
                  t.relkind IN ('r', 'v', 'f', 'm')
                  and t.oid = :table_oid
                  and ix.indisprimary = 'f'
              ORDER BY
                  t.relname,
                  i.relname
            is	::varcharR2six.indoption::varchartNULLisi.reloptionssa.attnums	ix.indkeys/
              SELECT
                  i.relname as relname,
                  ix.indisunique, ix.indexprs,
                  a.attname, a.attnum, c.conrelid, ix.indkey::varchar,
                  ix.indoption::varchar, i.reloptions, am.amname,
                  pg_get_expr(ix.indpred, ix.indrelid),
                  %s as indnkeyatts
              FROM
                  pg_class t
                        join pg_index ix on t.oid = ix.indrelid
                        join pg_class i on i.oid = ix.indexrelid
                        left outer join
                            pg_attribute a
                            on t.oid = a.attrelid and a.attnum = ANY(ix.indkey)
                        left outer join
                            pg_constraint c
                            on (ix.indrelid = c.conrelid and
                                ix.indexrelid = c.conindid and
                                c.contype in ('p', 'u', 'x'))
                        left outer join
                            pg_am am
                            on i.relam = am.oid
              WHERE
                  t.relkind IN ('r', 'v', 'f', 'm', 'p')
                  and t.oid = :table_oid
                  and ix.indisprimary = 'f'
              ORDER BY
                  t.relname,
                  i.relname
            iisix.indnkeyattsR�R�R�cSs
tt�S(N(RR�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt<lambda>lR2s;Skipped unsupported reflection of expression-based index %sR�R�tinciR7t
nulls_lasttnulls_firsttsortingRftduplicates_constraintt=R�tbtreetamnametpostgresql_whereR�tcolumn_namestinclude_columnsc3s1|]'\}}�d�d||fVqdS(R�R�N((RAR6R�(tidx(sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pys	<genexpr>�stcolumn_sortingR�tpostgresql_includetpostgresql_withtpostgresql_using(ii(ii(ii(ii(ii((R7(R
(R(ii(RGR�R|R�R	RRmRR�R�R�RR�R�R
R�R�R�tstript	enumerateR�R�R�(&R�R�RHRR�R�tIDX_SQLR�Retindexestsv_idx_nameR�tidx_nameRfR�RVtcol_numtconrelidtidx_keyt
idx_optionR�Rtfilter_definitiontindnkeyattsthas_idxR�tidx_keystinc_keysR�Rtcol_idxt	col_flagstcol_sortingtoptionR�R�R6tentry((RsV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_indexess�!
*


))







,
),cKs|j|||d|jd��}d}tj|�jdtj�}|j|td|��}t	d��}	xB|j
�D]4}
|	|
j}|
j|d<|
j
|d|
j<qWg|	j�D]?\}}i|d6g|dD]}
|d|
^q�d	6^q�S(
NREs�
            SELECT
                cons.conname as name,
                cons.conkey as key,
                a.attnum as col_num,
                a.attname as col_name
            FROM
                pg_catalog.pg_constraint cons
                join pg_attribute a
                  on cons.conrelid = a.attrelid AND
                    a.attnum = ANY(cons.conkey)
            WHERE
                cons.conrelid = :table_oid AND
                cons.contype = 'u'
        tcol_nameR�cSs
tt�S(N(RR�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRR2R�R�R�R(RGR�R	RRmRR�R�R�RR�R�R�R.RR�(R�R�RHRR�R�t
UNIQUE_SQLR�RetuniquesR�tucR�R6((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_unique_constraints�s

cKs_|j|||d|jd��}d}|jtj|�td|��}i|j�d6S(NREs�
            SELECT
                pgd.description as table_comment
            FROM
                pg_catalog.pg_description pgd
            WHERE
                pgd.objsubid = 0 AND
                pgd.objoid = :table_oid
        R�R(RGR�R�R	RR�R�(R�R�RHRR�R�tCOMMENT_SQLRe((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_table_commentscKs!|j|||d|jd��}d}|jtj|�td|��}g}x�|D]�\}	}
tjd|
dtj�}|s�t	j
d|
�d}n-tjddtj�jd	|j
d
��}i|	d6|d6}
|r|j
d
�ritd6|
d<n|j|
�q[W|S(NREs
            SELECT
                cons.conname as name,
                pg_get_constraintdef(cons.oid) as src
            FROM
                pg_catalog.pg_constraint cons
            WHERE
                cons.conrelid = :table_oid AND
                cons.contype = 'c'
        R�s^CHECK *\((.+)\)( NOT VALID)?$R5s)Could not parse CHECK constraint text: %rR2s^[\s\n]*\((.+)\)[\s\n]*$s\1iR�RPiR�R�(RGR�R�R	RR�R6RbtDOTALLR
R�R�R7RCR�R�(R�R�RHRR�R�t	CHECK_SQLRetretR�tsrcR�RPR,((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pytget_check_constraints$s&$	cCsb|p|j}|jsiSd}|dkr;|d7}n|d7}tj|�jdtjdtj�}|dkr�|jd|�}n|j|�}g}i}x�|j	�D]�}|j
|jf}	|	|kr�||	dj|j
�q�i|jd	6|j
d6|jd
6gd6||	<}
|j
dk	rM|
dj|j
�n|j|
�q�W|S(Ns�
            SELECT t.typname as "name",
               -- no enum defaults in 8.4 at least
               -- t.typdefault as "default",
               pg_catalog.pg_type_is_visible(t.oid) as "visible",
               n.nspname as "schema",
               e.enumlabel as "label"
            FROM pg_catalog.pg_type t
                 LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
                 LEFT JOIN pg_catalog.pg_enum e ON t.oid = e.enumtypid
            WHERE t.typtype = 'e'
        R�sAND n.nspname = :schema s ORDER BY "schema", "name", e.oidR�tlabelRR�R�R�(RJR�R	RRmRR�R�R�R�RR�R�R:R�R�(R�R�Rt	SQL_ENUMSRrReR�tenum_by_nameR�R�tenum_rec((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRKQs6	




c	Cs�d}tj|�}|jdt�j|�}i}x�|j�D]�}|}tjd|d�jd�}|dr�|df}n|d|df}i|d6|d	d	6|d
d
6||<qCW|S(Ns�
            SELECT t.typname as "name",
               pg_catalog.format_type(t.typbasetype, t.typtypmod) as "attype",
               not t.typnotnull as "nullable",
               t.typdefault as "default",
               pg_catalog.pg_type_is_visible(t.oid) as "visible",
               n.nspname as "schema"
            FROM pg_catalog.pg_type t
               LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
            WHERE t.typtype = 'd'
        t
future_results([^\(]+)R�iR�R�RR�R(	R	Rtexecution_optionsR�R�tmappingsR6R�RC(	R�R�tSQL_DOMAINSRrReR�R�R�R�((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyR��s
N(Rt(RORP(cR�R�R�R�tsupports_statement_cachetsupports_altertmax_identifier_lengthtsupports_sane_rowcountR�tsupports_native_booleanR�tsupports_sequencestsequences_optionalt"preexecute_autoincrement_sequencesR�tpostfetch_lastrowidtsupports_commentstsupports_default_valuestsupports_default_metavaluetsupports_empty_inserttsupports_multivalues_insertR�tdefault_paramstyleR�RRtstatement_compilerR�tddl_compilerRR?R:RFRTtexecution_ctx_clsRDt	inspectorR�RvR~R}RRutconnection_characteristicsReRdRlRtIndextTabletCheckConstrainttForeignKeyConstrainttconstruct_argumentstreflection_optionsRDR�R�R�R{R�R�R�R�R�ReRiRmRnR�R�R�R�R�R�R�R�R�R�R�R
tcacheRGR�R�RMRQR�R�R�R�R�RR�R-R2R4R9RKR�(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyRo0
s�



	$	
											'"	
' l	�2m	�$,4({R�tcollectionsRtdatetimeR�R6RRR�R2RR�RRt_hstoreRt_jsonRt_rangesRRR	R
tengineRRR
RRRRRRR_tsql.ddlRttypesRRRRRRRRRRRR�R�R�tUNICODERaR�RBt_DECIMAL_TYPESt_FLOAT_TYPESt
_INT_TYPEStLargeBinaryR�tFloatR�t
TypeEngineR�tPGInetR�tPGCidrR�t	PGMacAddrR�t
PGMacAddr8R�R�R�R�R�tNativeForEmulatedt_AbstractIntervalR�t
PGIntervalR�tPGBittPGUuidR�R�R�tCastR�R�R�tJSONPathTypeR#RRRRRR R"R$R&tStringR�tSQLCompilerRtDDLCompilerR�tGenericTypeCompilerRtIdentifierPreparerR:t	InspectorRDt_CreateDropBaseR�R�tDefaultExecutionContextRTtConnectionCharacteristicRdRlRuRo(((sV/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.pyt<module>s�-(
R�
	















���,�B;

Youez - 2016 - github.com/yon3zu
LinuXploit